Making Ethernet work on Android – Jetson TK1
e-con Systems™ till date are the only ones to provide Android Lollipop BSP for Jetson TK1. e-con provides complete support, and expert consulting regarding Android and NVIDIA Jetson.
Android normally supports Wi-Fi and 3G for internet/Data connectivity. But Ethernet is the only network interface available in Jetson. Though Android has support for Ethernet with DHCP only option, it won’t work as reliable as Wi-Fi or 3G. Here we are going to see how we can enable Ethernet for DATA connectivity in a reliable way with both DHCP and static IP.
Basically we need to make the Android OS to recognise Ethernet as a proper network connection like Wi-Fi and 3G. The below instructions are not just for Jetson Android, it can be used for any Android device with an Ethernet.
USING SHELL COMMANDS
Access the Shell through ADB or serial port. In this method, we can use network commands for configuring Ethernet directly. Access the shell and execute the following commands.
To set an Static IP and Gateway for the Ethernet Port,
$ busybox ifconfig eth0 <STATIC_IP_ADDR> up
$ busybox route add default gw <GATEWAY_IP_ADDR> eth0
To set DNS,
In Android Versions (< 4.2), DNS Server details would be set as system properties.
$ setprop net.eth0.dns1
$ setprop net.eth0.dns2
These properties became obsolete in the latest Android versions and we need to use following commands to set DNS.
$ ndc resolver flushif eth0
$ ndc resolver flushdefaultif
$ ndc resolver setifdns eth0 <DNS1_IP_ADDR> <DNS2_IP_ADDR>
$ ndc resolver setdefaultif eth0
In case if local DNS Servers are not available, You can make use of Global DNS Servers.
Ex. Google DNS Servers(188.8.131.52 and 184.108.40.206)
$ netcfg eth0 dhcp
DRAWBACKS OF USING SHELL COMMANDS:
- This method is not user friendly as it does not involve any User Interface.
- Android Framework does not recognise Ethernet as a proper network connection. In Android Framework, a separate process called Connectivity Service runs in background which monitors all network connections. With the shell commands the Ethernet configuration will not be intimated to Android service. Hence Android Framework fails to monitor Ethernet Connection. As a result, User would be able to access Internet but cannot make use of other services of framework like Tethering.
Hence we need to integrate Ethernet with Android Framework.
Write your own GUI Application
In General, AOSP does not contain any Ethernet Application. But it has support for Ethernet connection [DHCP only] in its frameworks which is not exposed to the Settings. Hence we can write our own application that can utilise this support for integrating Ethernet to Android Frameworks. Android Frameworks provides EthernetDataTracker which monitors the activity of Ethernet Connection. Whenever an Ethernet cable is connected, it automatically performs DHCP operation and updates Connectivity Service.
If Static IP Ethernet Support is required, then we need to notify this EthernetDataTracker about the Static IP Configuration Details.
NAME OF THE FILE : EthernetDataTracker.java
LOCATION : frameworks/base/core/java/android/net
EthernetDataTracker comes into play whenever an Ethernet cable is connected or disconnected. Within it, a thread runDhcp() runs continuously. When DHCP operation completes successfully, Linkproperties is filled and then Connectivity Service is updated.
If you wish to add Static IP Ethernet Support, then you need to modify this EthernetDataTracker.
Sample Code for Ethernet Application
Within Android Application, Get Ethernet IP information from the User and set them as system properties. Then call Network Management Service.
mNMService.setInterfaceDown(eth0); // This notifies EthernetDataTracker. Also makes the DHCP operation more reliable.
Under EthernetDataTracker, Get these System properties and update the LinkProperties object.
mLinkProperties.addLinkAddress(new LinkAddress(NetworkUtils.numericToInetAddress(SystemProperties.get(“net.eth0.ip”, “”)), 24));
If you are interested in Android support for Jetson Tegra K1 kit write to us at email@example.com or visit our page here.