Microbug / nRF51822

Fork of nRF51822 by Nordic Semiconductor

Files at this revision

API Documentation at this revision

Comitter:
rgrover1
Date:
Wed May 13 08:49:34 2015 +0100
Parent:
164:8bb2633e7976
Child:
166:fa0e88cac390
Commit message:
Synchronized with git rev b4eef8fc
Author: Rohit Grover
initial attempt at installing a handler for ADV_REPORT

Changed in this revision

btle/btle.cpp Show annotated file Show diff for this revision Revisions of this file
btle/btle_gap.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/btle/btle.cpp	Wed May 13 08:49:34 2015 +0100
+++ b/btle/btle.cpp	Wed May 13 08:49:34 2015 +0100
@@ -163,6 +163,24 @@
             // BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION));
             break;
 
+        case BLE_GAP_EVT_ADV_REPORT: {
+            const ble_gap_evt_adv_report_t *advReport = &p_ble_evt->evt.gap_evt.params.adv_report;
+            printf("GAP ADV Report [%02x %02x %02x %02x %02x %02x]\r\n",
+                advReport->peer_addr.addr[0], advReport->peer_addr.addr[1], advReport->peer_addr.addr[2],
+                advReport->peer_addr.addr[3], advReport->peer_addr.addr[4], advReport->peer_addr.addr[5]);
+        }
+            // typedef struct
+            // {
+            //   ble_gap_addr_t peer_addr;                     /**< Bluetooth address of the peer device. */
+            //   int8_t         rssi;                          /**< Received Signal Strength Indication in dBm. */
+            //   uint8_t        scan_rsp : 1;                  /**< If 1, the report corresponds to a scan response and the type field may be ignored. */
+            //   uint8_t        type     : 2;                  /**< See @ref BLE_GAP_ADV_TYPES. Only valid if the scan_rsp field is 0. */
+            //   uint8_t        dlen     : 5;                  /**< Advertising or scan response data length. */
+            //   uint8_t        data[BLE_GAP_ADV_MAX_SIZE];    /**< Advertising or scan response data. */
+            // } ble_gap_evt_adv_report_t;
+            // .peer_addr
+            break;
+
         default:
             break;
     }
--- a/btle/btle_gap.cpp	Wed May 13 08:49:34 2015 +0100
+++ b/btle/btle_gap.cpp	Wed May 13 08:49:34 2015 +0100
@@ -96,4 +96,20 @@
 {
     ASSERT_STATUS_RET_VOID( nrf_error );
 }
-#endif // SDK_CONN_PARAMS_MODULE_ENABLE
\ No newline at end of file
+#endif // SDK_CONN_PARAMS_MODULE_ENABLE
+
+
+void
+btle_gapStartScanning(void)
+{
+    ble_gap_scan_params_t scanParams = {
+        .active      = 0,        /**< If 1, perform active scanning (scan requests). */
+        .selective   = 0,        /**< If 1, ignore unknown devices (non whitelisted). */
+        .p_whitelist = NULL,     /**< Pointer to whitelist, NULL if none is given. */
+        .interval    = 1000,     /**< Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
+        .window      = 500,      /**< Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
+        .timeout     = 0,        /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */
+    };
+
+    sd_ble_gap_scan_start(&scanParams);
+}
\ No newline at end of file