Skip to content

Commit

Permalink
More information
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxudo committed Mar 27, 2023
1 parent f4e226e commit 776becb
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 12 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ Database:
* majorclass - varchar(255) - major class of device
* minorclass - varchar(255) - minor class of device
* services - text - string of exposed Bluetooth services
* controller_chipset - varchar(255) - controller chipset
* controller_firmware - varchar(255) - controller firmware version
* device_firmware - varchar(255) - device firmware version
* device_productid - varchar(255) - device product ID
* device_vendorid - varchar(255) - device vendor ID
5 changes: 5 additions & 0 deletions bluetooth_factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
'majorclass' => $faker->word(),
'minorclass' => $faker->word(),
'services' => $faker->text(),
'controller_chipset' => $faker->text(),
'controller_firmware' => $faker->text(),
'device_firmware' => $faker->text(),
'device_productid' => $faker->text(),
'device_vendorid' => $faker->text(),
];
});

5 changes: 5 additions & 0 deletions bluetooth_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class Bluetooth_model extends Eloquent
'majorclass',
'minorclass',
'services',
'controller_chipset',
'controller_firmware',
'device_firmware',
'device_productid',
'device_vendorid',
];

public $timestamps = false;
Expand Down
8 changes: 8 additions & 0 deletions js/bluetooth.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ var formatBluetoothSupported = function(colNumber, row){
(colvar === '0' ? i18n.t('bluetooth.unsupported') : '')
col.text(colvar)
}

var formatBluetoothChipset = function(colNumber, row){
var col = $('td:eq('+colNumber+')', row),
colvar = col.text();
colvar = colvar == 'THIRD_PARTY_DONGLE' ? i18n.t('bluetooth.third_party_dongle') :
colvar = colvar
col.text(colvar)
}
8 changes: 7 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,11 @@
"manufacturer": "Manufacturer",
"majorclass": "Major Device Class",
"minorclass": "Minor Device Class",
"services": "Services"
"services": "Services",
"controller_chipset": "Chipset",
"controller_firmware": "Firmware Version",
"device_firmware": "Firmware Version",
"device_productid": "Product ID",
"device_vendorid": "Vendor ID",
"third_party_dongle": "Third Party Dongle"
}
33 changes: 33 additions & 0 deletions migrations/2023_03_03_000001_bluetooth_add_controller_columns.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Capsule\Manager as Capsule;

class BluetoothAddControllerColumns extends Migration
{
private $tableName = 'bluetooth';

public function up()
{
$capsule = new Capsule();
$capsule::schema()->table($this->tableName, function (Blueprint $table) {
$table->string('controller_chipset')->nullable();
$table->string('controller_firmware')->nullable();
$table->string('device_firmware')->nullable();
$table->string('device_productid')->nullable();
$table->string('device_vendorid')->nullable();
});
}

public function down()
{
$capsule = new Capsule();
$capsule::schema()->table($this->tableName, function (Blueprint $table) {
$table->dropColumn('controller_chipset');
$table->dropColumn('controller_firmware');
$table->dropColumn('device_firmware');
$table->dropColumn('device_productid');
$table->dropColumn('device_vendorid');
});
}
}
46 changes: 38 additions & 8 deletions scripts/bluetooth.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,41 @@ def flatten_bluetooth_info(obj):

# Check if there is Bluetooth hardware
try:
# Check if we're running macOS 12+
if 'controller_properties' in list(obj.keys()) and 'devices_list' in list(obj.keys()):
obj_device = obj['devices_list']
elif 'controller_properties' in list(obj.keys()) and 'devices_list' not in list(obj.keys()):
obj_device = []

# Check for different types of output
# Big Sur and older
if 'device_title' in list(obj.keys()):
obj_device.extend(obj['device_title'])

# Monterey+, with connected devices
if 'device_connected' in list(obj.keys()):
for bt_item in obj['device_connected']:
for bt_item_0 in bt_item:
bt_item[bt_item_0]["device_isconnected"] = "attrib_Yes"
obj_device.extend(obj['device_connected'])

# Monterey+, with previously connected devices
if 'device_not_connected' in list(obj.keys()):
for bt_item in obj['device_not_connected']:
for bt_item_0 in bt_item:
bt_item[bt_item_0]["device_isconnected"] = "attrib_No"
obj_device.extend(obj['device_not_connected'])

# Monterey+, no devices connected
if 'controller_properties' in list(obj.keys()) and 'devices_list' not in list(obj.keys()) and 'device_connected' not in list(obj.keys()) and 'device_not_connected' not in list(obj.keys()) and 'device_title' not in list(obj.keys()):
obj_device = [{'blank_item':'blank_item'}]
else:
obj['device_title']
obj_device = obj['device_title']

# If we have no Bluetooth
if 'controller_properties' not in list(obj.keys()) and 'devices_list' not in list(obj.keys()) and 'device_connected' not in list(obj.keys()) and 'device_not_connected' not in list(obj.keys()) and 'device_title' not in list(obj.keys()):
return [{'power':-1}]
except:
try:
obj['local_device_title']
obj_device = [{'blank_item':'blank_item'}]
except:
return [{'power':-1}]


