hi,JayTu:
我試過可以執行得起來產生出一個黃底的ethernet APK圖示,執行它後卻發現無法正確地取得ip,故此demo(sample) code似乎是不太能在imx6q的板子上動作,有點奇怪,是否跟我在build code時用 lunch sabresd_6dq-user有關,是否此sample code不能在user下執行呢?
再請教您sample code中ip是用
SystemProperties.set("net." + info.getIfName() + ".ip", info.getIpAddress()); 回存
跟下面紅字那行在設定IP
void configureInterface(EthernetDevInfo info) {
.....
} else {
InterfaceConfiguration ifcg = null;
Log.d(TAG, "Static IP =" + info.getIpAddress());
try {
ifcg = mNMService.getInterfaceConfig(info.getIfName());
ifcg.setLinkAddress(new LinkAddress(NetworkUtils.numericToInetAddress(info.getIpAddress()), 24));
ifcg.setInterfaceUp();
mNMService.setInterfaceConfig(info.getIfName(), ifcg);
Log.d(TAG,"Static IP configuration succeeded");
} catch (RemoteException re){
Log.e(TAG,"Static IP configuration failed: " + re);
} catch (IllegalStateException e) {
Log.e(TAG,"Static IP configuration fialed: " + e);
}
....
那我應該用那種方式才能真正改變系統的IP 讓ifconfig eth0 這個指令能查到新設定的靜態IP(因為SystemProperties似乎沒辦法真正改變IP設定)?
而我看過這幾支sample code後並未發現有回存 gateway跟 subnetmask故這兩項又要如何回存系統內呢?
不然利用
ifconfig eth0 -->eth0的ip跟subnetmask
ip route show -->eth0的gateway ip
抓取IP、subnetmask、gateway時會發現靜態IP所設定的值沒被改變回系統,所以不知該如何才能做到呢?
再麻煩您幫幫忙了,感謝您。
感恩!!!