Geo beacon for VF.

Dependencies:   MMA8452 aconno_bsp adc52832_common

Committer:
jurica238814
Date:
Wed Sep 13 16:28:32 2017 +0000
Revision:
27:2c67f07590fd
Parent:
25:8ac3ff431ab1
BLE works. OUT PWM WORKS! LOW power consumption. ACC TODO!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jurica238814 27:2c67f07590fd 1 /*
jurica238814 27:2c67f07590fd 2 *
jurica238814 27:2c67f07590fd 3 * Made by Jurica Resetar @ aconno
jurica238814 27:2c67f07590fd 4 * More info @ aconno.de
jurica238814 27:2c67f07590fd 5 * All right reserved
jurica238814 27:2c67f07590fd 6 *
jurica238814 27:2c67f07590fd 7 */
jurica238814 16:a338d2417fd5 8
jurica238814 16:a338d2417fd5 9 #define MAC_ADDR_SIZE_B (6)
jurica238814 16:a338d2417fd5 10
jurica238814 16:a338d2417fd5 11 // Template allows you to use 'constant' values on non-constant places (XD)
jurica238814 16:a338d2417fd5 12 template<uint8_t dataSize>
jurica238814 16:a338d2417fd5 13
jurica238814 16:a338d2417fd5 14 class ACKService{
jurica238814 16:a338d2417fd5 15 public:
jurica238814 18:e844d3e6ab88 16 const static uint16_t ACK_SERVICE_UUID = 0xA000;
jurica238814 16:a338d2417fd5 17 const static uint16_t ACK_CHARA_UUID = 0xA001;
jurica238814 16:a338d2417fd5 18 const static uint16_t ACK_MAC_CHAR_UUID = 0xA002;
jurica238814 16:a338d2417fd5 19
jurica238814 16:a338d2417fd5 20 ACKService(BLEDevice &_ble, uint8_t *_initValues) : ble(_ble), ACK(ACK_CHARA_UUID, _initValues), MAC(ACK_MAC_CHAR_UUID, _initValues, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY){
jurica238814 16:a338d2417fd5 21 GattCharacteristic *charTable[] = {&ACK, &MAC}; // Add characteristick in table
jurica238814 16:a338d2417fd5 22 GattService AckService(ACK_SERVICE_UUID, charTable, sizeof(charTable)/sizeof(GattCharacteristic *));
jurica238814 16:a338d2417fd5 23 ble.addService(AckService); // Add service in the BLE
jurica238814 16:a338d2417fd5 24 }
jurica238814 25:8ac3ff431ab1 25 inline void updateMacAddress(uint8_t *MacAddress){
jurica238814 16:a338d2417fd5 26 ble.gattServer().write(MAC.getValueHandle(), MacAddress, MAC_ADDR_SIZE_B);
jurica238814 16:a338d2417fd5 27 }
jurica238814 25:8ac3ff431ab1 28
jurica238814 25:8ac3ff431ab1 29 inline GattAttribute::Handle_t getACKCharacteristicHandle(){
jurica238814 25:8ac3ff431ab1 30 return ACK.getValueHandle();
jurica238814 25:8ac3ff431ab1 31 }
jurica238814 16:a338d2417fd5 32 private:
jurica238814 16:a338d2417fd5 33 BLEDevice &ble;
jurica238814 16:a338d2417fd5 34 // Create new characteristic
jurica238814 16:a338d2417fd5 35 WriteOnlyArrayGattCharacteristic<uint8_t, dataSize> ACK;
jurica238814 16:a338d2417fd5 36 ReadOnlyArrayGattCharacteristic<uint8_t, MAC_ADDR_SIZE_B> MAC;
jurica238814 27:2c67f07590fd 37 };