BLE - Exclude services if GattServer is not available.

pull/9790/head
Vincent Coubard 2019-02-28 16:28:15 +00:00
parent 5ae59fc534
commit 3142f26def
15 changed files with 60 additions and 0 deletions

View File

@ -17,6 +17,8 @@
#ifndef MBED_BLE_BATTERY_SERVICE_H__ #ifndef MBED_BLE_BATTERY_SERVICE_H__
#define MBED_BLE_BATTERY_SERVICE_H__ #define MBED_BLE_BATTERY_SERVICE_H__
#if BLE_FEATURE_GATT_SERVER
#include "platform/mbed_assert.h" #include "platform/mbed_assert.h"
#include "ble/BLE.h" #include "ble/BLE.h"
@ -129,4 +131,6 @@ protected:
ReadOnlyGattCharacteristic<uint8_t> batteryLevelCharacteristic; ReadOnlyGattCharacteristic<uint8_t> batteryLevelCharacteristic;
}; };
#endif // BLE_FEATURE_GATT_SERVER
#endif /* #ifndef MBED_BLE_BATTERY_SERVICE_H__*/ #endif /* #ifndef MBED_BLE_BATTERY_SERVICE_H__*/

View File

@ -19,6 +19,8 @@
#ifndef __BLE_DFU_SERVICE_H__ #ifndef __BLE_DFU_SERVICE_H__
#define __BLE_DFU_SERVICE_H__ #define __BLE_DFU_SERVICE_H__
#if BLE_FEATURE_GATT_SERVER
#include "ble/BLE.h" #include "ble/BLE.h"
#include "ble/UUID.h" #include "ble/UUID.h"
@ -142,5 +144,7 @@ protected:
static ResetPrepare_t handoverCallback; /**< Application-specific handover callback. */ static ResetPrepare_t handoverCallback; /**< Application-specific handover callback. */
}; };
#endif // BLE_FEATURE_GATT_SERVER
#endif /* #ifndef __BLE_DFU_SERVICE_H__*/ #endif /* #ifndef __BLE_DFU_SERVICE_H__*/
#endif /* #ifdef TARGET_NRF51822 */ #endif /* #ifdef TARGET_NRF51822 */

View File

@ -19,6 +19,8 @@
#include "ble/BLE.h" #include "ble/BLE.h"
#if BLE_FEATURE_GATT_SERVER
/** /**
* @class DeviceInformationService * @class DeviceInformationService
* @brief BLE Device Information Service * @brief BLE Device Information Service
@ -135,4 +137,6 @@ protected:
GattCharacteristic softwareRevisionStringCharacteristic; GattCharacteristic softwareRevisionStringCharacteristic;
}; };
#endif // BLE_FEATURE_GATT_SERVER
#endif /* #ifndef __BLE_DEVICE_INFORMATION_SERVICE_H__*/ #endif /* #ifndef __BLE_DEVICE_INFORMATION_SERVICE_H__*/

View File

@ -19,6 +19,8 @@
#warning ble/services/EddystoneConfigService.h is deprecated. Please use the example in 'github.com/ARMmbed/ble-examples/tree/master/BLE_EddystoneService'. #warning ble/services/EddystoneConfigService.h is deprecated. Please use the example in 'github.com/ARMmbed/ble-examples/tree/master/BLE_EddystoneService'.
#if BLE_FEATURE_GATT_SERVER
#include "ble/BLE.h" #include "ble/BLE.h"
#include "ble/services/EddystoneService.h" #include "ble/services/EddystoneService.h"
#include "Timer.h" #include "Timer.h"
@ -543,4 +545,6 @@ private:
WriteOnlyGattCharacteristic<uint8_t> resetChar; WriteOnlyGattCharacteristic<uint8_t> resetChar;
}; };
#endif // BLE_FEATURE_GATT_SERVER
#endif // SERVICES_EDDYSTONE_BEACON_CONFIG_SERVICE_H_ #endif // SERVICES_EDDYSTONE_BEACON_CONFIG_SERVICE_H_

View File

@ -25,6 +25,8 @@
#include "Ticker.h" #include "Ticker.h"
#include "Timeout.h" #include "Timeout.h"
#if BLE_FEATURE_GATT_SERVER
static const uint8_t BEACON_EDDYSTONE[] = {0xAA, 0xFE}; static const uint8_t BEACON_EDDYSTONE[] = {0xAA, 0xFE};
//Debug is disabled by default //Debug is disabled by default
@ -654,4 +656,6 @@ public:
} }
}; };
#endif // BLE_FEATURE_GATT_SERVER
#endif // SERVICES_EDDYSTONEBEACON_H_ #endif // SERVICES_EDDYSTONEBEACON_H_

View File

