Bluetooth: Tests: Wait for sync from other devices only
The sync mechanism using Babblesim backchannels picked up self-sent messages. Use the device number as data to disambiguate messages from other devices. Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
This commit is contained in:
parent
0916eba4ad
commit
e5004d9261
1 changed files with 13 additions and 3 deletions
|
@ -21,6 +21,7 @@ void test_init(void)
|
|||
}
|
||||
|
||||
#define CHANNEL_ID 0
|
||||
#define MSG_SIZE 1
|
||||
|
||||
void backchannel_init(void)
|
||||
{
|
||||
|
@ -39,8 +40,7 @@ void backchannel_init(void)
|
|||
|
||||
void backchannel_sync_send(void)
|
||||
{
|
||||
/* Dummy message */
|
||||
uint8_t sync_msg[] = { 'A' };
|
||||
uint8_t sync_msg[MSG_SIZE] = { get_device_nbr() };
|
||||
|
||||
printk("Sending sync\n");
|
||||
bs_bc_send_msg(CHANNEL_ID, sync_msg, ARRAY_SIZE(sync_msg));
|
||||
|
@ -48,7 +48,17 @@ void backchannel_sync_send(void)
|
|||
|
||||
void backchannel_sync_wait(void)
|
||||
{
|
||||
while (!bs_bc_is_msg_received(CHANNEL_ID)) {
|
||||
uint8_t sync_msg[MSG_SIZE];
|
||||
|
||||
while (true) {
|
||||
if (bs_bc_is_msg_received(CHANNEL_ID) > 0) {
|
||||
bs_bc_receive_msg(CHANNEL_ID, sync_msg, ARRAY_SIZE(sync_msg));
|
||||
if (sync_msg[0] != get_device_nbr()) {
|
||||
/* Received a message from another device, exit */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
k_sleep(K_MSEC(1));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue