Skip to content

Commit

Permalink
Release v1.2
Browse files Browse the repository at this point in the history
Add ability to setup the zone in a second step when credentials are setup in a factory
Add error display when the LoRa board is not connected to device
  • Loading branch information
disk91 committed Dec 22, 2021
1 parent 1c2908c commit 0f0ec27
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 45 deletions.
6 changes: 6 additions & 0 deletions LoRaCom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,12 @@ bool processLoRaConfig(void) {
SERIALCONFIG.println("OK");
confStatus |= __LCONF_STATE_ZONE;
updated = true;
} else if ( strcmp(sZone,"LATER") == 0 ) {
loraConf.zone = ZONE_LATER;
SERIALCONFIG.println("ZONE: LATER");
SERIALCONFIG.println("OK");
confStatus |= __LCONF_STATE_ZONE;
updated = true;
} else {
SERIALCONFIG.println("KO");
}
Expand Down
1 change: 1 addition & 0 deletions LoRaCom.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ bool processLoRaConfig(void);
#define ZONE_KR920 7
#define ZONE_IN865 8
#define ZONE_AU915 9
#define ZONE_LATER 99
#define ZONE_MAX ZONE_AU915
#define ZONE_MIN ZONE_EU868

Expand Down
9 changes: 8 additions & 1 deletion LoRaComE5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,14 @@ void loraSetup(void) {
loraContext.currentSeqId = 1;
loraContext.downlinkPending = false;

sendATCommand("AT","+AT: OK","","",DEFAULT_TIMEOUT,false, NULL);
if ( ! sendATCommand("AT","+AT: OK","","",DEFAULT_TIMEOUT,false, NULL) ) {
// retry
if ( ! sendATCommand("AT","+AT: OK","","",DEFAULT_TIMEOUT,false, NULL) ) {
// error message
LoRaMissing();
while(1);
}
}
sendATCommand("AT+UART=TIMEOUT,0","+UART: TIMEOUT","","",DEFAULT_TIMEOUT,false, NULL);

// Setup region
Expand Down
12 changes: 10 additions & 2 deletions WioLoRaWanFieldTester.ino
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,26 @@ void setup() {
if ( zero ) {
//configPending();
while (true) {
if ( manageConfigScreen(true, first || hasChange ) ){
if ( manageConfigScreen(true, first || hasChange, false ) ){
NVIC_SystemReset();
}
first = false;
hasChange = processLoRaConfig();
}
} else if ( digitalRead(WIO_5S_PRESS) == LOW ) {
while ( digitalRead(WIO_5S_PRESS) == LOW );
manageConfigScreen(false,true);
manageConfigScreen(false,true, false);
NVIC_SystemReset();
}

#if HWTARGET == LORAE5
if ( loraConf.zone == ZONE_LATER ) {
loraConf.zone = ZONE_UNDEFINED;
manageConfigScreen(false,true,true);
NVIC_SystemReset();
}
#endif

gpsSetup();
displaySplash();
loraSetup();
Expand Down
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
//#define WITH_SPLASH_TTN 1


#define VERSION "v1.2a"
#define VERSION "v1.2"

#ifdef DEBUG
#define LOGLN(x) Serial.println x
Expand Down
93 changes: 54 additions & 39 deletions ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1123,31 +1123,31 @@ void refreshGpsDetails() {
// Return true when the configuration is valid
static uint8_t _currentItem = CONF_ITEM_ZONE;
static uint8_t _currentColumn = 0;
bool manageConfigScreen(bool interactive, bool firstRun) {
bool manageConfigScreen(bool interactive, bool firstRun, bool onlyZone) {
uint8_t change = 0;
bool keyGet = false;
if ( firstRun ) {
displayConfigScreen(_currentItem,_currentColumn,CONF_ACTION_NONE,true);
displayConfigScreen(_currentItem,_currentColumn,CONF_ACTION_NONE,true,onlyZone);
}
do {
if (digitalRead(WIO_5S_RIGHT) == LOW) {
if ( displayConfigScreen(_currentItem,_currentColumn,CONF_ACTION_NEXTCOL,false) ) {
if ( displayConfigScreen(_currentItem,_currentColumn,CONF_ACTION_NEXTCOL,false,onlyZone) ) {
_currentColumn++;
}
keyGet = true;
} else if (digitalRead(WIO_5S_LEFT) == LOW) {
if ( displayConfigScreen(_currentItem,_currentColumn,CONF_ACTION_PREVCOL,false) ) {
if ( displayConfigScreen(_currentItem,_currentColumn,CONF_ACTION_PREVCOL,false,onlyZone) ) {
_currentColumn--;
}
keyGet = true;
} else if (digitalRead(WIO_5S_UP) == LOW) {
if ( displayConfigScreen(_currentItem,_currentColumn,CONF_ACTION_PREVITEM,false) ) {
if ( displayConfigScreen(_currentItem,_currentColumn,CONF_ACTION_PREVITEM,false,onlyZone) ) {
_currentItem--;
_currentColumn = 0;
}
keyGet = true;
} else if (digitalRead(WIO_5S_DOWN) == LOW) {
if ( displayConfigScreen(_currentItem,_currentColumn,CONF_ACTION_NEXTITEM,false) ) {
if ( displayConfigScreen(_currentItem,_currentColumn,CONF_ACTION_NEXTITEM,false,onlyZone) ) {
_currentItem++;
_currentColumn = 0;
}
Expand Down Expand Up @@ -1222,7 +1222,7 @@ bool manageConfigScreen(bool interactive, bool firstRun) {
}
break;
}
displayConfigScreen(_currentItem,_currentColumn,CONF_ACTION_NONE,false);
displayConfigScreen(_currentItem,_currentColumn,CONF_ACTION_NONE,false,onlyZone);
change = 0;
}
if ( keyGet ) delay(200);
Expand All @@ -1240,7 +1240,7 @@ void highlightOneElement(uint8_t selectedItem, uint8_t selectedColumn, bool disp
#define TXT_ALL_VALUE_OFF_X (HIST_X_OFFSET+5+85)

// return true when action executed
bool displayConfigScreen(uint8_t selectedItem, uint8_t selectedColumn, uint8_t action, bool refreshAll) {
bool displayConfigScreen(uint8_t selectedItem, uint8_t selectedColumn, uint8_t action, bool refreshAll, bool onlyZone) {

// No need to refresh everytime
if ( refreshAll ) {
Expand Down Expand Up @@ -1292,56 +1292,62 @@ bool displayConfigScreen(uint8_t selectedItem, uint8_t selectedColumn, uint8_t a
case ZONE_AU915:
sprintf(sZone,"AU915");
break;
case ZONE_LATER:
sprintf(sZone,"NA");
break;
}
sprintf(sTmp,"Zone: %s", sZone);
tft.drawString(sTmp,TXT_ALL_OFF_X,TXT_ZONE_OFF_Y,GFXFF);

sprintf(sTmp,"DevEUI: %02X%02X%02X%02X%02X%02X%02X%02X",
loraConf.deveui[0],loraConf.deveui[1],
loraConf.deveui[2],loraConf.deveui[3],
loraConf.deveui[4],loraConf.deveui[5],
loraConf.deveui[6],loraConf.deveui[7]
);
tft.drawString(sTmp,TXT_ALL_OFF_X,TXT_DEVEUI_OFF_Y,GFXFF);
if ( !onlyZone ) {
sprintf(sTmp,"DevEUI: %02X%02X%02X%02X%02X%02X%02X%02X",
loraConf.deveui[0],loraConf.deveui[1],
loraConf.deveui[2],loraConf.deveui[3],
loraConf.deveui[4],loraConf.deveui[5],
loraConf.deveui[6],loraConf.deveui[7]
);
tft.drawString(sTmp,TXT_ALL_OFF_X,TXT_DEVEUI_OFF_Y,GFXFF);

sprintf(sTmp,"AppEUI: %02X%02X%02X%02X%02X%02X%02X%02X",
loraConf.appeui[0],loraConf.appeui[1],
loraConf.appeui[2],loraConf.appeui[3],
loraConf.appeui[4],loraConf.appeui[5],
loraConf.appeui[6],loraConf.appeui[7]
);
tft.drawString(sTmp,TXT_ALL_OFF_X,TXT_APPEUI_OFF_Y,GFXFF);

sprintf(sTmp,"AppEUI: %02X%02X%02X%02X%02X%02X%02X%02X",
loraConf.appeui[0],loraConf.appeui[1],
loraConf.appeui[2],loraConf.appeui[3],
loraConf.appeui[4],loraConf.appeui[5],
loraConf.appeui[6],loraConf.appeui[7]
);
tft.drawString(sTmp,TXT_ALL_OFF_X,TXT_APPEUI_OFF_Y,GFXFF);

sprintf(sTmp,"AppKEY: %02X%02X%02X%02X%02X%02X%02X%02X",
loraConf.appkey[0],loraConf.appkey[1],
loraConf.appkey[2],loraConf.appkey[3],
loraConf.appkey[4],loraConf.appkey[5],
loraConf.appkey[6],loraConf.appkey[7]
);
tft.drawString(sTmp,TXT_ALL_OFF_X,TXT_APPKEY_OFF_Y,GFXFF);

sprintf(sTmp," %02X%02X%02X%02X%02X%02X%02X%02X",
loraConf.appkey[8],loraConf.appkey[9],
loraConf.appkey[10],loraConf.appkey[11],
loraConf.appkey[12],loraConf.appkey[13],
loraConf.appkey[14],loraConf.appkey[15]
);
tft.drawString(sTmp,TXT_ALL_OFF_X,TXT_APPKEY_OFF_Y2,GFXFF);

sprintf(sTmp,"AppKEY: %02X%02X%02X%02X%02X%02X%02X%02X",
loraConf.appkey[0],loraConf.appkey[1],
loraConf.appkey[2],loraConf.appkey[3],
loraConf.appkey[4],loraConf.appkey[5],
loraConf.appkey[6],loraConf.appkey[7]
);
tft.drawString(sTmp,TXT_ALL_OFF_X,TXT_APPKEY_OFF_Y,GFXFF);

sprintf(sTmp," %02X%02X%02X%02X%02X%02X%02X%02X",
loraConf.appkey[8],loraConf.appkey[9],
loraConf.appkey[10],loraConf.appkey[11],
loraConf.appkey[12],loraConf.appkey[13],
loraConf.appkey[14],loraConf.appkey[15]
);
tft.drawString(sTmp,TXT_ALL_OFF_X,TXT_APPKEY_OFF_Y2,GFXFF);
}
// Previous Item & column
uint8_t prevCol = selectedColumn;
uint8_t prevItem = selectedItem;

// Clean previous
switch ( action ) {
case CONF_ACTION_NEXTITEM:
if ( onlyZone ) return false;
if ( selectedItem < CONF_ITEM_LAST) {
selectedItem++;
selectedColumn=0;
}
else return false;
break;
case CONF_ACTION_PREVITEM:
if ( onlyZone ) return false;
if ( selectedItem > CONF_ITEM_FIRST) {
selectedItem--;
selectedColumn=0;
Expand Down Expand Up @@ -1422,3 +1428,12 @@ void highlightOneElement(uint8_t selectedItem, uint8_t selectedColumn, bool disp
}

}

// Missing LoRA Board
void LoRaMissing() {

tft.fillRect(0,120-20,320,40,TFT_RED);
tft.setTextColor(TFT_WHITE);
tft.setFreeFont(FS9); // Select the orginal small TomThumb font
tft.drawString("LoRa board is missing",75,112, GFXFF);
}
5 changes: 3 additions & 2 deletions ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ bool refreshLiPo();
void refreshDistance();
void draw_splash_helium(int xOffset, int yOffset, int density);
void draw_splash_ttn(int xOffset, int yOffset, int density);
bool manageConfigScreen(bool interactive, bool firstRun);
bool displayConfigScreen(uint8_t selectedItem, uint8_t selectedColumn, uint8_t action, bool refreshAll);
bool manageConfigScreen(bool interactive, bool firstRun, bool onlyZone);
bool displayConfigScreen(uint8_t selectedItem, uint8_t selectedColumn, uint8_t action, bool refreshAll, bool onlyZone);
void LoRaMissing();

#define CONF_ACTION_NONE 0
#define CONF_ACTION_MODIFY 1
Expand Down

0 comments on commit 0f0ec27

Please sign in to comment.