pkg/*: replace #if ENABLE_DEBUG with IS_ACTIVE

This commit is contained in:
Bas Stottelaar 2020-10-23 00:40:45 +02:00
parent bf88a24fb4
commit 9dd3b7a3ec
6 changed files with 33 additions and 43 deletions

View File

@ -164,7 +164,7 @@ static void _on_scan_evt(uint8_t type, const ble_addr_t *addr, int8_t rssi,
static void _evt_dbg(const char *msg, int handle, const uint8_t *addr) static void _evt_dbg(const char *msg, int handle, const uint8_t *addr)
{ {
#if ENABLE_DEBUG if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[autoconn] %s (%i|", msg, handle); printf("[autoconn] %s (%i|", msg, handle);
if (addr) { if (addr) {
bluetil_addr_print(addr); bluetil_addr_print(addr);
@ -173,11 +173,7 @@ static void _evt_dbg(const char *msg, int handle, const uint8_t *addr)
printf("n/a"); printf("n/a");
} }
puts(")"); puts(")");
#else }
(void)msg;
(void)handle;
(void)addr;
#endif
} }
static void _on_netif_evt(int handle, nimble_netif_event_t event, static void _on_netif_evt(int handle, nimble_netif_event_t event,

View File

@ -110,17 +110,13 @@ uint8_t ot_call_command(char* command, void *arg, void* answer)
void output_bytes(const char* name, const uint8_t *aBytes, uint8_t aLength) void output_bytes(const char* name, const uint8_t *aBytes, uint8_t aLength)
{ {
#if ENABLE_DEBUG if (IS_ACTIVE(ENABLE_DEBUG)) {
DEBUG("%s: ", name); DEBUG("%s: ", name);
for (int i = 0; i < aLength; i++) { for (int i = 0; i < aLength; i++) {
DEBUG("%02x", aBytes[i]); DEBUG("%02x", aBytes[i]);
} }
DEBUG("\n"); DEBUG("\n");
#else }
(void)name;
(void)aBytes;
(void)aLength;
#endif
} }
OT_COMMAND ot_channel(otInstance* ot_instance, void* arg, void* answer) { OT_COMMAND ot_channel(otInstance* ot_instance, void* arg, void* answer) {

View File

@ -159,7 +159,7 @@ void recv_pkt(otInstance *aInstance, netdev_t *dev)
/* Get RSSI from a radio driver. RSSI should be in [dBm] */ /* Get RSSI from a radio driver. RSSI should be in [dBm] */
Rssi = (int8_t)rx_info.rssi; Rssi = (int8_t)rx_info.rssi;
if (ENABLE_DEBUG) { if (IS_ACTIVE(ENABLE_DEBUG)) {
DEBUG("Received message: len %d\n", (int) sReceiveFrame.mLength); DEBUG("Received message: len %d\n", (int) sReceiveFrame.mLength);
for (int i = 0; i < sReceiveFrame.mLength; ++i) { for (int i = 0; i < sReceiveFrame.mLength; ++i) {
DEBUG("%x ", sReceiveFrame.mPsdu[i]); DEBUG("%x ", sReceiveFrame.mPsdu[i]);
@ -216,7 +216,7 @@ void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aE
for (unsigned i = 0; i < IEEE802154_LONG_ADDRESS_LEN; i++) { for (unsigned i = 0; i < IEEE802154_LONG_ADDRESS_LEN; i++) {
reversed_addr[i] = (uint8_t) ((uint8_t *)aExtAddress)[IEEE802154_LONG_ADDRESS_LEN - 1 - i]; reversed_addr[i] = (uint8_t) ((uint8_t *)aExtAddress)[IEEE802154_LONG_ADDRESS_LEN - 1 - i];
} }
if (ENABLE_DEBUG) { if (IS_ACTIVE(ENABLE_DEBUG)) {
for (unsigned i = 0; i < IEEE802154_LONG_ADDRESS_LEN; ++i) { for (unsigned i = 0; i < IEEE802154_LONG_ADDRESS_LEN; ++i) {
DEBUG("%x ", (uint8_t) ((uint8_t *)reversed_addr)[i]); DEBUG("%x ", (uint8_t) ((uint8_t *)reversed_addr)[i]);
} }
@ -344,7 +344,7 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aPacket)
}; };
/*Set channel and power based on transmit frame */ /*Set channel and power based on transmit frame */
if (ENABLE_DEBUG) { if (IS_ACTIVE(ENABLE_DEBUG)) {
DEBUG("otPlatRadioTransmit->channel: %i, length %d\n", DEBUG("otPlatRadioTransmit->channel: %i, length %d\n",
(int) aPacket->mChannel, (int)aPacket->mLength); (int) aPacket->mChannel, (int)aPacket->mLength);
for (size_t i = 0; i < aPacket->mLength; ++i) { for (size_t i = 0; i < aPacket->mLength; ++i) {

View File

@ -88,8 +88,7 @@ static int mqtt_read(struct Network *n, unsigned char *buf, int len,
} }
} while (rc < len && xtimer_now64().ticks64 < send_tick && rc >= 0); } while (rc < len && xtimer_now64().ticks64 < send_tick && rc >= 0);
#ifdef ENABLE_DEBUG if (IS_ACTIVE(ENABLE_DEBUG) && IS_USED(MODULE_LWIP) && rc > 0) {
if (IS_USED(MODULE_LWIP) && rc > 0) {
DEBUG("MQTT buf asked for %d, available to read %d\n", DEBUG("MQTT buf asked for %d, available to read %d\n",
rc, tsrb_avail(&tsrb_lwip_tcp)); rc, tsrb_avail(&tsrb_lwip_tcp));
for (int i = 0; i < rc; i++) { for (int i = 0; i < rc; i++) {
@ -97,7 +96,6 @@ static int mqtt_read(struct Network *n, unsigned char *buf, int len,
} }
DEBUG("\n"); DEBUG("\n");
} }
#endif
return rc; return rc;
} }

View File

@ -712,7 +712,7 @@ void *_semtech_loramac_event_loop(void *arg)
/* save the uplink counter */ /* save the uplink counter */
_save_uplink_counter(mac); _save_uplink_counter(mac);
#endif #endif
if (ENABLE_DEBUG) { if (IS_ACTIVE(ENABLE_DEBUG)) {
switch (confirm->McpsRequest) { switch (confirm->McpsRequest) {
case MCPS_UNCONFIRMED: case MCPS_UNCONFIRMED:
{ {
@ -755,7 +755,7 @@ void *_semtech_loramac_event_loop(void *arg)
break; break;
} }
if (ENABLE_DEBUG) { if (IS_ACTIVE(ENABLE_DEBUG)) {
switch (indication->McpsIndication) { switch (indication->McpsIndication) {
case MCPS_UNCONFIRMED: case MCPS_UNCONFIRMED:
DEBUG("[semtech-loramac] MCPS indication Unconfirmed\n"); DEBUG("[semtech-loramac] MCPS indication Unconfirmed\n");

View File

@ -117,7 +117,7 @@ static int _event(struct dtls_context_t *ctx, session_t *session,
sock_dtls_t *sock = dtls_get_app_data(ctx); sock_dtls_t *sock = dtls_get_app_data(ctx);
msg_t msg = { .type = code, .content.ptr = session }; msg_t msg = { .type = code, .content.ptr = session };
#ifdef ENABLE_DEBUG if (IS_ACTIVE(ENABLE_DEBUG)) {
switch (code) { switch (code) {
case DTLS_EVENT_CONNECT: case DTLS_EVENT_CONNECT:
DEBUG("sock_dtls: event connect\n"); DEBUG("sock_dtls: event connect\n");
@ -129,7 +129,7 @@ static int _event(struct dtls_context_t *ctx, session_t *session,
DEBUG("sock_dtls: event renegotiate\n"); DEBUG("sock_dtls: event renegotiate\n");
break; break;
} }
#endif /* ENABLE_DEBUG */ }
if (!level && (code != DTLS_EVENT_CONNECT)) { if (!level && (code != DTLS_EVENT_CONNECT)) {
mbox_put(&sock->mbox, &msg); mbox_put(&sock->mbox, &msg);
} }