Skip to content
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

Add support to compile under Sloeber #49

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions ESP-sc-gway/ESP-sc-gway.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
// too much code compiled and loaded on your ESP8266.
//
// ----------------------------------------------------------------------------------------
#ifndef ESP_SC_GWAY_H_
#define ESP_SC_GWAY_H_

#define VERSION "V.5.3.3.H; 180825a"

Expand Down Expand Up @@ -87,7 +89,7 @@
// 4: ESP32 TTGO pinning (should work for 433 and OLED too).
// 5: ESP32 TTGO EU433 MHz with OLED
// 6: Other, define your own in loraModem.h
#define _PIN_OUT 1
#define _PIN_OUT 4

// Gather statistics on sensor and Wifi status
// 0= No statistics
Expand Down Expand Up @@ -117,8 +119,8 @@

// Define the name of the accesspoint if the gateway is in accesspoint mode (is
// getting WiFi SSID and password using WiFiManager)
#define AP_NAME "YourName"
#define AP_PASSWD "YourPassword"
#define AP_NAME ""
#define AP_PASSWD ""

// This section defines whether we use the gateway as a repeater
// For his, we use another output channle as the channel (default==0) we are
Expand All @@ -135,7 +137,7 @@
// OLED==0; No OLED display connected
// OLED==1; 0.9 Oled Screen based on SSD1306
// OLED==2; 1"3 Oled screens for Wemos, 128x64 SH1106
#define OLED 2
#define OLED 1


// Define whether we want to manage the gateway over UDP (next to management
Expand Down Expand Up @@ -189,7 +191,7 @@

// This defines whether or not we would use the gateway as
// as sort of backend system which decodes messages (see sensor.h file)
#define _LOCALSERVER 0 // See server definitions for decodes
#define _LOCALSERVER 1 // See server definitions for decodes

