I found a working solution which looks like this:
/*
* ble_5_phy_coded_scan_test.ino
* Description: Test app demonstrates SCANNING for standard (1 MBPS) and long range (Coded Phy) devices
* Author: Mark Leavitt mark@markleavitt.com
* Date: Mar 3 2021
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "Particle.h"
//SYSTEM_MODE(MANUAL); // Cellular connectivity not needed
SerialLogHandler logHandler(LOG_LEVEL_INFO); // Results will be logged over USB Serial
const size_t SCAN_RESULT_MAX = 100;
BleScanResult scanResults[SCAN_RESULT_MAX];
BleScanParams scanParams;
void setup() {
delay(5000); // Allow time for USB serial to connect
BLE.on();
Log.info("BLE 5 PHY CODED SCAN TEST");
scanParams.version = BLE_API_VERSION;
scanParams.size = sizeof(BleScanParams);
BLE.getScanParameters(&scanParams); // Get the default scan parameters
scanParams.timeout = 1000; // Change timeout to 10 seconds
// Scanning for both 1 MBPS and CODED PHY simultaneously requires scanning window <= 1/2 the scanning interval.
// We will widen the window to 2/3 of the interval so automatic override will be tested in simultaneous mode
scanParams.window = (2 * scanParams.interval) / 3 ;
BLE.setScanParameters(&scanParams); // Set the modified scan parameters
}
void loop() {
int count;
// First, scan and log with standard PHYS_1MBPS
scanParams.scan_phys = BLE_PHYS_1MBPS;
BLE.setScanParameters(scanParams);
count = BLE.scan(scanResults, SCAN_RESULT_MAX);
logDevices(count, "PHYS_1MBPS (standard)");
}
void logDevices(int deviceCount, String mode) {
Log.info("Scanning with %s found %d devices", mode.c_str(), deviceCount);
for (int i = 0; i < deviceCount; i++) {
Log.info(" Device addr: %02X:%02X:%02X:%02X:%02X:%02X, rssi: %d dBm, name: %s,
scanResults[i].address()[5], scanResults[i].address()[4],scanResults[i].address()[3],
scanResults[i].address()[2],scanResults[i].address()[1],scanResults[i].address()[0],
scanResults[i].rssi(), scanResults[i].advertisingData().deviceName().c_str(),
scanResults[i].advertisingData().serviceUUID());
}
Log.info("--------------------------------------------------------");
}
Now my Argon finds several Bluetooth devices including my sensor (https://github.com/atc1441/ATC_MiThermometer).
My sensor sends every minute an update of advertising data on the UUID 0x181A with the Tempereature, Humidity and Battery data. It is not necessary to connect to the sensor.
With my phone I can read the raw data without connecting.
The format of the advertising data is as follow:
Byte 5-10 MAC in correct order
Byte 11-12 Temperature in int16
Byte 13 Humidity in percent
Byte 14 Battery in percent
Byte 15-16 Battery in mV uint16_t
Byte 17 frame packet counter
Example: 0x0e, 0x16, 0x1a, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xbb, 0xcc, 0xdd, 0xdd, 0x00
I can see the correct MAC Address in the serial monitor but I do not know how to read the full advertasing data. Any ideas?
0003694802 [app] INFO: Scanning with PHYS_1MBPS (standard) found 7 devices
0003694802 [app] INFO: Device addr: 4C:E7:BF:16:8F:DD, rssi: -41 dBm, name:
0003694803 [app] INFO: Device addr: 64:38:A7:1F:42:98, rssi: -47 dBm, name:
0003694804 [app] INFO: Device addr: 20:CA:D3:4C:D8:7A, rssi: -51 dBm, name:
0003694804 [app] INFO: Device addr: 6E:96:DB:AD:31:7A, rssi: -67 dBm, name:
0003694805 [app] INFO: Device addr: 47:2D:A7:53:57:39, rssi: -64 dBm, name:
0003694806 [app] INFO: Device addr: 5B:B4:FA:51:22:F7, rssi: -81 dBm, name:
0003694807 [app] INFO: Device addr: A4:C1:38:CA:52:32, rssi: -43 dBm, name:
0003694807 [app] INFO: --------------------------------------------------------