2018-03-13 19:01:03 +00:00
|
|
|
% Regression tests for the bluetooth4LE layer
|
|
|
|
|
|
|
|
###################################
|
|
|
|
#### Bluetooth 4.0 Low Energie ####
|
|
|
|
###################################
|
|
|
|
|
|
|
|
+ BTLE tests
|
|
|
|
|
|
|
|
= Default build
|
|
|
|
|
|
|
|
a = BTLE()/BTLE_ADV()/BTLE_ADV_IND()
|
|
|
|
assert raw(a) == b'\xd6\xbe\x89\x8e\x00\x06\x00\x00\x00\x00\x00\x00Z9`'
|
|
|
|
|
|
|
|
= Basic dissection
|
|
|
|
|
|
|
|
b = BTLE(raw(a))
|
|
|
|
assert b.crc == 0x5a3960
|
|
|
|
assert b[BTLE_ADV_IND].AdvA == '00:00:00:00:00:00'
|
|
|
|
|
|
|
|
= BTLE_DATA build
|
|
|
|
|
|
|
|
a = BTLE(access_addr=0)/BTLE_DATA()/"toto"
|
|
|
|
a = BTLE(raw(a))
|
|
|
|
assert a[BTLE_DATA].len == 4
|
2018-07-17 14:55:48 +00:00
|
|
|
assert a[Raw].load == b"toto"
|
|
|
|
|
|
|
|
test1 = BTLE() / BTLE_ADV() / BTLE_ADV_IND() / EIR_Hdr() / EIR_ShortenedLocalName(local_name= 'wussa')
|
|
|
|
test1e = BTLE(raw(test1))
|
|
|
|
assert test1e[EIR_ShortenedLocalName].local_name == b"wussa"
|
|
|
|
|
|
|
|
test2 = BTLE(access_addr=1) / BTLE_DATA() / CtrlPDU(version=7)
|
|
|
|
test2e = BTLE(raw(test2))
|
|
|
|
assert test2e[CtrlPDU].version == 7
|
|
|
|
|
|
|
|
test3 = BTLE(access_addr=1) / BTLE_DATA() / L2CAP_Hdr() / ATT_Hdr() / ATT_PrepareWriteReq(handle = 0xa, value="test")
|
|
|
|
test3e = BTLE(raw(test3))
|
|
|
|
assert test3e[ATT_PrepareWriteReq].value == b"test"
|
|
|
|
assert test3e[ATT_PrepareWriteReq].handle == 0xa
|
|
|
|
assert test3e[ATT_Hdr].opcode == 0x16
|