BLE extension - compare received string with known string

Hello. I am creating a program to remotely control an arduino relay. I use BLE extension. I have everything working now, but I want to improve something. The question is how to compare the received data (String) with the known string.
My arduino sends the string: "a11". This is implemented as follows:

Serial.print("a11");

In the Android program, I received it and display it on the screen:
before
In my program it looks like this:
receive
But I want to compare the received String with the one known in the program and display the inscription ON or OFF instead. I tried to do it somehow like this, but it didn't work for me.


OFF is always displayed. How to correctly compare the strings? Maybe I'm doing something else wrong?

stringValues is a list.

If you try to treat it like a piece of text, AI2 will wrap it with ["JSON"] markup, messing up you comparison.

Either select item 1 from stringValues to feed into the comparison, or use a For Each Item in List block and test each item.

It's slightly worse than that. The default formatting of a list depends on the ShowListsAsJson property of Screen1. In newer projects, this is true by default. Older projects (or projects where it is unchecked) will default to the Scheme notation for lists using parentheses.

Generally, you can grab the first item in the list and use that value to compare to your intended target.

Thank you all for your help! Now everything works.


answer

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.