Skip to content

Commit 6cdfb19

Browse files
committed
BLE: TARGET_NRF - Avoid redefinition of ASSERT macro.
Instead, the BLE code use the macro ASSERT_TRUE
1 parent 2af37a6 commit 6cdfb19

File tree

9 files changed

+18
-20
lines changed

9 files changed

+18
-20
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/source/btle/btle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static void btle_handler(ble_evt_t *p_ble_evt)
234234
/*! @brief Callback when an error occurs inside the SoftDevice */
235235
void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name)
236236
{
237-
ASSERT(false, (void) 0);
237+
ASSERT_TRUE(false, (void) 0);
238238
}
239239

240240
/*!

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/source/btle/custom/custom_helper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ ble_uuid_t custom_convert_to_nordic_uuid(const UUID &uuid)
135135
#define CFG_CUSTOM_UUID_BASE "\x6E\x40\x00\x00\xB5\xA3\xF3\x93\xE0\xA9\xE5\x0E\x24\xDC\xCA\x9E"
136136
137137
uint8_t uuid_type = custom_add_uuid_base(CFG_CUSTOM_UUID_BASE);
138-
ASSERT(uuid_type > 0, ERROR_NOT_FOUND);
138+
ASSERT_TRUE(uuid_type > 0, ERROR_NOT_FOUND);
139139
140140
// We can now safely add the primary service and any characteristics
141141
// for our custom service ...

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/source/common/assertion.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ static inline void debugger_breakpoint(void)
125125
//--------------------------------------------------------------------+
126126
// Logical Assert
127127
//--------------------------------------------------------------------+
128-
#define ASSERT(...) ASSERT_TRUE(__VA_ARGS__)
129128
#define ASSERT_TRUE(condition , error) ASSERT_DEFINE( , (condition), error, "%s", "evaluated to false")
130129
#define ASSERT_FALSE(condition , error) ASSERT_DEFINE( ,!(condition), error, "%s", "evaluated to true")
131130

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/source/nRF5xGap.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ ble_error_t nRF5xGap::setAdvertisingData(const GapAdvertisingData &advData, cons
9696
//}
9797

9898
/* Send advertising data! */
99-
ASSERT(ERROR_NONE ==
99+
ASSERT_TRUE(ERROR_NONE ==
100100
sd_ble_gap_adv_data_set(advData.getPayload(),
101101
advData.getPayloadLen(),
102102
scanResponse.getPayload(),
@@ -105,7 +105,7 @@ ble_error_t nRF5xGap::setAdvertisingData(const GapAdvertisingData &advData, cons
105105

106106
/* Make sure the GAP Service appearance value is aligned with the
107107
*appearance from GapAdvertisingData */
108-
ASSERT(ERROR_NONE == sd_ble_gap_appearance_set(advData.getAppearance()),
108+
ASSERT_TRUE(ERROR_NONE == sd_ble_gap_appearance_set(advData.getAppearance()),
109109
BLE_ERROR_PARAM_OUT_OF_RANGE);
110110

111111
/* ToDo: Perform some checks on the payload, for example the Scan Response can't */
@@ -196,7 +196,7 @@ ble_error_t nRF5xGap::startAdvertising(const GapAdvertisingParams &params)
196196
adv_para.interval = params.getIntervalInADVUnits(); // advertising interval (in units of 0.625 ms)
197197
adv_para.timeout = params.getTimeout();
198198

199-
ASSERT(ERROR_NONE == sd_ble_gap_adv_start(&adv_para), BLE_ERROR_PARAM_OUT_OF_RANGE);
199+
ASSERT_TRUE(ERROR_NONE == sd_ble_gap_adv_start(&adv_para), BLE_ERROR_PARAM_OUT_OF_RANGE);
200200

201201
return BLE_ERROR_NONE;
202202
}
@@ -267,7 +267,7 @@ ble_error_t nRF5xGap::stopScan(void) {
267267
ble_error_t nRF5xGap::stopAdvertising(void)
268268
{
269269
/* Stop Advertising */
270-
ASSERT(ERROR_NONE == sd_ble_gap_adv_stop(), BLE_ERROR_PARAM_OUT_OF_RANGE);
270+
ASSERT_TRUE(ERROR_NONE == sd_ble_gap_adv_stop(), BLE_ERROR_PARAM_OUT_OF_RANGE);
271271

272272
state.advertising = 0;
273273

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/source/nRF5xGattServer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
5252
nordicUUID = custom_convert_to_nordic_uuid(service.getUUID());
5353

5454
uint16_t serviceHandle;
55-
ASSERT( ERROR_NONE ==
55+
ASSERT_TRUE( ERROR_NONE ==
5656
sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
5757
&nordicUUID,
5858
&serviceHandle),
@@ -88,7 +88,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
8888
}
8989
}
9090

91-
ASSERT ( ERROR_NONE ==
91+
ASSERT_TRUE ( ERROR_NONE ==
9292
custom_add_in_characteristic(BLE_GATT_HANDLE_INVALID,
9393
&nordicUUID,
9494
p_char->getProperties(),
@@ -123,7 +123,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
123123

124124
nordicUUID = custom_convert_to_nordic_uuid(p_desc->getUUID());
125125

126-
ASSERT(ERROR_NONE ==
126+
ASSERT_TRUE(ERROR_NONE ==
127127
custom_add_in_descriptor(BLE_GATT_HANDLE_INVALID,
128128
&nordicUUID,
129129
p_desc->getValuePtr(),
@@ -177,7 +177,7 @@ ble_error_t nRF5xGattServer::read(Gap::Handle_t connectionHandle, GattAttribute:
177177
.p_value = buffer,
178178
};
179179

180-
ASSERT( ERROR_NONE ==
180+
ASSERT_TRUE( ERROR_NONE ==
181181
sd_ble_gatts_value_get(connectionHandle, attributeHandle, &value),
182182
BLE_ERROR_PARAM_OUT_OF_RANGE);
183183
*lengthP = value.len;

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/btle/btle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ static void btle_handler(ble_evt_t *p_ble_evt)
292292
/*! @brief Callback when an error occurs inside the SoftDevice */
293293
void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name)
294294
{
295-
ASSERT(false, (void) 0);
295+
ASSERT_TRUE(false, (void) 0);
296296
}
297297

298298
/*!

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/common/assertion.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ static inline void debugger_breakpoint(void)
125125
//--------------------------------------------------------------------+
126126
// Logical Assert
127127
//--------------------------------------------------------------------+
128-
#define ASSERT(...) ASSERT_TRUE(__VA_ARGS__)
129128
#define ASSERT_TRUE(condition , error) ASSERT_DEFINE( , (condition), error, "%s", "evaluated to false")
130129
#define ASSERT_FALSE(condition , error) ASSERT_DEFINE( ,!(condition), error, "%s", "evaluated to true")
131130

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/nRF5xGap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ ble_error_t nRF5xGap::setAdvertisingData(const GapAdvertisingData &advData, cons
9696
//}
9797

9898
/* Send advertising data! */
99-
ASSERT(ERROR_NONE ==
99+
ASSERT_TRUE(ERROR_NONE ==
100100
sd_ble_gap_adv_data_set(advData.getPayload(),
101101
advData.getPayloadLen(),
102102
scanResponse.getPayload(),
@@ -105,7 +105,7 @@ ble_error_t nRF5xGap::setAdvertisingData(const GapAdvertisingData &advData, cons
105105

106106
/* Make sure the GAP Service appearance value is aligned with the
107107
*appearance from GapAdvertisingData */
108-
ASSERT(ERROR_NONE == sd_ble_gap_appearance_set(advData.getAppearance()),
108+
ASSERT_TRUE(ERROR_NONE == sd_ble_gap_appearance_set(advData.getAppearance()),
109109
BLE_ERROR_PARAM_OUT_OF_RANGE);
110110

111111
/* ToDo: Perform some checks on the payload, for example the Scan Response can't */
@@ -273,7 +273,7 @@ ble_error_t nRF5xGap::stopScan(void) {
273273
ble_error_t nRF5xGap::stopAdvertising(void)
274274
{
275275
/* Stop Advertising */
276-
ASSERT(ERROR_NONE == sd_ble_gap_adv_stop(), BLE_ERROR_PARAM_OUT_OF_RANGE);
276+
ASSERT_TRUE(ERROR_NONE == sd_ble_gap_adv_stop(), BLE_ERROR_PARAM_OUT_OF_RANGE);
277277

278278
state.advertising = 0;
279279

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/nRF5xGattServer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
5252
nordicUUID = custom_convert_to_nordic_uuid(service.getUUID());
5353

5454
uint16_t serviceHandle;
55-
ASSERT( ERROR_NONE ==
55+
ASSERT_TRUE( ERROR_NONE ==
5656
sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
5757
&nordicUUID,
5858
&serviceHandle),
@@ -88,7 +88,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
8888
}
8989
}
9090

91-
ASSERT ( ERROR_NONE ==
91+
ASSERT_TRUE ( ERROR_NONE ==
9292
custom_add_in_characteristic(BLE_GATT_HANDLE_INVALID,
9393
&nordicUUID,
9494
p_char->getProperties(),
@@ -123,7 +123,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
123123

124124
nordicUUID = custom_convert_to_nordic_uuid(p_desc->getUUID());
125125

126-
ASSERT(ERROR_NONE ==
126+
ASSERT_TRUE(ERROR_NONE ==
127127
custom_add_in_descriptor(BLE_GATT_HANDLE_INVALID,
128128
&nordicUUID,
129129
p_desc->getValuePtr(),
@@ -177,7 +177,7 @@ ble_error_t nRF5xGattServer::read(Gap::Handle_t connectionHandle, GattAttribute:
177177
.p_value = buffer,
178178
};
179179

180-
ASSERT( ERROR_NONE ==
180+
ASSERT_TRUE( ERROR_NONE ==
181181
sd_ble_gatts_value_get(connectionHandle, attributeHandle, &value),
182182
BLE_ERROR_PARAM_OUT_OF_RANGE);
183183
*lengthP = value.len;

0 commit comments

Comments
 (0)