BLE Device Names Null

Background:

I am trying to make an app that finds a type of BLE device by recognizing a pattern in its name.

In Python, I can do this:

import asyncio
from bleak import BleakScanner

async def main():
    devices = await BleakScanner.discover()
    for d in devices:
        if re.match("^S[a-f\d]{16}[A-F]$", d.name):
            # This is the correct device!
            print(d)

asyncio.run(main())

However, I understand that Monkey C does not support regex. So, I just tried searching for devices with a name that is 18 characters long, but I didn't get any hits.

I tried out 's BleScan app, and I found that almost all of the devices my watch found had a device name that is null.

I used the python script above on my laptop to find the BLE address of the device I want the watch to connect to, and I changed the code in my app to look for the specific BLE address instead of the device name, and it connected. So, it looks like the watch is not picking up the BLE device's name, even though my phone and laptop both do. Why might this be? Is there another way to do this that would get device names reliably?

    // THIS CODE DOES NOT WORK
    function onScanResults( scanResults ) {    	
        for( var result = scanResults.next(); result != null; result = scanResults.next() ) {
			var deviceName = device.getDeviceName();
			if (deviceName && deviceName.length().equals(18)) {
				Ble.setScanState(Ble.SCAN_STATE_OFF);
				view.device = Ble.pairDevice(result);
				Ui.requestUpdate();
			}
        }        
    }
    
    // THIS CODE WORKS
    function onScanResults( scanResults ) {    	
        for( var result = scanResults.next(); result != null; result = scanResults.next() ) {
			if (result.hasAddress("SPECIFIC_DEVICE_BLE_ADDRESS")) {
				Ble.setScanState(Ble.SCAN_STATE_OFF);
				view.device = Ble.pairDevice(result);
				Ui.requestUpdate();
			}
        }        
    }

If it is relevant, I am trying to make an app that is able to connect to Tesla vehicles over BLE using this new documentation.

Summary:

The best way to identify my class of devices is by recognizing a pattern in their device name. However, the watch seems to always list the device name as null.

Is there a way to consistently get the device name from a scan?

  • The name from the scan isn't available from all devices with CIQ Ble.  Not sure exactly why, but you can see it with my BleScan: https://apps.garmin.com/en-US/apps/9bcc8b66-8385-4afb-b93e-f69e01422284

    using NrfConnect on a phone, you can see the names.

    You can see Nordic Thingy52 devices (the main picture for this in the store shows "Thing17"), but based on the BLE devices around you, you also may not see the UUID for a device.

    Once you pair a device, you'll see device.getName() in the sim, but not on real devices.  In cases where I control both ends, I added a characteristic to get the name from the device, as this has been broken for some time.

    I go by UUID when scanning, and not the name, and I also put the scan result in persistent storage, and after a good pairing I use that, I don't scan, but just pair based on the saved scan result, so when scanning the first time, I just make sure there is only one device with the proper UUID in range.

  • When viewing a scan result in blescan, you can press select, and see the raw data, and you'll see the names in that if you see it in the general scan result.  It may have to do with the max of raw data seen on the watch, or the position of the name in the raw data from a specific result.