aconno acnsensa project for iOS devices with iBeacon packets support.

Dependencies:   LSM9DS1 Si7006A20 aconno_SEGGER_RTT aconno_bsp adc52832_common

Revision:
36:9e40cdef6bd6
Parent:
34:714dfddf2cd9
Child:
38:c90e1670ffb3
--- a/main.cpp	Mon Aug 06 16:10:04 2018 +0200
+++ b/main.cpp	Wed Aug 08 14:29:44 2018 +0000
@@ -100,6 +100,7 @@
 }
 
 static advertising_packet advertisementPacket;
+const int advDataSize = sizeof(advertising_packet);
 
 void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
 {
@@ -132,9 +133,10 @@
     }
 
 	uint8_t mac[6] = {0,0,0,0,0,0};
+	uint8_t initAdvData[] = {0};
     BLEProtocol::AddressType_t temp_address_type;
     ble.gap().getAddress(&temp_address_type, myMacAddress);
-    macServicePtr = new MACService(ble, mac);
+    macServicePtr = new MACService(ble, mac, initAdvData);
     macServicePtr->updateMacAddress(myMacAddress);    // Update MAC address
 
     ble.gap().onConnection(onConnectionCallback);
@@ -251,6 +253,7 @@
 }
 
 void updateData(){
+    static uint16_t serviceUuid = macServicePtr->SERVICE_UUID;
     static uint8_t advertisementType = 0;
     int16_t temp_acc[3];
     BLE &ble = BLE::Instance();
@@ -268,6 +271,7 @@
 		/* setup advertising */
 	    ble.gap().accumulateAdvertisingPayload(
 	        GapAdvertisingData::BREDR_NOT_SUPPORTED);
+    	ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)&(serviceUuid), sizeof(serviceUuid));
 	    ble.gap().accumulateAdvertisingPayload(
 	        GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA,
 	        (uint8_t *)&advertisementPacket, sizeof(advertisementPacket));
@@ -276,6 +280,9 @@
 
         adv_data = ble.getAdvertisingData();
         advertisementPacket.type = 0x00;
+        
+        wait_ms(WAKEUP_TIME_DELAY_MS);
+        
         readGyroscope((vector3_s *)advertisementPacket.gyroscope);
         readAccelerometer((vector3_s *)temp_acc);
         readMagnetometer((vector3_s *)advertisementPacket.magnetometer);
@@ -301,6 +308,8 @@
 	    temperaturePower = 1;
 	    lightPower = 1;
 	    shdn = 1; // Wake up the pressure sensor
+	    
+	    wait_ms(WAKEUP_TIME_DELAY_MS);
 
         printf("Sensor format 2.\n");
         analogIn.updateData();
@@ -335,6 +344,8 @@
 		ble.gap().startAdvertising();
     }
     if(++advertisementType > 2) advertisementType = 0;
+    
+    macServicePtr->setAdvData((uint8_t*)&advertisementPacket);
 }
 
 int main()