There seems to be discrepancy between documentation which descrbes content of the data received by bluetooth.get_adv()

"data contains the complete 31 bytes of the advertisement message".

That is true in one case, but not another as decribed below:

 

First I created and sent test pattern in advertising packet and then tried to receive it with TI sniffer.

When my adv data is set to test pattern:

010102030405060708090a0b0c0d0e0f1011121314151617

I can clearly see it in TI sniffer:

w

 

And then with WiPy:

 

(mac=b'\xb4\x99Ld\xba\xc9', addr_type=0, adv_type=0, rssi=-55, data=b'\x01\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\xca\x00\xf8\xff\xfd?\x1c')
b'\x01\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\xca\x00\xf8\xff\xfd?\x1c'
010102030405060708090a0b0c0d0e0f1011121314151617ca00f8fffd3f1c
None

 

Code to print above lines is:

 

adv = bluetooth.get_adv()

print(adv)
print(adv.data)
print( binascii.hexlify(adv.data).decode("utf-8"))

print(bluetooth.resolve_adv_data(adv.data, Bluetooth.ADV_MANUFACTURER_DATA))

 

When I switched content of advertising packet to contain my sensor data, there is Scan request performed by WiPy as it is clerly visible on sniffed data below:

:

qq

 

and there is no mention of needed data:

 

01A8681E.....

in WiPy output!!!:

 

(mac=b'\xb4\x99Ld\xba\xc9', addr_type=0, adv_type=0, rssi=-54, data=b'\x01h\n\tSensorTag\x05\x12P\x00 \x03\x02\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
b'\x01h\n\tSensorTag\x05\x12P\x00 \x03\x02\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
01680a0953656e736f72546167051250002003020a00000000000000000000
None

 

Later I have modified my advertising packet to contain ADV_NON_CONN_IND Adv PDU Type

 

 

Which has prevented WyPy from sending ScanA packet, but data reported by WiPy is only partially OK:

 

(mac=b'\xb4\x99Ld\xba\xc9', addr_type=0, adv_type=0, rssi=-55, data=b'\x01\x01\x06\x11\x06\xbaV\x89\xa6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
b'\x01\x01\x06\x11\x06\xbaV\x89\xa6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
0101061106ba5689a600000000000000000000000000000000000000000000
None

 

Is this really a bug?, or a feature, that can be solved by some undocumented settings change?

 

So my question is: How do I receive data contained in Advertising packet (01A8 to 9F01) ???

 

Full program: (Tabs are not showing...)

bluetooth = Bluetooth()
bluetooth.start_scan(-1)
allmessagecount=0

while True:
try:
adv = bluetooth.get_adv()

if adv:

if (allmessagecount %2) == 0:
pycom.rgbled(0x000030)
else:
pycom.rgbled(0x00007f)
allmessagecount=allmessagecount+1

gc.collect()

print(adv)
print(adv.data)
print( binascii.hexlify(adv.data).decode("utf-8"))

mfg_data = bluetooth.resolve_adv_data(adv.data, Bluetooth.ADV_MANUFACTURER_DATA)
print(mfg_data)

except Exception as err:
print('MainLoop-ERR#: ',err)
gc.collect()