High level Bluetooth Low Energy API and radio abstraction layer

Dependencies:   nRF51822

Dependents:   LinkNode_LIS3DH

Fork of BLE_API by Bluetooth Low Energy

Files at this revision

API Documentation at this revision

Comitter:
Rohit Grover
Date:
Fri Jul 11 14:39:17 2014 +0100
Parent:
104:6ef5abef5714
Child:
106:a20be740075d
Commit message:
add APIs for working with connectionParams

Changed in this revision

hw/BLEDevice.h Show annotated file Show diff for this revision Revisions of this file
hw/Gap.h Show annotated file Show diff for this revision Revisions of this file
--- a/hw/BLEDevice.h	Thu Jul 10 12:12:06 2014 +0100
+++ b/hw/BLEDevice.h	Fri Jul 11 14:39:17 2014 +0100
@@ -250,6 +250,11 @@
      */
     void waitForEvent(void);
 
+    ble_error_t getPreferredConnectionParams(Gap::ConnectionParams_t *params);
+    ble_error_t setPreferredConnectionParams(const Gap::ConnectionParams_t *params);
+    ble_error_t updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params);
+    // ble_version_t getVersion(void);
+
 public:
     BLEDevice() : transport(createBLEDeviceInstance()), advParams(), advPayload(), scanResponse(), needToSetAdvPayload(true) {
         advPayload.clear();
@@ -488,6 +493,23 @@
     transport->waitForEvent();
 }
 
+inline ble_error_t
+BLEDevice::getPreferredConnectionParams(Gap::ConnectionParams_t *params)
+{
+    return transport->getGap().getPreferredConnectionParams(params);
+}
+
+inline ble_error_t
+BLEDevice::setPreferredConnectionParams(const Gap::ConnectionParams_t *params)
+{
+    return transport->getGap().setPreferredConnectionParams(params);
+}
+
+inline ble_error_t
+BLEDevice::updateConnectionParams(Gap::Handle_t handle, const Gap::ConnectionParams_t *params) {
+    return transport->getGap().updateConnectionParams(handle, params);
+}
+
 /*
  * ALL OF THE FOLLOWING METHODS ARE DEPRECATED
  */
--- a/hw/Gap.h	Thu Jul 10 12:12:06 2014 +0100
+++ b/hw/Gap.h	Fri Jul 11 14:39:17 2014 +0100
@@ -40,22 +40,33 @@
         ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE
     } addr_type_t;
 
+    /* Describes the current state of the device (more than one bit can be set) */
+    typedef struct GapState_s {
+        unsigned advertising : 1; /**< peripheral is currently advertising */
+        unsigned connected   : 1; /**< peripheral is connected to a central */
+    } GapState_t;
+
+    typedef uint16_t Handle_t;
+
+    typedef struct {
+      uint16_t minConnectionInterval;        /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
+      uint16_t maxConnectionInterval;        /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
+      uint16_t slaveLatency;                 /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/
+      uint16_t connectionSupervisionTimeout; /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/
+    } ConnectionParams_t;
+
+public:
     /* These functions must be defined in the sub-class */
     virtual ble_error_t setAddress(addr_type_t type, const uint8_t address[6]) = 0;
     virtual ble_error_t setAdvertisingData(const GapAdvertisingData &, const GapAdvertisingData &) = 0;
     virtual ble_error_t startAdvertising(const GapAdvertisingParams &) = 0;
     virtual ble_error_t stopAdvertising(void)                    = 0;
     virtual ble_error_t disconnect(void)                         = 0;
-
-    /* Describes the current state of the device (more than one bit can be
-     *set) */
-    typedef struct GapState_s {
-        unsigned advertising : 1; /**< peripheral is currently advertising */
-        unsigned connected   : 1; /**< peripheral is connected to a central */
-    } GapState_t;
+    virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params) = 0;
+    virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params) = 0;
+    virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params) = 0;
 
     typedef void (*EventCallback_t)(void);
-    typedef uint16_t Handle_t;
     typedef void (*HandleSpecificEventCallback_t)(Handle_t);
 
     /* Event callback handlers */