Skip to content

Commit

Permalink
Immediately check wifi on boot.
Browse files Browse the repository at this point in the history
  • Loading branch information
etihwnad committed Jun 17, 2023
1 parent faeb17d commit d5eb0c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion git-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
*
* git describe --tags --always --dirty
*/
#define GIT_VERSION "v0.1.5"
#define GIT_VERSION "v0.1.6"
7 changes: 2 additions & 5 deletions mqtt_esp8266_uart_bridge.ino
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ESP8266WiFiMulti wifiMulti;
WiFiUDP udp;
NTPClient ntpClient(udp, NTP_SERVER, 0, NTP_UPDATE_INTERVAL);
PubSubClient mqtt(wifi);
typeof(millis()) last_wifi_check = 0;
typeof(millis()) last_wifi_check = -WIFI_RETRY_DELAY;
unsigned long last_mqtt_check = 0;


Expand Down Expand Up @@ -146,9 +146,6 @@ String hexToStr(uint8_t* arr, int n)
* Called whenever a payload is received from a subscribed MQTT topic.
*/
void mqtt_receive_callback(char* topic, byte* payload, unsigned int length) {
char buffer[256];
buffer[0] = 0;
int len = 0;

if (strcmp(topic, (MQTT_TOPIC_PREFIX + my_mac + MQTT_CONTROL_TOPIC).c_str()) == 0) {
// TODO: use this to change behavior
Expand Down Expand Up @@ -176,7 +173,7 @@ bool check_wifi()
if ((millis() - last_wifi_check) >= WIFI_RETRY_DELAY) {
Serial.print("[INFO] WiFi connecting.");

int retries = 5;
int retries = 10;
while (retries > 0 && wifiMulti.run() != WL_CONNECTED) {
delay(500);
Serial.print(".");
Expand Down

0 comments on commit d5eb0c7

Please sign in to comment.