Skip to content

Commit b1804f3

Browse files
authored
Merge pull request #134 from zfields/notehub
chore: refactor device id handling
2 parents c72dfdb + cb2dc7a commit b1804f3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/NotecardConnectionHandler.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -774,9 +774,13 @@ bool NotecardConnectionHandler::updateUidCache (void)
774774
result = false;
775775
} else {
776776
_notecard_uid = JGetString(rsp, "device");
777-
_device_id = JGetString(rsp, "sn");
778-
_device_id = (_device_id.length() ? _device_id : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
779-
Debug.print(DBG_DEBUG, F("NotecardConnectionHandler::%s updated cache with Notecard UID: <%s> and Arduino Device ID: <%s>"), __FUNCTION__, _notecard_uid.c_str(), _device_id.c_str());
777+
char device_id[] = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
778+
if (NoteGetEnv("_arduino_device_id", device_id, device_id, sizeof(device_id))) {
779+
_device_id = device_id;
780+
} else {
781+
Debug.print(DBG_DEBUG, F("NotecardConnectionHandler::%s Arduino Device ID not cached on Notecard, using default value: <%s>"), __FUNCTION__, _device_id.c_str());
782+
}
783+
Debug.print(DBG_DEBUG, F("NotecardConnectionHandler::%s updated local cache with Notecard UID: <%s> and Arduino Device ID: <%s>"), __FUNCTION__, _notecard_uid.c_str(), _device_id.c_str());
780784
result = true;
781785
}
782786
JDelete(rsp);

src/NotecardConnectionHandler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
******************************************************************************/
2929

3030
#define NOTECARD_CONNECTION_HANDLER_VERSION_MAJOR 1
31-
#define NOTECARD_CONNECTION_HANDLER_VERSION_MINOR 0
31+
#define NOTECARD_CONNECTION_HANDLER_VERSION_MINOR 1
3232
#define NOTECARD_CONNECTION_HANDLER_VERSION_PATCH 1
3333

3434
#define NOTECARD_CONNECTION_HANDLER_VERSION NOTE_C_STRINGIZE(NOTECARD_CONNECTION_HANDLER_VERSION_MAJOR) "." NOTE_C_STRINGIZE(NOTECARD_CONNECTION_HANDLER_VERSION_MINOR) "." NOTE_C_STRINGIZE(NOTECARD_CONNECTION_HANDLER_VERSION_PATCH)

0 commit comments

Comments
 (0)