From 3142f26def7cc9dd3ddb31affe58f440e756b1d7 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Thu, 28 Feb 2019 16:28:15 +0000 Subject: [PATCH] BLE - Exclude services if GattServer is not available. --- features/FEATURE_BLE/ble/services/BatteryService.h | 4 ++++ features/FEATURE_BLE/ble/services/DFUService.h | 4 ++++ features/FEATURE_BLE/ble/services/DeviceInformationService.h | 4 ++++ features/FEATURE_BLE/ble/services/EddystoneConfigService.h | 4 ++++ features/FEATURE_BLE/ble/services/EddystoneService.h | 4 ++++ features/FEATURE_BLE/ble/services/EnvironmentalService.h | 4 ++++ features/FEATURE_BLE/ble/services/HealthThermometerService.h | 4 ++++ features/FEATURE_BLE/ble/services/HeartRateService.h | 4 ++++ features/FEATURE_BLE/ble/services/LinkLossService.h | 4 ++++ features/FEATURE_BLE/ble/services/UARTService.h | 4 ++++ features/FEATURE_BLE/ble/services/URIBeaconConfigService.h | 4 ++++ features/FEATURE_BLE/ble/services/iBeacon.h | 4 ++++ features/FEATURE_BLE/source/services/DFUService.cpp | 4 ++++ features/FEATURE_BLE/source/services/UARTService.cpp | 4 ++++ .../FEATURE_BLE/source/services/URIBeaconConfigService.cpp | 4 ++++ 15 files changed, 60 insertions(+) diff --git a/features/FEATURE_BLE/ble/services/BatteryService.h b/features/FEATURE_BLE/ble/services/BatteryService.h index 2fcb7d516e..0b2af8d576 100644 --- a/features/FEATURE_BLE/ble/services/BatteryService.h +++ b/features/FEATURE_BLE/ble/services/BatteryService.h @@ -17,6 +17,8 @@ #ifndef MBED_BLE_BATTERY_SERVICE_H__ #define MBED_BLE_BATTERY_SERVICE_H__ +#if BLE_FEATURE_GATT_SERVER + #include "platform/mbed_assert.h" #include "ble/BLE.h" @@ -129,4 +131,6 @@ protected: ReadOnlyGattCharacteristic batteryLevelCharacteristic; }; +#endif // BLE_FEATURE_GATT_SERVER + #endif /* #ifndef MBED_BLE_BATTERY_SERVICE_H__*/ diff --git a/features/FEATURE_BLE/ble/services/DFUService.h b/features/FEATURE_BLE/ble/services/DFUService.h index 1614a3cfd9..a0284178d7 100644 --- a/features/FEATURE_BLE/ble/services/DFUService.h +++ b/features/FEATURE_BLE/ble/services/DFUService.h @@ -19,6 +19,8 @@ #ifndef __BLE_DFU_SERVICE_H__ #define __BLE_DFU_SERVICE_H__ +#if BLE_FEATURE_GATT_SERVER + #include "ble/BLE.h" #include "ble/UUID.h" @@ -142,5 +144,7 @@ protected: static ResetPrepare_t handoverCallback; /**< Application-specific handover callback. */ }; +#endif // BLE_FEATURE_GATT_SERVER + #endif /* #ifndef __BLE_DFU_SERVICE_H__*/ #endif /* #ifdef TARGET_NRF51822 */ diff --git a/features/FEATURE_BLE/ble/services/DeviceInformationService.h b/features/FEATURE_BLE/ble/services/DeviceInformationService.h index a52ace1e35..f4f215cab3 100644 --- a/features/FEATURE_BLE/ble/services/DeviceInformationService.h +++ b/features/FEATURE_BLE/ble/services/DeviceInformationService.h @@ -19,6 +19,8 @@ #include "ble/BLE.h" +#if BLE_FEATURE_GATT_SERVER + /** * @class DeviceInformationService * @brief BLE Device Information Service @@ -135,4 +137,6 @@ protected: GattCharacteristic softwareRevisionStringCharacteristic; }; +#endif // BLE_FEATURE_GATT_SERVER + #endif /* #ifndef __BLE_DEVICE_INFORMATION_SERVICE_H__*/ diff --git a/features/FEATURE_BLE/ble/services/EddystoneConfigService.h b/features/FEATURE_BLE/ble/services/EddystoneConfigService.h index 99bed208b1..3d706afdac 100644 --- a/features/FEATURE_BLE/ble/services/EddystoneConfigService.h +++ b/features/FEATURE_BLE/ble/services/EddystoneConfigService.h @@ -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'. +#if BLE_FEATURE_GATT_SERVER + #include "ble/BLE.h" #include "ble/services/EddystoneService.h" #include "Timer.h" @@ -543,4 +545,6 @@ private: WriteOnlyGattCharacteristic resetChar; }; +#endif // BLE_FEATURE_GATT_SERVER + #endif // SERVICES_EDDYSTONE_BEACON_CONFIG_SERVICE_H_ diff --git a/features/FEATURE_BLE/ble/services/EddystoneService.h b/features/FEATURE_BLE/ble/services/EddystoneService.h index 4a42a98548..4e306d4d2d 100644 --- a/features/FEATURE_BLE/ble/services/EddystoneService.h +++ b/features/FEATURE_BLE/ble/services/EddystoneService.h @@ -25,6 +25,8 @@ #include "Ticker.h" #include "Timeout.h" +#if BLE_FEATURE_GATT_SERVER + static const uint8_t BEACON_EDDYSTONE[] = {0xAA, 0xFE}; //Debug is disabled by default @@ -654,4 +656,6 @@ public: } }; +#endif // BLE_FEATURE_GATT_SERVER + #endif // SERVICES_EDDYSTONEBEACON_H_ diff --git a/features/FEATURE_BLE/ble/services/EnvironmentalService.h b/features/FEATURE_BLE/ble/services/EnvironmentalService.h index c081245beb..ab864c3608 100644 --- a/features/FEATURE_BLE/ble/services/EnvironmentalService.h +++ b/features/FEATURE_BLE/ble/services/EnvironmentalService.h @@ -19,6 +19,8 @@ #include "ble/BLE.h" +#if BLE_FEATURE_GATT_SERVER + /** * @class EnvironmentalService * @brief BLE Environmental Service. This service provides temperature, humidity and pressure measurement. @@ -100,4 +102,6 @@ private: ReadOnlyGattCharacteristic pressureCharacteristic; }; +#endif // BLE_FEATURE_GATT_SERVER + #endif /* #ifndef __BLE_ENVIRONMENTAL_SERVICE_H__*/ diff --git a/features/FEATURE_BLE/ble/services/HealthThermometerService.h b/features/FEATURE_BLE/ble/services/HealthThermometerService.h index af06b59f5d..bdb7e47e1d 100644 --- a/features/FEATURE_BLE/ble/services/HealthThermometerService.h +++ b/features/FEATURE_BLE/ble/services/HealthThermometerService.h @@ -19,6 +19,8 @@ #include "ble/BLE.h" +#if BLE_FEATURE_GATT_SERVER + /** * @class HealthThermometerService * @brief BLE Health Thermometer Service. This service provides the location of the thermometer and the temperature. @@ -146,4 +148,6 @@ protected: ReadOnlyGattCharacteristic tempLocation; }; +#endif // BLE_FEATURE_GATT_SERVER + #endif /* #ifndef __BLE_HEALTH_THERMOMETER_SERVICE_H__*/ diff --git a/features/FEATURE_BLE/ble/services/HeartRateService.h b/features/FEATURE_BLE/ble/services/HeartRateService.h index e8e239361c..1433b81499 100644 --- a/features/FEATURE_BLE/ble/services/HeartRateService.h +++ b/features/FEATURE_BLE/ble/services/HeartRateService.h @@ -19,6 +19,8 @@ #include "ble/BLE.h" +#if BLE_FEATURE_GATT_SERVER + /** * BLE Heart Rate Service. * @@ -228,4 +230,6 @@ protected: ReadOnlyGattCharacteristic hrmLocation; }; +#endif // BLE_FEATURE_GATT_SERVER + #endif /* #ifndef MBED_BLE_HEART_RATE_SERVICE_H__*/ diff --git a/features/FEATURE_BLE/ble/services/LinkLossService.h b/features/FEATURE_BLE/ble/services/LinkLossService.h index 9bfed115e5..290f87ea6b 100644 --- a/features/FEATURE_BLE/ble/services/LinkLossService.h +++ b/features/FEATURE_BLE/ble/services/LinkLossService.h @@ -19,6 +19,8 @@ #include "ble/Gap.h" +#if BLE_FEATURE_GATT_SERVER + /** * @class LinkLossService * @brief This service defines behavior when a link is lost between two devices. @@ -102,4 +104,6 @@ protected: ReadWriteGattCharacteristic alertLevelChar; }; +#endif // BLE_FEATURE_GATT_SERVER + #endif /* __BLE_LINK_LOSS_SERVICE_H__ */ diff --git a/features/FEATURE_BLE/ble/services/UARTService.h b/features/FEATURE_BLE/ble/services/UARTService.h index 241db763b4..bad42d00f0 100644 --- a/features/FEATURE_BLE/ble/services/UARTService.h +++ b/features/FEATURE_BLE/ble/services/UARTService.h @@ -27,6 +27,8 @@ #include "ble/UUID.h" #include "ble/BLE.h" +#if BLE_FEATURE_GATT_SERVER + extern const uint8_t UARTServiceBaseUUID[UUID::LENGTH_OF_LONG_UUID]; extern const uint16_t UARTServiceShortUUID; extern const uint16_t UARTServiceTXCharacteristicShortUUID; @@ -215,4 +217,6 @@ protected: * application. */ }; +#endif // BLE_FEATURE_GATT_SERVER + #endif /* #ifndef __BLE_UART_SERVICE_H__*/ diff --git a/features/FEATURE_BLE/ble/services/URIBeaconConfigService.h b/features/FEATURE_BLE/ble/services/URIBeaconConfigService.h index 6a6a583431..b2752652d4 100644 --- a/features/FEATURE_BLE/ble/services/URIBeaconConfigService.h +++ b/features/FEATURE_BLE/ble/services/URIBeaconConfigService.h @@ -25,6 +25,8 @@ #endif +#if BLE_FEATURE_GATT_SERVER + 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_CHAR[UUID::LENGTH_OF_LONG_UUID]; @@ -480,4 +482,6 @@ public: } }; +#endif // BLE_FEATURE_GATT_SERVER + #endif // SERVICES_URIBEACONCONFIGSERVICE_H_ diff --git a/features/FEATURE_BLE/ble/services/iBeacon.h b/features/FEATURE_BLE/ble/services/iBeacon.h index e3003e27d3..95bd55aa8e 100644 --- a/features/FEATURE_BLE/ble/services/iBeacon.h +++ b/features/FEATURE_BLE/ble/services/iBeacon.h @@ -19,6 +19,8 @@ #include "cmsis_compiler.h" #include "ble/BLE.h" +#if BLE_FEATURE_GATT_SERVER + /** * iBeacon Service. * @@ -251,4 +253,6 @@ protected: */ typedef iBeacon iBeaconService; +#endif // BLE_FEATURE_GATT_SERVER + #endif //MBED_BLE_IBEACON_H__ diff --git a/features/FEATURE_BLE/source/services/DFUService.cpp b/features/FEATURE_BLE/source/services/DFUService.cpp index b10e24c632..a559f11da2 100644 --- a/features/FEATURE_BLE/source/services/DFUService.cpp +++ b/features/FEATURE_BLE/source/services/DFUService.cpp @@ -18,6 +18,8 @@ #include "ble/services/DFUService.h" +#if BLE_FEATURE_GATT_SERVER + const uint8_t DFUServiceBaseUUID[] = { 0x00, 0x00, 0x00, 0x00, 0x12, 0x12, 0xEF, 0xDE, 0x15, 0x23, 0x78, 0x5F, 0xEA, 0xBC, 0xD1, 0x23, @@ -41,4 +43,6 @@ const uint8_t DFUServicePacketCharacteristicUUID[] = { DFUService::ResetPrepare_t DFUService::handoverCallback = NULL; +#endif // BLE_FEATURE_GATT_SERVER + #endif /* #ifdef TARGET_NRF51822 */ diff --git a/features/FEATURE_BLE/source/services/UARTService.cpp b/features/FEATURE_BLE/source/services/UARTService.cpp index 6d1edea01a..223064423b 100644 --- a/features/FEATURE_BLE/source/services/UARTService.cpp +++ b/features/FEATURE_BLE/source/services/UARTService.cpp @@ -16,6 +16,8 @@ #include "ble/services/UARTService.h" +#if BLE_FEATURE_GATT_SERVER + const uint8_t UARTServiceBaseUUID[UUID::LENGTH_OF_LONG_UUID] = { 0x6E, 0x40, 0x00, 0x00, 0xB5, 0xA3, 0xF3, 0x93, 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, 0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E, }; + +#endif // BLE_FEATURE_GATT_SERVER \ No newline at end of file diff --git a/features/FEATURE_BLE/source/services/URIBeaconConfigService.cpp b/features/FEATURE_BLE/source/services/URIBeaconConfigService.cpp index bcdcbb0e3b..4d8e75cb94 100644 --- a/features/FEATURE_BLE/source/services/URIBeaconConfigService.cpp +++ b/features/FEATURE_BLE/source/services/URIBeaconConfigService.cpp @@ -16,6 +16,8 @@ #include "ble/services/URIBeaconConfigService.h" +#if BLE_FEATURE_GATT_SERVER + #define UUID_URI_BEACON(FIRST, SECOND) { \ 0xee, 0x0c, FIRST, SECOND, 0x87, 0x86, 0x40, 0xba, \ 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 BEACON_UUID[sizeof(UUID::ShortUUIDBytes_t)] = {0xD8, 0xFE}; + +#endif // BLE_FEATURE_GATT_SERVER