nothing modified
Dependencies: mbed-src WizFi310Interface_Legacy_ DHT MQTT
Revision 19:2e11b8a64d23, committed 2019-02-06
- Comitter:
- irayya
- Date:
- Wed Feb 06 10:09:00 2019 +0000
- Parent:
- 18:0596e033d027
- Commit message:
- nothing modified
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 0596e033d027 -r 2e11b8a64d23 main.cpp --- a/main.cpp Thu Jan 10 05:36:23 2019 +0000 +++ b/main.cpp Wed Feb 06 10:09:00 2019 +0000 @@ -62,8 +62,8 @@ - pc.baud(115200); - char* topicfan = "/led"; + pc.baud(115200); + char* topicled = "/led"; printf("WizFi310 STATION. \r\n"); wizfi310.init(); printf("After Initialisation. \r\n"); @@ -85,26 +85,26 @@ printf("rc from TCP connect is %d\n", rc); printf("rc from TCP connect is %d\n", rc); - char MQTTClientID[30]; - - //MQTTPacket_connectData data = MQTTPacket_connectData_initializer; -// data.MQTTVersion = 3; -// sprintf(MQTTClientID,"WIZwiki-W7500-client-%d",rand()%1000); -// data.clientID.cstring = MQTTClientID; -// data.username.cstring = "testuser"; -// data.password.cstring = "testpassword"; + /*char MQTTClientID[30]; MQTTPacket_connectData data = MQTTPacket_connectData_initializer; data.MQTTVersion = 3; - data.clientID.cstring = "parents"; - + sprintf(MQTTClientID,"WIZwiki-W7500-client-%d",rand()%1000); + data.clientID.cstring = MQTTClientID; + data.username.cstring = "testuser"; + data.password.cstring = "testpassword"; + MQTTPacket_connectData data = MQTTPacket_connectData_initializer; + data.MQTTVersion = 3; + data.clientID.cstring = "parents";*/ + MQTTPacket_connectData data = MQTTPacket_connectData_initializer; if ((rc = client.connect(data)) != 0) printf("rc from MQTT connect is %d\n", rc); - if ((rc = client.subscribe(topicfan, MQTT::QOS1, messageArrived)) == 0) + if ((rc = client.subscribe(topicled, MQTT::QOS1, messageArrived)) == 0) printf("rc from MQTT subscribe for fan is %d\n", rc); MQTT::Message message; - char buf[100]; + //char buf[100]; + char buf[]="hello"; int error = 0; float hum = 0.0f, temp = 0.0f; char i = 0; @@ -120,17 +120,18 @@ message.retained = false; message.dup = false; - sprintf(buf, "%3.1f", hum); + //sprintf(buf, "%3.1f", hum); + message.payload = (void*)buf; message.payloadlen = strlen(buf); rc = client.publish("Wiz/humidity", message); printf("Wiz/humidity : %s\r\n",message.payload); - sprintf(buf, "%3.1f", temp); + /* sprintf(buf, "%3.1f", temp); message.payload = (void*)buf; message.payloadlen = strlen(buf); rc = client.publish("Wiz/temperature", message); - printf("Wiz/temperature : %s\r\n",message.payload); + printf("Wiz/temperature : %s\r\n",message.payload);*/ client.yield(1000); } }