The library offers a bunch of methods for sync mode communication. It may be confusing so, i want to offer some hint, how to use them. At first you need to connect to the access point. Here is some code I use for connecting the AP:
String portname = _chronos.GetComPortName();
if (String.IsNullOrEmpty(portname))
{
throw new ExecutionException("Access Point not found");
}
else
{
_chronos.OpenComPort(portname);
if (_chronos.PortOpen)
{
_chronos.StartSimpliciTI();
}
}
After you also start the SimpliciTI-Stack on the watch, you then can start to transmit SYNC-Packets. Whats contained in the packets depends on your implementation. Remember that a single packet only contains around 18 byte. So sending long string may not work. The standard firmware just uses byte command codes.
if (_chronos.PortOpen)
{
if (!_chronos.StartSyncMode())
{
throw new ExecutionException("Syncmode failed");
}
if (!_chronos.SendSyncCommand(new byte[] { (byte)SyncCommand.SYNC_AP_CMD_GET_STATUS, (byte)SyncStatusMode.SYNC_STATUS_TIME }))
{
throw new ExecutionException("SendSyncCommand GET_STATUS failed");
}
[…]
}
Those SYNC_ things are enums. The ellipsis then may contain some code to wait for the sync buffer to be filled and the read the contents:
SyncStatus syncStatus;
double dur = 1;
do
{
count++;
if (!_chronos.GetSyncBufferStatus(out syncStatus))
{
// error
}
if (syncStatus == SyncStatus.SYNC_USB_DATA_READY)
{
return _chronos.ReadSyncBuffer(out buffer);
}
if (delay > 0) wait = (int)(dur * count);
if (wait > 0) Thread.Sleep(wait);
} while (syncStatus != SyncStatus.SYNC_USB_DATA_READY && count < 100);
This is from some advanced waiting method that’s increasing the waiting time, starting with a really low waiting duration. Pay attention that it should used within a thread to work properly (Thread.Sleep()) or else the gui thread falls asleep.
I hope you get the idea of all those methods with all that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The library offers a bunch of methods for sync mode communication. It may be confusing so, i want to offer some hint, how to use them. At first you need to connect to the access point. Here is some code I use for connecting the AP:
After you also start the SimpliciTI-Stack on the watch, you then can start to transmit SYNC-Packets. Whats contained in the packets depends on your implementation. Remember that a single packet only contains around 18 byte. So sending long string may not work. The standard firmware just uses byte command codes.
Those SYNC_ things are enums. The ellipsis then may contain some code to wait for the sync buffer to be filled and the read the contents:
This is from some advanced waiting method that’s increasing the waiting time, starting with a really low waiting duration. Pay attention that it should used within a thread to work properly (Thread.Sleep()) or else the gui thread falls asleep.
I hope you get the idea of all those methods with all that.