From 31fa2aebbb3f8aa6033aa27585c0061599ea4846 Mon Sep 17 00:00:00 2001 From: andrespm Date: Sun, 3 Jul 2022 17:52:45 -0500 Subject: [PATCH] Correcion archivos erroneos --- mosquitto.conf | 29 +++++++++++++++++++++ mqtt_BBB.ino | 71 -------------------------------------------------- 2 files changed, 29 insertions(+), 71 deletions(-) create mode 100755 mosquitto.conf delete mode 100644 mqtt_BBB.ino diff --git a/mosquitto.conf b/mosquitto.conf new file mode 100755 index 0000000..a6fb471 --- /dev/null +++ b/mosquitto.conf @@ -0,0 +1,29 @@ +listener 1883 + +persistence true + +persistence_location /var/lib/mosquitto/ + +persistence_file mosquitto.db + +log_dest syslog + +log_dest stdout + +log_dest topic + +log_type error + +log_type warning + +log_type notice + +log_type information + +connection_messages true + +log_timestamp true + +allow_anonymous true + +password_file /etc/mosquitto/passwd diff --git a/mqtt_BBB.ino b/mqtt_BBB.ino deleted file mode 100644 index 2a61a64..0000000 --- a/mqtt_BBB.ino +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include - -const char* ssid = "Familia 2.4G"; -const char* password = "rr20072015"; -const char* mqttServer = "192.168.1.17"; -const int mqttPort = 1883; -const char* mqttUser = ""; -const char* mqttPassword = ""; - -WiFiClient espClient; -PubSubClient client(espClient); - -void OnMqttReceived(char *topic, byte *payload, unsigned int length) -{ - Serial.print("Received on "); - Serial.print(topic); - Serial.print(": "); - String content = ""; - for (size_t i = 0; i < length; i++) - { - content.concat((char)payload[i]); - } - Serial.print(content); - Serial.println(); -} - -void setup() -{ Serial.begin(115200); - WiFi.begin(ssid, password); - Serial.println("..................................."); - - Serial.print("Connecting to WiFi."); - while (WiFi.status() != WL_CONNECTED) - { delay(500); - Serial.print(".") ; - } - Serial.println("Connected to the WiFi network"); - - client.setServer(mqttServer, mqttPort); -while (!client.connected()) -{ Serial.println("Connecting to MQTT..."); - if (client.connect("prueba", mqttUser, mqttPassword )) - {Serial.println("connected"); - client.subscribe("prueba/xd"); - client.setCallback(OnMqttReceived); - } - else - { Serial.print("failed with state "); - Serial.print(client.state()); - delay(2000); - } -} -} - -void loop() - { client.loop(); - char str[16]; - -if(Serial.read()>0) -{ -sprintf(str, "%u", random(100)); - -client.publish("prueba/xd", str); -Serial.println(str); -delay(100); -} - - - - }