This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Bluetooth mesh on Thingy52 more difficult than expected

Hello, I am trying to implement some Bluetooth mesh functionality on my Thingy:52, and it's quite a daunting task.

I am using the mesh sdk v3.1.0 thingy:52 sdk v.2.1.0 and I have put the nrf5 sdk 15.0.0 next to the mesh sdk folder, as recommended.
I also put the thingy52 sdk in mesh_sdk/external.

Now I have already implemented quite a bit of software for the thingy52, and would just like to add some simple Bluetooth mesh code to it, to demo. I checked in mesh_sdk/examples and thought I would try the light_switch example.

I will post some code now to give a clear picture of what I've got.

thingy main.c file, it's not really that relevant here, but I am importing mesh.c for now and in the future I will want to create some mesh_init() function which I will call in the main function.

#include "sdk_config.h"

#include "log.c" // Logs with my own settings
#include "thingy.c"
#include "nfc.c"
#include "gps.c"
#include "lora.c"
#include "mesh.c"
#include "common.h"

/**@brief Application main function.
 */
int main(void)
{
    uint32_t err_code;
    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);
    
    // Initialize.
    APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
    err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);

    board_init();
    thingy_init();
    nfc_init();
    gps_init();
    lora_init();

    LOG_INFO("===== Thingy started! =====\r\n");

    for (;;)
    {
        app_sched_execute();
        
        if (!NRF_LOG_PROCESS()) // Process logs
        { 
            power_manage();
        }
    }
}

thingysdk/config/sdk_config.h, here I just had to define the BOARD_PCA10040 otherwise the #include "boards.h" broke.

#ifndef SDK_CONFIG_H
#define SDK_CONFIG_H
// <<< Use Configuration Wizard in Context Menu >>>\n
#ifdef USE_APP_CONFIG
#include "app_config.h"
#endif

#define NRF_LOG_ENABLED 1
#define NRF_LOG_DEFAULT_LEVEL NRF_LOG_LEVEL_DEBUG

#define BOARD_PCA10040 1
...

Now this is my mesh.c file, I have literally just copied the includes from the mesh_sdk/examples/light_switch/proxy_client/src/main.c, but everything completely breaks even with just these, and I don't understand why.

/*
  File: mesh.c
 */

#include <stdint.h>
#include <string.h>

/* HAL */
#include "boards.h"
#include "simple_hal.h"
#include "app_timer.h"

/* Core */
#include "nrf_mesh_configure.h"
#include "nrf_mesh.h"
#include "mesh_stack.h"
#include "device_state_manager.h"
#include "access_config.h"
#include "sdk_config.h"
#include "mesh_adv.h"
#include "nrf_sdh.h"
#include "nrf_sdh_ble.h"
#include "nrf_sdh_soc.h"
#include "ble_conn_params.h"
#include "ble_hci.h"
#include "proxy.h"

/* Provisioning and configuration */
#include "mesh_provisionee.h"
#include "mesh_app_utils.h"
#include "mesh_softdevice_init.h"

/* Models */
#include "generic_onoff_client.h"

/* Logging and RTT */
#include "log.h"
#include "rtt_input.h"

/* Example specific includes */
#include "app_config.h"
#include "nrf_mesh_config_examples.h"
#include "light_switch_example_common.h"
#include "example_common.h"

This is the compiler output:

In file included from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/sdk_components/nfc/t2t_lib/hal_t2t/hal_nfc_t2t.c:48:0:
/home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/sdk_components/nfc/t2t_lib/nfc_fixes.h:73:0: error: "HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND" redefined [-Werror]
     #define HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND
 ^
<command-line>:0:0: note: this is the location of the previous definition
Compiling file: nrf_drv_uart.c
Compiling file: app_uart.c
Assembly file: gcc_startup_nrf52.S
In file included from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/examples/common/include/simple_hal.h:43:0,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/project/pca20020_s132/mesh.c:10,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/project/pca20020_s132/main.c:53:
/home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/core/include/hal.h:70:19: error: #elif with no expression
 #elif NRF52_SERIES
                   ^
/home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/core/include/hal.h:114:2: error: #error "Unsupported hardware platform"
 #error "Unsupported hardware platform"
  ^
In file included from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/sdk_components/ble/common/ble_advdata.h:53:0,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/project/pca20020_s132/thingy.c:14,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/project/pca20020_s132/main.c:49:
/home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/access/api/device_state_manager.h:255:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '_Bool'
 _DEPRECATED bool dsm_address_subscription_get(dsm_handle_t address_handle);
             ^
In file included from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/core/include/packet.h:47:0,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/core/include/heartbeat.h:43,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/models/foundation/config/include/config_server_events.h:44,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/stack/api/mesh_stack.h:42,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/project/pca20020_s132/mesh.c:16,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/project/pca20020_s132/main.c:53:
/home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/core/include/utils.h:88:29: error: operator '||' has no right operand
 #elif (NRF51 || NRF52_SERIES)
                             ^
