Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fredlcore committed Feb 29, 2024
1 parent cbbcaed commit 68ec9f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 15 additions & 1 deletion BSB_LAN/BSB_LAN.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7778,7 +7778,7 @@ void startLoggingDevice() {
// disable w5100 while setting up SD
pinMode(10,OUTPUT);
digitalWrite(10,HIGH);
if (!SD.begin(4, SPI_DIV3_SPEED)) {
if (!SDCard.begin(4, SPI_DIV3_SPEED)) {
printToDebug(PSTR("SD card failed.\r\n")); // change SPI_DIV3_SPEED to SPI_HALF_SPEED if you are still having problems getting your SD card detected
} else {
printToDebug(PSTR("SD card mounted ok.\r\n"));
Expand Down Expand Up @@ -7820,6 +7820,8 @@ void createTemporaryAP () {
#endif
}

/*
#if defined(ESP32)
void networkEvent(WiFiEvent_t event) {
SerialOutput->print(PSTR("Event "));
SerialOutput->print(event);
Expand Down Expand Up @@ -7850,6 +7852,8 @@ void networkEvent(WiFiEvent_t event) {
}
SerialOutput->println();
}
#endif
*/

/** *****************************************************************
* Function: setup()
Expand Down Expand Up @@ -8233,7 +8237,9 @@ void setup() {
case WLAN: printlnToDebug(PSTR("WiFi/WLAN")); break;
}
printToDebug(PSTR("...\r\n"));
#if defined(ESP32)
// WiFi.onEvent(networkEvent);
#endif

#ifdef WIFISPI
WiFi.init(WIFI_SPI_SS_PIN); // SS signal is on Due pin 12
Expand Down Expand Up @@ -8274,7 +8280,11 @@ void setup() {
dnsserver = IPAddress(ip_addr[0], ip_addr[1], ip_addr[2], 1);
}
if (network_type == LAN) {
#if defined(ESP32)
if (!Ethernet.begin(mac, ip, dnsserver, gateway, subnet)) createTemporaryAP(); //Static IP
#else
Ethernet.begin(mac, ip, dnsserver, gateway, subnet); //Static IP
#endif
} else {
#if defined(ESP32)
WiFi.config(ip, gateway, subnet, dnsserver);
Expand All @@ -8284,7 +8294,11 @@ void setup() {
}
} else {
if (network_type == LAN) {
#if defined(ESP32)
if (!Ethernet.begin(mac)) createTemporaryAP(); // DHCP
#else
Ethernet.begin(mac); // DHCP
#endif
printToDebug(PSTR("Waiting for DHCP address"));
unsigned long timeout = millis();
while (!Ethernet.localIP() && millis() - timeout < 20000) {
Expand Down
5 changes: 3 additions & 2 deletions BSB_LAN/include/mqtt_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,10 @@ boolean mqtt_connect() {
if(MQTTPassword[0]) {
MQTTPass = MQTTPassword;
}
uint8_t MQTT_IP[4];
int result = sscanf(mqtt_host, "%d.%d.%d.%d", &MQTT_IP[0], &MQTT_IP[1], &MQTT_IP[2], &MQTT_IP[3]);
int addr[4];
int result = sscanf(mqtt_host, "%d.%d.%d.%d", &addr[0], &addr[1], &addr[2], &addr[3]);
if (result == 4) {
IPAddress MQTT_IP(addr[0],addr[1],addr[2],addr[3]);
MQTTPubSubClient->setServer(MQTT_IP, mqtt_port);
} else {
MQTTPubSubClient->setServer(mqtt_host, mqtt_port);
Expand Down

0 comments on commit 68ec9f5

Please sign in to comment.