[SOLVED] Presence with Android after using Iphone

Rules engine produces/can consume a json based template I believe. That makes it primarility a UI only programming language. I am afraid it can go only so far as simple-to-medium use cases. We still need a solid/modern scripting language that can be used by people to produce cool apps for this platform. I think Apple also has a modern scripting language on top of native app programming lang Objective-C.
The platform artifacts / events should be exposed to app developer via this scripting glue layer, and the app must be having permission (granted by user at install/update time) to sniff those events. Its a lot of design and coding work I know. But it will be cool. Maybe the Kotlin work that I am planning can trigger some excitement on this.

Sorry for going off-topic here, guys.

BTW I feel we should also “humbly” ask arping developer Mr. Thomas Habets thomas@habets.se to keep backwards compatibility in terms of help output (that we use to determine tool capabilities), and to not change meaning of a parm like -w to mean micro-secs instead of secs in future. Otherwise we will need to maintain and distribute our own copy of tool to ensure no surprises like this occur in future when openhabian gets a new raspbian-lite core and Mr. Thomas Habets changed output formats.

FTR Binding jar 2.3.0 and source is also copied here on github

Google Drive seems not to work with wget easily

Will create PR once @grhosso and I work things out on his setup. The fixes already improved reliability on my setup with Android 5 and 7 devices.

Things pending before PR is filed

  • introduce randomness to avoid / minimise parallel invoks of arping tool
  • fix any other issues that come up with @grhosso setup
  • extract latency from arping STDOUT
  • code analysis compliance
  • fast forward from 2.3.0 to 2.4.0-SNAPSHOT (master)
2 Likes

Thank to everybody and specially to @diyha , NOW IS WORKING :smiley:

My steps:

  1. Static ARP added in /etc/ethers
  2. Static IP setup.
  3. Unistalled binding
  4. Installed new binding from the repo above.
  5. NOW I CAN SEE the phone in INBOX and I have added as new Thing.
  6. I have setup param in the Thing with at least 3 retry, Refresh interval 60000, Timeout 5000.
  7. Network.cfg filed modified according to diyha indications.

I switch on off the wifi in the phone, and is detected properly.

2018-08-23 17:43:12.763 [vent.ItemStateChangedEvent] - Iphone_Sw changed from ON to OFF
2018-08-23 17:44:13.142 [vent.ItemStateChangedEvent] - Iphone_Sw changed from OFF to ON
2018-08-23 17:44:13.161 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_2_160' has been updated.
2018-08-23 17:46:18.875 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_2_160' has been updated.
2018-08-23 17:48:28.917 [vent.ItemStateChangedEvent] - Iphone_Sw changed from ON to OFF
2018-08-23 17:49:29.031 [vent.ItemStateChangedEvent] - Iphone_Sw changed from OFF to ON
2018-08-23 17:49:29.053 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_2_160' has been updated.
2 Likes

I am still skeptical about all flavors of Androids, would request users to test this fixed binding, make sure you set mac parameter in thing config to your Android’s wifi mac. See if binding reports device offline after few minutes or few hours, even when Android device is set to keep wifi on when locked.
There might be extra-smarts on some Androids that turn network stack off completely after couple of hours, I have seen this on Android 5 phone, it does cut off wifi after 10 hours of locked state.
Reliable presence detection still remains an active battle. :slight_smile:

Well, yesterday I tested the binding works fine when I get ON OFF properly but after a 5-8 minutes, goes OFF automatically even with Android setup with keep wifi on when locked, and device still connected in wifi.

2018-08-23 18:13:34.635 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_2_160' has been updated.
2018-08-23 18:15:44.659 [vent.ItemStateChangedEvent] - Iphone_Sw changed from ON to OFF
2018-08-23 18:16:44.791 [vent.ItemStateChangedEvent] - Iphone_Sw changed from OFF to ON
2018-08-23 18:16:44.797 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_2_160' has been updated.
2018-08-23 18:20:51.751 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_2_160' has been updated.
2018-08-23 18:23:01.776 [vent.ItemStateChangedEvent] - Iphone_Sw changed from ON to OFF
2018-08-23 18:30:32.916 [vent.ItemStateChangedEvent] - Iphone_Sw changed from OFF to ON
2018-08-23 18:30:32.937 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_2_160' has been updated.

In red was automatically OFF when actually phone was conencted, screen locked and slept.
Then I click on the phone in order to wake up the screen and I got quickly ON.

However, I think I could work with rules while is solved this little issue (I guess). I could create a rule that says, if door has not been open and device goes OFF, this is a false OFF, so turn ON again, or something like that. Using a Timer or something.

