Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Mosquitto » Publishing and Subscribing Using C Between 2 Computers(In the case where two computers are being used)
Publishing and Subscribing Using C Between 2 Computers [message #1833960] Wed, 28 October 2020 21:02
Pete Cal is currently offline Pete CalFriend
Messages: 2
Registered: October 2020
Location: Nashville TN
Junior Member
I must be missing something but I can't seem to figure out how to make this work.
I have two computers (soon to be Raspberry Pis but for now one is a Raspberry Pi and the others is a Windows PC).
I have a mosquitto broker running on the RPi. This has been running fine for almost a year, publishing and subscribing to many items on the RPi. All done using the C programming language.
Now I want to add a second RPi running a different C program. I would like to subscribe to and publish through the existing broker (unless there is another way).

My problem is the broker is created on the first computer using:
void createMosquitto(){
	mosquitto_lib_init();
	mosq = mosquitto_new("345Mz",true,NULL);
	mosquitto_loop_start(mosq);
	mosquitto_connect_async(mosq,MQTT_Host,MQTT_Port,60);
	}


which gives me mosq to use in publish and subscribe functions:
mosquitto_publish(mosq,NULL,Topic,strlen(action),action,2,false);


All of this is done on the first computer.
If I want to publish from the second computer I need mosq for the publish function above. How can I get the second computer the value of mosq for the broker on the first computer.

I feel like I have everything set up because I can open terminal windows on the RPi and the PC and subscribe and publish back and forth.


I'm not going to live long enough to do all I want to do.
Previous Topic:[Student] Will my simple scalable IoT platform work?
Next Topic:Blank Client ID - Auto ID?
Goto Forum:
  


Current Time: Fri Apr 26 17:00:12 GMT 2024

Powered by FUDForum. Page generated in 0.02930 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top