Updates to BLE 2.1.11 / ble-nrf51822 2.2.3

Minor amends:
  - bleDisconnectionCallback signature change
  - bleSetAdvertisingInterval now takes milliseconds as a parameter
  - event based invocation of DFU bootloader
master
Joe Finney 2015-12-11 00:24:21 +00:00
parent ae93079a65
commit 1e5d5c8dcf
2 changed files with 36 additions and 4 deletions

View File

@ -19,9 +19,8 @@ static MicroBitBLEManager *manager = NULL;
/**
* Callback when a BLE GATT disconnect occurs.
*/
static void bleDisconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
static void bleDisconnectionCallback(const Gap::DisconnectionCallbackParams_t *reason)
{
(void) handle; /* -Wunused-param */
(void) reason; /* -Wunused-param */
if (manager)
@ -153,7 +152,7 @@ void MicroBitBLEManager::init(ManagedString deviceName, ManagedString serialNumb
ble->accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
ble->accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)BLEName.toCharArray(), BLEName.length());
ble->setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
ble->setAdvertisingInterval(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(200));
ble->setAdvertisingInterval(200);
ble->startAdvertising();
}

View File

@ -11,6 +11,30 @@
#include "MicroBit.h"
#include "ble/UUID.h"
#if !defined(__arm)
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
/*
* The underlying Nordic libraries that support BLE do not compile cleanly with the stringent GCC settings we employ
* If we're compiling under GCC, then we suppress any warnings generated from this code (but not the rest of the DAL)
* The ARM cc compiler is more tolerant. We don't test __GNUC__ here to detect GCC as ARMCC also typically sets this
* as a compatability option, but does not support the options used...
*/
extern "C" {
#include "dfu_app_handler.h"
}
/*
* Return to our predefined compiler settings.
*/
#if !defined(__arm)
#pragma GCC diagnostic pop
#endif
/**
* Constructor.
* Create a representation of a MicroBit device.
@ -54,7 +78,16 @@ void MicroBitDFUService::onDataWritten(const GattWriteCallbackParams *params)
#if CONFIG_ENABLED(MICROBIT_DBG)
uBit.serial.printf(" ACTIVATING BOOTLOADER.\n");
#endif
bootloader_start();
// Call bootloader_start implicitly trough a event handler call
// it is a work around for bootloader_start not being public in sdk 8.1
ble_dfu_t p_dfu;
ble_dfu_evt_t p_evt;
p_dfu.conn_handle = params->connHandle;
p_evt.ble_dfu_evt_type = BLE_DFU_START;
dfu_app_on_dfu_evt(&p_dfu, &p_evt);
}
}
}