// Gateway Ident definitions
#define _DESCRIPTION "ESP Gateway" // Name of the gateway
Expand Down Expand Up @@ -260,7 +262,7 @@ struct wpas {
//
wpas wpa[] = {
{ "" , "" }, // Reserved for WiFi Manager
{ "fire", "water" },
{ "", "" },
{ "ape", "beer" }
};

Expand All @@ -270,4 +272,5 @@ wpas wpa[] = {
#define ASSERT(cond) if(!(cond)) gway_failed(__FILE__, __LINE__)
#else
#define ASSERT(cond) /**/
#endif
#endif
#endif //ESP_SC_GWAY_H_
2 changes: 1 addition & 1 deletion ESP-sc-gway/ESP-sc-gway.ino
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ using namespace std;

byte currentMode = 0x81;

bool sx1272 = true; // Actually we use sx1276/RFM95
bool sx1272 = false; // Actually we use sx1276/RFM95

uint32_t cp_nb_rx_rcv; // Number of messages received by gateway
uint32_t cp_nb_rx_ok; // Number of messages received OK
Expand Down
2 changes: 1 addition & 1 deletion ESP-sc-gway/_WiFi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ int WlanReadWpa() {
Serial.print(wpa[0].passw);
Serial.println(F(">"));
#endif

return 0;//Ldo: Function should return something
}


Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions ESP-sc-gway/_loraFiles.ino
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ int initConfig(struct espGwayConfig *c) {
(*c).cad = _CAD;
(*c).hop = false;
(*c).expert = false;
return 0;//Ldo: should return something
}


Expand Down
5 changes: 3 additions & 2 deletions ESP-sc-gway/_txRx.ino
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,8 @@ int receivePacket()

// This is one of the potential problem areas.
// If possible, USB traffic should be left out of interrupt routines
// rxpk PUSH_DATA received from node is rxpk (*2, par. 3.2)
/* // rxpk PUSH_DATA received from node is rxpk (*2, par. 3.2)

#ifdef _TTNSERVER
if (!sendUdp(ttnServer, _TTNPORT, buff_up, build_index)) {
return(-1); // received a message
Expand All @@ -639,7 +640,7 @@ int receivePacket()
return(-2); // received a message
}
#endif

*/
#if _LOCALSERVER==1
// Or special case, we do not use a local server to receive
// and decode the server. We use buildPacket() to call decode
Expand Down
181 changes: 179 additions & 2 deletions ESP-sc-gway/_wwwServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,183 @@ static void sensorData()
#endif
}

// ----------------------------------------------------------------------------
// WIFI CONFIG
// wifiData() displays the most important Wifi parameters gathered
//
// ----------------------------------------------------------------------------
static void wifiData()
{
if (gwayConfig.expert) {
String response="";
response +="<h2>WiFi Config</h2>";

response +="<table class=\"config_table\">";

response +="<tr><th class=\"thead\">Parameter</th><th class=\"thead\">Value</th></tr>";

response +="<tr><td class=\"cell\">WiFi host</td><td class=\"cell\">";
#if ESP32_ARCH==1
response +=WiFi.getHostname(); response+="</tr>";
#else
response +=wifi_station_get_hostname(); response+="</tr>";
#endif

response +="<tr><td class=\"cell\">WiFi SSID</td><td class=\"cell\">";
response +=WiFi.SSID(); response+="</tr>";

response +="<tr><td class=\"cell\">IP Address</td><td class=\"cell\">";
printIP((IPAddress)WiFi.localIP(),'.',response);
response +="</tr>";
response +="<tr><td class=\"cell\">IP Gateway</td><td class=\"cell\">";
printIP((IPAddress)WiFi.gatewayIP(),'.',response);
response +="</tr>";
response +="<tr><td class=\"cell\">NTP Server</td><td class=\"cell\">"; response+=NTP_TIMESERVER; response+="</tr>";
response +="<tr><td class=\"cell\">LoRa Router</td><td class=\"cell\">"; response+=_TTNSERVER; response+="</tr>";
response +="<tr><td class=\"cell\">LoRa Router IP</td><td class=\"cell\">";
printIP((IPAddress)ttnServer,'.',response);
response +="</tr>";
#ifdef _THINGSERVER
response +="<tr><td class=\"cell\">LoRa Router 2</td><td class=\"cell\">"; response+=_THINGSERVER;
response += String() + ":" + _THINGPORT + "</tr>";
response +="<tr><td class=\"cell\">LoRa Router 2 IP</td><td class=\"cell\">";
printIP((IPAddress)thingServer,'.',response);
response +="</tr>";
#endif
response +="</table>";

server.sendContent(response);
} // gwayConfig.expert
} // wifiData


// ----------------------------------------------------------------------------
// SYSTEMDATA
// This section contain a number of system specific data such as heap size etc.
// ----------------------------------------------------------------------------
static void systemData()
{
if (gwayConfig.expert) {
String response="";
response +="<h2>System Status</h2>";

response +="<table class=\"config_table\">";
response +="<tr>";
response +="<th class=\"thead\">Parameter</th>";
response +="<th class=\"thead\">Value</th>";
response +="<th colspan=\"2\" class=\"thead\">Set</th>";
response +="</tr>";

response +="<tr><td style=\"border: 1px solid black; width:120px;\">Gateway ID</td>";
response +="<td class=\"cell\">";
if (MAC_array[0]< 0x10) response +='0'; response +=String(MAC_array[0],HEX); // The MAC array is always returned in lowercase
if (MAC_array[1]< 0x10) response +='0'; response +=String(MAC_array[1],HEX);
if (MAC_array[2]< 0x10) response +='0'; response +=String(MAC_array[2],HEX);
response +="FFFF";
if (MAC_array[3]< 0x10) response +='0'; response +=String(MAC_array[3],HEX);
if (MAC_array[4]< 0x10) response +='0'; response +=String(MAC_array[4],HEX);
if (MAC_array[5]< 0x10) response +='0'; response +=String(MAC_array[5],HEX);
response+="</tr>";


response +="<tr><td class=\"cell\">Free heap</td><td class=\"cell\">"; response+=ESP.getFreeHeap(); response+="</tr>";
// XXX We Shoudl find an ESP32 alternative
#if !defined ESP32_ARCH
response +="<tr><td class=\"cell\">ESP speed</td><td class=\"cell\">"; response+=ESP.getCpuFreqMHz();
response +="<td style=\"border: 1px solid black; width:40px;\"><a href=\"SPEED=80\"><button>80</button></a></td>";
response +="<td style=\"border: 1px solid black; width:40px;\"><a href=\"SPEED=160\"><button>160</button></a></td>";
response+="</tr>";
response +="<tr><td class=\"cell\">ESP Chip ID</td><td class=\"cell\">"; response+=ESP.getChipId(); response+="</tr>";
#endif
response +="<tr><td class=\"cell\">OLED</td><td class=\"cell\">"; response+=OLED; response+="</tr>";

#if STATISTICS>=1
response +="<tr><td class=\"cell\">WiFi Setups</td><td class=\"cell\">"; response+=gwayConfig.wifis; response+="</tr>";
response +="<tr><td class=\"cell\">WWW Views</td><td class=\"cell\">"; response+=gwayConfig.views; response+="</tr>";
#endif

response +="</table>";
server.sendContent(response);
} // gwayConfig.expert
} // systemData


// ----------------------------------------------------------------------------
// INTERRUPT DATA
// Display interrupt data, but only for debug >= 2
//
// ----------------------------------------------------------------------------
static void interruptData()
{
if (gwayConfig.expert) {
uint8_t flags = readRegister(REG_IRQ_FLAGS);
uint8_t mask = readRegister(REG_IRQ_FLAGS_MASK);
String response="";

response +="<h2>System State and Interrupt</h2>";

response +="<table class=\"config_table\">";
response +="<tr>";
response +="<th class=\"thead\">Parameter</th>";
response +="<th class=\"thead\">Value</th>";
response +="<th colspan=\"2\" class=\"thead\">Set</th>";
response +="</tr>";

response +="<tr><td class=\"cell\">_state</td>";
response +="<td class=\"cell\">";
switch (_state) { // See loraModem.h
case S_INIT: response +="INIT"; break;
case S_SCAN: response +="SCAN"; break;
case S_CAD: response +="CAD"; break;
case S_RX: response +="RX"; break;
case S_TX: response +="TX"; break;
default: response +="unknown"; break;
}
response +="</td></tr>";

response +="<tr><td class=\"cell\">flags (8 bits)</td>";
response +="<td class=\"cell\">0x";
if (flags <16) response += "0";
response +=String(flags,HEX); response+="</td></tr>";


response +="<tr><td class=\"cell\">mask (8 bits)</td>";
response +="<td class=\"cell\">0x";
if (mask <16) response += "0";
response +=String(mask,HEX); response+="</td></tr>";

response +="<tr><td class=\"cell\">Re-entrant cntr</td>";
response +="<td class=\"cell\">";
response += String() + gwayConfig.reents;
response +="</td></tr>";

response +="<tr><td class=\"cell\">ntp call cntr</td>";
response +="<td class=\"cell\">";
response += String() + gwayConfig.ntps;
response+="</td></tr>";

response +="<tr><td class=\"cell\">ntpErr cntr</td>";
response +="<td class=\"cell\">";
response += String() + gwayConfig.ntpErr;
response +="</td>";
response +="<td colspan=\"2\" style=\"border: 1px solid black;\">";
stringTime(gwayConfig.ntpErrTime, response);
response +="</td>";
response +="</tr>";

response +="<tr><td class=\"cell\">Time Correction (uSec)</td><td class=\"cell\">";
response += txDelay;
response +="</td>";
response +="<td class=\"cell\"><a href=\"DELAY=-1\"><button>-</button></a></td>";
response +="<td class=\"cell\"><a href=\"DELAY=1\"><button>+</button></a></td>";
response +="</tr>";

response +="</table>";

server.sendContent(response);
}// if gwayConfig.expert
} // interruptData


// ----------------------------------------------------------------------------
// SEND WEB PAGE()
Expand Down Expand Up @@ -1224,7 +1401,7 @@ void setupWWW()
} // setupWWW



