Caching the advertising data and the scan response.

Fork of MaximBLE by Maxim Integrated

Files at this revision

API Documentation at this revision

Comitter:
kgills
Date:
Tue Mar 22 18:16:10 2016 +0000
Parent:
0:b562096246b3
Commit message:
Caching the advertising data and scan response.

Changed in this revision

MaximGap.cpp Show annotated file Show diff for this revision Revisions of this file
MaximGap.h Show annotated file Show diff for this revision Revisions of this file
--- a/MaximGap.cpp	Thu Mar 03 14:13:21 2016 +0000
+++ b/MaximGap.cpp	Tue Mar 22 18:16:10 2016 +0000
@@ -52,9 +52,11 @@
         return BLE_ERROR_PARAM_OUT_OF_RANGE;
     }
 
-    /* set advertising and scan response data for discoverable mode */
-    DmAdvSetData(DM_DATA_LOC_ADV, advData.getPayloadLen(), (uint8_t*)advData.getPayload());
-    DmAdvSetData(DM_DATA_LOC_SCAN, scanResponse.getPayloadLen(), (uint8_t*)scanResponse.getPayload());
+    /* save advertising and scan response data */
+    advDataLen = advData.getPayloadLen();
+    scanResponseLen = scanResponse.getPayloadLen();
+    memcpy((void*)advDataCache, (void*)advData.getPayload(), advDataLen);
+    memcpy((void*)advDataCache, (void*)advData.getPayload(), scanResponseLen);
 
     return BLE_ERROR_NONE;
 }
@@ -94,6 +96,10 @@
         return BLE_ERROR_PARAM_OUT_OF_RANGE;
     }
 
+    /* set advertising and scan response data for discoverable mode */
+    DmAdvSetData(DM_DATA_LOC_ADV, advDataLen, advDataCache);
+    DmAdvSetData(DM_DATA_LOC_SCAN, scanResponseLen, scanResponseCache);
+
     DmAdvSetInterval(params.getInterval(), params.getInterval());
     DmAdvStart(params.getAdvertisingType(), params.getTimeout());
 
--- a/MaximGap.h	Thu Mar 03 14:13:21 2016 +0000
+++ b/MaximGap.h	Tue Mar 22 18:16:10 2016 +0000
@@ -102,6 +102,11 @@
 
     MaximGap(MaximGap const &);
     void operator=(MaximGap const &);
+    
+    uint8_t advDataCache[HCI_LEN_LE_SET_ADV_DATA];
+    uint8_t scanResponseCache[HCI_LEN_LE_SET_SCAN_RESP_DATA];
+    int advDataLen;
+    int scanResponseLen;
 };
 
 #endif /* _MAXIM_GAP_H_ */