Skip to content

Commit df47f93

Browse files
authored
Merge pull request #551 from LeeLeahy2/heartbeat-sync
MP: Discovery is also syncing the clock upon receiving HEARTBEAT frames
2 parents 1f37067 + 63fedee commit df47f93

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

Firmware/LoRaSerial/LoRaSerial.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const int FIRMWARE_VERSION_MINOR = 0;
6464
#define UNIQUE_ID_BYTES 16 //Number of bytes in the unique ID
6565

6666
//Frame lengths
67-
#define MP_HEARTBEAT_BYTES 1 //Number of data bytes in the MP_HEARTBEAT frame
67+
#define MP_HEARTBEAT_BYTES (sizeof(uint8_t) + sizeof(unsigned long)) //Number of data bytes in the MP_HEARTBEAT frame
6868
#define P2P_FIND_PARTNER_BYTES sizeof(unsigned long) //Number of data bytes in the FIND_PARTNER frame
6969
#define P2P_SYNC_CLOCKS_BYTES (sizeof(uint8_t) + sizeof(unsigned long)) //Number of data bytes in the SYNC_CLOCKS frame
7070
#define P2P_ZERO_ACKS_BYTES sizeof(unsigned long) //Number of data bytes in the ZERO_ACKS frame

Firmware/LoRaSerial/Radio.ino

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,7 @@ bool xmitDatagramP2PSyncClocks()
931931
radioCallHistory[RADIO_CALL_xmitDatagramP2PSyncClocks] = currentMillis;
932932

933933
startOfData = endOfTxData;
934-
memcpy(endOfTxData, &channelNumber, sizeof(channelNumber));
935-
endOfTxData += sizeof(channelNumber);
934+
*endOfTxData++ = channelNumber;
936935

937936
memcpy(endOfTxData, &currentMillis, sizeof(currentMillis));
938937
endOfTxData += sizeof(unsigned long);
@@ -1149,18 +1148,20 @@ bool xmitDatagramMpHeartbeat()
11491148
radioCallHistory[RADIO_CALL_xmitDatagramMpHeartbeat] = millis();
11501149

11511150
startOfData = endOfTxData;
1152-
memcpy(endOfTxData, &channelNumber, sizeof(channelNumber));
1153-
endOfTxData += sizeof(channelNumber);
1151+
*endOfTxData++ = channelNumber;
1152+
1153+
memcpy(endOfTxData, &currentMillis, sizeof(currentMillis));
1154+
endOfTxData += sizeof(unsigned long);
11541155

11551156
/*
1156-
endOfTxData ---.
1157-
|
1158-
V
1159-
+----------+---------+----------+------------+---------+----------+
1160-
| Optional | | Optional | Optional | Channel | |
1161-
| NET ID | Control | C-Timer | SF6 Length | Number | Trailer |
1162-
| 8 bits | 8 bits | 2 bytes | 8 bits | 1 byte | n Bytes |
1163-
+----------+---------+----------+------------+---------+----------+
1157+
endOfTxData ---.
1158+
|
1159+
V
1160+
+----------+---------+----------+------------+---------+---------+----------+
1161+
| Optional | | Optional | Optional | Channel | | |
1162+
| NET ID | Control | C-Timer | SF6 Length | Number | Millis | Trailer |
1163+
| 8 bits | 8 bits | 2 bytes | 8 bits | 1 byte | 4 bytes | n Bytes |
1164+
+----------+---------+----------+------------+---------+---------+----------+
11641165
*/
11651166

11661167
//Verify the data length

Firmware/LoRaSerial/States.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,6 @@ void updateRadioState()
13051305
startChannelTimer();
13061306
channelTimerStart -= settings.maxDwellTime;
13071307
syncChannelTimer(txSyncClocksUsec);
1308-
triggerEvent(TRIGGER_RX_SYNC_CLOCKS);
13091308

13101309
if (settings.debugSync)
13111310
{

0 commit comments

Comments
 (0)