Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Kura » Raspberry pi B, kura, mqtt(Send mqtt messages from Kura)
Raspberry pi B, kura, mqtt [message #1777063] Fri, 24 November 2017 09:06 Go to next message
Javier A. is currently offline Javier A.Friend
Messages: 10
Registered: November 2017
Junior Member
Good morning, I have a raspberry pi with kura installed and for other hand my computer with "mosquitto" (a mqtt broker). I´m tryng to send a mqtt message from my raspberry to mosquitto, the problem is:
-To test how works mqtt, i write a simple example in java with eclipse to send a mqtt msg.
    try {
    	System.out.println(1);
	    MqttClient client = new MqttClient("tcp://192.168.0.116:1883", 
            MqttClient.generateClientId());
	    client.connect();
    	    System.out.println(2);
	    MqttMessage message = new MqttMessage();
	    message.setPayload(messageString.getBytes());
	    client.publish("test", message);
	
	    System.out.println("\tMessage '"+ messageString +"' to 'test'");
	
	    client.disconnect();
	
	    System.out.println("== END PUBLISHER ==");
    }catch(Exception e){
    	System.out.println(e.getMessage());
    }

And it works, in mosquitto i can see the msg.

I write helloword example follow doc (tested and works show msg in kura-console), now with this example I wanted to test send mqtt msg with kura. I configure kura project, export *.jar, generate *.dp and install it using kura interface and all good, without errors.
protected void activate(ComponentContext componentContext) {
    	
    	System.out.println("Start: Hello World");    	
    	
    	try {
    		String messageString = "Hello World from Java!";
        	System.out.println(1);
    	    MqttClient client = new MqttClient("tcp://192.168.0.93:1883", MqttClient.generateClientId());
    	    client.connect();
        	System.out.println(2);
    	    MqttMessage message = new MqttMessage();
    	    message.setPayload(messageString.getBytes());
    	    client.publish("test", message);
    	
    	    System.out.println("\tMessage '"+ messageString +"' to 'test'");
    	
    	    client.disconnect();
    	
    	    System.out.println("== END PUBLISHER ==");
        }catch(Exception e){
        	System.out.println(e.getMessage());
       }
    }

    protected void deactivate(ComponentContext componentContext) {

    	System.out.println("Stop: Hello World");
    	
        s_logger.info("Bundle " + APP_ID + " has stopped!");
    }

But when I go to "Kura->Devices->Bundles" the state is "Installed"instead of "Active" and when I try to start it, show an error
index.php/fa/31384/0/
index.php/fa/31385/0/

Someone has some idea about how can I solve this or how have I to do to send mqtt msg from Kura to mosquito.

All help is wellcome.

Thank.
  • Attachment: error.jpg
    (Size: 22.50KB, Downloaded 351 times)
  • Attachment: error log.jpg
    (Size: 54.06KB, Downloaded 359 times)
Re: Raspberry pi B, kura, mqtt [message #1777296 is a reply to message #1777063] Tue, 28 November 2017 09:05 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 279
Registered: July 2015
Location: Italy
Senior Member
Hi,
I believe you have to wrap paho in your bundle.
As stated in the console, that dependency is missing.

Best regards,
Matteo
Re: Raspberry pi B, kura, mqtt [message #1777753 is a reply to message #1777296] Mon, 04 December 2017 09:27 Go to previous message
Javier A. is currently offline Javier A.Friend
Messages: 10
Registered: November 2017
Junior Member
I have added paho library in the manifest "org.eclipse.paho.client.mqttv3;version="1.1.0"".

Matteo Maiero wrote on Tue, 28 November 2017 09:05
Hi,
I believe you have to wrap paho in your bundle.
As stated in the console, that dependency is missing.

Best regards,
Matteo

Previous Topic:Can Protocol
Next Topic:Simulator for S7
Goto Forum:
  


Current Time: Sun Nov 18 06:40:29 GMT 2018

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

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

Back to the top