Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822
Fork of BLE_Button by
Revision 12:d6be80bffa01, committed 2016-09-01
- Comitter:
- trvd1707
- Date:
- Thu Sep 01 17:47:24 2016 +0000
- Parent:
- 11:80a9d811aab1
- Commit message:
- Adding Led2 to debug
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Aug 31 21:50:26 2016 +0000
+++ b/main.cpp Thu Sep 01 17:47:24 2016 +0000
@@ -53,6 +53,7 @@
void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
{
BLE::Instance().gap().startAdvertising();
+ led2=1;
}
void periodicCallback(void)
@@ -66,6 +67,12 @@
void onBleInitError(BLE &ble, ble_error_t error)
{
/* Initialization error handling should go here */
+ while(1) {
+ led2 = 0;
+ wait(0.2);
+ led2 = 1;
+ wait(0.2);
+ }
}
/**
@@ -73,6 +80,7 @@
*/
void bleInitComplete(BLE::InitializationCompleteCallbackContext *params)
{
+ led2=0;
BLE& ble = params->ble;
ble_error_t error = params->error;
@@ -84,6 +92,7 @@
/* Ensure that it is the default instance of BLE */
if(ble.getInstanceID() != BLE::DEFAULT_INSTANCE) {
+ onBleInitError(ble, error);
return;
}
@@ -112,16 +121,16 @@
button.rise(buttonReleasedCallback);
BLE &ble = BLE::Instance();
- ble.init(bleInitComplete);
+ ble_error_t error = ble.init(bleInitComplete) ;
+ if ( error != BLE_ERROR_NONE){
+ /* In case of error, forward the error handling to onBleInitError */
+ onBleInitError(ble, error);
+ }
/* SpinWait for initialization to complete. This is necessary because the
* BLE object is used in the main loop below. */
- while (ble.hasInitialized() == false) { /* spin loop */
- led2 = 0;
- wait(0.1);
- led2 = 1 ;
- }
- led2 = 0;
+// while (ble.hasInitialized() == false) { /* spin loop */
+ // }
while (true) {
if (buttonState != IDLE) {
buttonServicePtr->updateButtonState(buttonState);
