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: LSM9DS1 Si7006A20 aconno_SEGGER_RTT aconno_bsp adc52832_common
service.h
00001 /* 00002 * 00003 * Made by Jurica Resetar @ aconno 00004 * More info @ aconno.de 00005 * All right reserved 00006 * 00007 */ 00008 00009 #include "service_macros.h" 00010 00011 #define MAC_ADDR_SIZE_B (6) 00012 00013 extern const int advDataSize; 00014 00015 class MACService{ 00016 public: 00017 const static uint16_t SERVICE_UUID = 0xA000; 00018 const static uint16_t ADV_DATA_UUID = 0xA001; 00019 const static uint16_t MAC_CHAR_UUID = 0xA002; 00020 00021 MACService(BLEDevice &_ble, uint8_t *mac, uint8_t *initAdvData) : ble(_ble), 00022 MAC(MAC_CHAR_UUID, mac), 00023 advData(ADV_DATA_UUID, initAdvData, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) 00024 { 00025 // Add characteristic in table 00026 GattCharacteristic *charTable[] = {&MAC, &advData}; 00027 GattService MACService(SERVICE_UUID, charTable, 00028 sizeof(charTable)/sizeof(GattCharacteristic *)); 00029 ble.addService(MACService); // Add service in the BLE 00030 } 00031 inline void updateMacAddress(uint8_t *MacAddress){ 00032 ble.gattServer().write(MAC.getValueHandle(), 00033 MacAddress, MAC_ADDR_SIZE_B); 00034 } 00035 00036 CHARACTERISTIC_A(ReadOnly, uint8_t, 25, advData, AdvData); 00037 00038 private: 00039 BLEDevice &ble; 00040 // Create new characteristic 00041 ReadOnlyArrayGattCharacteristic<uint8_t, MAC_ADDR_SIZE_B> MAC; 00042 };
Generated on Fri Jul 15 2022 07:56:49 by
1.7.2