Skip to content

Commit

Permalink
samples: openthread: Fix for coap client wo/ multiprotocol
Browse files Browse the repository at this point in the history
The bluetooth header does not compile without bluetooth enabled
1. needed to ifdef ble_utils for cmake
2. had to #if instead of runtime if as the function will not be defined
3. had to #if callback functions as #2 des disable usage

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
  • Loading branch information
MarekPorwisz authored and rlubos committed May 29, 2020
1 parent ed15b09 commit d045c8f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
7 changes: 5 additions & 2 deletions samples/openthread/coap_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})

project(openthread_coap_client)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})

target_sources(app PRIVATE src/coap_client.c
src/coap_client_utils.c)

target_sources_ifdef(CONFIG_BT app PRIVATE src/ble_utils.c)

target_include_directories(app PRIVATE ../coap_server/interface)
24 changes: 16 additions & 8 deletions samples/openthread/coap_client/src/coap_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@
#include <dk_buttons_and_leds.h>
#include <logging/log.h>

#include "ble_utils.h"
#include "coap_client_utils.h"

#if CONFIG_BT
#include "ble_utils.h"
#endif

LOG_MODULE_REGISTER(coap_client, CONFIG_COAP_CLIENT_LOG_LEVEL);

#define OT_CONNECTION_LED DK_LED1
#define BLE_CONNECTION_LED DK_LED2
#define MTD_SED_LED DK_LED3

#if CONFIG_BT

#define COMMAND_REQUEST_UNICAST 'u'
#define COMMAND_REQUEST_MULTICAST 'm'
#define COMMAND_REQUEST_PROVISIONING 'p'
Expand Down Expand Up @@ -62,6 +67,8 @@ static void on_ble_disconnect(struct k_work *item)
dk_set_led_off(BLE_CONNECTION_LED);
}

#endif /* CONFIG_BT */

static void on_ot_connect(struct k_work *item)
{
ARG_UNUSED(item);
Expand Down Expand Up @@ -120,15 +127,16 @@ void main(void)
return;
}

if (IS_ENABLED(CONFIG_BT)) {
ret = ble_utils_init(&on_nus_received, NULL, on_ble_connect,
on_ble_disconnect);
if (ret) {
LOG_ERR("Cannot init BLE utilities");
return;
}
#if CONFIG_BT
ret = ble_utils_init(&on_nus_received, NULL, on_ble_connect,
on_ble_disconnect);
if (ret) {
LOG_ERR("Cannot init BLE utilities");
return;
}

#endif /* CONFIG_BT */

coap_client_utils_init(on_ot_connect, on_ot_disconnect,
on_mtd_mode_toggle);
}

0 comments on commit d045c8f

Please sign in to comment.