uholeschak / ediabaslib

.NET BMW and VAG Ediabas interpreter library
GNU General Public License v3.0
653 stars 159 forks source link

Connect to ESP8266 Deep OBD ELM327 through local network #169

Closed shar34 closed 7 months ago

shar34 commented 7 months ago

I have Android multimedia with USB WiFi modem connected and connected Deep OBD ESP8266 adapter to modem network. I can ping adapter through local network, but in application button "Connect" not available until I connect to a WiFi network or turn on the access point, after this (enable access point for example), button get available and I can connect to adapter with IP address in usb0 local network (no matter if there any clients connected to access point or not):

console:/ # ifconfig usb0
usb0      Link encap:Ethernet  HWaddr 6e:29:65:dd:24:bb  Driver cdc_ether
          inet addr:192.168.1.200  Bcast:192.168.1.255  Mask:255.255.255.0 
          inet6 addr: fe80::6c29:65ff:fedd:24bb/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1494 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:1458 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:135804 TX bytes:139198 

console:/ # ping 192.168.1.34 # <- Deep OBD address in usb0 local network
PING 192.168.1.34 (192.168.1.34) 56(84) bytes of data.
64 bytes from 192.168.1.34: icmp_seq=1 ttl=128 time=227 ms
64 bytes from 192.168.1.34: icmp_seq=2 ttl=128 time=45.3 ms
64 bytes from 192.168.1.34: icmp_seq=3 ttl=128 time=67.6 ms
64 bytes from 192.168.1.34: icmp_seq=4 ttl=128 time=88.9 ms
64 bytes from 192.168.1.34: icmp_seq=5 ttl=128 time=2.66 ms
64 bytes from 192.168.1.34: icmp_seq=6 ttl=128 time=2.74 ms

Is possible to make "Connect" button available with no WiFi or AP on (maybe add some "force" or "local network" options in settings)? thanks.

uholeschak commented 7 months ago

You could enter a manual IP address in the ENET IP dialog field. This is only possible if the adapter is an ENET adapter.

shar34 commented 7 months ago

With no WiFi or AP enable this settings not available (I have Deep OBD ELM327 adapter with ESP8266 for E-series).

uholeschak commented 7 months ago

If you select the Deep OBD WIFI adapter type you could also enter an adapter ip manually. Hotspot mode is also detected.

uholeschak commented 7 months ago

LAN connection has many problems and should not be used.

shar34 commented 7 months ago

screen1 screen2

But adapter connected at this moment.

shar34 commented 7 months ago

screen4 Just enable access point and I can connect to adapter in LAN network.

uholeschak commented 7 months ago

So it is solved? Are us using hotspot mode now?

shar34 commented 7 months ago

