Skip to content

Commit 6d1e76b

Browse files
bluetooth: Add EIR appearance
1 parent a8583a5 commit 6d1e76b

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

scapy/layers/bluetooth.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,71 @@ class EIR_PublicTargetAddress(EIR_Element):
12631263
]
12641264

12651265

1266+
class EIR_Appearance(EIR_Element):
1267+
name = "EIR_Appearance2"
1268+
fields_desc = [
1269+
BitEnumField('category', 0, 10, tot_size=-2, enum={
1270+
0x000: 'Unknown',
1271+
0x001: 'Phone',
1272+
0x002: 'Computer',
1273+
0x003: 'Watch',
1274+
0x004: 'Clock',
1275+
0x005: 'Display',
1276+
0x006: 'Remote Control',
1277+
0x007: 'Eyeglasses',
1278+
0x008: 'Tag',
1279+
0x009: 'Keyring',
1280+
0x00A: 'Media Player',
1281+
0x00B: 'Barcode Scanner',
1282+
0x00C: 'Thermometer',
1283+
0x00D: 'Heart Rate Sensor',
1284+
0x00E: 'Blood Pressure',
1285+
0x00F: 'Human Interface Device',
1286+
0x010: 'Glucose Meter',
1287+
0x011: 'Running Walking Sensor',
1288+
0x012: 'Cycling',
1289+
0x013: 'Control Device',
1290+
0x014: 'Network Device',
1291+
0x015: 'Sensor',
1292+
0x016: 'Light Fixtures',
1293+
0x017: 'Fan',
1294+
0x018: 'HVAC',
1295+
0x019: 'Air Conditioning',
1296+
0x01A: 'Humidifier',
1297+
0x01B: 'Heating',
1298+
0x01C: 'Access Control',
1299+
0x01D: 'Motorized Device',
1300+
0x01E: 'Power Device',
1301+
0x01F: 'Light Source',
1302+
0x020: 'Window Covering',
1303+
0x021: 'Audio Sink',
1304+
0x022: 'Audio Source',
1305+
0x023: 'Motorized Vehicle',
1306+
0x024: 'Domestic Appliance',
1307+
0x025: 'Wearable Audio Device',
1308+
0x026: 'Aircraft',
1309+
0x027: 'AV Equipment',
1310+
0x028: 'Display Equipment',
1311+
0x029: 'Hearing aid',
1312+
0x02A: 'Gaming',
1313+
0x02B: 'Signage',
1314+
0x031: 'Pulse Oximeter',
1315+
0x032: 'Weight Scale',
1316+
0x033: 'Personal Mobility Device',
1317+
0x034: 'Continuous Glucose Monitor',
1318+
0x035: 'Insulin Pump',
1319+
0x036: 'Medication Delivery',
1320+
0x037: 'Spirometer',
1321+
0x051: 'Outdoor Sports Activity'
1322+
}),
1323+
XBitField('subcategory', 0, 6, end_tot_size=-2)
1324+
]
1325+
1326+
@property
1327+
def appearance(self):
1328+
return (self.category << 6) + self.subcategory
1329+
1330+
12661331
class EIR_ServiceData32BitUUID(EIR_Element):
12671332
name = 'EIR Service Data - 32-bit UUID'
12681333
fields_desc = [
@@ -2376,6 +2441,7 @@ class HCI_LE_Meta_Long_Term_Key_Request(Packet):
23762441
bind_layers(EIR_Hdr, EIR_ServiceSolicitation128BitUUID, type=0x15)
23772442
bind_layers(EIR_Hdr, EIR_ServiceData16BitUUID, type=0x16)
23782443
bind_layers(EIR_Hdr, EIR_PublicTargetAddress, type=0x17)
2444+
bind_layers(EIR_Hdr, EIR_Appearance, type=0x19)
23792445
bind_layers(EIR_Hdr, EIR_ServiceData32BitUUID, type=0x20)
23802446
bind_layers(EIR_Hdr, EIR_ServiceData128BitUUID, type=0x21)
23812447
bind_layers(EIR_Hdr, EIR_Manufacturer_Specific_Data, type=0xff)

test/scapy/layers/bluetooth.uts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,13 @@ p = HCI_Hdr(hex_bytes('043e1402010001554433221100080717ffeeddccbbaaaa'))
476476
assert EIR_PublicTargetAddress in p
477477
assert p[EIR_PublicTargetAddress].bd_addr == 'aa:bb:cc:dd:ee:ff'
478478

479+
= Parse EIR_Appearance
480+
p = BTLE(hex_bytes("d6be898e201660d4d3cebffb0201050319420c0303e7fe040948393850c27c"))
481+
assert EIR_Appearance in p
482+
assert p[EIR_Appearance].appearance == 0x0c42
483+
assert p[EIR_Appearance].category == 0x31 #'Pulse Oximeter'
484+
assert p[EIR_Appearance].subcategory == 0x02 # Wrist Worn Pulse Oximeter
485+
479486
= Parse EIR_ServiceData32BitUUID
480487

481488
p = HCI_Hdr(hex_bytes('042fff01c47c80894df801000c0128a269a30c4a125d13f30196894df80c012820f61a1a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'))

0 commit comments

Comments
 (0)