Skip to content

Commit f8690c5

Browse files
author
Eric Jennings
committed
Reordered wifi startup routine to ensure connection on power-up
1 parent cf6a73e commit f8690c5

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

ScoutHandler.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ void PinoccioScoutHandler::setup() {
1818
Gainspan.connectEventHandler = hqConnectHandler;
1919
Gainspan.disconnectEventHandler = hqDisconnectHandler;
2020

21+
Scout.enableBackpackVcc();
2122
Serial.print("Wi-Fi backpack connecting...");
2223
Scout.wifi.setup();
2324
Scout.wifi.init();
@@ -167,15 +168,15 @@ static void fieldAnnounceConfirm(NWK_DataReq_t *req) {
167168
isAnnouncing = false;
168169
}
169170

170-
void PinoccioScoutHandler::fieldAnnounce(int chan, char *message) {
171+
void PinoccioScoutHandler::fieldAnnounce(uint16_t chan, char *message) {
171172
int len = strlen(message);
172173

173174
if (isAnnouncing) {
174175
return;
175176
}
176177

177-
Serial.print("announcing to ");
178-
Serial.print(chan, DEC);
178+
Serial.print("announcing to 0x");
179+
Serial.print(chan, HEX);
179180
Serial.print(" ");
180181
Serial.println(message);
181182

ScoutHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class PinoccioScoutHandler {
1212

1313
void setup();
1414
void loop();
15-
void fieldAnnounce(int chan, char *message);
15+
void fieldAnnounce(uint16_t chan, char *message);
1616

1717
protected:
1818
};

utility/webGainspan.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,32 +123,35 @@ uint8_t webGainspan::setup(uint32_t baud) {
123123

124124
//(Serial.println("DEBUG: Gainspan::setup 3"));
125125

126-
if (!send_cmd_w_resp(CMD_AUTOCONFIGSET)) {
127-
//(Serial.println("DEBUG: Gainspan::init 3.1"));
128-
return 0;
129-
}
130-
131-
//(Serial.println("DEBUG: Gainspan::setup 4"));
132-
133-
while (isAutoConfigSet && millis() - timeout < 10000 && !respDone) {
126+
while (isAutoConfigSet && millis() - timeout < 15000 && !respDone) {
134127
buf = readline();
128+
//Serial.print(buf.length());
129+
//Serial.print(": ");
130+
//Serial.println(buf);
135131
buf.trim();
136132
if (buf.startsWith("NWCONN-SUCCESS")) {
137-
//(Serial.println("DEBUG: Gainspan::setup 4.1"));
133+
//(Serial.println("DEBUG: Gainspan::setup 3.1"));
138134
//(Serial.println(buf));
139135
respDone = 1;
140136
return 1;
141137
}
142138
}
143139

144-
delay(100);
145-
//(Serial.println("DEBUG: Gainspan::setup 5"));
140+
//delay(100);
141+
//(Serial.println("DEBUG: Gainspan::setup 4"));
146142
return 0;
147143
}
148144

149145
uint8_t webGainspan::init() {
150146
//(Serial.println("DEBUG: Gainspan::init 1"));
151147

148+
// get autoconnect setting
149+
//(Serial.println("DEBUG: Gainspan::init 2"));
150+
if (!send_cmd_w_resp(CMD_AUTOCONFIGSET)) {
151+
//(Serial.println("DEBUG: Gainspan::init 2.1"));
152+
return 0;
153+
}
154+
152155
// get device ID
153156
//(Serial.println("DEBUG: Gainspan::init 3"));
154157
if (!send_cmd_w_resp(CMD_GET_MAC_ADDR)) {
@@ -352,7 +355,7 @@ uint8_t webGainspan::parse_resp(uint8_t cmd) {
352355

353356
while (!resp_done) {
354357

355-
if (millis() - timeout > 15000) {
358+
if (millis() - timeout > 10000) {
356359
// timeout, return error
357360
ret = 0;
358361
resp_done = 1;

0 commit comments

Comments
 (0)