BLE scan doesn't end

I’m new to thunkable today, and I’m trying to get it to talk to an arduino featuring BLE. I know the arduino is working because I can talk to it with BLE scanner apps. I wanted to use thunkable to give some sort of useful UI.

However, the thunkable BLE scan doesn’t seem to end. My code block is below. The label ‘Connected’ is set to ‘Scanning…’ but never changes to ‘Scan complete’.

thunkable
I do notice that the label ‘Value’ gets set to 0, which means either the scan is asynchronous, or the scan is terminating without entering the ‘then do’ section.

Any ideas?

Thanks, Tony

Hey @tony4k717, :wave:

Welcome to the community! can you tell us a little more about your set up please?

Presumably you’re using Thunkable Live, but are you using Android or iOS?

Thanks.

Yes, thunkable live, on a Moto G4 with Android 7.0. Both android itself and BLE scanner app (LightBlue) see the arduino.

got it.

Does the Arduino have on-board BLE or are you using something like a HC-05 or a HM-10?

In my case BLE Component is not working on iOS 13.1.1: no scan, no connect via Device Name or via UUID (I download my app).

Arduino Nano 33 BLE - has on-board BLE module.

Hi Domnhall,
I downloaded my APK and ran it under adb, Here’s the output from where the log first shows bluetooth activity:

10-18 10:01:50.266 21452 21641 D BluetoothAdapter: STATE_ON

