Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse SmartHome » Need help on networkAddressService(Integrating networkAddressService)
Need help on networkAddressService [message #1798697] Fri, 23 November 2018 00:20 Go to next message
Markus Michels is currently offline Markus MichelsFriend
Messages: 4
Registered: November 2018
Junior Member
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 #1798756 is a reply to message #1798697] Fri, 23 November 2018 15:46 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
> Is it correct that I need to add a rule to the Java Build Path to get access to

No, you need to import the package org.eclipse.smarthome.core.net in your MANIFEST.MF. Is this maybe the missing piece of the puzzle?
Re: Need help on networkAddressService [message #1798772 is a reply to message #1798756] Fri, 23 November 2018 23:55 Go to previous messageGo to next message
Markus Michels is currently offline Markus MichelsFriend
Messages: 4
Registered: November 2018
Junior Member
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?
Re: Need help on networkAddressService [message #1798773 is a reply to message #1798772] Sat, 24 November 2018 00:04 Go to previous message
Markus Michels is currently offline Markus MichelsFriend
Messages: 4
Registered: November 2018
Junior Member
ok, I found it myself:

the class had a @NonNullByDefault, which I now removed
Previous Topic:SSE(Server Sent Events) not working through domain name URL
Next Topic:rxtx + Gnu.io problem
Goto Forum:
  


Current Time: Sun Feb 23 21:26:24 GMT 2020

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

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

Back to the top