I want connect to adapter without enable WiFi or hotstop, but without, button "Connect" disabled :(

uholeschak commented 7 months ago

What is the problem? Simply enable WiFi. Only one click. This is a singular problem only required for one person. Would you pay for a global option in the settings to disable WiFi check?

shar34 commented 7 months ago

Problem with android auto, when connect phone, it automatically enable\disable WiFi and hotstop, in this case, adapter get disconnected, and even enable WiFi and not connect to WiFi network, button still disabled. I love this app and I've been wanting to send a donation for a long time, but unfortunately I can't do it through PayPal.

uholeschak commented 7 months ago

The question is, if connected to android auto is the routing is still working? The problem is, that the data is bound to an interface connection type so it may fail anyway.

shar34 commented 7 months ago

Yes, check now, I can connect to adapter while android auto connection working.

uholeschak commented 7 months ago

Ok so a global option to disable the "WiFi is enabled" check would be sufficient?

shar34 commented 7 months ago

Yes, thanks very much. I'll try to found someone who has euro card to send donation through PayPal.

shar34 commented 7 months ago

It's seems like donation send successful (around 20-21 euro). Thanks for the quick replies and help.

uholeschak commented 7 months ago

Thanks, maybe I could also detect if the specified IP matches a valid Ethernet connection. Similar code must exist for the ENET interface.

uholeschak commented 7 months ago

I have now uploaded a new beta active with: https://play.google.com/apps/testing/de.holeschak.bmw_deep_obd In this version the local Ethernet interface is detected in DeepOBDWifi mode. If you set an adapter IP address and it matches the subnet of the Ethernet interface, then the button is enabled. The check for a valid adapter is also disabled in this mode.

shar34 commented 7 months ago

In last beta version buttons still disabled ("Connect" button too), but adapter connected to local 'usb0' network. screen5

uholeschak commented 7 months ago

As described, the important point is that the network adapter is configured correctly with a subnet and the selected ip address is inside the range of the subnet. In the edit dialog for the ip address the adapter and the subnet is displayed, if WiFi is off. The adapter could be configured in the android settings. Do not use DHCP! Specify the adapter ip and a subnet there.

shar34 commented 7 months ago
127|console:/ # ifconfig usb0 
usb0      Link encap:Ethernet  HWaddr 36:20:56:28:26:3c  Driver cdc_ether
          inet addr:192.168.1.200  Bcast:192.168.1.255  Mask:255.255.255.0 
          inet6 addr: fe80::3420:56ff:fe28:263c/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2570 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:2782 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:250410 TX bytes:263554 

console:/ # ip route
192.168.1.0/24 dev usb0 proto kernel scope link src 192.168.1.200 
console:/ # ping 192.168.1.34 
PING 192.168.1.34 (192.168.1.34) 56(84) bytes of data.
64 bytes from 192.168.1.34: icmp_seq=1 ttl=128 time=2.85 ms
64 bytes from 192.168.1.34: icmp_seq=2 ttl=128 time=2.59 ms
^C
--- 192.168.1.34 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 2.592/2.722/2.853/0.140 ms
console:/ #

On Android headunit I set 'usb0' interface to static 192.168.1.200 address (192.168.1.1, 255.255.255.0). Adapter also set to static address - 192.168.1.34. And I can get adapter settings from browser. Maybe DeepOBD application not see this 'usb0' local interface? In standard Android settings I do not see this interface.

uholeschak commented 7 months ago

The adapter must official visible in android. It has to be a valid official ethernet adapter. There must a Ethernet configuration page in the android system settings. What is displayed in the edit dialog for the ip address? Is there adapter ip and subnet displayed (screenshot)? If you attach the adapter a configuration popup hint should appear in android. I think ethernet adapters should have name ethx and not usbx.

shar34 commented 7 months ago

This network interface is missing in the Android system settings. No, not any notifications while plug, I do manually bring up and set address from terminal and can access devices in this local network. screenshot

uholeschak commented 7 months ago

So this means in the ip edit dialog of the app no adapter information is displayed? This means in Android not bind network is existing. Then this is more an accident that it's working.

shar34 commented 7 months ago

Yes, I don't know why it's working too :)

uholeschak commented 7 months ago

Could you make a screenshot of the ip edit dialog in the app (WiFi off)?

shar34 commented 7 months ago

Edit dialog is disabled when WiFi off. screenshot2

uholeschak commented 7 months ago

I mean the window if you select "Adapter IP" in the menu. This is only enabled if a valid ethernet adapter is present ... If you enable WiFi it will get enabled, but then you see the WiFi adapter configuration in the dialog. Insert a standard USB Ethernet adapter and connect it to a network. Then you see how it should work.

shar34 commented 7 months ago

Connected standard USB Ethernet adapter and connect to some router, 'eth0' configured automatically (I don't execute any commands in terminal), new icon appear in status bar, but still no any ethernet adapters in android system settings and edit IP in DeepOBD still disabled. screenshot7

uholeschak commented 7 months ago

If you have custom rom they may have removed Ethernet support in Android because it's not required ... If you use a smartphone and attach an Ethernet adapter, an icons in the toolbar appears to configure the adapter. If you click this item you get into the android system settings for the adapter and could specify the ip address. For such a special edge case I could only make a hidden configuration file that you have put manually in the apps folder.

shar34 commented 7 months ago

Any solutions (the easiest to implement in code) to make "Connect" button enabled without WiFi/Hotspot/Ethernet will works, all other buttons, like edit ip, need only one time when firstly configuring.

uholeschak commented 7 months ago

And the check if a valid adapter is connected must be disabled ... I am not sure what happens if Android has not official network connection. Maybe you have to add another "dummy" adapter to enable network communication.

uholeschak commented 7 months ago

I have published a new beta, it requires some time to update. In the global settings to go export configuration. The file location is displayed. In this file change the XML node DisableNetworkCheck at the end of the file to true. Then use import configuration in the global settings. Afterwarts the button and the menu entry should be always enabled.