Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[android] length 0 of device manufacturer data #28

Open
mrquincle opened this issue Apr 9, 2017 · 11 comments
Open

[android] length 0 of device manufacturer data #28

mrquincle opened this issue Apr 9, 2017 · 11 comments
Labels

Comments

@mrquincle
Copy link

Error with one of the properties regarding device manufacturer data.

04-09 12:47:29.517  3910  4310 D bt_btif_gattc: btif_gattc_update_properties BLE device name=Crown len=5 dev_type=2
04-09 12:47:29.517  3910  4310 E bt_btif : property type:241, len:0 is invalid
04-09 12:47:29.517  3910  4310 E bt_btif_dm: ### ASSERT : system/bt/main/../btif/src/btif_dm.c line 4655 failed to save remote device manufacturer (1) ###

Is the length properly set for the custom data that is sent?

@AlexDM0
Copy link
Contributor

AlexDM0 commented Apr 9, 2017 via email

@mrquincle
Copy link
Author

mrquincle commented Apr 9, 2017

Feel free to move to appropriate location. If this is intended behavior on Android device it belongs here (I thought). If it reflects a bug in the firmware, it might be moved there.

@mrquincle
Copy link
Author

mrquincle commented Apr 9, 2017

In https://github.com/crownstone/bluenet/blob/master/src/ble/cs_Stack.cpp#L358

