Fix problem with multiple selected devices (secondary address)

- resend SND_NKE to ensure all devices are deselected, because the first
SND_NKE could get lost
This commit is contained in:
Stefan Wahren 2012-07-04 21:21:01 +02:00
parent 736181b35e
commit 433744c80a

View File

@ -101,7 +101,7 @@ main(int argc, char **argv)
frame->address = MBUS_ADDRESS_NETWORK_LAYER;
if (debug)
printf("%s: debug: sending init frame\n", __PRETTY_FUNCTION__);
printf("%s: debug: sending init frame #1\n", __PRETTY_FUNCTION__);
if (mbus_send_frame(handle, frame) == -1)
{
@ -110,8 +110,27 @@ main(int argc, char **argv)
return 1;
}
mbus_recv_frame(handle, &reply);
while (mbus_recv_frame(handle, &reply) != -1);
//
// resend SND_NKE, maybe the first get lost
//
frame->control = MBUS_CONTROL_MASK_SND_NKE | MBUS_CONTROL_MASK_DIR_M2S;
frame->address = MBUS_ADDRESS_NETWORK_LAYER;
if (debug)
printf("%s: debug: sending init frame #2\n", __PRETTY_FUNCTION__);
if (mbus_send_frame(handle, frame) == -1)
{
fprintf(stderr, "Failed to send mbus frame.\n");
mbus_frame_free(frame);
return 1;
}
while (mbus_recv_frame(handle, &reply) != -1);
if (strlen(addr_str) == 16)
{
// secondary addressing