You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by chihi asma <ch...@yahoo.fr> on 2009/10/28 15:57:04 UTC
Invoking UPnP actions
Hi,
I have an UPnP Control point that detects very well UPnP devices and for the need of my application I have to implement another bundle that can invoke a UPnP device's actions,
Can anyone tell me which is the best method to do that? How can I invoke actions from another bundle than the control point?
Thanks in advance for your help.
Asma
Re: Invoking UPnP actions
Posted by Francesco Furfari <fr...@isti.cnr.it>.
Hello Asma,
more or less your bundle should:
1) Search for the UPnPDevice service that matches your device
String myFilter = "(" + UPnPDevice.ID + "="+ aDeviceId + ")";
ServiceReference[] refs =
context.getServiceReferences(UPnPDevice.class.getName(),myFilter );
if (refs != null) {
UPnPDevice myDevice = (UPnPDevice) context.getService(refs[0]);
}
there are different way to do it .... by deviceID, by deviceType, by
services and so on, and remember you may have different matches.
2) Retrieve the UPnPAction object from the UPnPDevice object:
UPnPAction myAction =
myDevice.getService(aServiceId).getAction(aActionName);
3) Invoke the action by passing the right parameters
myDictionary = new Hashtable();
myDictionary.add("parameterName1", value);
myDictionary.add("parameterName2", value);
result = myAction.invoke(myDictionary);
... parse dictionary result if any
the above snippets supposes the UPnP device is already running and
discovered by the UPnPBase driver. In case your bundle is installed
before of the device, you need to register a ServiceListener to be
notified when the UPnP device is plugged on the network.
regards,
francesco
chihi asma wrote:
> Hi,
>
> I have an UPnP Control point that detects very well UPnP devices and for the need of my application I have to implement another bundle that can invoke a UPnP device's actions,
> Can anyone tell me which is the best method to do that? How can I invoke actions from another bundle than the control point?
> Thanks in advance for your help.
>
> Asma
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org