PipeConnection example | Thales IoT Developer Community
October 5, 2015 - 7:40am, 3691 views
Hi,
Can someone please share some sample code on how to use the PipeConnection for Inter-MIDlet communication?
From the IMP-NG documentation, I can see that the two methods available are getName() and getVersion(). If that is true, then how can we send data from one MIDlet to another.
I also see that we can use only wildcards (*). How will we specify a particular MIDlet or process?
Thanks,
SRN7
Hello,
You can use PipeConnection in a similar way you use the socket connections (you can find examples for sockets in the API).
Just use the PipeConnection and PipeServerConnection interfaces and the connection name appropriate for pipe connections.
You have to use a wildcard instead of MIDlet name but you can specify the name and version of the connection. So if you setup a server in another MIDlet with the address pipe://:my_pipe:1.0; you will be able to connect to it using this address pipe://*:my_pipe:1.0; on a client side.
Best regards,
Bartłomiej
Hi Bartłomiej,
Thank you for your reply. It was of great help in removing a few confusions I had. I am now able to establish communication between two MIDlets.
Thanks,
SRN7
Is there any working example out there ? Tried to change the socket example with "PipeServerConnection", but always get "java.lang.IllegalArgumentException: Malformed server protocol name" from the Connector with the following URL string: "pipe://:my_pipe:1.0".
Some useful hints to get around this or where I'm wrong ?
Thanks i.adv. and regards,
Eaglecode
Hello EAGLECODE,
It seems that you have forgotten to add the semicolon in the end of the address string as it is shown in the API.
Maybe you have just copied it form my post where I also had forgotten to add it (it's already corrected). SRN7 probably also didn't notice that mistake.
I'm sorry for that. Now you should have no problems with establishing the connection.
Regards,
Bartłomiej
Hi Bartłomiej,
thanks! That's it - works like a charm now.
cheers,
eaglecode