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
BLECommunication.cpp
00001 #include "BLECommunication.h" 00002 00003 00004 BLECommunication::BLECommunication(SmartPlugBLE& system,BLE &_ble): 00005 ble(_ble),smartPlugService(ble,system) 00006 { 00007 00008 ble.init(); 00009 ble.gattServer().onDataWritten(&smartPlugService,&SmartPlugService::onDataWritten); 00010 smartPlugService.setupService(); 00011 start(); 00012 } 00013 00014 void BLECommunication::start(void) 00015 { 00016 ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); 00017 ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t*)list, sizeof(list)); 00018 ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::UNKNOWN); 00019 ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));//cannot blink after this 00020 00021 ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); 00022 ble.gap().setAdvertisingInterval(1000); /* 1000ms */ 00023 00024 ble.gap().startAdvertising(); 00025 while(true) 00026 { 00027 ble.waitForEvent(); 00028 } 00029 }
Generated on Sun Aug 14 2022 15:35:44 by
1.7.2