Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self):
self.name="Command Completed"
self.payload=[UIntByte("allow pkt"),OgfOcf("cmd"),Itself("resp code")]
def decode(self,data):
for x in self.payload:
data=x.decode(data)
#Now we have a sequence of len, type data with possibly a RSSI byte at the end
datalength = self.payload[-1].val
while datalength > 0:
length=UIntByte("sublen")
data=length.decode(data)
code=EIR_Hdr()
data=code.decode(data)
myinfo = None
if code.val == 0x01:
#Flag
myinfo=BitFieldByte("flags",0,["Undef","Undef","Simul LE - BR/EDR (Host)","Simul LE - BR/EDR (Control.)","BR/EDR Not Supported",
"LE General Disc.","LE Limited Disc."])
elif code.val == 0x02:
myinfo=NBytes_List("Incomplete uuids",2)
elif code.val == 0x03:
myinfo=NBytes_List("Complete uuids",2)
elif code.val == 0x04:
myinfo=NBytes_List("Incomplete uuids",4)
def __init__(self, name, subfield_cls, length_field_cls=UIntByte):
self.name = name
self.subfield_cls = subfield_cls
self.length_field = length_field_cls("count of " + name)
self.payload = []
def __init__(self):
self.name="Adv Report"
self.payload=[EnumByte("ev type",0,{0:"generic adv", 3:"no connection adv", 4:"scan rsp"}),
EnumByte("addr type",0,{0:"public", 1:"random"}),
MACAddr("peer"),UIntByte("length")]
def __init__(self,code=0,payload=[]):
super().__init__(HCI_EVENT)
self.payload.append(Byte("code"))
self.payload.append(UIntByte("length"))