#5, First Floor, 4th Street , Dr. Subbarayan Nagar, Kodambakkam, Chennai-600 024 pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to subscribe the message from server in MQTT?


Receiver of the message is called subscriber in pub/sub pattern. Client connect with broker and requests the topics, broker will publish the topics to subscriber.

Source code

Step 1: Open a file at location:contiki/ mqtt-sn-contiki/main_core.c

// To subscribe

mqtt_sn_init(); // initiation

char *topic =”/topic_1″;

mqtt_sn_sub(topic,0); //subscribe

Step 2: Initiate the subscriber
contiki/ mqtt-sn-contiki/mqtt_sn.c
void init_sub(void *ptr)
resp_con_t mqtt_sn_sub_send(char *topic, uint8_t qos)
Subscribes the messages from broker.

Step 3: Function receives the topics.
void mqtt_sn_callback(char *topic, char *message)
Reeived topic and message from server or broker

Step 4: Run the simulation