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

cannot receive message

Hi all,

I am using nRF SDK for Mesh v1.0.1 and I want to implement following as in picture:

I am publishing to group address (group address because in the future I want to use more nodes with simple OnOff server model). I send the message from the OnOff client to the OnOff server, the light switch turns on. But I am not receiving message after publishing  to that group address (I didnt change code for switch server and from the simple_on_off_server.c I can see that after receiving SIMPLE_ON_OFF_OPCODE_SET_UNRELIABLE the callback function responds with publish_state() to the address set as publish address for that simple OnOff server model - and that is set by provisioner). In nrf connect app I can see, that the message is sent from the OnOff server model, but not received by simple OnOff client model. First I thought that I set the bad Publish address for OnOff server model (set to PROVISIONER ADDRESS + 1 - in nrf_mesh_config_app.h set the right count of models[3] and elements[2 for light switch client example]) but I dont think that this is the issue. I enclose key parts of code: 

SERVER_COUNT set to 1, because I provision only 1 element

key functions from main.c: 

SERVER_COUNT set to 1 because I want to provision only one element

access_setu() function and all the necessary configuring for OnOff client model:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static void access_setup(void)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Setting up access layer and models\n");
dsm_init();
access_init();
m_netkey_handle = DSM_HANDLE_INVALID;
m_appkey_handle = DSM_HANDLE_INVALID;
for (uint32_t i = 0; i < SERVER_COUNT; ++i)
{
m_devkey_handles[i] = DSM_HANDLE_INVALID;
m_server_handles[i] = DSM_HANDLE_INVALID;
}
m_group_handle = DSM_HANDLE_INVALID;
/* Initialize and enable all the models before calling ***_flash_config_load. */
ERROR_CHECK(config_client_init(config_client_event_cb));
ERROR_CHECK(health_client_init(&m_health_client, 0, health_event_cb));
for (uint32_t i = 0; i < 1; ++i)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void provisioner_prov_complete_cb(const nrf_mesh_prov_evt_complete_t * p_prov_data)
{
/* We should not get here if all servers are provisioned. */
NRF_MESH_ASSERT(m_configured_devices < SERVER_COUNT);
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Provisioning complete. Adding address 0x%04x.\n", p_prov_data->address);
ERROR_CHECK(dsm_address_publish_add(p_prov_data->address, &m_server_handles[m_provisioned_devices]));
ERROR_CHECK(dsm_devkey_add(p_prov_data->address, m_netkey_handle, p_prov_data->p_devkey, &m_devkey_handles[m_provisioned_devices]));
ERROR_CHECK(config_client_server_bind(m_devkey_handles[m_provisioned_devices]));
ERROR_CHECK(config_client_server_set(m_devkey_handles[m_provisioned_devices],
m_server_handles[m_provisioned_devices]));
m_provisioned_devices++;
/* Move on to the configuration step. */
provisioner_configure(UNPROV_START_ADDRESS + m_configured_devices);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void provisioner_config_successful_cb(void)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Configuration of device %u successful\n", m_configured_devices);
hal_led_pin_set(BSP_LED_0 + m_configured_devices, false);
m_configured_devices++;
if (m_configured_devices < SERVER_COUNT)
{
provisioner_wait_for_unprov(UNPROV_START_ADDRESS + m_provisioned_devices);
hal_led_pin_set(BSP_LED_0 + m_configured_devices, true);
}
else
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "All servers provisioned\n");
hal_led_blink_ms(LEDS_MASK, 100, 4);
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

from provisioner.c:

the handler prov_evt_handler() completed fine

I went through this steps by incrementing ->

static const config_steps_t server_config[]=
{
PROV_STATE_CONFIG_COMPOSITION_GET,
PROV_STATE_CONFIG_APPKEY_ADD,
PROV_STATE_CONFIG_APPKEY_BIND_HEALTH,
PROV_STATE_CONFIG_APPKEY_BIND_ONOFF,
PROV_STATE_CONFIG_PUBLICATION_HEALTH,
PROV_STATE_CONFIG_PUBLICATION_ONOFF,
PROV_STATE_CONFIG_SUBSCRIPTION,
};

i include where i have doubts:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* Configure the publication parameters for the On/Off server: */
case PROV_STATE_CONFIG_PUBLICATION_ONOFF:
{
config_publication_state_t pubstate = {0};
pubstate.element_address = m_target_address;
pubstate.publish_address.type = NRF_MESH_ADDRESS_TYPE_UNICAST;
pubstate.publish_address.value = PROVISIONER_ADDRESS + 1;
pubstate.appkey_index = 0;
pubstate.frendship_credential_flag = false;
pubstate.publish_ttl = SERVER_COUNT;
pubstate.publish_period.step_num = 0;
pubstate.publish_period.step_res = ACCESS_PUBLISH_RESOLUTION_100MS;
pubstate.retransmit_count = 1;
pubstate.retransmit_interval = 0;
pubstate.model_id.company_id = ACCESS_COMPANY_ID_NORDIC;
pubstate.model_id.model_id = SIMPLE_ON_OFF_SERVER_MODEL_ID;
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Setting publication address for the On/Off server to 0x%04x\n", pubstate.publish_address.value);
ERROR_CHECK(config_client_model_publication_set(&pubstate));
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

What am I missing? Something to change in mesh_config_app.h or what? Thankful for each one answer. 

Patrik