Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Download WifiManager from https://github.com/tzapu/WiFiManager */
- /*
- With this Example you don't need to configure SSID and Password before compile and load the sketch.
- If your node doesn't connect to your WiFi or isn't configured yet you will see an open WiFi network called "Souliss",
- connect to the wifi and open on your browser this address: http://192.168.4.1 and configure your WiFi,
- then you can open your Souliss Android App and enjoy! :)
- *(Chrome on Android not supported)
- */
- #include <WiFiClient.h>
- #include <EEPROM.h>
- #include <ESP8266mDNS.h>
- #include <WiFiManager.h>
- WiFiManager wifi(0);
- /**************************************************************************
- Souliss - Hello World for Expressif ESP8266
- This is the basic example, create a software push-button on Android
- using SoulissApp (get it from Play Store).
- Load this code on ESP8266 board using the porting of the Arduino core
- for this platform.
- ***************************************************************************/
- // Configure the framework
- #include "bconf/MCU_ESP8266.h" // Load the code directly on the ESP8266
- #include "conf/Gateway.h" // The main node is the Gateway, we have just one node
- //#include "conf/IPBroadcast.h"
- #include "conf/DynamicAddressing.h" // Use dynamic addresses
- #include <SPI.h>
- // Include framework code and libraries
- #include <ESP8266WiFi.h>
- #include "Souliss.h"
- // This identify the Slot number of typicals
- #define ANTITHEFT 4 // This is the memory slot used for the execution of the anti-theft
- #define WATCHDOG 5
- // **** Define here the right pin for your ESP module ****
- #define BLINK 2
- void setup()
- {
- Serial.begin(115200);
- wifi.autoConnect("Souliss");
- WiFi.mode(WIFI_STA);
- Initialize();
- // Set network parameters
- Souliss_GetIPAddress();
- SetAsGateway(myvNet_dhcp);
- SetAddressingServer();
- // Connect to the WiFi network and get an address from DHCP
- // GetIPAddress();
- // SetAsGateway(myvNet_dhcp); // Set this node as gateway for SoulissApp
- // This is the vNet address for this node, used to communicate with other
- // nodes in your Souliss network
- // SetAddress(0xAB01, 0xFF00, 0x0000);
- // SetAsPeerNode(0xAB02, 1);
- // SetAsPeerNode(0xD002, 2); //RGB Led etc connected to peer Node 1 - 0xDO01 using USART
- // Setup the anti-theft
- Set_T41(ANTITHEFT);
- pinMode(BLINK, OUTPUT); // Use pin as output
- pinMode(0, INPUT);
- }
- void loop()
- {
- // Here we start to play
- EXECUTEFAST() {
- UPDATEFAST();
- FAST_50ms() { // We process the logic and relevant input and output every 50 milliseconds
- if (WiFi.status() == WL_CONNECTED) {
- digitalWrite(BLINK, !digitalRead(BLINK));
- }
- }
- FAST_510ms() {
- // Input from anti-theft sensor
- LowDigIn(0, Souliss_T4n_Alarm, ANTITHEFT);
- // Execute the anti-theft logic
- Logic_T41(ANTITHEFT);
- }
- // Here we handle here the communication with Android
- FAST_GatewayComms();
- FAST_2110ms() {
- // Build a watchdog chain to monitor the nodes
- mInput(ANTITHEFT) = Watchdog(0xAB02, WATCHDOG, Souliss_T4n_Alarm);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement