Skip to content

Latest commit

 

History

History
105 lines (74 loc) · 4 KB

h4wifi.md

File metadata and controls

105 lines (74 loc) · 4 KB

H4P Flyer

H4P_WiFi

Service shortname wifi

Provides WiFi management / reconnection, Asynchronous Webserver, and OTA updates.


Contents


Usage

H4P_WiFi whiffy(...

This plugin is a "singleton" - there may be only one single instance of it in the app. It may be instantiated as any name the user chooses, prefix all API calls below with that name.

Dependencies

H4P_PinMachine H4P_Signaller

  • You must copy the data sub-folder to your sketch folder and upload to LittleFS (ESP8266) or SPIFFS (ESP32). To do this you will need to intall either the LittleFS upload tool or the ESP32 sketch data uploader (or both).

  • On devices with > 1MB flash also copy the images in the data_jpg folder for an enhanced UI experience

Commands Added

  • h4/wifi/change/x,y (payload x,y = newssid,newpassword)
  • h4/wifi/msg/x (payload x = messge to be sent to scrolling message area in webUI

Service Commands

stop will disconnect from WiFi and initiate closedown of all Plugins the depend on WiFi start will connect to WiFi and start webserver and all dependent services


API

For guidance on the use of the ui... functions, see Customising the web UI

/*
Constructor
ssid / psk = your router credentials. psk = pre-shared key = password
device is the local name for e.g. OTA. Will be visible in your system as < device >.local
*/
H4P_WiFi(string ssid,string psk,string device=""):

// Command and control
void change(string ssid,string psk); // connect to new SSID
/*
webUI functions

Common parameters:

const string& name; Title Of The Field...It Gets "Proper Cased" "oh my" becomes "Oh My" 
const string& section="u"; the webUI panel to add the field to.
It is recommended to leave this as the default "u" for User fields.

*/
uiAddBoolean(const string& name,const string& section="u"); // fixed red/green boolean as tf=true or false
uiAddDropdown(const string& name,H4P_NVP_MAP options,const string& section="u");// dropdown box from maps of options
uiAddGlobal(const string& name,const string& section="u"); // Take field values from h4p[name]
uiAddImg(const string& name,const string& url,const string& section="u");// adds image from url
uiAddImgButton(const string& name,const string& section="u");// adds clickable image (simulates a button)
uiAddInput(const string& name,const string& section="u")// simple text input
uiAddText(const string& name,const string& v,const string& section="u")// fixed string value
uiAddText(const string& name,int v,const string& section="u")// fixed int value
uiAddAllUsrFields(const string& section="u");// searches for all global variable starting usr_... and adds them to UI
uiMessage(const string& msg, Args... args); // Show scrolling printf-style message in UI
uiSetValue(const string& ui,const int f); // change int field value
uiSetValue(const string& ui,const string& value); // change string field value

Example sketches


(c) 2021 Phil Bowles [email protected]