@ -19,6 +19,8 @@
#include "ble/BLE.h" #include "ble/BLE.h"
#if BLE_FEATURE_GATT_SERVER
/** /**
* @class EnvironmentalService * @class EnvironmentalService
* @brief BLE Environmental Service. This service provides temperature, humidity and pressure measurement. * @brief BLE Environmental Service. This service provides temperature, humidity and pressure measurement.
@ -100,4 +102,6 @@ private:
ReadOnlyGattCharacteristic<PressureType_t> pressureCharacteristic; ReadOnlyGattCharacteristic<PressureType_t> pressureCharacteristic;
}; };
#endif // BLE_FEATURE_GATT_SERVER
#endif /* #ifndef __BLE_ENVIRONMENTAL_SERVICE_H__*/ #endif /* #ifndef __BLE_ENVIRONMENTAL_SERVICE_H__*/

View File

@ -19,6 +19,8 @@
#include "ble/BLE.h" #include "ble/BLE.h"
#if BLE_FEATURE_GATT_SERVER
/** /**
* @class HealthThermometerService * @class HealthThermometerService
* @brief BLE Health Thermometer Service. This service provides the location of the thermometer and the temperature. * @brief BLE Health Thermometer Service. This service provides the location of the thermometer and the temperature.
@ -146,4 +148,6 @@ protected:
ReadOnlyGattCharacteristic<uint8_t> tempLocation; ReadOnlyGattCharacteristic<uint8_t> tempLocation;
}; };
#endif // BLE_FEATURE_GATT_SERVER
#endif /* #ifndef __BLE_HEALTH_THERMOMETER_SERVICE_H__*/ #endif /* #ifndef __BLE_HEALTH_THERMOMETER_SERVICE_H__*/

View File

@ -19,6 +19,8 @@
#include "ble/BLE.h" #include "ble/BLE.h"
#if BLE_FEATURE_GATT_SERVER
/** /**
* BLE Heart Rate Service. * BLE Heart Rate Service.
* *
@ -228,4 +230,6 @@ protected:
ReadOnlyGattCharacteristic<uint8_t> hrmLocation; ReadOnlyGattCharacteristic<uint8_t> hrmLocation;
}; };
#endif // BLE_FEATURE_GATT_SERVER
#endif /* #ifndef MBED_BLE_HEART_RATE_SERVICE_H__*/ #endif /* #ifndef MBED_BLE_HEART_RATE_SERVICE_H__*/

View File

@ -19,6 +19,8 @@
#include "ble/Gap.h" #include "ble/Gap.h"
#if BLE_FEATURE_GATT_SERVER
/** /**
* @class LinkLossService * @class LinkLossService
* @brief This service defines behavior when a link is lost between two devices. * @brief This service defines behavior when a link is lost between two devices.
@ -102,4 +104,6 @@ protected:
ReadWriteGattCharacteristic<uint8_t> alertLevelChar; ReadWriteGattCharacteristic<uint8_t> alertLevelChar;
}; };
#endif // BLE_FEATURE_GATT_SERVER
#endif /* __BLE_LINK_LOSS_SERVICE_H__ */ #endif /* __BLE_LINK_LOSS_SERVICE_H__ */

View File

@ -27,6 +27,8 @@
#include "ble/UUID.h" #include "ble/UUID.h"
#include "ble/BLE.h" #include "ble/BLE.h"
#if BLE_FEATURE_GATT_SERVER
extern const uint8_t UARTServiceBaseUUID[UUID::LENGTH_OF_LONG_UUID]; extern const uint8_t UARTServiceBaseUUID[UUID::LENGTH_OF_LONG_UUID];
extern const uint16_t UARTServiceShortUUID; extern const uint16_t UARTServiceShortUUID;
extern const uint16_t UARTServiceTXCharacteristicShortUUID; extern const uint16_t UARTServiceTXCharacteristicShortUUID;
@ -215,4 +217,6 @@ protected:
* application. */ * application. */
}; };
#endif // BLE_FEATURE_GATT_SERVER
#endif /* #ifndef __BLE_UART_SERVICE_H__*/ #endif /* #ifndef __BLE_UART_SERVICE_H__*/

View File

@ -25,6 +25,8 @@
#endif #endif
#if BLE_FEATURE_GATT_SERVER
extern const uint8_t UUID_URI_BEACON_SERVICE[UUID::LENGTH_OF_LONG_UUID]; extern const uint8_t UUID_URI_BEACON_SERVICE[UUID::LENGTH_OF_LONG_UUID];
extern const uint8_t UUID_LOCK_STATE_CHAR[UUID::LENGTH_OF_LONG_UUID]; extern const uint8_t UUID_LOCK_STATE_CHAR[UUID::LENGTH_OF_LONG_UUID];
extern const uint8_t UUID_LOCK_CHAR[UUID::LENGTH_OF_LONG_UUID]; extern const uint8_t UUID_LOCK_CHAR[UUID::LENGTH_OF_LONG_UUID];
@ -480,4 +482,6 @@ public:
} }
}; };
#endif // BLE_FEATURE_GATT_SERVER
#endif // SERVICES_URIBEACONCONFIGSERVICE_H_ #endif // SERVICES_URIBEACONCONFIGSERVICE_H_

