ESPNOW Shipping and receiving
Posted: Fri Jul 07, 2023 8:57 pm
Hello,
I am trying to adapt the espnow example for sending and receiving messages which are byte array generated by creating a public key when I receive it on the other device I get something totally different as the arrayI should receive would have to start with 04.
What I have added would be as follows:
And at the reception it would be:
I have generated the keys as follows:
How can I make sure it is sent correctly?
I am trying to adapt the espnow example for sending and receiving messages which are byte array generated by creating a public key when I receive it on the other device I get something totally different as the arrayI should receive would have to start with 04.
What I have added would be as follows:
Code: Select all
case EXAMPLE_ESPNOW_SEND_CB:
rest of the code
if (!is_broadcast)
{
send_param->len = sizeof(key_public_bob);
memcpy(send_param->buffer, key_public_bob, send_param->len);
if (esp_now_send(send_param->dest_mac, key_public_bob,sizeof(key_public_bob)) != ESP_OK)
{
ESP_LOGE(TAG, "Send error2");
}
send_param->count--;
if (send_param->count == 0)
{
ESP_LOGI(TAG, "Send done");
example_espnow_deinit(send_param);
vTaskDelete(NULL);
}
}
Code: Select all
else if (ret == EXAMPLE_ESPNOW_DATA_UNICAST)
{
ESP_LOGI(TAG, "Receive %dth unicast data from: " MACSTR ", len: %d", recv_seq, MAC2STR(recv_cb->mac_addr), recv_cb->data_len);
memcpy(received_data, recv_cb->data, recv_cb->data_len);
received_data[recv_cb->data_len] = '\0';
received_data_length = recv_cb->data_len;
//ESP_LOGI(TAG, "Chain: %s", received_data);
printf("Data received ");
for (int i = 0; i < received_data_length; i++)
{
printf("%02hhx ", received_data[i]);
}
/* If receive unicast ESPNOW data, also stop sending broadcast ESPNOW data. */
send_param->broadcast = false;
}
Code: Select all
psa_key_handle_t key_priv_bob;
uint8_t key_public_bob[65];
psa_generate_key(&attributes, &key_priv_bob);
psa_export_public_key(key_priv_bob, &key_public_bob, sizeof(key_public_bob), &olenB);