In file included from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/core/include/transport.h:48:0,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/core/include/heartbeat.h:48,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/models/foundation/config/include/config_server_events.h:44,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/stack/api/mesh_stack.h:42,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/project/pca20020_s132/mesh.c:16,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/project/pca20020_s132/main.c:53:
/home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/core/api/nrf_mesh_opt.h:127:1: error: unknown type name '_DEPRECATED'
 _DEPRECATED uint32_t nrf_mesh_opt_set(nrf_mesh_opt_id_t id, const nrf_mesh_opt_t * const p_opt);
 ^
/home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/core/api/nrf_mesh_opt.h:127:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'nrf_mesh_opt_set'
 _DEPRECATED uint32_t nrf_mesh_opt_set(nrf_mesh_opt_id_t id, const nrf_mesh_opt_t * const p_opt);
                      ^
/home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/core/api/nrf_mesh_opt.h:139:1: error: unknown type name '_DEPRECATED'
 _DEPRECATED uint32_t nrf_mesh_opt_get(nrf_mesh_opt_id_t id, nrf_mesh_opt_t * const p_opt);
 ^
/home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/core/api/nrf_mesh_opt.h:139:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'nrf_mesh_opt_get'
 _DEPRECATED uint32_t nrf_mesh_opt_get(nrf_mesh_opt_id_t id, nrf_mesh_opt_t * const p_opt);
                      ^
In file included from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/core/include/bitfield.h:45:0,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/models/foundation/health/include/health_server.h:45,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/stack/api/mesh_stack.h:43,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/project/pca20020_s132/mesh.c:16,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/project/pca20020_s132/main.c:53:
/home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/core/include/toolchain.h:81:0: error: "_ENABLE_IRQS" redefined [-Werror]
     #define _ENABLE_IRQS(_was_masked) do{ if (!(_was_masked)) { __enable_irq(); } } while(0)
 ^
In file included from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/access/api/device_state_manager.h:46:0,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/models/foundation/config/include/config_server_events.h:42,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/stack/api/mesh_stack.h:42,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/project/pca20020_s132/mesh.c:16,
                 from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/project/pca20020_s132/main.c:53:
/home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/mesh/bootloader/include/toolchain.h:62:0: note: this is the location of the previous definition
     #define _ENABLE_IRQS(_was_masked) if (!_was_masked) { __enable_irq(); }
 ^
In file included from /home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/project/pca20020_s132/main.c:53:0:
/home/robban/sommarjobb/hubben/nrf5_sdk_for_mesh/external/thingysdkv210/project/pca20020_s132/mesh.c:21:21: fatal error: nrf_sdh.h: No such file or directory
 #include "nrf_sdh.h"
                     ^
cc1: all warnings being treated as errors
compilation terminated.

These errors are complete nonsense to me. At least I know that some of the problems are coming from the generic_onoff_client.h file, because I edited everything else out and had these issues.

It feels like I'm walking in circles trying to just implement some small mesh functionality into my thingy. Feels like I'm on the completely wrong track in some sense.
Could someone please help me to the right direction here?

Parents
  • I don't understand at all how the thingy52 is supposed to be flashed with both Bluetooth mesh and other custom functionality. As I mentioned above, the thingy sdk is now an external to the mesh sdk in mesh_sdk/external, is this the right place to put it? I saw some page where it was recommended.

    But anytime I try to compile the thingy sdk, from thingysdk/project/pca20020_s132/armgcc I just get all of these errors. Maybe I am trying to compile it in the wrong manner? I would really appreciate some help, this is quite frustrating!

  • robertsehlstedt said:
    I don't understand at all how the thingy52 is supposed to be flashed with both Bluetooth mesh and other custom functionality.

     But you were able to flash the thingy with the hex-files from the demo's I linked to before? And they worked for you?

    What I meant by linking you to the examples were that you could use that as a template to see how you could create a mesh application for the Thingy, as there are no support for the Thingy in the nRF5 SDK for Mesh. 

    I am trying to implement some Bluetooth mesh functionality on my Thingy:52

     Do you want to add Mesh functionality to the Thingy:52 application that is a part of the Thingy SDK, or do you simply just want a Mesh application that can be run on the Thingy:52?

    -Joakim

Reply
  • robertsehlstedt said:
    I don't understand at all how the thingy52 is supposed to be flashed with both Bluetooth mesh and other custom functionality.

     But you were able to flash the thingy with the hex-files from the demo's I linked to before? And they worked for you?

    What I meant by linking you to the examples were that you could use that as a template to see how you could create a mesh application for the Thingy, as there are no support for the Thingy in the nRF5 SDK for Mesh. 

    I am trying to implement some Bluetooth mesh functionality on my Thingy:52

     Do you want to add Mesh functionality to the Thingy:52 application that is a part of the Thingy SDK, or do you simply just want a Mesh application that can be run on the Thingy:52?

    -Joakim

Children
Related