question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

All devices scanned have name equals to null

See original GitHub issue

Expected Behavior

Scanning devices should return a name in order to understand which device is which.

Current Behavior

Scanning devices return objects with name and localName equals null:

Device {
    id : "2C:F0:EE:19:27:CF"
    isConnectable : null 
    localName : null
    manufacturerData : "TAAQBQsUluNJ"
    mtu : 23
    name : null
    overflowServiceUUIDs : null
    rssi : -62 
    serviceData : null 
    serviceUUIDs : null 
    solicitedServiceUUIDs : null 
    txPowerLevel : null
    _manager : BleManager
    __proto__ : Object
}

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions. Both JS and platform logs can be enabled via setLogLevel function call.

  • Library version: 1.0.3
  • Platform: currently tested only in Android
  • Contents of the package.json file:
  "dependencies": {
    "react": "16.8.3",
    "react-native": "0.59.8",
    "react-native-ble-plx": "^1.0.3",
    "react-native-gesture-handler": "^1.3.0",
    "react-navigation": "^3.11.0"
  },
  "devDependencies": {
    "@babel/core": "^7.4.5",
    "@babel/runtime": "^7.4.5",
    "babel-jest": "^24.8.0",
    "jest": "^24.8.0",
    "metro-react-native-babel-preset": "^0.54.1",
    "react-test-renderer": "16.8.3"
  },
  • Formatted code sample or link to a repository:
import React from "react";
import { PermissionsAndroid, View, Text, Button } from "react-native";
import { BleManager } from 'react-native-ble-plx';    

const ProfileScreen = props => {
  async function requestCameraPermission() {
    try {
      const granted = await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION,
        {
          title: 'Cool Photo App Camera Permission',
          message: 'Cool Photo App needs access to your camera',
          buttonNeutral: 'Ask Me Later',
          buttonNegative: 'Cancel',
          buttonPositive: 'OK',
        },
      );
      if (granted === PermissionsAndroid.RESULTS.GRANTED) {
        console.log('You can use the camera');
        return true;
      } else {
        console.log('Camera permission denied');
        return false;
      }
    } catch (err) {
      console.warn(err);
      return false;
    }
  }

  scanAndConnect = () => {
    const permission = requestCameraPermission();

    if (permission) {
      const bluetoothInstance = new BleManager();

      bluetoothInstance.startDeviceScan(null, null, (error, device) => {
        if (error) {
          console.log(error);
          return
        } else {
          console.log(device);
        }
      });
    } else {
      console.log("permission not granted")
    }
  };

  return (
    <View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
      <Text>Profile</Text>
      <Button 
        title="Start scanning"
        onPress={scanAndConnect}/>
      </View>
  )
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12

github_iconTop GitHub Comments

5reactions
sudomanncommented, Feb 19, 2020

I don’t understand how this library reports device name and localName as null. I simply logged all detected devices, and every single one, null. Using my smartphone to see all bluetooth devices in the area reveals them with human readable names. Therefore, they are reporting them. I instantiated a manager and scanned for devices. Is there a step i missed?

0reactions
sudomanncommented, Jul 21, 2020

@tyrone2kx oddly enough, it started displaying showing the names soon after. I also noticed sometimes the scan results had duplicates. One might show the name, while the other might not.

It might help to log all the scan results and closely inspect.

Read more comments on GitHub >

github_iconTop Results From Across the Web

All devices scanned have name equals to null #481
Scanning devices should return a name in order to understand which device is which. Current Behavior. Scanning devices return objects with name and...
Read more >
bluetooth - android BluetoothDevice.getName() return null
It will return null if the device does not expose its name in the advertisement or scan response. There is no requirement in...
Read more >
BLE Device Names Null - Discussion - Connect IQ
However, the watch seems to always list the device name as null. Is there a way to consistently get the device name from...
Read more >
react-native-ble-plx all devices name are null
All devices scanned have name equals to null #481 - GitHub ... Scanning devices return objects with name and localName equals null :....
Read more >
Some BLE devices are retuning device name NULL during ...
Some BLE devices on android 13 OS is returning device name as NULL but return name correctly on android 12 and older OS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found