Simple BLE Scanner with basic info callout needed

So, I am looking for a simple-as-possible BLE scanner which works on an Argon. Can anyone help?

Background: I want a BLE scan which calls out the name + advertising string of any BLE devices in range.

I found Jared Woolf’s BLE scanner, which does exactly this (and provides a really good tutorial on the subject) but the code he provides (see download link near the end of his page) won’t compile in the WEB IDE - despite being for Particle - and I can’t really tell why from the error messages I get (see below).

Someone else has posted on github having the exact same issue 8 months ago and has never got an answer so I am not confident that my “me too” post will get his attention either. Thus, I am looking for help or an alternative if anyone can provide one or the other!

Thanks as always.

Jared’s page is here:

Github refs
[GitHub - jaredwolff/particle-bluetooth-presence-detection: Used a Particle Argon and Tile Mate to do basic presence detection.
(Chokes on build · Issue #2 · jaredwolff/particle-bluetooth-presence-detection · GitHub)

ble_scanner.ino:105:45: no match for 'operator=' (operand types are 'particle::BleAddress' and '<unresolved overloaded function type>')

ble_scanner.ino:112:36: cannot resolve overloaded function 'rssi' based on conversion to type 'int8_t' {aka 'signed char'}

Both these calls lack the () to indicate that you want the respective functions called/executed and not the function pointers to be returned.

i.e.

  BleAddress addr = scanResult->address();
  // and
  lastRSSI = scanResult->rssi();
2 Likes

ScruffR is correct. Prior to 3.0.0 you could access the member variables directly, but in 3.0.0 and later you need to use the accessor functions. There are a few more after the lines in question, but it’s the same change:


// Callback when a new device is found advertising
void scanResultCallback(const BleScanResult *scanResult, void *context) {

    // If device address doesn't match or we're not in "learning mode"
    if( !(searchAddress == scanResult->address()) && !isLearningModeOn() ) {
        return;
    }

    // Collect the uuids showing in the advertising data
    BleUuid uuids[4];
    int uuidsAvail = scanResult->advertisingData().serviceUUID(uuids,sizeof(uuids)/sizeof(BleUuid));

    // Print out mac info
    BleAddress addr = scanResult->address();
    Log.trace("MAC: %02X:%02X:%02X:%02X:%02X:%02X", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
    Log.trace("RSSI: %dBm", scanResult->rssi());

    // Loop over all available UUIDs
    // For tile devices there should only be one
    for(int i = 0; i < uuidsAvail; i++){

        // Print out the UUID we're looking for
        if( uuids[i].shorted() == TILE_UUID ) {
            Log.trace("UUID: %x", uuids[i].shorted());

            // If we're in learning mode. Save to EEprom
            if( isLearningModeOn() ) {
                searchAddress = scanResult->address();
                EEPROM.put(TILE_EEPROM_ADDRESS, searchAddress);
                setLearningModeOff();
            }

            // Save info
            lastSeen = millis();
            lastRSSI = scanResult->rssi();

            // Stop scanning
            BLE.stopScanning();

            return;
        }
    }

}

3 Likes

Ah! thanks gents. I’ll make those changes tomorrow and then I should have something that works to start from! Thanks as ever. I’ll cross post this fix onto the github page too.

It occurs to me that there will be a lot of other code hanging around on the web which will now cause this same error and that cause people to give up. I don’t know anything like enough to know what would be involved, but I wonder would it be possible to get the compiler to give a more useful error message where this problem is encountered?

Thanks again.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.