Andriy Makukha
/
football_project_wo_output
football_project_wo_output
Fork of football_project by
Diff: main.cpp
- Revision:
- 90:b4d53a870147
- Parent:
- 89:425369a595c4
- Child:
- 91:0fc897cccc06
--- a/main.cpp Sat Jun 11 06:50:32 2016 +0000 +++ b/main.cpp Sun Jun 12 05:10:34 2016 +0000 @@ -3,7 +3,7 @@ #include "output.h" #include <DebounceIn.h> #ifdef BLE_ENABLE - #include "ble/BLE.h" + #include "ble/services/DFUService.h" #endif using namespace std; @@ -12,12 +12,15 @@ Output out; #ifdef BLE_ENABLE +BLEDevice ble; +DFUService dfu(ble); + /* Optional: Device Name, add for human read-ability */ -const static char DEVICE_NAME[] = "PassiveCoach"; +//const static char DEVICE_NAME[] = "PassiveCoach"; /* You have up to 26 bytes of advertising data to use. */ //const static uint8_t AdvData[] = {0x01,0x02,0x03,0x04,0x05}; /* Example of hex data */ -const static uint8_t AdvData[] = {"Keep the Space!"}; /* Example of character data */ +//const static uint8_t AdvData[] = {"Keep the Space!"}; /* Example of character data */ #endif // BLE_ENABLE /////////////////////////////////// PINS /////////////////////////////////// @@ -138,64 +141,63 @@ } #ifdef BLE_ENABLE -/* Optional: Restart advertising when peer disconnects */ +/* +// Optional: Restart advertising when peer disconnects void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params) { BLE::Instance().gap().startAdvertising(); } -/** - * This function is called when the ble initialization process has failed - */ + +// This function is called when the ble initialization process has failed void onBleInitError(BLE &ble, ble_error_t error) { - /* Avoid compiler warnings */ + // Avoid compiler warnings (void) ble; (void) error; - /* Initialization error handling should go here */ + // Initialization error handling should go here } -/** - * Callback triggered when the ble initialization process has finished - */ +// Callback triggered when the ble initialization process has finished void bleInitComplete(BLE::InitializationCompleteCallbackContext *params) { BLE& ble = params->ble; ble_error_t error = params->error; if (error != BLE_ERROR_NONE) { - /* In case of error, forward the error handling to onBleInitError */ + // In case of error, forward the error handling to onBleInitError onBleInitError(ble, error); return; } - /* Ensure that it is the default instance of BLE */ + // Ensure that it is the default instance of BLE if(ble.getInstanceID() != BLE::DEFAULT_INSTANCE) { return; } - /* Set device name characteristic data */ + // Set device name characteristic data ble.gap().setDeviceName((const uint8_t *) DEVICE_NAME); - /* Optional: add callback for disconnection */ + // Optional: add callback for disconnection ble.gap().onDisconnection(disconnectionCallback); - /* Sacrifice 3B of 31B to Advertising Flags */ + // Sacrifice 3B of 31B to Advertising Flags ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE ); ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); - /* Sacrifice 2B of 31B to AdvType overhead, rest goes to AdvData array you define */ + // Sacrifice 2B of 31B to AdvType overhead, rest goes to AdvData array you define ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, AdvData, sizeof(AdvData)); - /* Optional: Add name to device */ + // Optional: Add name to device ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); - /* Set advertising interval. Longer interval == longer battery life */ - ble.gap().setAdvertisingInterval(100); /* 100ms */ + // Set advertising interval. Longer interval == longer battery life + ble.gap().setAdvertisingInterval(100); // 100ms - /* Start advertising */ + // Start advertising ble.gap().startAdvertising(); } +*/ #endif // BLE_ENABLE /////////////////////////////////// CLASSES /////////////////////////////////// @@ -335,8 +337,10 @@ #ifdef BLE_ENABLE // BLE initialization + /* BLE& ble = BLE::Instance(BLE::DEFAULT_INSTANCE); ble.init(bleInitComplete); // Initialize BLE baselayer + */ #endif // BLE_ENABLE // Pick node number @@ -474,7 +478,7 @@ } #ifdef BLE_ENABLE - ble.waitForEvent(); +// ble.waitForEvent(); #endif } } \ No newline at end of file