Can someone identify the error preventing BLE2 from displaying?

Happy Tuesday,

I finally get my right shoulder surgery in 8 days - I guess you have to be an old fart to eagerly anticipate things like this. But please, on to my code. I have done some extensive reading but any information presented to me doesn't filter in properly to be incorporated. If some kind soul would make a recommendation/suggestion (besides "give up coding"), I would be elated and have some design concepts to work on while I heal.

I am attaching several PNGs showing all BLE device communication blocks. No matter what I try, I only display data from BLE1 upon pressing the Start button, The device speaks first "Connecting with available devices and then, "Connecting to remote sensor one established". Which makes sense so far, even to me. I click the start button, that block runs and then BLE1 is located and displayed. The BLE2 text label and its adjacent label data never display. BLE1 and its related data always display. Can someone eyeball these blocks and tell me what is wrong or missing, such that I only read the data from one Bluetooth extension? What prevents BLE2 from getting into the action?

If more information is requested, I will endeavor to provide it although I think this is a no-brainer for a super user or anyone who has done something like this before. I am thankful for, and I appreciate any direct information that may be provided.

  1. Where's the sketch, so we can compare transmitting and receiving UUIDs?

  2. Why do you write over this TinyDB entry immediately?
    image
    Are you teasing the first UUID?

  3. Why are you adding a blank to the end of the stored UUID? Since when do UUIDs have blanks?

image

What's in global NAME?

And how is it associated with both devices?

Why do you insist that the incoming list of values be exactly one item long?
What if it has more than one item>
Then none of the items would be processed, because of your exact test.

A proper test would be length of list > 0.
image

Wow, thank you so much. I will address all of the issues you alluded to and see what happens. If I am still locked out cold, I will slam the code up here and see what shakes out. I think my literal answer to every "why" question you have presented is "because I don't know any better, but your questions lead me to solutions.

OK, I have the basics down, just not in a way that serves me. The attached .ala code will connect to both of my remote devices but not as I intend(ed). When the "Connect" button is clicked, the app looks for and finds the second remote sensor (ATMO2), and connects to it. I then must press the "Connect" button again for it to connect to the first remote sensor (ATMO1).

As to your earlier question regarding the Global Name, that is the MAC address of the ESP32C3 modules. The device names are "ATMO1" and ATMO2" and the UUIDs utilize the first and last character of the first 8 characters of the UUID for differentiation. I also use Global NAME1 and NAME2 for the device names.

My request, if you would be so kind, would be for you to show me or describe to me what I must do so that both LE1 and LE2 connect with the first click of the "Connect" button. Also, if you can discern why LE2 is identified first, I would love to know why. Thank you so much. I can almost pat myself on the back for this one (except for that stupid shoulder) but I am not nearly at 100%, yet.

I am including the Arduino code showing UUID settings for both remote devices.

Only_2_BLEs.aia (3.0 MB)

I reviewed all the blocks for BLE at

looking for how BLE_NAME ties to devices or services or characteristics.

I see in your .ino snippets that you #defined constants named BLE_NAME but I don't see any calls to BLE commands to tie those names to anything.

Did I miss something?

Maybe if you post both .ino files some one can spot something, like missing advertising calls.

This is an example of scanning for and connecting to 2 BLE devices:

Note that the NAME is not needed, and probably adds a complication.

P S. I see you scan after connecting.
Isn't that an offense to monogamy?

Well, you know, I've always been a pretty free spirit but I will look into this corporal offense. When One's guide through the darkness is unfettered ignorance, any flashlight is deeply appreciated. As for the name of the MAC address, WOW! It is unlike me to not try to remove something just to see what happens. Thank you for the link to multiple BLE connections. I will report back when I have achieved fusion.

Good morning, two questions if I may be so bold.

  1. How do I scan before connecting? Creating a procedure comes to mind but I cannot squeeze a "When" statement that handles connection into a procedure. I think simply having the right order here will make it all work.

With no discernable change on my part, pressing the "Connect" button connects to the first device and, after that connection is established, pressing "Connect" again calls up the second device with both displaying in real time.

  1. Can I (and how may I;) use a timer to replace or automate the connect button? Or something else? I would also be happy just pressing the connect button once, instead of twice.

I appreciate the references and literature you have given but everyone else is doing it a different way from me (and each other, as well). That provides me with a wall of "OMG, what do I have to learn now . . ." I am using floats, others are using strings, I just do not have the coding skills to paint over my code with the shades and nuances of other programs. I feel like I am about 90% with what I presented (connecting to 2 BLE streams - it does, just not automatically), and I have gotten it to work this far without clogging the community airwaves.

The last thing I want to be here is a P.I.T.A. (not the bread;), and I know you address many posts every day as a power user. If this request is too time-consuming, I completely understand and I will raise it as general help topic as I am so close to success and it seems like a timing issue. Thank you, again.

I consider doing a multi-connect a needless complication.

The two column approach presented in the sample posted earlier in this thread is simple.

Each column controls connection to a separate device.

Keep it simple.

I arrived on a variation of that theme. I used a clock timer to create a delay between calling the BLE devices. Given the previous .ala I posted, does this make sense? Or does it even matter if it makes sense if it works consistently?

OK, I will approach that two-column file one more time now that I have this functional. It really doesn't matter if, in keeping it simple, I am unable to achieve my objective. I now have a template, of sorts, to overlay upon.

Good Morning,

I wish I could translate the 2-column, 1-BLE examples you sent a link for to my own needs but I just cannot understand how to do it. I feel as though I am far better off accomplishing something that works (however "needlessly complicated" it is) instead of beating my head against the wall in frustration because I cannot comprehend the solution that you would like me to employ. I just get lost for hours and waste mental resources trying to make my design work with a single BLE extension.

I would gratefully accept a little guidance in doing it with a single BLE as applying someone else's general .ala file is beyond my current abilities. I would love to simplify but I believe I need a wee bit of force-feeding.

If that is not something that brightens your day (and why would it;), may I ask a simple question regarding doing it "my way?"

The .ala I previously posted locates BLE1 and BLE2 and uses each to display, respectively, ATMO1 and ATMO2. Once location permissions are given, the app grabs the data from ATMO1 and ATMO2 and displays it beneath the icons.

The .ala I am attaching "should" do the same thing using BLE3 and BLE4 to display ATMO3 and ATMO4 respectively. Instead, it does nothing. While it may not be the perfect way to do things - it still should work IMHO. It does not!

I am not asking you to write code for me (unless you want to show me briefly how I can do this more simply) but would you please give my file a brief lookover and help me ascertain why it does not function at all when it has been lifted, line-by-line, from code that works on BL1 and BL2?

If my request(s) have become overbearing, please let me know and I will throw this up to the community as a revised "A vs B" conundrum. Thank you so much.

Only_2_BLE3_BLE4.aia (3.0 MB)

Feel free to ask the community

Thank you for all of your time and expertise. It turns out - user error, or senior moment, if you will. Both files work perfectly. I just had to get my head out of an uncomfortably tight location to see it through. Namaste.

Thanks for telling us.
We have enough walls to bang our heads on.