File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 22
33#import < IOBluetooth/IOBluetooth.h>
44
5+ @interface IOBluetoothDevice ()
6+ @property (nonatomic ) uint8_t batteryPercentCase;
7+ @property (nonatomic ) uint8_t batteryPercentCombined;
8+ @property (nonatomic ) uint8_t batteryPercentLeft;
9+ @property (nonatomic ) uint8_t batteryPercentRight;
10+ @property (nonatomic ) uint8_t batteryPercentSingle;
11+ @end
12+
513const char * ffDetectBluetooth (FFlist* devices /* FFBluetoothResult */ )
614{
715 NSArray <IOBluetoothDevice *>* ioDevices = IOBluetoothDevice .pairedDevices ;
1422 ffStrbufInitS (&device->name , ioDevice.name .UTF8String );
1523 ffStrbufInitS (&device->address , ioDevice.addressString .UTF8String );
1624 ffStrbufInit (&device->type );
17- device->battery = 0 ;
25+
26+ if (ioDevice.batteryPercentSingle )
27+ device->battery = ioDevice.batteryPercentSingle ;
28+ else if (ioDevice.batteryPercentCombined )
29+ device->battery = ioDevice.batteryPercentCombined ;
30+ else if (ioDevice.batteryPercentCase )
31+ device->battery = ioDevice.batteryPercentCase ;
32+
1833 device->connected = !!ioDevice.isConnected ;
1934 if (ioDevice.serviceClassMajor & kBluetoothServiceClassMajorLimitedDiscoverableMode )
2035 ffStrbufAppendS (&device->type , " Limited Discoverable Mode, " );
You can’t perform that action at this time.
0 commit comments