aconno acnsensa project for iOS devices with iBeacon packets support.

Dependencies:   LSM9DS1 Si7006A20 aconno_SEGGER_RTT aconno_bsp adc52832_common

Revision:
15:9870514aec92
Parent:
10:a2364dee495f
Parent:
13:4747e6e8396a
Child:
16:e86a91db0b72
--- a/main.cpp	Wed Aug 01 17:10:46 2018 +0200
+++ b/main.cpp	Wed Aug 01 17:13:18 2018 +0200
@@ -39,9 +39,11 @@
 #define DEBUG_PRINT     (1)
 #define SLEEP_TIME      (0.150)          /* Sleep time in seconds */
 #define WAKE_UP_TIME    (0.150)          /* Awake time in ms */
-#define ADV_INTERVAL    (100)            /* Advertising interval in ms */
+#define ADV_INTERVAL    (1000)            /* Advertising interval in ms */
 #define GO_TO_SLEEP     (0)              /* Sleep flag: 0 -> Device will not go to sleep, 1 -> Will go to sleep mode */
-#define CALIBRATION_STEPS 20
+#define CALIBRATION_STEPS (20)
+
+#define TX_POWER        (4)
 
 static NRF52_SAADC analogIn;
 static NRF52_DigitalOut lightPower(p28);
@@ -131,6 +133,7 @@
     ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, (uint8_t *)&advertisementPacket, sizeof(advertisementPacket));
     ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED);    
     ble.gap().setAdvertisingInterval(ADV_INTERVAL);
+    ble.gap().setTxPower(TX_POWER);        // Set TX power to TX_POWER
     ble.gap().startAdvertising();    
 }
 
@@ -148,16 +151,7 @@
 
 uint8_t getBattery(){
     uint16_t batteryVoltage = analogIn.getData()[0];
-    /* // Old code.
-    if(batteryVoltage >= 810) return 100;
-    if(batteryVoltage >= 796) return 85;
-    if(batteryVoltage >= 782) return 75;
-    if(batteryVoltage >= 768) return 50;
-    if(batteryVoltage >= 754) return 25;
-    if(batteryVoltage >= 740) return 10;
-    return 0;
-    */
-    // New version.
+    
     const uint16_t zero_percent_limit = 739;
     const uint16_t onehundred_percent_limit = 810;
     const uint16_t percentage_increments = 5;