NordicPlayground / nRF51-ble-bcast-mesh

Other
324 stars 121 forks source link

Inconsistent ble_adv_addr in rbc_mesh_event_t #82

Closed olsky closed 8 years ago

olsky commented 8 years ago

I see some inconsistency in

rbc_mesh_event_handler(rbc_mesh_event_t* evt)

first 3 bytes of the address are ok, but not the last three. Test scenario:

Am I missing something? Thank you.

trond-snekvik commented 8 years ago

https://github.com/NordicSemiconductor/nRF51-ble-bcast-mesh/blob/sdk-8-support/nRF51/rbc_mesh/src/transport_control.c#L112 ? :)

olsky commented 8 years ago

yes, I've seen it, and have no clue why it can be different :) decided to check if its only at my side...

trond-snekvik commented 8 years ago

Essentially, the line memcpy(&evt->ble_adv_addr, p_addr, sizeof(p_mesh_adv_data)); copies only four bytes of the address structure, since sizeof(<a pointer>) is 4 on a 32-bit system.

The ble_gap_addr_t-structure we're copying is defined in the SD-header ble_gap.h, Line 394:

typedef struct
{
  uint8_t addr_type;                    /**< See @ref BLE_GAP_ADDR_TYPES. */
  uint8_t addr[BLE_GAP_ADDR_LEN];       /**< 48-bit address, LSB format. */
} ble_gap_addr_t;

and uses the first byte as addr type. Therefore, only 3 bytes of the addr-array are copied. Change the line to memcpy(&evt->ble_adv_addr, p_addr, sizeof(ble_gap_addr_t));, and you should see some improvements :)

olsky commented 8 years ago

:-) thanks, have had a coredump somehow :-D