Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def decode(self,data):
myinfo=NBytes("Service Data uuid",self.length)
data=myinfo.decode(data)
self.payload.append(myinfo)
if data:
myinfo=Itself("Adv Payload")
data=myinfo.decode(data)
self.payload.append(myinfo)
return data
def decode(self,data):
for x in self.payload:
data=x.decode(data)
code=self.payload[0]
if code.val==b"\x02":
ev=RepeatedField("Reports", HCI_LEM_Adv_Report)
data=ev.decode(data)
self.payload.append(ev)
else:
ev=Itself("Payload")
data=ev.decode(data)
self.payload.append(ev)
return data
elif code.val == 0x14:
myinfo=NBytes_List("Service Solicitation uuid",2)
elif code.val == 0x15:
myinfo=NBytes_List("Service Solicitation uuid",16)
elif code.val == 0x16:
myinfo=Adv_Data("Advertised Data",2)
elif code.val == 0x1f:
myinfo=NBytes_List("Service Solicitation uuid",4)
elif code.val == 0x20:
myinfo=Adv_Data("Advertised Data",4)
elif code.val == 0x21:
myinfo=Adv_Data("Advertised Data",16)
elif code.val == 0xff:
myinfo=ManufacturerSpecificData()
else:
myinfo=Itself("Payload for %s"%code.strval)
xx=myinfo.decode(data[:length.val-len(code)])
self.payload.append(myinfo)
datalength -= length.val + len(code)
data=data[length.val-len(code):]
if data:
myinfo=IntByte("rssi")
data=myinfo.decode(data)
self.payload.append(myinfo)
return data