void Nrf51822BluetoothStack::configureIBeaconAdvData(IBeacon* beacon) {

The getArray() function from cs_iBeacon.h is used, which is hardcoded to 23. So that can't go wrong...

In https://github.com/crownstone/bluenet/blob/master/src/ble/cs_Stack.cpp#L411

void Nrf51822BluetoothStack::configureBleDeviceAdvData() {

The struct _advdata.p_manuf_specific_data is not set, neither the size of that struct.

This function seems not to be used? In a case CONFIG_IBEACON_ENABLED in cs_main_crownstone.cpp:

bool enabled = *(bool*)p_data;

This needs a low-level check to see how the packets actually look.

@mrquincle
Copy link
Author

mrquincle commented Apr 9, 2017

In wireshark I see the following:

Device d6:cc:73:b4:9c:be:

Bluetooth HCI Event - LE Meta
    Event Code: LE Meta (0x3e)
    Parameter Total Length: 40
    Sub Event: LE Advertising Report (0x02)
    Num Reports: 1
    Event Type: Scan Response (0x04)
    Peer Address Type: Random Device Address (0x01)
    BD_ADDR: d6:cc:73:b4:9c:be (d6:cc:73:b4:9c:be)
    Data Length: 28
    Advertising Data
        Service Data - 16 bit UUID
            Length: 20
            Type: Service Data - 16 bit UUID (0x16)
            UUID 16: Unknown (0xc001)
            Service Data: 0170f842830d8f9aae0b540d4ddf25faa6
        Device Name (shortened): Crown
            Length: 6
            Type: Device Name (shortened) (0x08)
            Device Name: Crown
    RSSI (dB): -88

Device cb:69:b8:69:14:6e:

Bluetooth HCI Event - LE Meta
    Event Code: LE Meta (0x3e)
    Parameter Total Length: 40
    Sub Event: LE Advertising Report (0x02)
    Num Reports: 1
    Event Type: Scan Response (0x04)
    Peer Address Type: Random Device Address (0x01)
    BD_ADDR: cb:69:b8:69:14:6e (cb:69:b8:69:14:6e)
    Data Length: 28
    Advertising Data
        Service Data - 16 bit UUID
            Length: 20
            Type: Service Data - 16 bit UUID (0x16)
            UUID 16: Unknown (0xc001)
            Service Data: 01181fba5e9422fc47a8951a348dacd26f
        Device Name (shortened): Crown
            Length: 6
            Type: Device Name (shortened) (0x08)
            Device Name: Crown
    RSSI (dB): -92

There are no differences that I can spot at first sight.

Then the same devices again, but for their iBeacon advertisements:

Device d6:cc:73:b4:9c:be:

See: Event Type: Connectable Undirected Advertising (0x00)

Bluetooth HCI Event - LE Meta
    Event Code: LE Meta (0x3e)
    Parameter Total Length: 42
    Sub Event: LE Advertising Report (0x02)
    Num Reports: 1
    Event Type: Connectable Undirected Advertising (0x00)
    Peer Address Type: Random Device Address (0x01)
    BD_ADDR: d6:cc:73:b4:9c:be (d6:cc:73:b4:9c:be)
    Data Length: 30
    Advertising Data
        Flags
            Length: 2
            Type: Flags (0x01)
            000. .... = Reserved: 0x0
            ...0 .... = Simultaneous LE and BR/EDR to Same Device Capable (Host): false (0x0)
            .... 0... = Simultaneous LE and BR/EDR to Same Device Capable (Controller): false (0x0)
            .... .1.. = BR/EDR Not Supported: true (0x1)
            .... ..1. = LE General Discoverable Mode: true (0x1)
            .... ...0 = LE Limited Discoverable Mode: false (0x0)
        Manufacturer Specific
            Length: 26
            Type: Manufacturer Specific (0xff)
            Company ID: Apple, Inc. (0x004c)
            Data: 021521719e9ddbb9434a9d9085e335fcccba778527dbc4
    RSSI (dB): -89

Device cb:69:b8:69:14:6e:

See: Event Type: Non-Connectable Undirected Advertising (0x03)

Bluetooth HCI Event - LE Meta
    Event Code: LE Meta (0x3e)
    Parameter Total Length: 42
    Sub Event: LE Advertising Report (0x02)
    Num Reports: 1
    Event Type: Non-Connectable Undirected Advertising (0x03)
    Peer Address Type: Random Device Address (0x01)
    BD_ADDR: cb:69:b8:69:14:6e (cb:69:b8:69:14:6e)
    Data Length: 30
    Advertising Data
        Flags
            Length: 2
            Type: Flags (0x01)
            000. .... = Reserved: 0x0
            ...0 .... = Simultaneous LE and BR/EDR to Same Device Capable (Host): false (0x0)
            .... 0... = Simultaneous LE and BR/EDR to Same Device Capable (Controller): false (0x0)
            .... .1.. = BR/EDR Not Supported: true (0x1)
            .... ..1. = LE General Discoverable Mode: true (0x1)
            .... ...0 = LE Limited Discoverable Mode: false (0x0)
        Manufacturer Specific
            Length: 26
            Type: Manufacturer Specific (0xff)
            Company ID: Apple, Inc. (0x004c)
            Data: 021521719e9ddbb9434a9d9085e335fcccbaf93a43fec4
    RSSI (dB): -92

Do I have an old version for one of the Crownstone's firmware? Where can I check that?

@mrquincle
Copy link
Author

mrquincle commented Apr 9, 2017

Correction. They both send out connectable and non-connectable iBeacon advertisements.

@AlexDM0
Copy link
Contributor

AlexDM0 commented Apr 9, 2017 via email

@mrquincle
Copy link
Author

This probably stems from not using a UUID from SIG yet as 16-bit Service Data UUID.

The question is... Do we need it? Do we actually use the Shortened Local Name (0x08) type in the scan response, see https://github.com/crownstone/bluenet/blob/master/docs/PROTOCOL.md?

I think we can get rid of these 10 bytes and use a 128 bit UUID that does not need registering.

Another road would be to not use scan responses at all. Just use our own advertisement type. We already have a company UUID. So it makes sense to use Manufacturer Specific (Data GAP 11.1.4) with the 16 bit company identifier.

@vliedel
Copy link
Contributor

vliedel commented Apr 10, 2017

If we use the 128bit UUID, we don't have enough bytes left for the data. 1B AD len + 1B ad type + 16B UUID + 17B data = 35B, while we only have 31B. We only made the name as long as possible, and would drop it if it wouldn't fit.

@vliedel
Copy link
Contributor

vliedel commented Apr 10, 2017

For the other road: we could indeed interleave iBeacon messages with the data messages, and not use a scan response at all. However, I think IPhones may not be able to recognize which IBeacon messages belongs to which data messages (as you don't get the MAC address), @AlexDM0 should know.

@AlexDM0
Copy link
Contributor

AlexDM0 commented Apr 10, 2017 via email

@AlexDM0
Copy link
Contributor

AlexDM0 commented Oct 26, 2021

Is this still an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants