BLE_Health_Thermometer; based on todotani-san's mod. Libraries are now genuine.

Dependencies:   BLE_API TMP102 mbed nRF51822

Fork of BLE_HTM_HRM1017 by Yoshihiro TSUBOI

Files at this revision

API Documentation at this revision

Comitter:
ytsuboi
Date:
Thu Aug 27 15:14:41 2015 +0000
Parent:
7:794248dbc19b
Child:
9:554af3c63d0c
Commit message:
Updated to the latest of the underlying libraries. Thanks, takafuminaka

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 15:14:41 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 15:14:41 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: */
@@ -56,19 +55,19 @@
 {
     advertisingStateLed = 1;
     
-    DEBUG("Disconnected handle %u, reason %u\n", handle, reason);
-    DEBUG("Restarting the advertising process\n\r");
-    ble.startAdvertising();
+    DEBUG("Disconnected handle %u, reason %u\r\n", handle, reason);
+    DEBUG("Restarting the advertising process\r\n");
+    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");
     }
 }
@@ -95,28 +94,28 @@
     Ticker ticker;
     ticker.attach(periodicCallback, 1);
        
-    DEBUG("Initialising the nRF51822\n");
+    DEBUG("Initialising the nRF51822\r\n");
     ble.init();
-    DEBUG("Init done\n");
-    ble.onDisconnection(disconnectionCallback);
-    ble.onConnection(onConnectionCallback);
+    DEBUG("Init done\r\n");
+    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");
+    DEBUG("Start Advertising\r\n");
 
-    ble.addService(htmService);
-    ble.addService(battService);
-    DEBUG("Add Service\n");
+    ble.gattServer().addService(htmService);
+    ble.gattServer().addService(battService);
+    DEBUG("Add Service\r\n");
 
     while (true) {
         if (triggerSensorPolling) {
@@ -140,11 +139,11 @@
       
       /* Update the temperature. Note that we need to convert to an ieee11073 format float. */
       float temperature = healthThemometer.read();
-      DEBUG("temp:%f\n", temperature);
+      DEBUG("temp:%f\r\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
 }
 
 /**
@@ -159,4 +158,3 @@
     
     return ( ((uint32_t)exponent) << 24) | mantissa;
 }
-
--- a/mbed.bld	Sat Sep 13 09:32:10 2014 +0000
+++ b/mbed.bld	Thu Aug 27 15:14:41 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 15:14:41 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#98215c4f3a25
+http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#ca9c9c2cfc6a