switch to a yotta layout

This commit is contained in:
Rohit Grover 2015-06-19 13:37:31 +01:00
parent 1bb021e666
commit 75beb80315
40 changed files with 68 additions and 41 deletions

View file

@ -17,7 +17,7 @@
#ifndef __BLE_BATTERY_SERVICE_H__
#define __BLE_BATTERY_SERVICE_H__
#include "BLE.h"
#include "ble/BLE.h"
/**
* @class BatteryService

View file

@ -17,8 +17,8 @@
#ifndef __BLE_DFU_SERVICE_H__
#define __BLE_DFU_SERVICE_H__
#include "BLE.h"
#include "UUID.h"
#include "ble/BLE.h"
#include "ble/UUID.h"
extern "C" void bootloader_start(void);

View file

@ -17,7 +17,7 @@
#ifndef __BLE_DEVICE_INFORMATION_SERVICE_H__
#define __BLE_DEVICE_INFORMATION_SERVICE_H__
#include "BLE.h"
#include "ble/BLE.h"
/**
* @class DeviceInformationService

View file

@ -17,7 +17,7 @@
#ifndef __BLE_HEART_RATE_SERVICE_H__
#define __BLE_HEART_RATE_SERVICE_H__
#include "BLE.h"
#include "ble/BLE.h"
/**
* @class HeartRateService

View file

@ -20,8 +20,8 @@
#include "mbed.h"
#include "Stream.h"
#include "UUID.h"
#include "BLE.h"
#include "ble/UUID.h"
#include "ble/BLE.h"
extern const uint8_t UARTServiceBaseUUID[UUID::LENGTH_OF_LONG_UUID];
extern const uint16_t UARTServiceShortUUID;

View file

@ -17,7 +17,7 @@
#ifndef SERVICES_URIBEACONCONFIGSERVICE_H_
#define SERVICES_URIBEACONCONFIGSERVICE_H_
#include "BLE.h"
#include "ble/BLE.h"
#include "mbed.h"
extern const uint8_t UUID_URI_BEACON_SERVICE[UUID::LENGTH_OF_LONG_UUID];
@ -159,26 +159,26 @@ class URIBeaconConfigService {
{
const char DEVICE_NAME[] = "mUriBeacon Config";
ble.clearAdvertisingPayload();
ble.gap().clearAdvertisingPayload();
ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
// UUID is in different order in the ADV frame (!)
uint8_t reversedServiceUUID[sizeof(UUID_URI_BEACON_SERVICE)];
for (unsigned int i = 0; i < sizeof(UUID_URI_BEACON_SERVICE); i++) {
reversedServiceUUID[i] = UUID_URI_BEACON_SERVICE[sizeof(UUID_URI_BEACON_SERVICE) - i - 1];
}
ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS, reversedServiceUUID, sizeof(reversedServiceUUID));
ble.accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_TAG);
ble.accumulateScanResponse(GapAdvertisingData::COMPLETE_LOCAL_NAME, reinterpret_cast<const uint8_t *>(&DEVICE_NAME), sizeof(DEVICE_NAME));
ble.accumulateScanResponse(GapAdvertisingData::TX_POWER_LEVEL,
reinterpret_cast<uint8_t *>(&defaultAdvPowerLevels[URIBeaconConfigService::TX_POWER_MODE_LOW]),
sizeof(uint8_t));
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS, reversedServiceUUID, sizeof(reversedServiceUUID));
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_TAG);
ble.gap().accumulateScanResponse(GapAdvertisingData::COMPLETE_LOCAL_NAME, reinterpret_cast<const uint8_t *>(&DEVICE_NAME), sizeof(DEVICE_NAME));
ble.gap().accumulateScanResponse(GapAdvertisingData::TX_POWER_LEVEL,
reinterpret_cast<uint8_t *>(&defaultAdvPowerLevels[URIBeaconConfigService::TX_POWER_MODE_LOW]),
sizeof(uint8_t));
ble.setTxPower(params.advPowerLevels[params.txPowerMode]);
ble.setDeviceName(reinterpret_cast<const uint8_t *>(&DEVICE_NAME));
ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
ble.setAdvertisingInterval(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(ADVERTISING_INTERVAL_MSEC));
ble.gap().setTxPower(params.advPowerLevels[params.txPowerMode]);
ble.gap().setDeviceName(reinterpret_cast<const uint8_t *>(&DEVICE_NAME));
ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
ble.gap().setAdvertisingInterval(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(ADVERTISING_INTERVAL_MSEC));
}
/* Helper function to switch to the non-connectible normal mode for URIBeacon. This gets called after a timeout. */
@ -202,12 +202,12 @@ class URIBeaconConfigService {
extern void saveURIBeaconConfigParams(const Params_t *paramsP); /* forward declaration; necessary to avoid a circular dependency. */
saveURIBeaconConfigParams(&params);
ble.clearAdvertisingPayload();
ble.setTxPower(params.advPowerLevels[params.txPowerMode]);
ble.setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED);
ble.setAdvertisingInterval(beaconPeriod);
ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, BEACON_UUID, sizeof(BEACON_UUID));
ble.gap().clearAdvertisingPayload();
ble.gap().setTxPower(params.advPowerLevels[params.txPowerMode]);
ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED);
ble.gap().setAdvertisingInterval(beaconPeriod);
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, BEACON_UUID, sizeof(BEACON_UUID));
serviceData[serviceDataLen++] = BEACON_UUID[0];
serviceData[serviceDataLen++] = BEACON_UUID[1];
@ -216,7 +216,7 @@ class URIBeaconConfigService {
for (unsigned j = 0; j < uriDataLength; j++) {
serviceData[serviceDataLen++] = uriData[j];
}
ble.accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA, serviceData, serviceDataLen);
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA, serviceData, serviceDataLen);
}
private:
@ -259,11 +259,11 @@ class URIBeaconConfigService {
/* Re-map beaconPeriod to within permissible bounds if necessary. */
if (params.beaconPeriod != 0) {
bool paramsUpdated = false;
if (params.beaconPeriod < ble.getMinAdvertisingInterval()) {
params.beaconPeriod = ble.getMinAdvertisingInterval();
if (params.beaconPeriod < ble.gap().getMinAdvertisingInterval()) {
params.beaconPeriod = ble.gap().getMinAdvertisingInterval();
paramsUpdated = true;
} else if (params.beaconPeriod > ble.getMaxAdvertisingInterval()) {
params.beaconPeriod = ble.getMaxAdvertisingInterval();
} else if (params.beaconPeriod > ble.gap().getMaxAdvertisingInterval()) {
params.beaconPeriod = ble.gap().getMaxAdvertisingInterval();
paramsUpdated = true;
}
if (paramsUpdated) {

View file

@ -1 +0,0 @@
These files are common to all implementations of the BLE_API.

29
module.json Normal file
View file

@ -0,0 +1,29 @@
{
"name": "ble",
"version": "0.0.0",
"description": "The BLE module offers a high level abstraction for using Bluetooth Low Energy on multiple platforms.",
"keywords": [
"Bluetooth",
"BLE"
],
"author": "Rohit Grover",
"repository": {
"url": "git@github.com:mbedmicro/BLE_API.git",
"type": "git"
},
"homepage": "http://mbed.org/ble",
"licenses": [
{
"url": "https://spdx.org/licenses/Apache-2.0",
"type": "Apache-2.0"
}
],
"dependencies": {
"mbed": "^3.0.2"
},
"targetDependencies": {
"nrf51822": {
"ble-nrf51822":"~0.0.1"
}
}
}

View file

@ -1 +0,0 @@
The public API exposed through header files.

View file

@ -14,7 +14,7 @@
* limitations under the License.
*/
#include "BLE.h"
#include "ble/BLE.h"
#if defined(TARGET_OTA_ENABLED)
#include "DFUService.h"

View file

@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "DiscoveredCharacteristic.h"
#include "GattClient.h"
#include "ble/DiscoveredCharacteristic.h"
#include "ble/GattClient.h"
GattClient::ReadCallback_t DiscoveredCharacteristic::onDataReadCallback;
GattClient::WriteCallback_t DiscoveredCharacteristic::onDataWriteCallback;

View file

@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "Gap.h"
#include "GapScanningParams.h"
#include "ble/Gap.h"
#include "ble/GapScanningParams.h"
GapScanningParams::GapScanningParams(uint16_t interval, uint16_t window, uint16_t timeout, bool activeScanning) :
_interval(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(interval)),

View file

@ -14,7 +14,7 @@
* limitations under the License.
*/
#include "DFUService.h"
#include "ble/services/DFUService.h"
const uint8_t DFUServiceBaseUUID[] = {
0x00, 0x00, 0x00, 0x00, 0x12, 0x12, 0xEF, 0xDE,

View file

@ -14,7 +14,7 @@
* limitations under the License.
*/
#include "UARTService.h"
#include "ble/services/UARTService.h"
const uint8_t UARTServiceBaseUUID[UUID::LENGTH_OF_LONG_UUID] = {
0x6E, 0x40, 0x00, 0x00, 0xB5, 0xA3, 0xF3, 0x93,

View file

@ -14,7 +14,7 @@
* limitations under the License.
*/
#include "URIBeaconConfigService.h"
#include "ble/services/URIBeaconConfigService.h"
#define UUID_URI_BEACON(FIRST, SECOND) { \
0xee, 0x0c, FIRST, SECOND, 0x87, 0x86, 0x40, 0xba, \