% 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 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 = BTLE layers # a crazy packet with all classes in it! pkt = BTLE()/BTLE_ADV()/BTLE_ADV_DIRECT_IND()/BTLE_ADV_IND()/BTLE_ADV_NONCONN_IND()/BTLE_ADV_SCAN_IND()/BTLE_CONNECT_REQ()/BTLE_DATA()/BTLE_PPI()/BTLE_SCAN_REQ()/BTLE_SCAN_RSP() assert BTLE in pkt.layers() assert BTLE_ADV in pkt.layers() assert BTLE_ADV_DIRECT_IND in pkt.layers() assert BTLE_ADV_IND in pkt.layers() assert BTLE_ADV_NONCONN_IND in pkt.layers() assert BTLE_ADV_SCAN_IND in pkt.layers() assert BTLE_CONNECT_REQ in pkt.layers() assert BTLE_DATA in pkt.layers() assert BTLE_PPI in pkt.layers() assert BTLE_SCAN_REQ in pkt.layers() assert BTLE_SCAN_RSP in pkt.layers()