ADT7410 sample

Dependencies:   ADT7410 BLE_API mbed nRF51822

Fork of BLENano_SimpleTemplate_temp_170802 by Jun ADI

Files at this revision

API Documentation at this revision

Comitter:
Jun_adi
Date:
Sun Aug 13 05:45:20 2017 +0000
Parent:
7:a1e3e531e518
Commit message:
ADT7410 Sample for BLE Nano

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r a1e3e531e518 -r 236994820e39 main.cpp
--- a/main.cpp	Wed Aug 02 13:31:52 2017 +0000
+++ b/main.cpp	Sun Aug 13 05:45:20 2017 +0000
@@ -113,18 +113,24 @@
 //onTimeout
 //======================================================================
 
-/*
+
 void m_status_check_handle(void)
 {   
-    uint8_t buf[2];
-    //Read Analog port
-    float s = ANALOG;
-    uint16_t value = s*1024; 
-    buf[0] = (value >> 8);
-    buf[1] = value;
+        uint8_t buf[2];
+        float tempadt;
+        
+        // get temperature every two seconds
+        tempadt = temp.getTemp();
+    
+        int16_t value0 = tempadt;                   //Get integer value
+        int16_t value1 = (tempadt - value0)*100;    //Get decimal value
+        buf[0] = value0;
+        buf[1] = value1;
+    
+        //Send out
+        ble.updateCharacteristicValue(rxCharacteristic.getValueAttribute().getHandle(), buf, 2);
 
 }
-*/
 
 //======================================================================
 //convert reverse UUID
@@ -147,7 +153,13 @@
 
     //Timer Setting [us]
     Ticker ticker;
-    //ticker.attach_us(m_status_check_handle, TICKER_TIME);
+    ticker.attach_us(m_status_check_handle, TICKER_TIME);
+    
+    // reset sensor to default values
+    temp.reset();
+
+    // reduce sample rate to save power
+    temp.setConfig(ONE_SPS_MODE);   
     
     //BLE init
     ble.init();
@@ -183,35 +195,11 @@
     //Start Advertising
     ble.startAdvertising(); 
     
-    
-    uint8_t buf[2];
-    float tempadt;
-    
-    // reset sensor to default values
-    temp.reset();
-
-    // reduce sample rate to save power
-    temp.setConfig(ONE_SPS_MODE);   
-
-    
     //------------------------------------------------------------
     //Loop
     //------------------------------------------------------------
     while(1)
     {
-    
-        // get temperature every two seconds
-        tempadt = temp.getTemp();
-    
-        int16_t value0 = tempadt;                   //Get integer value
-        int16_t value1 = (tempadt - value0)*100;    //Get decimal value
-        buf[0] = value0;
-        buf[1] = value1;
-    
-        //Send out
-        ble.updateCharacteristicValue(rxCharacteristic.getValueAttribute().getHandle(), buf, 2);
-        wait(0.5);
-        
         ble.waitForEvent(); 
     }
 }
\ No newline at end of file