mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-18 02:52:05 +00:00
Final checkin of WiFi and basic HTTP server
This commit is contained in:
parent
c656a95a84
commit
493b25f23e
@ -397,16 +397,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#define GPS_POWER_CTRL_CH 3
|
#define GPS_POWER_CTRL_CH 3
|
||||||
#define LORA_POWER_CTRL_CH 2
|
#define LORA_POWER_CTRL_CH 2
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// WiFi Configuration
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Set WiFi credentials using the API (Does this work?)
|
|
||||||
// meshtastic --setpref WiFi_SSID_NAME yournetwork
|
|
||||||
// meshtastic --setpref WiFi_SSID_PASSWORD yourpassword
|
|
||||||
//
|
|
||||||
// WiFi_Mode
|
|
||||||
// 0 = Disabled
|
|
||||||
// 1 = Enabled
|
|
||||||
#define WiFi_MODE 1
|
|
||||||
|
@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "mesh-pb-constants.h"
|
#include "mesh-pb-constants.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
|
#include "meshwifi/meshwifi.h"
|
||||||
|
|
||||||
using namespace meshtastic; /** @todo remove */
|
using namespace meshtastic; /** @todo remove */
|
||||||
|
|
||||||
@ -746,10 +747,10 @@ void Screen::setFrames()
|
|||||||
// call a method on debugInfoScreen object (for more details)
|
// call a method on debugInfoScreen object (for more details)
|
||||||
normalFrames[numframes++] = &Screen::drawDebugInfoSettingsTrampoline;
|
normalFrames[numframes++] = &Screen::drawDebugInfoSettingsTrampoline;
|
||||||
|
|
||||||
#if WiFi_MODE
|
if (isWifiAvailable()) {
|
||||||
// call a method on debugInfoScreen object (for more details)
|
// call a method on debugInfoScreen object (for more details)
|
||||||
normalFrames[numframes++] = &Screen::drawDebugInfoWiFiTrampoline;
|
normalFrames[numframes++] = &Screen::drawDebugInfoWiFiTrampoline;
|
||||||
#endif
|
}
|
||||||
|
|
||||||
ui.setFrames(normalFrames, numframes);
|
ui.setFrames(normalFrames, numframes);
|
||||||
ui.enableAllIndicators();
|
ui.enableAllIndicators();
|
||||||
|
@ -327,10 +327,8 @@ void setup()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if WiFi_MODE
|
|
||||||
// Initialize Wifi
|
// Initialize Wifi
|
||||||
initWifi();
|
initWifi();
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!rIf)
|
if (!rIf)
|
||||||
recordCriticalError(ErrNoRadio);
|
recordCriticalError(ErrNoRadio);
|
||||||
@ -423,10 +421,8 @@ void loop()
|
|||||||
// feel slow
|
// feel slow
|
||||||
msecstosleep = 10;
|
msecstosleep = 10;
|
||||||
|
|
||||||
#if WiFi_MODE
|
|
||||||
// TODO: This should go into a thread handled by FreeRTOS.
|
// TODO: This should go into a thread handled by FreeRTOS.
|
||||||
handleWebResponse();
|
handleWebResponse();
|
||||||
#endif
|
|
||||||
|
|
||||||
delay(msecstosleep);
|
delay(msecstosleep);
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "meshwifi.h"
|
#include "meshwifi/meshwifi.h"
|
||||||
#include "meshhttp.h"
|
#include "meshwifi/meshhttp.h"
|
||||||
|
|
||||||
|
|
||||||
WebServer webserver(80);
|
WebServer webserver(80);
|
||||||
@ -14,6 +14,10 @@ String sender = "";
|
|||||||
|
|
||||||
|
|
||||||
void handleWebResponse() {
|
void handleWebResponse() {
|
||||||
|
if (isWifiAvailable() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
webserver.handleClient();
|
webserver.handleClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,14 +5,34 @@
|
|||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "meshwifi/meshhttp.h"
|
#include "meshwifi/meshhttp.h"
|
||||||
|
|
||||||
|
bool isWifiAvailable()
|
||||||
|
{
|
||||||
|
const char *wifiName = radioConfig.preferences.wifi_ssid;
|
||||||
|
const char *wifiPsw = radioConfig.preferences.wifi_password;
|
||||||
|
|
||||||
|
if (*wifiName && *wifiPsw) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable WiFi
|
||||||
void deinitWifi()
|
void deinitWifi()
|
||||||
{
|
{
|
||||||
WiFi.mode(WIFI_MODE_NULL);
|
WiFi.mode(WIFI_MODE_NULL);
|
||||||
DEBUG_MSG("WiFi Turned Off\n");
|
DEBUG_MSG("WiFi Turned Off\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Startup WiFi
|
||||||
void initWifi()
|
void initWifi()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (isWifiAvailable() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//strcpy(radioConfig.preferences.wifi_ssid, WiFi_SSID_NAME);
|
//strcpy(radioConfig.preferences.wifi_ssid, WiFi_SSID_NAME);
|
||||||
//strcpy(radioConfig.preferences.wifi_password, WiFi_SSID_PASSWORD);
|
//strcpy(radioConfig.preferences.wifi_password, WiFi_SSID_PASSWORD);
|
||||||
if (radioConfig.has_preferences) {
|
if (radioConfig.has_preferences) {
|
||||||
|
@ -12,3 +12,4 @@ void deinitWifi();
|
|||||||
|
|
||||||
void WiFiEvent(WiFiEvent_t event);
|
void WiFiEvent(WiFiEvent_t event);
|
||||||
|
|
||||||
|
bool isWifiAvailable();
|
Loading…
Reference in New Issue
Block a user