for bt_device in obj_device:
for item in bt_device:
device = {}
Expand Down Expand Up @@ -106,6 +125,10 @@ def flatten_bluetooth_info(obj):

elif item_local == 'general_vendorID' or item_local == 'controller_vendorID':
device['vendor_id'] = obj_local[item_local]
elif item_local == 'controller_chipset':
device['controller_chipset'] = obj_local[item_local]
elif item_local == 'controller_firmwareVersion':
device['controller_firmware'] = obj_local[item_local]


if item_att == 'device_addr' or item_att == 'device_address':
Expand All @@ -124,6 +147,13 @@ def flatten_bluetooth_info(obj):
elif item_att == 'device_ispaired' or item_att == 'device_paired':
device['ispaired'] = to_bool(bt_device[item][item_att])

elif item_att == 'device_firmwareVersion':
device['device_firmware'] = bt_device[item][item_att]
elif item_att == 'device_productID':
device['device_productid'] = bt_device[item][item_att]
elif item_att == 'device_vendorID':
device['device_vendorid'] = bt_device[item][item_att]

elif item_att == 'device_manufacturer':
device['manufacturer'] = bt_device[item][item_att]
elif item_att == 'device_majorClassOfDevice_string' or item_att == 'device_majorType':
Expand Down
3 changes: 3 additions & 0 deletions views/bluetooth_devices_listing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ table:
- {i18n_header: bluetooth.manufacturer, column: bluetooth.manufacturer}
- {i18n_header: bluetooth.majorclass, column: bluetooth.majorclass}
- {i18n_header: bluetooth.minorclass, column: bluetooth.minorclass}
- {i18n_header: bluetooth.device_vendorid, column: bluetooth.device_vendorid}
- {i18n_header: bluetooth.device_productid, column: bluetooth.device_productid}
- {i18n_header: bluetooth.device_firmware, column: bluetooth.device_firmware}
3 changes: 2 additions & 1 deletion views/bluetooth_listing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ table:
- {i18n_header: bluetooth.power, column: bluetooth.power, formatter: binaryOnOff}
- {i18n_header: bluetooth.discoverable, column: bluetooth.discoverable, formatter: binaryYesNo}
- {i18n_header: bluetooth.supports_lowenergy, column: bluetooth.supports_lowenergy, formatter: binaryYesNo}
- {i18n_header: bluetooth.supports_airdrop, column: bluetooth.supports_airdrop, formatter: formatBluetoothSupported}
- {i18n_header: bluetooth.supports_instanthotspot, column: bluetooth.supports_instanthotspot, formatter: formatBluetoothSupported}
- {i18n_header: bluetooth.supports_handoff, column: bluetooth.supports_handoff, formatter: formatBluetoothSupported}
- {i18n_header: bluetooth.remotewake, column: bluetooth.remotewake, formatter: binaryYesNo}
- {i18n_header: bluetooth.autoseek_keyboard, column: bluetooth.autoseek_keyboard, formatter: binaryYesNo}
- {i18n_header: bluetooth.autoseek_pointing, column: bluetooth.autoseek_pointing, formatter: binaryYesNo}
- {i18n_header: bluetooth.connectable, column: bluetooth.connectable, formatter: binaryYesNo}
- {i18n_header: bluetooth.apple_bluetooth_version, column: bluetooth.apple_bluetooth_version}
- {i18n_header: bluetooth.controller_chipset, column: bluetooth.controller_chipset, formatter: formatBluetoothChipset}
- {i18n_header: bluetooth.controller_firmware, column: bluetooth.controller_firmware}
8 changes: 6 additions & 2 deletions views/bluetooth_tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
if(d[prop] !== 0 && d[prop] == '' || d[prop] == null){
inforows = inforows
}
else if(prop == 'machine_address' || prop == 'hardware_transport' || prop == 'machine_name' || prop == 'vendor_id'){
else if(prop == 'controller_chipset' && d[prop] == 'THIRD_PARTY_DONGLE' ){
inforows = inforows + '<tr><th>'+i18n.t('bluetooth.'+prop)+'</th><td>'+i18n.t('bluetooth.third_party_dongle')+'</td></tr>';
}
else if(prop == 'machine_address' || prop == 'hardware_transport' || prop == 'machine_name' || prop == 'vendor_id' || prop == 'controller_chipset' || prop == 'controller_firmware'){
inforows = inforows + '<tr><th>'+i18n.t('bluetooth.'+prop)+'</th><td>'+d[prop]+'</td></tr>';
}
Expand Down Expand Up @@ -74,7 +78,7 @@
}
else if(prop == 'device_address' || prop == 'manufacturer' || prop == 'majorclass' || prop == 'minorclass' || prop == 'services'){
else if(prop == 'device_address' || prop == 'manufacturer' || prop == 'majorclass' || prop == 'minorclass' || prop == 'services' || prop == 'device_firmware' || prop == 'device_productid' || prop == 'device_vendorid'){
devicerows = devicerows + '<tr><th>'+i18n.t('bluetooth.'+prop)+'</th><td>'+d[prop]+'</td></tr>';
}
else if(prop == 'batterypercent'){
Expand Down

0 comments on commit 776becb

Please sign in to comment.