Need help on networkAddressService [message #1798697] |
Thu, 22 November 2018 19:20  |
Eclipse User |
|
|
|
I need some help to integrate the NetworkAddressService to get the primary IP.
Preparation in the Code:
```
import org.eclipse.smarthome.core.net.NetworkAddressService;
Class:
private NetworkAddressService networkAddressService;
Code inside the ThingFactoryClass class (tried also others):
@Reference
protected void setNetworkAddressService(NetworkAddressService networkAddressService) {
this.networkAddressService = networkAddressService;
}
protected void unsetNetworkAddressService(NetworkAddressService networkAddressService) {
this.networkAddressService = null;
}
Usage:
networkAddressService.getPrimaryIpv4HostAddress()
```
Sounds easy, but the problem is that the setNetworkAddressService() is never called. The binding gets loaded, but I reach never the breakpoint I set on the routine.
I checked OSGI-INF/ThingFactory.xml
```
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="..." activate="activate" configuration-pid="telekomtv" immediate="true" name="org.openhab.binding.telekomtv.internal.TelekomTVHandlerFactory">
<service servicefactory="false">
<provide interface="org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory"/>
<provide interface="org.openhab.binding.telekomtv.internal.TelekomTVHandlerFactory"/>
</service>
<reference bind="setNetworkAddressService" interface="org.eclipse.smarthome.core.net.NetworkAddressService" name="NetworkAddressService" unbind="unsetNetworkAddressService"/>
<implementation class="org.openhab.binding.telekomtv.internal.TelekomTVHandlerFactory"/>
</scr:component>
```
so the @Reference works. Otherwise Eclipse told me that this is not a public interface.
Is it correct that I need to add a rule to the Java Build Path to get access to
I checked out ESH API Reference->NetworkAddressService documentation, but it does not contain no information how integrate the class. Need some help.
|
|
|
|
Re: Need help on networkAddressService [message #1798772 is a reply to message #1798756] |
Fri, 23 November 2018 18:55   |
Eclipse User |
|
|
|
Hi Kai, this did the magic. Thanks!!
When I'm going to implement UpnpIOParticipant and add
import org.eclipse.smarthome.io.transport.upnp.UpnpIOParticipant;
import org.eclipse.smarthome.io.transport.upnp.UpnpIOService;
@Override
public void onValueReceived(String variable, String value, String service) {}
Eclipse shows the following error:
Multiple markers at this line
- Illegal redefinition of parameter variable, inherited method from UpnpIOParticipant does not constrain this parameter
- Illegal redefinition of parameter value, inherited method from UpnpIOParticipant does not constrain this parameter
- Illegal redefinition of parameter service, inherited method from UpnpIOParticipant does not constrain this parameter
- implements org.eclipse.smarthome.io.transport.upnp.UpnpIOParticipant.onValueReceived
However, declaration of UpnpIOParticipant contains
/** Called when the UPNP IO service receives a {variable,value} tuple for the given UPNP service **/
public void onValueReceived(String variable, String value, String service);
so exactly like my implementation.
onServiceSubscribed same - Eclipse reports errors on String
whereas onStatusChanged is accepted, because it contains no String parameters.
Any magic hint?
|
|
|
|
Powered by
FUDForum. Page generated in 0.14032 seconds