/// <summary> /// ''' Get the AP server request /// ''' Process the request /// ''' Send the AP server request /// ''' </summary> public static void APServerRequestHandler() { ESP8266.PrintData("AP Server Request"); string ReturnString = ProcessAPServerRequest(ESP8266.ServerRequest); ESP8266.SendServerRequest(ReturnString); }
/// <summary> /// ''' Put Esp8266 in AP mode /// ''' </summary> public static void StartAPMode() { CurrentMode = (int)Mode.AP; Thread.Sleep(CommandDelay); // Puts chip in AP Mode with no security // Default IP address is 192.168.4.1 // Default SSID varies with chip // To set SSID, Password etc. // https://github.com/espressif/ESP8266_AT/wiki/CWSAP SendData("AT+CWMODE=3"); Thread.Sleep(6000); // Get the AP IP address ESP8266.SendData("AT+CIPAP?"); Thread.Sleep(CommandDelay); }
/// <summary> /// ''' Sends the data requested /// ''' </summary> public static void SendServerRequest(string ServerRequestedData) { try { int FileLength = ServerRequestedData.Length; int BytesSent = 0; while (BytesSent < FileLength) { int BytesToRead = FileLength - BytesSent; if (BytesToRead > MAX_BUFF) { BytesToRead = MAX_BUFF; } ESP8266.SendData("AT+CIPSENDBUF=" + LinkedID + "," + BytesToRead); Thread.Sleep(20); string DataToSend = ServerRequestedData.Substring(BytesSent, BytesToRead); ESP8266.SendData(DataToSend); BytesSent += BytesToRead; } Thread.Sleep(20); SendData("AT+CIPCLOSE=" + LinkedID); } catch (Exception ex) { PrintData("Error: SendServerRequest: " + ex.ToString()); } }
public static void Main() { // Debug.Print(Resources.GetString(Resources.StringResources.String1)); ESP8266.DataReceivedEvent += DataReceivedHandler; ESP8266.ServerRequestEvent += ServerRequestHandler; ESP8266.APServerRequestEvent += APServerRequestHandler; // Default is 6000 MS ESP8266.CommandDelay = 3000; // Default is -5 for US central time offset from GMT time ESP8266.LocalTimeOffSet = -5; ESP8266.Initialize(PA13, PA14, "COM2"); ESP8266.GetVersion(); ESP8266.Connect("weaver", "3098280065"); ESP8266.SetTime(); ESP8266.PrintData(DateTime.Now.ToString("dd MMM HH:mm")); ESP8266.StartServer(); ESP8266.PrintData("IP Address: " + ESP8266.IPAddress); // ********* Uncomment to start Access Point mode // ESP8266C.StartAPMode() while ((true)) { Thread.Sleep(1000); } }
// Toewijzen waarden door middel van het verkrijgen van de bijbehorende componenten in de AppManager prefab. private void Awake() { customText = this.GetComponent <CustomText>(); esp8266 = this.GetComponent <ESP8266>(); }
/// <summary> /// ''' Get the serial port received data from the ESP8266C device /// ''' Print to the console /// ''' </summary> public static void DataReceivedHandler() { ESP8266.PrintData("Received: " + ESP8266.Data); }