/* //Ldo: Functions wifiData() systemData() interruptData() should be before sendWebPage() to compile under Sloeber
// ----------------------------------------------------------------------------
// WIFI CONFIG
// wifiData() displays the most important Wifi parameters gathered
Expand Down Expand Up @@ -1401,6 +1578,6 @@ static void interruptData()
server.sendContent(response);
}// if gwayConfig.expert
} // interruptData

*/
#endif // A_SERVER==1

4 changes: 4 additions & 0 deletions ESP-sc-gway/loraFiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
// Define Pattern debug settings, this allows debugging per
// module rather than per level. See also pdebug.
//
#ifndef LORAFILES_H_
#define LORAFILES_H_

#define P_SCAN 0x01
#define P_CAD 0x02
#define P_RX 0x04
Expand Down Expand Up @@ -90,3 +93,4 @@ struct espGwayConfig {
#define LOGFILEREC 100

#endif
#endif //LORAFILES_H_
4 changes: 3 additions & 1 deletion ESP-sc-gway/loraModem.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
//
//
// ------------------------------------------------------------------------------------

#ifndef LORAMODEM_H_
#define LORAMODEM_H_

// ----------------------------------------
// Used by REG_PAYLOAD_LENGTH to set receive payload length
Expand Down Expand Up @@ -509,3 +510,4 @@ struct LoraUp {
#define MGT_SET_SF 0x16
#define MGT_SET_FREQ 0x17

#endif
5 changes: 4 additions & 1 deletion ESP-sc-gway/oLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
// 0. No OLED connected
// 1. 0.9" OLED (cheap)
// 2. 1.3" OLED with much better and larger display
#ifndef OLED_H_
#define OLED_H_

#if OLED>=1 // If OLED is used

Expand Down Expand Up @@ -65,4 +67,5 @@ SSD1306 display(OLED_ADDR, OLED_SDA, OLED_SCL);// i2c ADDR & SDA, SCL on wemos
SH1106 display(OLED_ADDR, OLED_SDA, OLED_SCL); // i2c ADDR & SDA, SCL on wemos
#endif

#endif//OLED>=1
#endif//OLED>=1
#endif//OLED_H_
3 changes: 3 additions & 0 deletions ESP-sc-gway/sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
//
//
// ------------------------------------------------------------------------------------
#ifndef SENSOR_H_
#define SENSOR_H_

#if _TRUSTED_NODES >= 1
struct nodex {
Expand Down Expand Up @@ -92,3 +94,4 @@ codex decodes[] = {
}
};
#endif //_LOCALSERVER
#endif //SENSOR_H_