The question about making a BLE app

Hello, everyone.
I'm using the example of the Nordic SDK(version 17), ble_app_uart.
I checked that strings are printed through the nRF Connect app.
And now I want to test it using App Inventor.
But the first step, Bluetooth connection, doesn't work. If you press the scan button and press the list button, nothing appears in the list.

Can I get a solution to this problem?
Thank you in advance.

A couple of things you can try.

First you have called "StartScanning", which will continue until you tell it to "StopScanning". So you'll have to add this instruction in your blocks.

As you've correctly done, you are placing your DeviceList in a list, but this only happens when there is something in the device list. This is not immediate.

So that is why this happens "and press the list button, nothing appears in the list."

The more common way of showing your device list is to use a "ListView" object where you simply add device list to this when they arrive via the "when DeviceFound" method is triggered. This will auto update on screen.

The alternative, if you want to do it your way, is to maybe only active the List button when DeviceFound is triggered or change button colour etc to indicate.

Then suggest add the stopscanning within the "AfterPicking" block.

Then, don't use a timer and the "ReadStrings" method. If you look at the nRFconnect picture you can see the "TX Characteristic" has a "NOTIFY" property. Thus use the "RegisterForStrings" method instead.

An event trigger will then occur if a string arrives via the "when StringsReceived" method. Use this to read your strings etc.

2 Likes

Thank you for your help.
I corrected the block as you said. But no matter how long I wait, it still doesn't scan. Can I know why?

Are you using the emulator or are you using the connect-->AI companion option.

No, I'm not using an emulator. I've never used an emulator before, is it related to this?

Hi, that's OK then. BLE will not work with the Emulator, only with the Companion or a built APK.

There are two things on the Android side:

  1. Ensure that Google Locate is enabled (security feature)
  2. Ensure that Bluetooth is enabled!

RegisterForString does not need a Timer.