crownstone / bluenet

Bluenet is the in-house firmware on Crownstone hardware. Functions: switching, dimming, energy monitoring, presence detection, indoor localization, switchcraft.
https://crownstone.rocks
91 stars 62 forks source link

updateAdvertisement #27

Closed mrquincle closed 5 years ago

mrquincle commented 8 years ago

The updateAdvertisement function at https://github.com/crownstone/bluenet/blob/sdk_11/src/ble/cs_Stack.cpp#L634-L652 does not respect the fact that the device might NOT be advertising there.

As a workaround I'm not stopping the program if ble_advdata_set returns NRF_ERROR_INVALID_PARAMETER (0x07), but it should just not enter that function if it's not advertising.

The other functions are organized like this:

Bug: it shouldn't be possible to raise a softdevice error calling updateAdvertisement.

mrquincle commented 8 years ago

The code:

void Nrf51822BluetoothStack::updateAdvertisement() {
//      Why disabled?
//  if (!_advertising)
//      return;

    uint32_t err;
    err = ble_advdata_set(&_advdata, &_scan_resp);

    switch(err) {
    //case NRF_ERROR_INVALID_PARAMETER:
    case 0x07:
        LOGi("Invalid advertisement configuration");
        break;
    default:
    //  BLE_CALL(sd_ble_gap_adv_stop, ());
        BLE_CALL(ble_advdata_set, (&_advdata, &_scan_resp));
    //  BLE_CALL(sd_ble_gap_adv_start, (&adv_params));
    }
}
mrquincle commented 7 years ago

This needs still some love.

vliedel commented 5 years ago

This should be fixed by the advertising refactor e1df303b51c5d937e3998d20e4fe74ecda98f4da