mb-listener.c
//Default function in MQTT paho (Runs when msg is received)
Default function in MQTT paho (Runs when msg is received)
Default function in MQTT paho ( Runs when msg is received )
int msgarrvd(void *context, char *topicName, int topicLen, MQTTClient_message *message)
{
    int i;
    char* payloadptr;
    char messageText[message->payloadlen];
    printf("Message arrived\n");
    printf("     topic: %s\n", topicName);
    printf("   message: ");
    payloadptr = message->payload;
    for(i=0; i < message->payloadlen; i++)
    {
	  messageText[i] = *payloadptr++;
    }
	  messageText[i] = '\0';
    lightLED(messageText[0]);
    printf("%s",messageText);
    putchar('\n');
    MQTTClient_freeMessage(&message);
    MQTTClient_free(topicName);
    return 1;
}
int msgarrvd ( void * context , char * topicName , int topicLen , MQTTClient_message * message ) { int i ; char * payloadptr ; char messageText [ message -> payloadlen ] ; printf ( " \n " ) ; printf ( " \n " , topicName ) ; printf ( " " ) ; payloadptr = message -> payload ; for ( i = 0 ; i < message -> payloadlen ; i ++ ) { messageText [ i ] = * payloadptr ++ ; } messageText [ i ] = ' \0 ' ; lightLED ( messageText [ 0 ] ) ; printf ( " " , messageText ) ; putchar ( ' \n ' ) ; MQTTClient_freeMessage ( & message ) ; MQTTClient_free ( topicName ) ; return 1 ; }
Default function in MQTT paho (Runs when msg is received)
Default function in MQTT paho ( Runs when msg is received )
//   putchar(*payloadptr++);