View File

@ -19,6 +19,8 @@
#include "cmsis_compiler.h" #include "cmsis_compiler.h"
#include "ble/BLE.h" #include "ble/BLE.h"
#if BLE_FEATURE_GATT_SERVER
/** /**
* iBeacon Service. * iBeacon Service.
* *
@ -251,4 +253,6 @@ protected:
*/ */
typedef iBeacon iBeaconService; typedef iBeacon iBeaconService;
#endif // BLE_FEATURE_GATT_SERVER
#endif //MBED_BLE_IBEACON_H__ #endif //MBED_BLE_IBEACON_H__

View File

@ -18,6 +18,8 @@
#include "ble/services/DFUService.h" #include "ble/services/DFUService.h"
#if BLE_FEATURE_GATT_SERVER
const uint8_t DFUServiceBaseUUID[] = { const uint8_t DFUServiceBaseUUID[] = {
0x00, 0x00, 0x00, 0x00, 0x12, 0x12, 0xEF, 0xDE, 0x00, 0x00, 0x00, 0x00, 0x12, 0x12, 0xEF, 0xDE,
0x15, 0x23, 0x78, 0x5F, 0xEA, 0xBC, 0xD1, 0x23, 0x15, 0x23, 0x78, 0x5F, 0xEA, 0xBC, 0xD1, 0x23,
@ -41,4 +43,6 @@ const uint8_t DFUServicePacketCharacteristicUUID[] = {
DFUService::ResetPrepare_t DFUService::handoverCallback = NULL; DFUService::ResetPrepare_t DFUService::handoverCallback = NULL;
#endif // BLE_FEATURE_GATT_SERVER
#endif /* #ifdef TARGET_NRF51822 */ #endif /* #ifdef TARGET_NRF51822 */

View File

@ -16,6 +16,8 @@
#include "ble/services/UARTService.h" #include "ble/services/UARTService.h"
#if BLE_FEATURE_GATT_SERVER
const uint8_t UARTServiceBaseUUID[UUID::LENGTH_OF_LONG_UUID] = { const uint8_t UARTServiceBaseUUID[UUID::LENGTH_OF_LONG_UUID] = {
0x6E, 0x40, 0x00, 0x00, 0xB5, 0xA3, 0xF3, 0x93, 0x6E, 0x40, 0x00, 0x00, 0xB5, 0xA3, 0xF3, 0x93,
0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E, 0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E,
@ -39,3 +41,5 @@ const uint8_t UARTServiceRXCharacteristicUUID[UUID::LENGTH_OF_LONG_UUID] = {
0x6E, 0x40, (uint8_t)(UARTServiceRXCharacteristicShortUUID >> 8), (uint8_t)(UARTServiceRXCharacteristicShortUUID & 0xFF), 0xB5, 0xA3, 0xF3, 0x93, 0x6E, 0x40, (uint8_t)(UARTServiceRXCharacteristicShortUUID >> 8), (uint8_t)(UARTServiceRXCharacteristicShortUUID & 0xFF), 0xB5, 0xA3, 0xF3, 0x93,
0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E, 0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E,
}; };
#endif // BLE_FEATURE_GATT_SERVER

View File

@ -16,6 +16,8 @@
#include "ble/services/URIBeaconConfigService.h" #include "ble/services/URIBeaconConfigService.h"
#if BLE_FEATURE_GATT_SERVER
#define UUID_URI_BEACON(FIRST, SECOND) { \ #define UUID_URI_BEACON(FIRST, SECOND) { \
0xee, 0x0c, FIRST, SECOND, 0x87, 0x86, 0x40, 0xba, \ 0xee, 0x0c, FIRST, SECOND, 0x87, 0x86, 0x40, 0xba, \
0xab, 0x96, 0x99, 0xb9, 0x1a, 0xc9, 0x81, 0xd8, \ 0xab, 0x96, 0x99, 0xb9, 0x1a, 0xc9, 0x81, 0xd8, \
@ -33,3 +35,5 @@ const uint8_t UUID_BEACON_PERIOD_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_B
const uint8_t UUID_RESET_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x89); const uint8_t UUID_RESET_CHAR[UUID::LENGTH_OF_LONG_UUID] = UUID_URI_BEACON(0x20, 0x89);
const uint8_t BEACON_UUID[sizeof(UUID::ShortUUIDBytes_t)] = {0xD8, 0xFE}; const uint8_t BEACON_UUID[sizeof(UUID::ShortUUIDBytes_t)] = {0xD8, 0xFE};
#endif // BLE_FEATURE_GATT_SERVER