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.
aconnoBLE.cpp
00001 /* 00002 * Made by Jurica @ aconno 00003 * All rights reserved 00004 * 00005 */ 00006 00007 #include "aconnoBLE.h" 00008 #include "BLEConfig.h" 00009 #include "ble/BLE.h" 00010 #include "GapAdvertisingData.h" 00011 #include "BLEData.h" 00012 #include "service.h" 00013 00014 extern advertisingFormat manufacturerSpecificData; 00015 static EventQueue eventQueue(EVENT_COUNT * EVENTS_EVENT_SIZE); 00016 Service *service; 00017 00018 00019 void onBleInitError(BLE &ble, ble_error_t error) 00020 { 00021 /* Avoid compiler warnings */ 00022 (void) ble; 00023 (void) error; 00024 /* Initialization error handling should go here */ 00025 } 00026 00027 void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) 00028 { 00029 BLE &ble = context->ble; 00030 eventQueue.call(Callback<void()>(&ble, &BLE::processEvents)); 00031 } 00032 00033 EventQueue *getBLEEventQueue(void) 00034 { 00035 return &eventQueue; 00036 } 00037 00038 void bleInitComplete(BLE::InitializationCompleteCallbackContext *params){ 00039 BLE &ble = params->ble; 00040 00041 /* setup NTP service and characteristic */ 00042 service = new Service(ble); 00043 ble.gap().onDisconnection(disconnectionCallback); 00044 ble.gap().onConnection(onConnectionCallback); 00045 ble.gattServer().onDataWritten(onDataCallback); 00046 00047 /* setup event handling */ 00048 ble.onEventsToProcess(scheduleBleEventsProcessing); 00049 00050 /* setup advertising */ 00051 ble.gap().accumulateAdvertisingPayload( 00052 GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, 00053 (uint8_t *)&manufacturerSpecificData, sizeof(advertisingFormat)); 00054 ble.gap().setAdvertisingInterval(A_ADV_INTERVAL_MS); 00055 ble.gap().startAdvertising(); 00056 } 00057 00058 void onConnectionCallback(const Gap::ConnectionCallbackParams_t *params){ 00059 //printf("Device is connected.\n"); 00060 } 00061 00062 void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params){ 00063 //printf("Device is disconnected.\n"); 00064 BLE::Instance().gap().startAdvertising(); 00065 } 00066 00067 void onDataCallback(const GattWriteCallbackParams *params){ 00068 if(params->handle == service->getTimeCharacteristicHandle()){ 00069 } 00070 }
Generated on Tue Aug 23 2022 10:29:07 by
1.7.2