跳到主要内容
安卓主板 · 触摸显示屏 · 固件 — 始于 2013 年

Network

Static methodsBroadcast — returns void

Configure the Ethernet interface and the Wi-Fi hotspot from code. Handy for provisioning a fleet to fixed addresses without touching each device's settings UI.

Static IP​

public static void setStaticIp(
Context context,
String ipAddr, // "192.168.1.50"
String gateway, // "192.168.1.1"
String netMask, // "255.255.255.0"
String dns1, // "8.8.8.8"
String dns2) // "1.1.1.1"
ItempApiPub.setStaticIp(context,
"192.168.1.50", "192.168.1.1", "255.255.255.0",
"8.8.8.8", "1.1.1.1");

Switching static / DHCP​

public static void switchStaticAndDhcp(Context context, String value)
// intended: ItempApiPub.ETHERNET_DHCP ("0") or ETHERNET_STATIC ("1")
Choosing DHCP explicitly

To select the mode directly, send the broadcast yourself and pass the mode through the static_dhcp extra:

Intent intent = new Intent("com.itemp.adb.switch.static.ip");
intent.putExtra("static_dhcp", ItempApiPub.ETHERNET_DHCP); // "0" = DHCP
context.sendBroadcast(intent);

Constants: ETHERNET_DHCP = "0", ETHERNET_STATIC = "1". The exact behaviour of the switchStaticAndDhcp(context, value) helper is being confirmed — use the direct broadcast above when you need DHCP specifically.

Typical order when provisioning: set the static details, then switch the mode.

ItempApiPub.setStaticIp(context, "192.168.1.50", "192.168.1.1",
"255.255.255.0", "8.8.8.8", "1.1.1.1");

Intent toStatic = new Intent("com.itemp.adb.switch.static.ip");
toStatic.putExtra("static_dhcp", ItempApiPub.ETHERNET_STATIC);
context.sendBroadcast(toStatic);

Wi-Fi hotspot​

Start an access point:

public void startWifiAp(
Context context,
String ssid,
String password,
String ipAddress, // static AP IP, e.g. "192.168.43.1"; null/empty = dynamic
boolean isHideSsid)
new ItempApiPub().startWifiAp(context,
"ITP-Setup", "a-strong-password", "192.168.43.1", false);

Stop it:

public void stopWifiAp(Context context)
These two are instance methods

startWifiAp and stopWifiAp are not static in the reference source — call them on an ItempApiPub instance, unlike the rest of this API. The band is fixed to 5 GHz in the current firmware; the 2.4 GHz option is present in the source but disabled.

Notes​

Static IP is applied asynchronously. The call returns before the interface reconfigures. If you are on that interface (e.g. over ADB), expect the connection to drop and come back on the new address.

An invalid IP silently falls back. Passing a malformed or empty ipAddress to the hotspot makes it dynamic rather than failing — double-check the string.

  • System time — NTP needs a working network
  • Debug — network ADB for remote access