You can try new build with more verbose logs, we will see what arping is doing

https://github.com/asvilabs/esh-oh-legacy/blob/master/org.openhab.binding.network-2.3.0.jar?raw=true

It is the same version that I have, 2.3.0

the number is same, but build is different. temporarily enabled some logs for debugging purpose, at INFO level.
You can drop new file over old file in openhab addons folder.

:laughing: ok thank you. I let you know how is going


Here is the log I have added some comments between [ ] in the log to better understaing my test.

Regards.

2018-08-24 17:03:34.476 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:04:34.538 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:04:34.552 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:04:34.555 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:05:34.648 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:05:34.661 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:05:34.664 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:06:34.756 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:06:34.769 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:06:34.772 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:06:39.730 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_2_160' has been updated.         [TURN OFF WIFI FROM MY PHONE]
2018-08-24 17:07:39.782 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:07:39.797 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:07:39.803 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:08:44.791 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:08:44.804 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:08:44.809 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:08:49.758 [vent.ItemStateChangedEvent] - phone_sw changed from ON to OFF							[DETECTED BY BINDING]
2018-08-24 17:09:49.804 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:09:49.818 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:09:49.823 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:10:54.812 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:10:54.827 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:10:54.831 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:11:59.821 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:11:59.835 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:11:59.838 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:11:59.859 [vent.ItemStateChangedEvent] - phone_sw changed from OFF to ON 							[TURN ON WIFI FROM MY PHONE]
2018-08-24 17:11:59.877 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_2_160' has been updated.
2018-08-24 17:12:59.926 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:12:59.939 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:12:59.943 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response.  [I LOCK THE SCREEN IN ORDER TO GET PHONE SLEEP AND SEE WHAT IS HAPPENNING]
2018-08-24 17:14:00.002 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:14:00.016 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:14:00.020 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:15:00.254 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:15:00.269 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:15:00.274 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:16:00.466 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:16:00.480 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:16:00.484 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:17:01.074 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:17:01.089 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:17:01.095 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:18:01.896 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:18:01.909 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:18:01.914 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:18:06.870 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_2_160' has been updated.			[BINDING DOES NOT DETECT PRESENCE]
2018-08-24 17:19:06.922 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:19:06.937 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:19:06.941 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:20:11.931 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:20:11.947 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:20:11.953 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:20:16.898 [vent.ItemStateChangedEvent] - phone_sw changed from ON to OFF								[BINDING CONFIRMS OFF AND SWITCH OFF, BECAUSE ARPING DOES NOT DETECT PHONE] 
2018-08-24 17:21:16.950 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:21:16.969 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:21:16.973 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:22:21.958 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:22:21.972 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:22:21.975 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response
2018-08-24 17:23:26.967 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:23:26.980 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDERR=arping: libnet_init(LIBNET_LINK, eth0): libnet_open_link(): UID/EUID 0 or capability CAP_NET_RAW required
arping: you may need to run as root
2018-08-24 17:23:26.984 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => no response

Ok. Can you do following?

Login to your OH server, its Linux right?
If yes, do

sudo chmod u+s $(which arping)

Yes, linux.

Let mw know


:+1:
Login as pi or openhabian. On your shell prompt (not karaf), run this command

sudo chmod u+s $(which arping)

And then monitor logs. No need to restart Linux or openHAB or binding.

After type it

sudo chmod u+s $(which arping)

So far, is arping well, I get time response even with phone locked, so far after 10 minutes, I did not have any “false” OFF. I will post tomorrow after some test.

thanks!

