Skip to content

Commit 4acb77b

Browse files
committed
[TagVal] Change serial number from integer to string
1 parent 6ab0a07 commit 4acb77b

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/RemoteConnector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ void TagValueRemoteConnector::encodeJoin() {
367367
char szName[40];
368368
safeProgCpy(szName, localInfoPgm->uuid, sizeof(szName));
369369
transport->writeField(FIELD_UUID, szName);
370-
transport->writeFieldLong(FIELD_SERIAL_NO, (long)getBoardSerialNumber());
370+
transport->writeField(FIELD_SERIAL_NO, getBoardSerialNumber());
371371
safeProgCpy(szName, localInfoPgm->name, sizeof(szName));
372372
transport->writeField(FIELD_MSG_NAME, szName);
373373
transport->writeFieldInt(FIELD_VERSION, API_VERSION);

src/tcUtil.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ char szGlobalBuffer[16];
1919

2020
// if not defined give a developer one of one short of a billion
2121
#ifndef TC_BOARD_SERIAL_NO
22-
#define TC_BOARD_SERIAL_NO 999999999L
22+
#define TC_BOARD_SERIAL_NO "999999999"
2323
#endif //!TC_BOARD_SERIAL_NO
2424

2525
// and implement the function
26-
const long glTcSerialNumber PROGMEM = TC_BOARD_SERIAL_NO;
27-
uint32_t getBoardSerialNumber() {
28-
return pgm_read_dword(&glTcSerialNumber);
26+
const char glTcSerialNumber[] PROGMEM = TC_BOARD_SERIAL_NO;
27+
const char * getBoardSerialNumber() {
28+
return reinterpret_cast<const char *>(glTcSerialNumber);
2929
}
3030
#endif // !TC_MANUAL_SERIAL_NO_IMPL
3131

@@ -50,7 +50,7 @@ void showVersionDialog(const ConnectorLocalInfo *localInfo) {
5050
char sz[25];
5151
tccore::copyTcMenuVersion(sz, sizeof(sz));
5252
strncat(sz, " S/N:", sizeof(sz) - strlen(sz) - 1);
53-
fastltoa(sz, (long)getBoardSerialNumber(), 9, NOT_PADDED, sizeof sz);
53+
strncat(sz, getBoardSerialNumber(), sizeof(sz) - strlen(sz) - 1);
5454
dialog->copyIntoBuffer(sz);
5555
});
5656
}

src/tcUtil.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ struct ConnectorLocalInfo {
3131
* Provides the serial number for the board, it can be displayed and also used in remote JOIN messages to identify
3232
* the board uniquiely by UUID and serial number.
3333
*
34-
* If you want to use the default implementation you can define flag TC_BOARD_SERIAL_NO to a long int value that will
34+
* If you want to use the default implementation you can define flag TC_BOARD_SERIAL_NO to a string literal that will
3535
* be stored as a constant in memory.
3636
*
3737
* If you want to have a custom implementation, define TC_MANUAL_SERIAL_NO_IMPL and then you must implement this method
3838
* yourself instead. This function should not take undue time if implemented by you as it could block networking.
3939
* @return the serial number
4040
*/
41-
uint32_t getBoardSerialNumber();
41+
const char * getBoardSerialNumber();
4242

4343
/**
4444
* Show the TcMenu version in a dialog that can be dismissed

0 commit comments

Comments
 (0)