Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- https://youtu.be/srqj46WrCLY youtube=v12345vtm
- basic concept of telnet session to peha domotics stm module
- send a XML request and print out the respons
- */
- #include <ESP8266WiFi.h>
- const char* ssid = "WiFi";
- const char* password = "pass";
- const char* host = "192.168.1.2"; //peha STM adress
- const int PehaXMLport = 6680; //xml telnet port fixed adres by peha
- const int PehaHTTPport = 80; //browser port http://192.168.1.2/modulestates.html
- void setup() {
- Serial.begin(115200);
- delay(10);
- Serial.println();
- Serial.println();
- Serial.print("Connecting to ");
- Serial.println(ssid);
- WiFi.mode(WIFI_STA);
- WiFi.begin(ssid, password);
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.print(".");
- }
- Serial.println("");
- Serial.println("WiFi connected");
- Serial.println("IP address: ");
- Serial.println(WiFi.localIP());
- Serial.print("connecting to peha STM ip ");
- Serial.println(host);
- Serial.print(" at port ");
- Serial.println(PehaXMLport + "\n\n\n");
- }
- void loop() {
- WiFiClient client; //to connect to peha
- if (!client.connect(host, PehaXMLport)) {
- Serial.println("connection failed");
- return;
- }
- // This will send the request to the server
- String tafellampTogglen = "<methodCall><methodName>service.stm.simInputEvent</methodName><params><param><value><i4>0</i4></value></param><param><value><i4>0</i4></value></param><param><value><i4>0</i4></value></param><param><value><i4>2</i4></value></param><param><value><i4>4</i4></value></param></params></methodCall>";
- Serial.println( "xml request from esp8266 to peha:\n" + tafellampTogglen);
- client.print(tafellampTogglen);
- unsigned long timeout = millis();
- while (client.available() == 0) {
- if (millis() - timeout > 5000) {
- Serial.println(">>> Client Timeout !");
- client.stop();
- return;
- }
- }
- // Read all the lines of the reply from server and print them to Serial
- Serial.println("\n\nstart of peha respons........");
- while (client.available()) {
- String peharespons = client.readStringUntil('\r');
- Serial.print(peharespons);
- }
- Serial.println("end of peha respons...........");
- delay(300000);
- }
Advertisement
Add Comment
Please, Sign In to add comment