Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. /* Download WifiManager from https://github.com/tzapu/WiFiManager */
  2. /*
  3. With this Example you don't need to configure SSID and Password before compile and load the sketch.
  4. If your node doesn't connect to your WiFi or isn't configured yet you will see an open WiFi network called "Souliss",
  5. connect to the wifi and open on your browser this address: http://192.168.4.1 and configure your WiFi,
  6. then you can open your Souliss Android App and enjoy! :)
  7. *(Chrome on Android not supported)
  8. */
  9. #include <WiFiClient.h>
  10. #include <EEPROM.h>
  11. #include <ESP8266mDNS.h>
  12. #include <WiFiManager.h>
  13.  
  14. WiFiManager wifi(0);
  15.  
  16. /**************************************************************************
  17. Souliss - Hello World for Expressif ESP8266
  18.  
  19. This is the basic example, create a software push-button on Android
  20. using SoulissApp (get it from Play Store).
  21.  
  22. Load this code on ESP8266 board using the porting of the Arduino core
  23. for this platform.
  24.  
  25. ***************************************************************************/
  26.  
  27. // Configure the framework
  28. #include "bconf/MCU_ESP8266.h" // Load the code directly on the ESP8266
  29. #include "conf/Gateway.h" // The main node is the Gateway, we have just one node
  30. //#include "conf/IPBroadcast.h"
  31. #include "conf/DynamicAddressing.h" // Use dynamic addresses
  32. #include <SPI.h>
  33.  
  34. // Include framework code and libraries
  35. #include <ESP8266WiFi.h>
  36. #include "Souliss.h"
  37.  
  38. // This identify the Slot number of typicals
  39. #define ANTITHEFT 4 // This is the memory slot used for the execution of the anti-theft
  40. #define WATCHDOG 5
  41.  
  42.  
  43. // **** Define here the right pin for your ESP module ****
  44. #define BLINK 2
  45.  
  46. void setup()
  47. {
  48. Serial.begin(115200);
  49. wifi.autoConnect("Souliss");
  50. WiFi.mode(WIFI_STA);
  51. Initialize();
  52.  
  53. // Set network parameters
  54. Souliss_GetIPAddress();
  55. SetAsGateway(myvNet_dhcp);
  56. SetAddressingServer();
  57.  
  58. // Connect to the WiFi network and get an address from DHCP
  59. // GetIPAddress();
  60. // SetAsGateway(myvNet_dhcp); // Set this node as gateway for SoulissApp
  61.  
  62. // This is the vNet address for this node, used to communicate with other
  63. // nodes in your Souliss network
  64. // SetAddress(0xAB01, 0xFF00, 0x0000);
  65. // SetAsPeerNode(0xAB02, 1);
  66. // SetAsPeerNode(0xD002, 2); //RGB Led etc connected to peer Node 1 - 0xDO01 using USART
  67.  
  68.  
  69. // Setup the anti-theft
  70. Set_T41(ANTITHEFT);
  71.  
  72. pinMode(BLINK, OUTPUT); // Use pin as output
  73. pinMode(0, INPUT);
  74. }
  75.  
  76. void loop()
  77. {
  78. // Here we start to play
  79. EXECUTEFAST() {
  80. UPDATEFAST();
  81.  
  82. FAST_50ms() { // We process the logic and relevant input and output every 50 milliseconds
  83. if (WiFi.status() == WL_CONNECTED) {
  84. digitalWrite(BLINK, !digitalRead(BLINK));
  85.  
  86. }
  87.  
  88.  
  89. }
  90.  
  91. FAST_510ms() {
  92. // Input from anti-theft sensor
  93. LowDigIn(0, Souliss_T4n_Alarm, ANTITHEFT);
  94.  
  95. // Execute the anti-theft logic
  96. Logic_T41(ANTITHEFT);
  97. }
  98.  
  99. // Here we handle here the communication with Android
  100. FAST_GatewayComms();
  101.  
  102. FAST_2110ms() {
  103.  
  104. // Build a watchdog chain to monitor the nodes
  105. mInput(ANTITHEFT) = Watchdog(0xAB02, WATCHDOG, Souliss_T4n_Alarm);
  106. }
  107.  
  108.  
  109. }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement