Nakatafu ☆ / Mbed 2 deprecated BLE_HTM_HRM1017

Dependencies:   BLE_API TMP102 mbed nRF51822

Fork of BLE_HTM_HRM1017 by Yoshihiro TSUBOI

Files at this revision

API Documentation at this revision

Comitter:
takafuminaka
Date:
Thu Aug 27 14:27:16 2015 +0000
Parent:
7:794248dbc19b
Child:
9:c8d094afaa45
Commit message:
update to the latest of the underlying libraries.; ?????????????????????????; ?????????

Changed in this revision

BLE_API.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
nRF51822.lib Show annotated file Show diff for this revision Revisions of this file
--- a/BLE_API.lib	Sat Sep 13 09:32:10 2014 +0000
+++ b/BLE_API.lib	Thu Aug 27 14:27:16 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#0fb20195102b
+http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#8d316a3271a8
--- a/main.cpp	Sat Sep 13 09:32:10 2014 +0000
+++ b/main.cpp	Thu Aug 27 14:27:16 2015 +0000
@@ -1,7 +1,6 @@
 #include "mbed.h"
 #include "TMP102.h"
-#include "BLEDevice.h"
-#include "ble_hts.h"
+#include "BLE.h"
 
 #define NEED_CONSOLE_OUTPUT 1 /* Set this if you need debug messages on the console;
                                * it will have an impact on code-size and power consumption. */
@@ -17,7 +16,7 @@
 static volatile bool  triggerSensorPolling = false;
 
 BLEDevice  ble;
-TMP102      healthThemometer(p22, p20, 0x90);  /* The TMP102 connected to our board */
+TMP102      healthThemometer(I2C_SDA0, I2C_SCL0, 0x90);  /* The TMP102 connected to our board */
 //TMP102      healthThemometer(I2C_SDA1, I2C_SCL1, 0x90);  /* The TMP102 connected to our board */
 
 /* LEDs for indication: */
@@ -58,17 +57,17 @@
     
     DEBUG("Disconnected handle %u, reason %u\n", handle, reason);
     DEBUG("Restarting the advertising process\n\r");
-    ble.startAdvertising();
+    ble.gap().startAdvertising();
 }
 
-void onConnectionCallback(Gap::Handle_t handle, const Gap::ConnectionParams_t *params)   //Mod
+void onConnectionCallback(const Gap::ConnectionCallbackParams_t *params)   //Mod
 {
     advertisingStateLed = 0;
 
-    DEBUG("connected. Got handle %u\r\n", handle);
+    DEBUG("connected. Got handle %u\r\n", params->handle);
 
     connectionParams.slaveLatency = 1;
-    if (ble.updateConnectionParams(handle, &connectionParams) != BLE_ERROR_NONE) {
+    if (ble.gap().updateConnectionParams(params->handle, &connectionParams) != BLE_ERROR_NONE) {
         DEBUG("failed to update connection paramter\r\n");
     }
 }
@@ -98,24 +97,24 @@
     DEBUG("Initialising the nRF51822\n");
     ble.init();
     DEBUG("Init done\n");
-    ble.onDisconnection(disconnectionCallback);
-    ble.onConnection(onConnectionCallback);
+    ble.gap().onDisconnection(disconnectionCallback);
+    ble.gap().onConnection(onConnectionCallback);
 
-    ble.getPreferredConnectionParams(&connectionParams);
+    ble.gap().getPreferredConnectionParams(&connectionParams);
 
     /* setup advertising */
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t*)uuid16_list, sizeof(uuid16_list));
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_THERMOMETER);
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
-    ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
-    ble.setAdvertisingInterval(160); /* 100ms; in multiples of 0.625ms. */
-    ble.startAdvertising();
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t*)uuid16_list, sizeof(uuid16_list));
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_THERMOMETER);
+    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
+    ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
+    ble.gap().setAdvertisingInterval(160); /* 100ms; in multiples of 0.625ms. */
+    ble.gap().startAdvertising();
     advertisingStateLed = 1;
     DEBUG("Start Advertising\n");
 
-    ble.addService(htmService);
-    ble.addService(battService);
+    ble.gattServer().addService(htmService);
+    ble.gattServer().addService(battService);
     DEBUG("Add Service\n");
 
     while (true) {
@@ -143,8 +142,8 @@
       DEBUG("temp:%f\n", temperature);
       uint32_t temp_ieee11073 = quick_ieee11073_from_float(temperature);
       memcpy(thermTempPayload+1, &temp_ieee11073, 4);
-      ble.updateCharacteristicValue(tempChar.getValueAttribute().getHandle(), thermTempPayload, sizeof(thermTempPayload));  //Mod
-      ble.updateCharacteristicValue(battLevel.getValueAttribute().getHandle(), (uint8_t *)&batt, sizeof(batt));             //Mod
+      ble.gattServer().write(tempChar.getValueAttribute().getHandle(), thermTempPayload, sizeof(thermTempPayload));  //Mod
+      ble.gattServer().write(battLevel.getValueAttribute().getHandle(), (uint8_t *)&batt, sizeof(batt));             //Mod
 }
 
 /**
--- a/mbed.bld	Sat Sep 13 09:32:10 2014 +0000
+++ b/mbed.bld	Thu Aug 27 14:27:16 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/8ed44a420e5c
\ No newline at end of file
--- a/nRF51822.lib	Sat Sep 13 09:32:10 2014 +0000
+++ b/nRF51822.lib	Thu Aug 27 14:27:16 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#98215c4f3a25
+http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#ca9c9c2cfc6a