最新revisionだとなんかerrorになるので、暫定的に rev 111にrevert。ごめんなさい。こういうときどういうふうにcommitすればいいのか分からなかったので。

Dependents:   MiniSteer_BLE

Fork of BLE_API by Bluetooth Low Energy

Revision:
118:f2de8009b969
Parent:
117:0fb20195102b
--- a/public/Gap.h	Mon Sep 08 17:11:58 2014 +0100
+++ b/public/Gap.h	Wed Sep 17 04:54:22 2014 +0000
@@ -40,19 +40,6 @@
         ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE
     } addr_type_t;
 
-    /**
-     * enumeration for disconnection reasons. The values for these reasons are
-     * derived from Nordic's implementation; but the reasons are meant to be
-     * independent of the transport. If you are returned a reason which is not
-     * covered by this enumeration, then please refer to the underlying
-     * transport library.
-     */
-    enum DisconnectionReason_t {
-        REMOTE_USER_TERMINATED_CONNECTION = 0x13,
-        LOCAL_HOST_TERMINATED_CONNECTION  = 0x16,
-        CONN_INTERVAL_UNACCEPTABLE        = 0x3B,
-    };
-
     /* 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 */
@@ -74,42 +61,39 @@
     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(DisconnectionReason_t reason) = 0;
+    virtual ble_error_t disconnect(void)                         = 0;
     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;
 
-    virtual ble_error_t setDeviceName(const uint8_t *deviceName) = 0;
-    virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP) = 0;
-    virtual ble_error_t setAppearance(uint16_t appearance) = 0;
-    virtual ble_error_t getAppearance(uint16_t *appearanceP) = 0;
-
     typedef void (*EventCallback_t)(void);
-    typedef void (*ConnectionEventCallback_t)(Handle_t, const ConnectionParams_t *);
-    typedef void (*DisconnectionEventCallback_t)(Handle_t, DisconnectionReason_t);
+    typedef void (*HandleSpecificEventCallback_t)(Handle_t);
 
     /* Event callback handlers */
     void setOnTimeout(EventCallback_t callback) {
         onTimeout = callback;
     }
-    void setOnConnection(ConnectionEventCallback_t callback) {
+    void setOnConnection(HandleSpecificEventCallback_t callback) {
         onConnection = callback;
     }
-    void setOnDisconnection(DisconnectionEventCallback_t callback) {
+    void setOnDisconnection(HandleSpecificEventCallback_t callback) {
         onDisconnection = callback;
     }
 
-    void processConnectionEvent(Handle_t handle, const ConnectionParams_t *params) {
-        state.connected = 1;
-        if (onConnection) {
-            onConnection(handle, params);
-        }
-    }
-
-    void processDisconnectionEvent(Handle_t handle, DisconnectionReason_t reason) {
-        state.connected = 0;
-        if (onDisconnection) {
-            onDisconnection(handle, reason);
+    void processHandleSpecificEvent(GapEvents::gapEvent_e type, Handle_t handle) {
+        switch (type) {
+            case GapEvents::GAP_EVENT_CONNECTED:
+                state.connected = 1;
+                if (onConnection) {
+                    onConnection(handle);
+                }
+                break;
+            case GapEvents::GAP_EVENT_DISCONNECTED:
+                state.connected = 0;
+                if (onDisconnection) {
+                    onDisconnection(handle);
+                }
+                break;
         }
     }
 
@@ -137,9 +121,9 @@
     GapState_t state;
 
 private:
-    EventCallback_t              onTimeout;
-    ConnectionEventCallback_t    onConnection;
-    DisconnectionEventCallback_t onDisconnection;
+    EventCallback_t               onTimeout;
+    HandleSpecificEventCallback_t onConnection;
+    HandleSpecificEventCallback_t onDisconnection;
 };
 
 #endif // ifndef __GAP_H__