Jump to content

Search the Community

Showing results for tags 'mqtt multplie publishers'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks

Calendars

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Location


Interests


Sparkfun


Github

Found 1 result

  1. I am running the following code in EK-TM4C1294XL Launchpad.The program gets downloaded successfully and I am able to see the published messages in the MQTT BOX application.But when I download the same program in another launchpad and try to run both at the same time , one launchpad stopped sending data.How to run two MQTT publishers publishing to same topic .Is there any changes required in the code? Thanks #define MQTTCLIENT_QOS2 1 #include <SPI.h> #include <Ethernet.h> #include <EthernetStack.h> #include <Countdown.h> #include <MQTTClient.h> char printbuf[100]; int arrivedcount = 0; void messageArrived(MQTT::MessageData& md) { MQTT::Message &message = md.message; sprintf(printbuf, "Message %d arrived: qos %d, retained %d, dup %d, packetid %d\n", ++arrivedcount, message.qos, message.retained, message.dup, message.id); Serial.print(printbuf); sprintf(printbuf, "Payload %s\n", (char*)message.payload); Serial.print(printbuf); } EthernetStack ipstack; MQTT::Client<EthernetStack, Countdown> client = MQTT::Client<EthernetStack, Countdown>(ipstack); const char* topic = "TEST TOPIC"; void connect() { char hostname[] = "iot.eclipse.org"; int port = 1883; sprintf(printbuf, "Connecting to %s:%d\n", hostname, port); Serial.print(printbuf); int rc = ipstack.connect(hostname, port); if (rc != 1) { sprintf(printbuf, "rc from TCP connect is %d\n", rc); Serial.print(printbuf); } Serial.println("MQTT connecting"); MQTTPacket_connectData data = MQTTPacket_connectData_initializer; data.MQTTVersion = 3; data.clientID.cstring = (char*)"energia-sample"; rc = client.connect(data); if (rc != 0) { sprintf(printbuf, "rc from MQTT connect is %d\n", rc); Serial.print(printbuf); } Serial.println("MQTT connected"); rc = client.subscribe(topic, MQTT::QOS2, messageArrived); if (rc != 0) { sprintf(printbuf, "rc from MQTT subscribe is %d\n", rc); Serial.print(printbuf); } Serial.println("MQTT subscribed"); } void setup() { Serial.begin(115200); Serial.println("Starting Ethernet"); Ethernet.enableLinkLed(); Ethernet.enableActivityLed(); Ethernet.begin(0); Serial.println("\nIP Address obtained"); // We are connected and have an IP address. Serial.println(Ethernet.localIP()); Serial.println("MQTT Hello example"); connect(); } void loop() { if (!client.isConnected()) connect(); MQTT::Message message; arrivedcount = 0; // Send and receive QoS 0 message char buf[100]; sprintf(buf, "Count2"); Serial.println(buf); message.qos = MQTT::QOS0; message.retained = false; message.dup = false; message.payload = (void*)buf; message.payloadlen = strlen(buf)+1; int rc = client.publish(topic, message); while (arrivedcount == 0) client.yield(500); delay(500); }
×
×
  • Create New...