2018-08-24 17:53:04.978 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:53:05.860 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDOUT=ARPING 192.168.2.160
60 bytes from <MAC> (192.168.2.160): index=0 time=737.179 msec
2018-08-24 17:53:05.980 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => online
2018-08-24 17:54:06.055 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:54:06.260 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDOUT=ARPING 192.168.2.160
60 bytes from <MAC> (192.168.2.160): index=0 time=77.062 msec
2018-08-24 17:54:06.380 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => online
2018-08-24 17:55:06.474 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:55:07.090 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDOUT=ARPING 192.168.2.160
60 bytes from <MAC> (192.168.2.160): index=0 time=457.160 msec
2018-08-24 17:55:07.230 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => online
2018-08-24 17:55:11.468 [me.event.ThingUpdatedEvent] - Thing 'network:pingdevice:192_168_2_160' has been updated.
2018-08-24 17:56:11.516 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:56:11.680 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDOUT=ARPING 192.168.2.160
60 bytes from <MAC> (192.168.2.160): index=0 time=17.102 msec
2018-08-24 17:56:11.800 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => online
2018-08-24 17:57:16.527 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:57:17.050 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDOUT=ARPING 192.168.2.160
60 bytes from <MAC> (192.168.2.160): index=0 time=377.220 msec
2018-08-24 17:57:17.170 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => online
2018-08-24 17:58:21.538 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:58:22.380 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDOUT=ARPING 192.168.2.160
60 bytes from <MAC> (192.168.2.160): index=0 time=667.275 msec
2018-08-24 17:58:22.500 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => online
2018-08-24 17:59:26.547 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 17:59:27.110 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDOUT=ARPING 192.168.2.160
60 bytes from <MAC> (192.168.2.160): index=0 time=377.270 msec
2018-08-24 17:59:27.230 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => online
2018-08-24 18:00:31.559 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 18:00:31.750 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDOUT=ARPING 192.168.2.160
60 bytes from <MAC> (192.168.2.160): index=0 time=17.219 msec
2018-08-24 18:00:31.870 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => online
2018-08-24 18:01:36.571 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 18:01:37.150 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDOUT=ARPING 192.168.2.160
60 bytes from <MAC> (192.168.2.160): index=0 time=427.066 msec
2018-08-24 18:01:37.270 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => online
2018-08-24 18:02:41.581 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 18:02:41.850 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDOUT=ARPING 192.168.2.160
60 bytes from <MAC> (192.168.2.160): index=0 time=117.220 msec
2018-08-24 18:02:41.970 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => online
2018-08-24 18:04:51.604 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 18:04:52.110 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDOUT=ARPING 192.168.2.160
60 bytes from <MAC> (192.168.2.160): index=0 time=377.237 msec
2018-08-24 18:04:52.230 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => online
2018-08-24 18:05:56.616 [INFO ] [org.openhab.binding.network         ] - Running arping 2.14+ for mac <MAC> ip 192.168.2.160 via eth0
2018-08-24 18:05:57.240 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 STDOUT=ARPING 192.168.2.160
60 bytes from <MAC> (192.168.2.160): index=0 time=477.158 msec
2018-08-24 18:05:57.360 [INFO ] [org.openhab.binding.network         ] - arping 192.168.2.160 via eth0 => online
1 Like

Cool. :+1:
Watch it for 10 hours please. Yours is Android 8, Samsung?

Also, regarding my doubt about concurrent executions causing libnet native errors, it turns out the binding does arping on all available interfaces on host, I happen to have a 4g modem connected to openhabian host besides local LAN. That 4g modem’s eth1 interface was giving that strange native error. So it wasn’t a concurrency issue at libnet level. I removed randomness+locking fixes from latest code.

Will create a PR once I polish the code such that big brothers don’t reject it. :wink:

It is Samsung Galaxy s9+. EDIT: Sorry, yes Android 8.0

Sure, tomorrow I will let you know :wink:

1 Like

This morning I have seen the log and everything worked fine, always got answer from arping. But I am not sure if has been more than 10 hours, so I will have a look today and tomorrow, but it seems that is working good.

:wink:

1 Like

Glad to know its working with Android 8 too.

Here is a summary of important changes that made network binding work for my Android 5 and 7 phones. The PR will contain this summary report:

  • Adapt to new arping version 2.14 in raspbian stretch. Parameter -w [timeout] now means micro-seconds instead of seconds
  • New startegy for sending / receiving and terminating arping. Combine -c and -C options. -c6 -C1 -w5000000 means send upto 6 packets, wait for 5 secs in between each send, return with success immediately after receiving 1 packet. This allows for robustness as well as quick result. Current binding sends only 1 packet which is far too optimistic on busy networks.
  • Introduce -t [MAC] hint to arping. It made my Android phones respond. Only specifying -i [iface] IP doesn’t always work. Not all phones respond to broadcast ARP who-has-ip queries in low power state, but apparently they do respond to queries targeted at their MAC.
  • Extract latency information from arping output, optionally.
  • Pipe in STDERR of arping and print it in OH logs, that helps identifying installation issues (especially setuid), illegal argument issues (due to version upgrades), or any other issues.
  • Try to determine success from arping STDOUT and then fallback to exit code.

This may be a little outside the scope but I know I and the other Docker users would appreciate it if you too a look to see whether the latest arping is being included in the Docker images and advise what we may need to do if it isn’t re these changes. Obviously it isn’t a big deal until these changes get merged.