Hi,
I've been working on a project where I need to send data from UART over mesh, I managed to create custom model for sending string data over mesh, I did merge UART example with mesh SDK, I started with light switch demo from mesh SDK v2.0.1 and with nRF5 SDK v15, now I'm trying to get the data received on UART to send it over mesh, but I didn't do it correctly, the send_my_message function kept sending the same random data, Any idea on how to make that work, it would be greatly appreciated.
Here is a snippet of my code:
//function to send data over mesh
void send_my_message (char s[])
{
uint32_t status=0;
uint8_t buffer[5];
strcpy(buffer, (uint8_t) s);
uint8_t length;
uint16_t address;
access_message_tx_t msg;
length= sizeof(buffer);
if (length)
{
msg.opcode.opcode = simple_message_OPCODE_SEND;
msg.opcode.company_id = 0x0059; // Nordic's company ID
msg.p_buffer = (const uint8_t *) &buffer[0];
msg.length =length;
status= simple_message_client_set_unreliable(&m_clients[0], buffer, length);
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Status : %u \n", status);
if (status == NRF_ERROR_INVALID_STATE ||
status == NRF_ERROR_BUSY||status == NRF_ERROR_NO_MEM)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Cannot send. Device is busy.\n");
hal_led_blink_ms(LEDS_MASK, 50, 4);
}
else
{
ERROR_CHECK(status);
}
}
}
//function for receiving and sending data over UART
void uart_putstring(char s[])
{
uint8_t len = strlen(s);
for (uint8_t i = 0; i < len; i++)
{
while (app_uart_put(s[i]) != NRF_SUCCESS);
}
}
void uart_getstring(char s[])
{
uint8_t len = strlen(s);
for (uint8_t i = 0; i < len; i++)
{
while (app_uart_get(&s[i]) != NRF_SUCCESS);
}
}
//how I send the data over mesh from UART
printf("\r\nUART example started.\r\n");
for (;;)
{
(void)sd_app_evt_wait();
// uint8_t cr;
char s[5];
uint32_t status = NRF_SUCCESS;
// while (app_uart_get(&cr) != NRF_SUCCESS);
// while (app_uart_put(cr) != NRF_SUCCESS);
uart_getstring(s);
uart_putstring(s);
send_my_message(s); // failed to send data from UART
}
here is my log
Thank you,
A.