-
Notifications
You must be signed in to change notification settings - Fork 3
migrate device from TTN V2 to TTN V3 #22
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
Changes from 5 commits
8f98697
9f4234e
de20a31
68b3e7b
bf9ecbd
acc99ef
c438660
85ded3f
83591b4
38f1f47
da813c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,10 @@ Module: Catena4430_cMeasurementLoop_SDcard.cpp | |
|
|
||
| #include <Catena_Download.h> | ||
|
|
||
| #include <Catena_Fram.h> | ||
|
|
||
| #include <Arduino_LoRaWAN_lmic.h> | ||
|
|
||
| #include <SD.h> | ||
| #include <mcciadk_baselib.h> | ||
|
|
||
|
|
@@ -33,6 +37,8 @@ using namespace McciCatena; | |
|
|
||
| SDClass gSD; | ||
|
|
||
| constexpr char gkMigrateFileName[] = "MIGRATE.V3"; | ||
|
|
||
| /****************************************************************************\ | ||
| | | ||
| | Some utilities | ||
|
|
@@ -571,4 +577,57 @@ cMeasurementLoop::updateFromSd( | |
| } | ||
| } | ||
|
|
||
| void | ||
| cMeasurementLoop::handleSdTTNv3Migrate( | ||
| void | ||
| ) | ||
| { | ||
| bool fMigrate = false; | ||
| bool fResult = this->checkSdCard(); | ||
|
|
||
| if (fResult) | ||
| { | ||
| if (! gSD.exists(gkMigrateFileName)) | ||
| fMigrate = false; | ||
| else | ||
| fMigrate = true; | ||
| } | ||
|
|
||
| if (fMigrate) | ||
dhineshkumarmcci marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| bool fFramUpdate = false; | ||
| auto const pFram = gCatena.getFram(); | ||
| static const uint8_t AppEUI[] = { 1, 0, 0, 0, 0, 0, 0, 0 }; | ||
|
|
||
| if (pFram == nullptr) | ||
| fFramUpdate = false; | ||
| else | ||
| { | ||
| pFram->saveField(cFramStorage::kAppEUI, AppEUI); | ||
| fFramUpdate = true; | ||
| } | ||
|
|
||
| if (fFramUpdate) | ||
| { | ||
| this->rejoinNetwork(); | ||
| gSD.remove(gkMigrateFileName); | ||
| gLog.printf(gLog.kInfo, "cFramStorage::kAppEUI: update: success\n"); | ||
| } | ||
| else | ||
| gLog.printf(gLog.kError, "cFramStorage::kAppEUI: not updated\n"); | ||
| } | ||
| } | ||
|
|
||
| void | ||
| cMeasurementLoop::rejoinNetwork( | ||
| void | ||
| ) | ||
| { | ||
| auto const pFram = gCatena.getFram(); | ||
| pFram->saveField(cFramStorage::kDevAddr, 0); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can return an error. Check return value. As a consequence, rejoinNetwork can return an error.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I have planned to check return value, unfortunately API saveField is of datatype In this case, I believe we can use API getField to read the value written in FRAM, and then compare to check for error. @terrillmoore Please advice on this.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I filed a bug report but didn't make the change. No, don't use getField(); the saveField() API is going to change to be bool, and we'll deal with it then.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. created a pull-request for changes with |
||
|
|
||
| LMIC_unjoin(); | ||
| LMIC_startJoining(); | ||
| } | ||
|
|
||
| #undef FUNCTION | ||
Uh oh!
There was an error while loading. Please reload this page.