10-18 10:01:50.272 4578 4597 D BtGatt.GattService: registerClient() - UUID=c09b7548-b542-4481-820e-a1634dedc956
10-18 10:01:50.273 4578 4649 D BtGatt.GattService: onClientRegistered() - UUID=c09b7548-b542-4481-820e-a1634dedc956, clientIf=6
10-18 10:01:50.273 21452 21464 D BluetoothLeScanner: onClientRegistered() - status=0 clientIf=6 mClientIf=0
10-18 10:01:50.274 4578 10530 D BtGatt.GattService: start scan with filters
10-18 10:01:50.276 4578 4654 D BtGatt.ScanManager: handling starting scan
10-18 10:01:50.285 4578 4649 D BtGatt.GattService: onScanFilterEnableDisabled() - clientIf=6, status=0, action=1
10-18 10:01:50.285 4578 4649 D BtGatt.ScanManager: callback done for clientIf - 6 status - 0
10-18 10:01:50.286 4578 4654 D BtGatt.ScanManager: configureFilterParamter 500 10000 1 0
10-18 10:01:50.289 4578 4649 D BtGatt.GattService: onScanFilterParamsConfigured() - clientIf=6, status=0, action=0, availableSpace=14
10-18 10:01:50.289 4578 4649 D BtGatt.ScanManager: callback done for clientIf - 6 status - 0
10-18 10:01:50.290 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - queue=2
10-18 10:01:50.290 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - ScanSetting Scan mode=0 mLastConfiguredScanSetting=0
10-18 10:01:50.472 875 875 I MSM-irqbalance: Decided to move IRQ177 from CPU7 to CPU5
10-18 10:01:50.862 4068 22831 I Places : ?: PlacesBleScanner stop()
10-18 10:01:50.869 4068 4068 I BeaconBle: ZERO_POWER is disabled.
10-18 10:01:50.869 4068 4068 I BeaconBle: ‘L’ hardware scan: scan stopped, no powered clients
10-18 10:01:50.869 4068 4068 I BeaconBle: Places requested to stop scan
10-18 10:01:50.870 4068 4068 I BeaconBle: Scan canceled successfully.
10-18 10:01:50.874 4068 22831 I PlaceInferenceEngine: [anon] Changed inference mode: 0
10-18 10:01:50.874 4068 22831 I PlaceInferenceEngine: [account#1954530981] Changed inference mode: 0
10-18 10:01:50.906 4068 5216 W NetworkScheduler: Task was rescheduled during execution - postponing the schedule request
10-18 10:01:50.908 4068 5216 V ConnectivityManager: isActiveNetworkMetered() returns:false
10-18 10:01:51.231 21452 21641 D BluetoothAdapter: STATE_ON
10-18 10:01:51.232 4578 12497 D BtGatt.GattService: stopScan() - queue size =2
10-18 10:01:51.233 4578 5115 D BtGatt.GattService: unregisterClient() - clientIf=6
10-18 10:01:51.237 21452 21641 D BluetoothAdapter: STATE_ON
10-18 10:01:51.237 4578 4649 D BtGatt.GattService: onScanFilterParamsConfigured() - clientIf=6, status=0, action=1, availableSpace=15
10-18 10:01:51.237 4578 4649 D BtGatt.ScanManager: callback done for clientIf - 6 status - 0
10-18 10:01:51.238 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - queue=1
10-18 10:01:51.238 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - ScanSetting Scan mode=0 mLastConfiguredScanSetting=0
10-18 10:01:51.241 4578 4924 D BtGatt.GattService: registerClient() - UUID=0cfeb789-44e1-4873-a31c-c08521995bbf
10-18 10:01:51.242 4578 4649 D BtGatt.GattService: onClientRegistered() - UUID=0cfeb789-44e1-4873-a31c-c08521995bbf, clientIf=6
10-18 10:01:51.242 21452 21465 D BluetoothLeScanner: onClientRegistered() - status=0 clientIf=6 mClientIf=0
10-18 10:01:51.243 4578 12497 D BtGatt.GattService: start scan with filters
10-18 10:01:51.246 4578 4654 D BtGatt.ScanManager: handling starting scan
10-18 10:01:51.249 4578 4649 D BtGatt.GattService: onScanFilterEnableDisabled() - clientIf=6, status=0, action=1
10-18 10:01:51.250 4578 4649 D BtGatt.ScanManager: callback done for clientIf - 6 status - 0
10-18 10:01:51.250 4578 4654 D BtGatt.ScanManager: configureFilterParamter 500 10000 1 0
10-18 10:01:51.251 4578 4649 D BtGatt.GattService: onScanFilterParamsConfigured() - clientIf=6, status=0, action=0, availableSpace=14
10-18 10:01:51.251 4578 4649 D BtGatt.ScanManager: callback done for clientIf - 6 status - 0
10-18 10:01:51.252 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - queue=2
10-18 10:01:51.252 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - ScanSetting Scan mode=0 mLastConfiguredScanSetting=0
10-18 10:01:54.156 2501 9437 I MotoSensors: Sensorhub hal setDelay: 1 - 10
10-18 10:01:54.156 2501 9437 I MotoSensors: Sensorhub hal setdelay: 1 - 10
10-18 10:01:54.702 3822 3822 D KeyguardUpdateMonitor: received broadcast android.intent.action.BATTERY_CHANGED
10-18 10:01:54.700 2501 7498 D BatteryService: mLastPlugType/mPlugType:1/1
10-18 10:01:54.703 2501 7498 D BatteryService: set mLastPlugType to 1
10-18 10:01:54.703 4096 4096 D VideoCall_LowBattery: BatteryIntent received: android.intent.action.BATTERY_CHANGED
10-18 10:01:54.704 4703 4797 W QCNEJ : |CORE| CNE received unexpected action: android.intent.action.BATTERY_CHANGED
10-18 10:01:54.705 4578 4925 D HeadsetStateMachine: Disconnected process message: 10, size: 0
10-18 10:01:54.705 4578 4925 D HeadsetStateMachine: Enter processIntentBatteryChanged()
10-18 10:01:54.705 4578 4925 D HeadsetStateMachine: Exit processIntentBatteryChanged()
10-18 10:01:54.705 4578 4925 D HeadsetStateMachine: Exit Disconnected processMessage()
10-18 10:01:54.711 3822 3822 D KeyguardUpdateMonitor: handleBatteryUpdate
10-18 10:01:54.721 4096 4096 D VideoCall_LowBattery: allowVideoCallsInLowBattery: false isCarrierOneSupported: false mIsLowbattery: false
10-18 10:01:55.473 875 875 I MSM-irqbalance: Decided to move IRQ65 from CPU4 to CPU5
10-18 10:01:55.582 10488 10523 I WorkerManager: dispose()
10-18 10:01:55.582 10488 10523 W ThreadPoolDumper: Queue length for executor EventBus is now 11. Perhaps some tasks are too long, or the pool is too small.
10-18 10:01:56.357 21452 21641 D BluetoothAdapter: STATE_ON
10-18 10:01:56.358 4578 10530 D BtGatt.GattService: stopScan() - queue size =2
10-18 10:01:56.359 4578 4591 D BtGatt.GattService: unregisterClient() - clientIf=6
10-18 10:01:56.362 21452 21641 D BluetoothAdapter: STATE_ON
10-18 10:01:56.365 4578 12498 D BtGatt.GattService: registerClient() - UUID=efc52154-4b70-43bc-8479-b3396973e1f6
10-18 10:01:56.366 4578 4649 D BtGatt.GattService: onScanFilterParamsConfigured() - clientIf=6, status=0, action=1, availableSpace=15
10-18 10:01:56.366 4578 4649 D BtGatt.ScanManager: callback done for clientIf - 6 status - 0
10-18 10:01:56.366 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - queue=1
10-18 10:01:56.366 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - ScanSetting Scan mode=0 mLastConfiguredScanSetting=0
10-18 10:01:56.368 4578 4649 D BtGatt.GattService: onClientRegistered() - UUID=efc52154-4b70-43bc-8479-b3396973e1f6, clientIf=6
10-18 10:01:56.368 21452 21464 D BluetoothLeScanner: onClientRegistered() - status=0 clientIf=6 mClientIf=0
10-18 10:01:56.369 4578 16201 D BtGatt.GattService: start scan with filters
10-18 10:01:56.373 4578 4654 D BtGatt.ScanManager: handling starting scan
10-18 10:01:56.379 4578 4649 D BtGatt.GattService: onScanFilterEnableDisabled() - clientIf=6, status=0, action=1
10-18 10:01:56.380 4578 4649 D BtGatt.ScanManager: callback done for clientIf - 6 status - 0
10-18 10:01:56.380 4578 4654 D BtGatt.ScanManager: configureFilterParamter 500 10000 1 0
10-18 10:01:56.383 4578 4649 D BtGatt.GattService: onScanFilterParamsConfigured() - clientIf=6, status=0, action=0, availableSpace=14
10-18 10:01:56.383 4578 4649 D BtGatt.ScanManager: callback done for clientIf - 6 status - 0
10-18 10:01:56.383 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - queue=2
10-18 10:01:56.383 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - ScanSetting Scan mode=0 mLastConfiguredScanSetting=0
10-18 10:01:58.248 21452 21641 D BluetoothAdapter: STATE_ON
10-18 10:01:58.248 4578 12497 D BtGatt.GattService: stopScan() - queue size =2
10-18 10:01:58.250 4578 5115 D BtGatt.GattService: unregisterClient() - clientIf=6
10-18 10:01:58.251 4578 4649 D BtGatt.GattService: onScanFilterParamsConfigured() - clientIf=6, status=0, action=1, availableSpace=15
10-18 10:01:58.251 4578 4649 D BtGatt.ScanManager: callback done for clientIf - 6 status - 0
10-18 10:01:58.251 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - queue=1
10-18 10:01:58.251 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - ScanSetting Scan mode=0 mLastConfiguredScanSetting=0
10-18 10:01:58.589 2501 4119 I MotoSensors: Sensorhub hal setDelay: 1 - 10
10-18 10:01:58.589 2501 4119 I MotoSensors: Sensorhub hal setdelay: 1 - 10
10-18 10:01:59.007 2501 3758 D BatteryService: uevent={POWER_SUPPLY_TEMP=250, POWER_SUPPLY_STATUS=Charging, POWER_SUPPLY_CAPACITY=44, ACTION=change, DEVPATH=/devices/soc.0/qpnp-smbcharger-17/power_supply/battery, POWER_SUPPLY_AGE=134, POWER_SUPPLY_VOLTAGE_MAX=4350, SUBSYSTEM=power_supply, POWER_SUPPLY_NUM_SYSTEM_TEMP_LEVELS=8, POWER_SUPPLY_VOLTAGE_MAX_DESIGN=4350000, POWER_SUPPLY_INPUT_CURRENT_MAX=700000, POWER_SUPPLY_CHARGE_FULL=4124000, POWER_SUPPLY_NAME=battery, POWER_SUPPLY_FLASH_CURRENT_MAX=1039971, POWER_SUPPLY_HEALTH=Good, POWER_SUPPLY_CYCLE_COUNT=0, POWER_SUPPLY_TECHNOLOGY=Li-ion, POWER_SUPPLY_CHARGE_TYPE=Fast, POWER_SUPPLY_PRESENT=1, POWER_SUPPLY_CONSTANT_CHARGE_CURRENT_MAX=2500000, POWER_SUPPLY_TEMP_HOTSPOT=0, POWER_SUPPLY_INPUT_CURRENT_SETTLED=1, POWER_SUPPLY_SAFETY_TIMER_ENABLED=0, POWER_SUPPLY_FLASH_ACTIVE=0, POWER_SUPPLY_VOLTAGE_NOW=3992133, SEQNUM=24013, POWER_SUPPLY_CHARGE_FULL_DESIGN=3059000, POWER_SUPPLY_CURRENT_NOW=-368192, POWER_SUPPLY_SYSTEM_TEMP_LEVEL=0, POWER_SUPPLY_CHARGE_COUNTER=1464061, POWER_SUPPLY_CHARGE_RATE=Normal, POWER_SUPPLY_CHARGING_ENABLED=1, POWER_SUPPLY_BATTERY_CHARGING_ENABLED=1}
10-18 10:01:59.010 2501 10958 D BatteryService: mLastPlugType/mPlugType:1/1
10-18 10:01:59.010 2501 10958 D BatteryService: set mLastPlugType to 1
10-18 10:01:59.012 3822 3822 D KeyguardUpdateMonitor: received broadcast android.intent.action.BATTERY_CHANGED
10-18 10:01:59.013 4096 4096 D VideoCall_LowBattery: BatteryIntent received: android.intent.action.BATTERY_CHANGED
10-18 10:01:59.013 4578 4925 D HeadsetStateMachine: Disconnected process message: 10, size: 0
10-18 10:01:59.014 4578 4925 D HeadsetStateMachine: Enter processIntentBatteryChanged()
10-18 10:01:59.014 4578 4925 D HeadsetStateMachine: Exit processIntentBatteryChanged()
10-18 10:01:59.014 4578 4925 D HeadsetStateMachine: Exit Disconnected processMessage()
10-18 10:01:59.014 3822 3822 D KeyguardUpdateMonitor: handleBatteryUpdate
10-18 10:01:59.014 4703 4797 W QCNEJ : |CORE| CNE received unexpected action: android.intent.action.BATTERY_CHANGED
10-18 10:01:59.027 4096 4096 D VideoCall_LowBattery: allowVideoCallsInLowBattery: false isCarrierOneSupported: false mIsLowbattery: false
10-18 10:01:59.052 555 555 I SFPerfTracer: triggers: (rate: 4015:250294) (compose: 3:93) (post: 0:3) (render: 0:140) (0:345067 frames) (1:364231)
10-18 10:01:59.052 555 555 D SFPerfTracer: layers: (3:10) (StatusBar (0xac410c00): 1:38959) (com.android.systemui.ImageWallpaper (0xac421400): 0:10807)* (Sprite (0xac40e400): 0:30)* (animation background stackId=1 (0xac40f800): 0:30)* (DimLayerController/Stack=0 (0xac423c00): 0:106)* (NavigationBar (0xac40d000): 0:1439) (com.google.android.googlequicksearchbox/com.google.android.launcher.GEL (0xac420000): 0:66)- (com.google.android.googlequicksearchbox/com.google.android.launcher.GEL (0xac422800): 0:103)- (Starting net.parkhagiwara.tony.bleslider (0xac40bc00): 0:43)- (net.parkhagiwara.tony.bleslider/host.exp.exponent.MainActivity (0xac604000): 0:63)
10-18 10:02:00.003 3822 3822 D KeyguardUpdateMonitor: received broadcast android.intent.action.TIME_TICK
10-18 10:02:00.003 3822 3822 D KeyguardUpdateMonitor: handleTimeUpdate
10-18 10:02:00.472 875 875 I MSM-irqbalance: Decided to move IRQ178 from CPU4 to CPU5
10-18 10:02:04.200 4578 4578 D HeadsetPhoneState: Enter onSignalStrengthsChanged
10-18 10:02:04.200 4578 4578 D HeadsetPhoneState: Exit onSignalStrengthsChanged
10-18 10:02:04.267 4068 5216 W NetworkScheduler: Task was rescheduled during execution - postponing the schedule request
10-18 10:02:04.270 4068 5216 V ConnectivityManager: isActiveNetworkMetered() returns:false
10-18 10:02:04.331 4068 21427 W NetworkScheduler: Task was rescheduled during execution - postponing the schedule request
10-18 10:02:04.336 4068 5216 W NetworkScheduler: Task was rescheduled during execution - postponing the schedule request
10-18 10:02:04.338 4068 5216 V ConnectivityManager: isActiveNetworkMetered() returns:false
10-18 10:02:04.393 4068 21427 W NetworkScheduler: Task was rescheduled during execution - postponing the schedule request
10-18 10:02:05.472 875 875 I MSM-irqbalance: Decided to move IRQ174 from CPU4 to CPU5
10-18 10:02:06.401 21452 21641 D BluetoothAdapter: STATE_ON
10-18 10:02:06.403 4578 5115 D BtGatt.GattService: registerClient() - UUID=29190ef9-8f0f-4616-8865-e1a64849ee98
10-18 10:02:06.404 4578 4649 D BtGatt.GattService: onClientRegistered() - UUID=29190ef9-8f0f-4616-8865-e1a64849ee98, clientIf=6
10-18 10:02:06.405 21452 21464 D BluetoothLeScanner: onClientRegistered() - status=0 clientIf=6 mClientIf=0
10-18 10:02:06.405 4578 4597 D BtGatt.GattService: start scan with filters
10-18 10:02:06.408 4578 4654 D BtGatt.ScanManager: handling starting scan
10-18 10:02:06.412 4578 4649 D BtGatt.GattService: onScanFilterEnableDisabled() - clientIf=6, status=0, action=1
10-18 10:02:06.412 4578 4649 D BtGatt.ScanManager: callback done for clientIf - 6 status - 0
10-18 10:02:06.412 4578 4654 D BtGatt.ScanManager: configureFilterParamter 500 10000 1 0
10-18 10:02:06.413 4578 4649 D BtGatt.GattService: onScanFilterParamsConfigured() - clientIf=6, status=0, action=0, availableSpace=14
10-18 10:02:06.413 4578 4649 D BtGatt.ScanManager: callback done for clientIf - 6 status - 0
10-18 10:02:06.413 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - queue=2
10-18 10:02:06.413 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - ScanSetting Scan mode=0 mLastConfiguredScanSetting=0
10-18 10:02:06.844 2501 2518 I art : Background partial concurrent mark sweep GC freed 65872(3MB) AllocSpace objects, 5(100KB) LOS objects, 33% free, 28MB/42MB, paused 1.943ms total 168.015ms
10-18 10:02:07.259 21452 21458 I art : Do full code cache collection, code=85KB, data=125KB
10-18 10:02:07.261 21452 21458 I art : After code cache collection, code=66KB, data=58KB
10-18 10:02:09.320 4578 4578 D HeadsetPhoneState: Enter onSignalStrengthsChanged
10-18 10:02:09.320 4578 4578 D HeadsetPhoneState: Exit onSignalStrengthsChanged
10-18 10:02:10.169 4616 4619 E ANDR-PERF-MPCTL: Invalid profile no. 0, total profiles 0 only
10-18 10:02:10.337 4616 4619 E ANDR-PERF-MPCTL: Invalid profile no. 0, total profiles 0 only
10-18 10:02:11.719 4616 4619 E ANDR-PERF-MPCTL: Invalid profile no. 0, total profiles 0 only
10-18 10:02:13.159 4578 4578 D HeadsetPhoneState: Enter onSignalStrengthsChanged
10-18 10:02:13.160 4578 4578 D HeadsetPhoneState: Exit onSignalStrengthsChanged
10-18 10:02:14.416 21452 21641 D BluetoothAdapter: STATE_ON
10-18 10:02:14.416 4578 12497 D BtGatt.GattService: stopScan() - queue size =2
10-18 10:02:14.418 4578 5115 D BtGatt.GattService: unregisterClient() - clientIf=6
10-18 10:02:14.424 4578 4649 D BtGatt.GattService: onScanFilterParamsConfigured() - clientIf=6, status=0, action=1, availableSpace=15
10-18 10:02:14.424 4578 4649 D BtGatt.ScanManager: callback done for clientIf - 6 status - 0
10-18 10:02:14.424 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - queue=1
10-18 10:02:14.424 4578 4654 D BtGatt.ScanManager: configureRegularScanParams() - ScanSetting Scan mode=0 mLastConfiguredScanSetting=0

1 Like

Another possibility; the arduino demo app has the arduino acting as the ‘central’ BLE agent, which would mean Thunkable would have to be a peripheral. Does Thunkable work as a BLE peripheral or central?

Sorry for late reply. The BLE component doesn’t work with the iOS companion. You need to build the app and install on your iOS device to try that out.

Here is what we showed in the live preview -

Best,
Wei

Can you send me your app link? wei@thunkable.com

Thanks,
Wei