This questions seems to have been asked before in bits and bobs, but it's been hard to get a full concrete answer to this, which should be simple (in hindsight) I hope.
Boards are nRF52382 dev boards, Bluetooth Mesh.
I've got one board running the serial example, acting as a provisioner/client controlled by the PyACI script.
The server board is running the light switch server example. All I wish to do is have 2+ elements on the server, with each element running 1 Generic On/OFF (GOO) model. The serial board through the PyACI can then be used to switch On/Off each GOO model - i.e. turning a chosen LED on/off.
I roughly followed the code in https://devzone.nordicsemi.com/f/nordic-q-a/35374/how-to-add-multiple-elements-in-a-server-node 's answer for the server node code, but for GOO rather than Simple OO.
So far this isn't working - I've tried fiddling around with a few settings/adding/removing new lines.
First off I changed in /include/nrf_mesh_config_app.h
#define ACCESS_MODEL_COUNT (4) // my change 3 to 4 #define ACCESS_ELEMENT_COUNT (2) //my change 1 to 2
Then, in server/src/main.c:
#define ONOFF_SERVER_0_LED (BSP_LED_0) // my change #define ONOFF_SERVER_1_LED (BSP_LED_1) static bool m_device_provisioned; /*************************************************************************************************/ static void app_onoff_server_set_cb(const app_onoff_server_t * p_server, bool onoff); static void app_onoff_server_get_cb(const app_onoff_server_t * p_server, bool * p_present_onoff); static void app_onoff_server_set_cb_1(const app_onoff_server_t * p_server, bool onoff); static void app_onoff_server_get_cb_1(const app_onoff_server_t * p_server, bool * p_present_onoff); /* Generic OnOff server structure definition and initialization */ // add a 2nd one of these with different arguments 0,3,4 ?? APP_ONOFF_SERVER_DEF(m_onoff_server_0, APP_CONFIG_FORCE_SEGMENTATION, APP_CONFIG_MIC_SIZE, app_onoff_server_set_cb, app_onoff_server_get_cb) APP_ONOFF_SERVER_DEF(m_onoff_server_1, APP_CONFIG_FORCE_SEGMENTATION, APP_CONFIG_MIC_SIZE, app_onoff_server_set_cb_1, app_onoff_server_get_cb_1) /* Callback for updating the hardware state */ static void app_onoff_server_set_cb(const app_onoff_server_t * p_server, bool onoff) { /* Resolve the server instance here if required, this example uses only 1 instance. */ __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Setting GPIO value: %d\n", onoff) hal_led_pin_set(ONOFF_SERVER_0_LED, onoff); } static void app_onoff_server_set_cb_1(const app_onoff_server_t * p_server, bool onoff) { /* Resolve the server instance here if required, this example uses only 1 instance. */ __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Setting GPIO value: %d\n", onoff) hal_led_pin_set(ONOFF_SERVER_1_LED, onoff); } /* Callback for reading the hardware state */ static void app_onoff_server_get_cb(const app_onoff_server_t * p_server, bool * p_present_onoff) { /* Resolve the server instance here if required, this example uses only 1 instance. */ *p_present_onoff = hal_led_pin_get(ONOFF_SERVER_0_LED); } static void app_onoff_server_get_cb_1(const app_onoff_server_t * p_server, bool * p_present_onoff) { /* Resolve the server instance here if required, this example uses only 1 instance. */ *p_present_onoff = hal_led_pin_get(ONOFF_SERVER_1_LED); } static void app_model_init(void) { /* Instantiate onoff server on element index 0 */ ERROR_CHECK(app_onoff_init(&m_onoff_server_0, 0)); ERROR_CHECK(app_onoff_init(&m_onoff_server_1, 1)); } /*************************************************************************************************/
/*************************************************************************************************/
As you can see, it is quite a brute force strategy to attempt multiple elements.
Unfortunately we get an error message when executing within Segger (normal vanilla light-switch runs fine from this)
esh_softdevice_init.c, 109, sd_ble_enable: app_ram_base should be adjusted to 0x20002DA0 <t: 529>, main.c, 220, Initializing and adding models <t: 532>, app_error_weak.c, 105, Mesh error 4 at 0x00026767
which points to the line ERROR_CHECK(app_onoff_init(&m_onoff_server_1, 1)); in the server main.
I was expecting some issues getting these elements to be accessed by the PyACI, but not have these sort of issues just having the board run with no connections.
Help greatly appreciated!