Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
app-notes:metric-cloudsetup:sdk-dio-mqtt-subscribe [2020/11/12 13:50] – created erdmannapp-notes:metric-cloudsetup:sdk-dio-mqtt-subscribe [2021/07/27 12:09] (current) dodenhoeft
Line 1: Line 1:
 +====== Mqtt subscribe DIO Status ======
 +
 +The following script will send a subscribe message to the topic, if DIO status has been changed. 
 +
 <file c sdk-dio-mqtt-subscribe.are> <file c sdk-dio-mqtt-subscribe.are>
 HOST = "123.123.123.123";  HOST = "123.123.123.123"; 
Line 46: Line 50:
  
 if(buffer=="1") { if(buffer=="1") {
- printf("switch GPIO 1 on\n");+ printf("switch DIO 1 on\n");
  if (nb_dio_set("out1", 1) < 0 ) {  if (nb_dio_set("out1", 1) < 0 ) {
- printf("GPIO1 switch on failed\n");+ printf("DIO switch on failed\n");
  exit(1);  exit(1);
 } }
 }else { }else {
  if(buffer=="0") {  if(buffer=="0") {
-        printf("switch GPIO 1 off\n");+        printf("switch DIO 1 off\n");
         if (nb_dio_set("out1", 0) < 0 ) {         if (nb_dio_set("out1", 0) < 0 ) {
-   printf("GPIO1 switch off failed\n");+   printf("DIO switch off failed\n");
      exit(1);      exit(1);
      }      }
Line 62: Line 66:
  
 //For debugging //For debugging
-//printf("Buffer: %s\n", ret.msg.msg); 
 //dump(buffer); //dump(buffer);
-//printf("%s\n",buffer); 
- 
  
 if(ret<0){ if(ret<0){