Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpm: check if answer was received before waiting for it in the GPM fw… #34

Merged
merged 1 commit into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions XBeeLibrary.Core/Models/GpmManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023, Digi International Inc.
* Copyright 2023,2024, Digi International Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
Expand Down Expand Up @@ -498,9 +498,15 @@ private string SendGPMAPIPacket(XBeePacket packet, int timeout)
// Send the packet.
device.SendPacketAsync(packet);
// Wait for response or timeout.
lock (gpmLock)
// Check first if the answer to the packet was not already received. Interfaces
// such as Bluetooth can take some time to execute the write operation and, by
// the time that process finishes, the answer could have been already received.
if (!gpmPacketReceived)
{
Monitor.Wait(gpmLock, Math.Max(timeout, AbstractXBeeDevice.DEFAULT_RECEIVE_TIMETOUT));
lock (gpmLock)
{
Monitor.Wait(gpmLock, Math.Max(timeout, AbstractXBeeDevice.DEFAULT_RECEIVE_TIMETOUT));
}
}

if (!gpmPacketSent)
Expand Down