Dear all,
I have two nRF52 Preview DK boards with the SoC nRF52840. I am testing the light switch example on both boards. I have changed the light_switch_server, such that after pressing "Button1" the server send a message to the client, unfortunately this simple test doesn´t work. First of all, it is possible to do that? On the simple_on_off_server.c i have created a function "publish_state2", this is equal to the function "publish_state", but has a different opcode, please see below the code. The function publish_state2 is called after "Button1" is pressed and if the device is provisioned.
void publish_state2(simple_on_off_server_t * p_server, bool value) { simple_on_off_msg_status_t status; status.present_on_off = value ? 1 : 0; access_message_tx_t msg; msg.opcode.opcode = SIMPLE_ON_OFF_OPCODE_DATA; msg.opcode.company_id = ACCESS_COMPANY_ID_NORDIC; msg.p_buffer = (const uint8_t *) &status; msg.length = sizeof(status); (void) access_model_publish(p_server->model_handle, &msg); }
/** Simple OnOff opcodes. */ typedef enum { SIMPLE_ON_OFF_OPCODE_SET = 0xC1, /**< Simple OnOff Set. */ SIMPLE_ON_OFF_OPCODE_GET = 0xC2, /**< Simple OnOff Get. */ SIMPLE_ON_OFF_OPCODE_SET_UNRELIABLE = 0xC3, /**< Simple OnOff Set Unreliable. */ SIMPLE_ON_OFF_OPCODE_STATUS = 0xC4, /**< Simple OnOff Status. */ SIMPLE_ON_OFF_OPCODE_DATA = 0xC5 } simple_on_off_opcode_t;
In the client side i have created a new opcode handler, please see the code below.
static const access_opcode_handler_t m_opcode_handlers[] = { {{SIMPLE_ON_OFF_OPCODE_STATUS, ACCESS_COMPANY_ID_NORDIC}, handle_status_cb}, {{SIMPLE_ON_OFF_OPCODE_DATA, SIMPLE_ON_OFF_OPCODE_DATA}, handle_data_cb} };
static void handle_data_cb(access_model_handle_t handle, const access_message_rx_t * p_message, void * p_args) { data_received=true; __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Data received"); hal_led_pin_set(14,true); hal_led_pin_set(15,true); }
Based on the light switch example i also have the following questions?
- The light switch client implements one model for each switch server. So, a network composed by one gateway (provisioner) and many end-devices (in the order of hundreds), the gateway receives and send data to the end-devices, this gateway should implement one model for each end-device?
- The light switch servers can communicate between them?
Best regards,
Rafael Santos Costa