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.
Fork of NNN40_CLI by
Diff: CLI_Source/ble_cli.cpp
- Revision:
- 17:03c8af30087a
- Parent:
- 16:d1682a3e93f5
- Child:
- 18:4f5b317c04b9
diff -r d1682a3e93f5 -r 03c8af30087a CLI_Source/ble_cli.cpp
--- a/CLI_Source/ble_cli.cpp Thu Sep 08 07:10:20 2016 +0000
+++ b/CLI_Source/ble_cli.cpp Mon Sep 19 02:26:11 2016 +0000
@@ -1161,16 +1161,46 @@
char_count = 0;
}
-static void cynBLEInitCommand(void)
+/*Tsungta, @0913 modify to compatiable with mbed os 5.0*/
+#include <mbed-events/events.h>
+void onBleInitError(BLE &ble, ble_error_t error)
+{
+ (void)ble;
+ (void)error;
+ /* Initialization error handling should go here */
+}
+
+void bleInitComplete(BLE::InitializationCompleteCallbackContext *params)
{
- deltaBLE.init();
+
+}
+
+static EventQueue eventQueue(
+ /* event count */ 16 * /* event size */ 32
+);
+
+void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) {
+ BLE &deltaBLE = BLE::Instance();
+ eventQueue.post(Callback<void()>(&deltaBLE, &BLE::processEvents));
+}
+
+void cynBLEInitCommand(void)
+{
+ BLE &deltaBLE = BLE::Instance();
+
+ deltaBLE.onEventsToProcess(scheduleBleEventsProcessing);
+ deltaBLE.init(bleInitComplete);
deltaBLE.onDisconnection(disconnectionCallback);
deltaBLE.onConnection(onConnectionCallback);
deltaBLE.onTimeout(onTimeoutCallback);
deltaBLE.gattServer().onDataRead(triggerRead);
cyntecPrintOk();
+ while (true) {
+ eventQueue.dispatch();
+ }
}
+/*Tsungta, end of @0913 modification*/
//Silvia modify
static void cynBLECenInitCommand(void)
@@ -1539,7 +1569,7 @@
#endif
//
#if SIMPLE_CMD_NAME
- {"INT", cynBLEInitCommand, NULL, "Init BLE stack"},
+ //{"INT", cynBLEInitCommand, NULL, "Init BLE stack"},//Tsungta, INT is called in main.cpp
{"GIO", cynBLEGPIOCommand, NULL, "Config gpio, Usage: <GPIO NO> <set|clear>"},
{"SLP", cynBLESystemOffCommand, NULL, "System off mode, Usage: <GPIO NO>"},
{"RST", cynResetCommand, NULL, "Soft reset"},
@@ -1569,7 +1599,7 @@
{"CDN", cynBLECenDisNotifyCommand, NULL, "BLE Central disable notification of specific characteristics, Usage: <SERVICE UUID> <CHAR UUID>"},
{NULL, NULL, NULL, NULL},
#else
- {"init", cynBLEInitCommand, NULL, "Init BLE stack"},
+ //{"init", cynBLEInitCommand, NULL, "Init BLE stack"},//Tsungta, init is called in main.cpp
{"gpio", cynBLEGPIOCommand, NULL, "Config gpio, Usage: <GPIO NO> <set|clear>"},
{"sleep", cynBLESystemOffCommand, NULL, "System off mode, Usage: <GPIO NO>"},
{"reset", cynResetCommand, NULL, "Soft reset"},
