Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API MMA8652 nRF51822 mbed-src
Revision 6:2fb6cf3c9047, committed 2014-10-14
- Comitter:
- rosterloh84
- Date:
- Tue Oct 14 13:04:06 2014 +0000
- Parent:
- 5:21ec0f1f019a
- Commit message:
- Updates before refactoring BuddiService
Changed in this revision
--- a/BLE_API.lib Tue Sep 16 08:23:26 2014 +0000 +++ b/BLE_API.lib Tue Oct 14 13:04:06 2014 +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/#4b68a819ab4f
--- a/Configuration.h Tue Sep 16 08:23:26 2014 +0000
+++ b/Configuration.h Tue Oct 14 13:04:06 2014 +0000
@@ -11,7 +11,7 @@
{
const uint8_t deviceName[] = "Buddi Blueband";
-const int advertisingInterval = 160; // (0.625 ms units)
+const int advertisingInterval = 1600; // 1s (0.625 ms units)
// default connection parameters conforming to Apple recommendations
const int minConnectionInterval = 16; // (1.25 ms units)
--- a/DevInfoService.cpp Tue Sep 16 08:23:26 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-#include "DevInfoService.h"
-#include "Logger.h"
-#include "Configuration.h"
-
-namespace DevInfo {
-
-// https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.device_information.xml
-// Manufacturer Name String
-static char vendor[] = "Buddi Ltd.";
-static GattCharacteristic vendorChar(GattCharacteristic::UUID_MANUFACTURER_NAME_STRING_CHAR,
- (uint8_t *)vendor,
- sizeof(vendor),
- sizeof(vendor),
- GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ);
-// Model Number String
-static char model[] = "BlueBand";
-static GattCharacteristic modelChar(GattCharacteristic::UUID_MODEL_NUMBER_STRING_CHAR,
- (uint8_t *)model,
- sizeof(model),
- sizeof(model),
- GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ);
-// Serial Number String
-static char serial[] = "1234567890";
-static GattCharacteristic serialChar(GattCharacteristic::UUID_SERIAL_NUMBER_STRING_CHAR,
- (uint8_t *)serial,
- sizeof(serial),
- sizeof(serial),
- GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ);
-// Hardware Revision String
-static char hwversion[] = "Hardware: 0";
-static GattCharacteristic hwChar(GattCharacteristic::UUID_HARDWARE_REVISION_STRING_CHAR,
- (uint8_t *)hwversion,
- sizeof(hwversion),
- sizeof(hwversion),
- GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ);
-// Firmware Revision String
-static char fwversion[] = "Firmware: 0001";
-static GattCharacteristic fwChar(GattCharacteristic::UUID_FIRMWARE_REVISION_STRING_CHAR,
- (uint8_t *)fwversion,
- sizeof(fwversion),
- sizeof(fwversion),
- GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ);
-// Software Revision String
-static char swversion[] = "Build: 0001";
-static GattCharacteristic swChar(GattCharacteristic::UUID_SOFTWARE_REVISION_STRING_CHAR,
- (uint8_t *)swversion,
- sizeof(swversion),
- sizeof(swversion),
- GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ);
-// System ID
-static char systemId = 'A';
-static GattCharacteristic systemID(GattCharacteristic::UUID_SYSTEM_ID_CHAR,
- (uint8_t *)systemId,
- sizeof(systemId),
- sizeof(systemId),
- GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ);
-
-static GattCharacteristic *devInfoChars[] = {&vendorChar, &modelChar, &serialChar, &hwChar, &fwChar, &swChar, &systemID };
-static GattService devInfoService(GattService::UUID_DEVICE_INFORMATION_SERVICE, devInfoChars, sizeof(devInfoChars) / sizeof(GattCharacteristic *));
-
-static BLEDevice* ble;
-
-void init(BLEDevice &bleDevice)
-{
- ble = &bleDevice;
- ble->addService(devInfoService);
- DEBUG("Added Device Information service\r\n");
-}
-
-} // namespace DevInfo
\ No newline at end of file
--- a/DevInfoService.h Tue Sep 16 08:23:26 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-#ifndef _H_DEVINFOSERVICE_H
-#define _H_DEVINFOSERVICE_H
-
-#include "BLEDevice.h"
-
-namespace DevInfo {
- void init(BLEDevice &ble);
-}
-
-#endif //_H_DEVINFOSERVICE_H
\ No newline at end of file
--- a/main.cpp Tue Sep 16 08:23:26 2014 +0000
+++ b/main.cpp Tue Oct 14 13:04:06 2014 +0000
@@ -26,8 +26,9 @@
#include "BLEDevice.h"
//#include "nRF51822n.h"
//#include "MMA8652.h"
-#include "DevInfoService.h"
#include "BuddiService.h"
+#include "BatteryService.h"
+#include "DeviceInformationService.h"
/******************************************************************************
* Module Preprocessor Constants
@@ -57,23 +58,13 @@
void bluetoothInit();
-// https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.battery_service.xml
-static uint8_t batteryLevel = 100;
-GattCharacteristic batteryPercentage(GattCharacteristic::UUID_BATTERY_LEVEL_CHAR, (uint8_t *)batteryLevel, sizeof(batteryLevel), sizeof(batteryLevel),
- GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY);
-GattCharacteristic *batteryChars[] = {&batteryPercentage };
-GattService batteryService(GattService::UUID_BATTERY_SERVICE, batteryChars, sizeof(batteryChars) / sizeof(GattCharacteristic *));
-
-//static const uint16_t uuid16_list[] = {GattService::UUID_DEVICE_INFORMATION_SERVICE,
-// GattService::UUID_BATTERY_SERVICE};
-//static const unit8_t uuid128_list[] = {(const uint8_t *)buddi_service_uuid_rev,
-// (const uint8_t *)buddi_service_uuid_rev,
-// (const uint8_t *)buddi_service_uuid_rev};
-
static volatile bool triggerSensorPolling = false; /* set to high periodically to indicate to the main thread that
* polling is necessary. */
static Gap::ConnectionParams_t connectionParams;
-
+
+uint8_t batteryLevel = 100;
+BatteryService *batteryServicePtr = NULL;
+
/******************************************************************************
* Function Prototypes
*******************************************************************************/
@@ -130,10 +121,10 @@
DEBUG("Notifications enabled for %d\r\n", handle);
}
-void onDataWritten(uint16_t charHandle, const GattCharacteristicWriteCBParams *params)
+void onDataWritten(const GattCharacteristicWriteCBParams *params)
{
// bubble up to services, they will emit callbacks if handle matches
- Nudge::handleDataWritten(charHandle, params);
+ //Nudge::handleDataWritten(params);
}
/**
@@ -176,10 +167,9 @@
connectionParams.connectionSupervisionTimeout);
// Initialise services
- //ble.addService(devInfoService);
- DevInfo::init(ble);
- ble.addService(batteryService);
- //ble.addService(buddiService);
+ BatteryService batteryService(ble);
+ batteryServicePtr = &batteryService;
+ DeviceInformationService deviceInfo(ble, "Buddi Ltd.", "BlueBand", "1234567890", "Hardware: 0", "Firmware: 0001", "Build: 0001");
Nudge::init(ble);
/* setup advertising */
@@ -222,12 +212,12 @@
/* Do blocking calls or whatever is necessary for sensor polling. */
if (ble.getGapState().connected) {
/* Update the battery measurement */
- //batteryLevel = adc1.read_u16()&0x0FFF) * 3.3/4096;
+ //batteryLevel = adc1.read_u16()&0x0FFF) * 3.3/4096;
batteryLevel--;
if (batteryLevel == 1) {
batteryLevel = 100;
}
- //ble.updateCharacteristicValue(batteryPercentage.getHandle(), &batteryLevel, sizeof(batteryLevel));
+ batteryServicePtr->updateBatteryLevel(batteryLevel);
}
} else {
--- a/mbed-src.lib Tue Sep 16 08:23:26 2014 +0000 +++ b/mbed-src.lib Tue Oct 14 13:04:06 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-src/#3e2706a32e81 +http://mbed.org/users/mbed_official/code/mbed-src/#3dfac0d3ce7b
--- a/nRF51822.lib Tue Sep 16 08:23:26 2014 +0000 +++ b/nRF51822.lib Tue Oct 14 13:04:06 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#98215c4f3a25 +http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#936d81c963fe