MPU6050センサ Wallbot_BLE用 サンプル

Dependencies:   BLE_API mbed nRF51822

Revision:
18:7ef0e3b768c2
Parent:
17:e7c43d1b362f
Child:
19:234f3afad29d
diff -r e7c43d1b362f -r 7ef0e3b768c2 main.cpp
--- a/main.cpp	Wed May 27 13:24:05 2015 +0000
+++ b/main.cpp	Wed May 27 13:57:42 2015 +0000
@@ -17,7 +17,7 @@
 
 //#define MIN_CONN_INTERVAL 250  /**< Minimum connection interval */
 //#define MAX_CONN_INTERVAL 350  /**< Maximum connection interval */
-#define CONN_INTERVAL 313  /**< connection interval 250ms; in multiples of 0.125ms. (durationInMillis * 1000) / UNIT_0_625_MS; */
+#define CONN_INTERVAL 250  /**< connection interval 250ms; in multiples of 0.125ms. (durationInMillis * 1000) / UNIT_0_625_MS; */
 #define CONN_SUP_TIMEOUT  8000 /**< Connection supervisory timeout (6 seconds); in multiples of 0.125ms. */
 #define SLAVE_LATENCY     0
 
@@ -137,7 +137,9 @@
     ble.startAdvertising();
 }
 
-void onConnectionCallback(Gap::Handle_t handle, Gap::addr_type_t peerAddrType, const Gap::address_t peerAddr, const Gap::ConnectionParams_t *params)   //Mod
+void connectionCallback(Gap::Handle_t handle, Gap::addr_type_t peerAddrType,
+                        const Gap::Address_t peerAddr, Gap::addr_type_t ownAddrType,
+                        const Gap::Address_t ownAddr, const Gap::ConnectionParams_t *params)
 {
 
     //DEBUG("connected. Got handle %u\r\n", handle);
@@ -148,19 +150,20 @@
     /*  CFG_GAP_CONNECTION_MIN_INTERVAL_MS / CFG_GAP_CONNECTION_MAX_INTERVAL_MSを  */
     /*  直接編集すること                                                             */
     /******************************************************************************/
-
+        //Gap::Handle_t handle;
         Gap::ConnectionParams_t gap_conn_params;
         gap_conn_params.minConnectionInterval        = Gap::MSEC_TO_GAP_DURATION_UNITS(CONN_INTERVAL);
         gap_conn_params.maxConnectionInterval        = Gap::MSEC_TO_GAP_DURATION_UNITS(CONN_INTERVAL);
         gap_conn_params.connectionSupervisionTimeout = Gap::MSEC_TO_GAP_DURATION_UNITS(CONN_SUP_TIMEOUT);
         gap_conn_params.slaveLatency                 = SLAVE_LATENCY;
-        ble.updateConnectionParams(handle, &gap_conn_params);
-    //if (ble.updateConnectionParams(handle, &gap_conn_params) != BLE_ERROR_NONE) {
-    //    DEBUG("failed to update connection paramter\r\n");
-    //}
+        //ble.updateConnectionParams(handle, &gap_conn_params);
+        
+    if (ble.updateConnectionParams(handle, &gap_conn_params) != BLE_ERROR_NONE) {
+        //DEBUG("failed to update connection paramter\r\n");
+    }
 }
 
-void onDataWrittenCallback(const GattCharacteristicWriteCBParams *params){
+void writtenCallback(const GattCharacteristicWriteCBParams *params){
     char acceleroRange = 0xFF;
     char gyroRange = 0xFF;
     
@@ -271,8 +274,8 @@
     
     ble.init();
     ble.onDisconnection(disconnectionCallback);
-    ble.onConnection(onConnectionCallback);
-    ble.onDataWritten(onDataWrittenCallback);
+    ble.onConnection(connectionCallback);
+    ble.onDataWritten(writtenCallback);
     ble.onTimeout(timeoutCallback);
 
     /* setup device name */