This is the code and the start of the app. I am not sure what to do because it does not run and I am sensing some issues. I do not mind it being readjusted or redesigned if need be
I am moving this thread to the other thread you started for the same app.
Ok. I was not sure how to ask this question and worded it a couple different ways. While I am getting an error I also would not mind some tips to help create something fully functional. I am not a computer science major, I am in engineering for the quality side of things and this is really hard for me to grasp
I'd suggest disabling the Disconnect block in the ErrorOccurred event. My guess is that you're on Android 12 or later, and because of that the BLE extension is throwing an error when it tries to disconnect (due to permission changes related to Bluetooth in Android 12) and that this triggers ErrorOccurred, which in turn calls Disconnect, etc. until the stack overflows.
I am now receiving an error saying Screen ErrorError 9101 in extension BluetoothLE: Expected device index between 1 and 0. Any idea what that could mean?
This error is thrown by the Connect method when the supplied index is out of bounds. Given that the latter value is 0, this means that internally the BLE extension hasn't discovered any devices. I don't see any when BluetoothLE1.DeviceFound blocks in your code, so it's possible you haven't confirmed that the device has been discovered before trying to connect.
So I should discover the bluetooth device by using the BluetoothLE1.DeviceFound block and then use the bluetoothLE1. connected block?
Not necessarily, but the BLE extension manages some internal state about what devices it knows about. You may want to try out this how-to about setting up an app to connect to a BLE device:
Why? My Samsung has Bluetooth internally. It is how I communicate and pair with my Bluetooth devices. Have you tried it to pair with your Arduino? Your S21 probably has the same feature as my A13. It can also be accessed using system settings.
When I attempt to pair to the S21 it tells me that it is unable to pair and to check settings for the device and try again. i am assuming that has something to do with the code i wrote to program. It does connect on the other app though. So I am really not sure what is going on
Thank you for this. I am going to review this and make some changes and see what I can do!
Will this work with the Nano 33 BLE. It says its specific to the iot
(added to FAQ)
@ewpatton do you know if the setup of our blocks are correct? Do they have to be in a specific order?
The BLE extension's logic is that you:
- Scan for nearby devices--internally this populates the BLE's device list
- Connect to a device at a given index--usually you'd do this by populating a list view with the BLE's device list and then let the user choose.
- Send/receive data with the connected device
As I previously mentioned, I don't see how you're informing the user of the list of nearby devices and that's likely getting you into trouble since the device list may not be populated yet depending on the scan frequency, etc. of the device
Ok thank you. I will make some changes and see what I can do
As I mentioned already, it might be good to go through the tutorial I linked just to get a basic connection going. Once you know that works, then you can take what you've learned and translate it into your existing app.
Yes I will do that. Thank you