Skip to content

Commit 43ea9a8

Browse files
committed
add DHCP Server Adress and npm version
1 parent 7c40a50 commit 43ea9a8

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ wifi.getIP((ip) => {
151151
console.log(ip);
152152
});
153153
```
154+
Get DHCP Server Adress
155+
```javascript
156+
//get the DHCP server IP
157+
wifi.getDhcpServerAddress((ip) => {
158+
console.log(ip);
159+
});
160+
```
154161

155162
Remove/Forget the Wifi network from mobile by SSID, returns boolean
156163
This method will remove the wifi network as per the passed SSID from the device list.

android/src/main/java/com/devstepbcn/wifi/AndroidWifiModule.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,13 @@ public void reScanAndLoadWifiList(Callback successCallback, Callback errorCallba
364364
wifi.startScan();
365365
}
366366

367+
@ReactMethod
368+
public void getDhcpServerAddress(Callback callback) {
369+
DhcpInfo dhcpInfo = wifi.getDhcpInfo();
370+
String ip = longToIP(dhcpInfo.serverAddress);
371+
callback.invoke(ip);
372+
}
373+
367374
public static String longToIP(int longIp){
368375
StringBuffer sb = new StringBuffer("");
369376
String[] strip=new String[4];
@@ -408,7 +415,7 @@ public WifiReceiver(final WifiManager wifi, Callback successCallback, Callback e
408415
public void onReceive(Context c, Intent intent) {
409416

410417
c.unregisterReceiver(this);
411-
418+
412419
try {
413420
List < ScanResult > results = this.wifi.getScanResults();
414421
JSONArray wifiArray = new JSONArray();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-android-wifi",
3-
"version": "0.0.32",
3+
"version": "0.0.33",
44
"description": "A react-native implementation for viewing and connecting to Wifi networks on Android devices.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)