BlueTooth advertising data



  • Tag: Bletooth data

    This is maybe easier to see here:

    http://bellacon.com/Forum/advertising.html

    I am trying to receive content of advertising packet as I am receiving using TI sniffer.

    When my adv data is set to test pattern:

    010102030405060708090a0b0c0d0e0f1011121314151617

    I can clearly see it in TI sniffer:

    alt text

    As well in content of adv.data:

    (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 advertising packet data changes to contain my sensor data, there is Scan request performed by WiPy as it is clerly visible on sniffed data below:

    alt text

    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

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

    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()



  • @zmrzli

    Make sure you are sending the correct length and AD types according to the ADVERTISING AND SCAN RESPONSE DATA FORMAT (page 2081 on the Bluetooth 4.2 Core Spec - you can access the specification here https://www.bluetooth.com/specifications/adopted-specifications ).

    If you're looking to use BLE advertising packets to send your data you probably want to use AD type 0xFF (Manufacturer Specific Data) followed by the 2 company identifier octets.

    So your format should be 1 byte length + 0xFF + <2 bytes company identifier> + your data then filled with 00 until the 31 byte limit.

    You can't read improperly formatted advertising data.



Pycom on Twitter