xvcv

Dependencies:   BLE_API mbed nRF51822

Fork of MEDRON_SNIFFER_ABCD-KIMLIKLI-OLANLARI-TARAMA-YAPAR_30062016 by HAKAN AYDIN

Revision:
8:649bd171929e
Parent:
7:91324daa3bfa
Child:
9:69a2ad0bcdb7
--- a/main.cpp	Mon Jul 20 09:00:24 2015 +0000
+++ b/main.cpp	Fri Jul 31 09:13:50 2015 +0000
@@ -18,21 +18,21 @@
 #include "BLE.h"
 #include "TMP_nrf51/TMP_nrf51.h"
 
-#define COMP_ID_TEST 0xFEFE
+#define APP_SPECIFIC_ID_TEST 0xFEFE
 
 #pragma pack(1)
 /* Advertising data  */
-typedef struct advertisingData {
-    uint8_t length; /* doesn't include itself*/
+struct AdvertisingData_t {
+    uint8_t length; /* doesn't include itself */
     GapAdvertisingData::DataType dataType;
     uint8_t data[1];
-} advertisingData_t;
+};
 
-typedef struct manufacturerData {
-    uint16_t companyId;
-    /* User defined manufacture data */
-    TMP_nrf51::tmpSensorValue_t tmpSensorValue;
-} manufacturerData_t;
+struct ApplicationData_t {
+    uint16_t applicationSpecificId;             /* An ID used to identify temperature value
+                                                   in the manufacture specific AD data field */
+    TMP_nrf51::tmpSensorValue_t tmpSensorValue; /* User defined application data */
+};
 #pragma pack()
 
 BLE        ble;
@@ -45,16 +45,17 @@
 
 void advertisementCallback(const Gap::AdvertisementCallbackParams_t *params)
 {
-    advertisingData_t *pAdvData = NULL;
+    AdvertisingData_t *pAdvData = NULL;
     uint8_t len = 0;
     
     /* Search for the manufacturer data */
     while(len < params->advertisingDataLen) {
-        pAdvData = (advertisingData_t *)&params->advertisingData[len];
+        pAdvData = (AdvertisingData_t *)&params->advertisingData[len];
         if(pAdvData->dataType == GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA) {
-            manufacturerData_t *pManuData = (manufacturerData_t *)pAdvData->data;
-            if(pManuData->companyId == COMP_ID_TEST) {
-                printf("Recv temp is %f\r\n", (float)pManuData->tmpSensorValue);
+            ApplicationData_t *pAppData = (ApplicationData_t *)pAdvData->data;
+            if(pAppData->applicationSpecificId == APP_SPECIFIC_ID_TEST) {
+                printf("From [%02x %02x %02x], ", params->peerAddr[2], params->peerAddr[1], params->peerAddr[0]);
+                printf("Temp is %f\r\n", (float)pAppData->tmpSensorValue);
                 break;
             }
         }