React Native (with Expo Go): get wifi and mobile networks signal strength

413 Views Asked by At

I have started learning React Native and one of my first goal is to display the wifi and mobile network signal strength in dBm.

I have tried multiple packages but could not find signal strength.

I have for example:

import React, { useState, useEffect } from 'react';
import { Text, View } from 'react-native';
import NetInfo from '@react-native-community/netinfo';

const App = () => {
const [wifiStrength, setWifiStrength] = useState(null);


useEffect(() => {
    const interval = setInterval(() => {
    NetInfo.fetch().then(state => {
    console.log("Type ", state);
    console.log("Details", state.details);
    setWifiStrength(state.details.strength);
  });  

}, 10000);

   return () => clearInterval(interval);
}, []);

return (
<View>
  <Text>Wifi signal strength: {wifiStrength}</Text>
  <Text>Mobile network signal strength: XX dBm</Text>
 
</View>
 );
 };

export default App;

I get the following output in the console:

Type  {"details": {"bssid": "02:00:00:00:00:00", "frequency": 5220, "ipAddress": "192.168.1.88", "isConnectionExpensive": false, "linkSpeed": 866, "rxLinkSpeed": 585, "strength": 99, "subnet": "255.255.255.0", "txLinkSpeed": 866}, "isConnected": true, "isInternetReachable": true, "isWifiEnabled": true, "type": "wifi"}

Details {"bssid": "02:00:00:00:00:00", "frequency": 5220, "ipAddress": "192.168.1.88", "isConnectionExpensive": false, "linkSpeed": 866, "rxLinkSpeed": 585, "strength": 99, "subnet": "255.255.255.0", "txLinkSpeed": 866}

There is a field for strenght but it's not the signal strength in dBm.

My questions:

  • how can I get the signal strength in dBm?
  • how can I get network information from the mobile network? Netinfo doesn't tell me anything about it

Thanks!

0

There are 0 best solutions below