Amazing technological breakthrough possible @S-Logix

Office Address

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

Social List

How to send the publisher send message to server in MQTT contiki cooja?


Sender of the messages is called publisher in pub/sub pattern. Publish the topics periodically and also know about how to send the publish message to server in MQTT contiki cooja simulator.

Source code

Step 1: Open a file at location:contiki/ mqtt-sn-contiki/main_core.c
Define topics like this,
static char *topics_mqtt[] = {“/topic_1”, “/topic_2”, “/topic_3″”/topic_4”, “/topic_5”, “/topic_6”};

Step 2: Create socket to publish
mqtt_sn_init(); // initiation
size_t i;
all_topics[i] = topics_mqtt[i];
all_topics[i] = topic_hw;

Step 3: initiate broker and publish the message periodically
while(1) {
if (etimer_expired(&time_poll))

Step 4: contiki/ mqtt-sn-contiki/mqtt_sn.c
resp_con_t mqtt_sn_pub_send(char *topic, char *message, bool retain_flag, uint8_t qos). handles publish message to broker.

Step 5: Open cooja simulator

Run simulation

How to send the publisher send message to server in MQTT contiki cooja
handles publish message to broker MQTT contiki cooja