Lizzy project
Dependencies: aconno_I2C Lis2dh12 adc52832_common aconno_SEGGER_RTT
aconno_ble/aconno_ble.cpp
- Committer:
- jurica238814
- Date:
- 2018-03-07
- Revision:
- 0:fc77522f4d28
- Child:
- 8:7ba4f82de9b6
File content as of revision 0:fc77522f4d28:
/* * Made by Jurica Resetar @ aconno * More info @ aconno.de * */ #include "aconno_ble.h" /** * Callback triggered when the ble initialization process has finished */ void bleInitComplete(BLE::InitializationCompleteCallbackContext *params) { advertising_packet advertisementPacket; BLE& ble = params->ble; ble_error_t error = params->error; if (error != BLE_ERROR_NONE) { return; } /* Ensure that it is the default instance of BLE */ if(ble.getInstanceID() != BLE::DEFAULT_INSTANCE) { return; } advertisementPacket.header = APPLICATION_ID; advertisementPacket.type = 0x00; advertisementPacket.gyroscope[0] = (int16_t)0; advertisementPacket.gyroscope[1] = (int16_t)0; advertisementPacket.gyroscope[2] = (int16_t)0; advertisementPacket.accelerometer[0] = (int16_t)0; advertisementPacket.accelerometer[1] = (int16_t)0; advertisementPacket.accelerometer[2] = (int16_t)0; advertisementPacket.magnetometer[0] = (int16_t)0; advertisementPacket.magnetometer[1] = (int16_t)0; advertisementPacket.magnetometer[2] = (int16_t)0; /* setup advertising */ ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED); ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, (uint8_t *)&advertisementPacket, sizeof(uint8_t)*11); ble.gap().setAdvertisingInterval(ADV_INTERVAL_MS); ble.gap().startAdvertising(); } void updatePayload(BLE *ble, advertising_packet *advertisementPacket) { ble->gap().stopAdvertising(); GapAdvertisingData advetisementData = GapAdvertisingData(); advetisementData = ble->getAdvertisingData(); advetisementData.updateData(advetisementData.MANUFACTURER_SPECIFIC_DATA, (uint8_t *)advertisementPacket, sizeof(advertising_packet)); ble->setAdvertisingData(advetisementData); //ble->gap().startAdvertising(); }