Newbie SMS Test

Hello everyone, I have a question about SMS processing.
I have an Arduino with sensors connected to a sim800L that sends and receive SMS to inform me for different states. To make simple, let's say that I have 5 contacts that are either open or closed. When the state of one or more contacts changes it sends me an SMS that summarizes their states.
For example :
C1F.
C2O.
C3F.
C4O.
C5O.
With its unique number I know how to treat it in MIT-INVENTOR2, on the other hand, where I have worries it is to treat SMS. I know how to recover the SMS: (finally I believe?)
I created a variable for the number and list:
image
I think I'll put the SMS in the list, if it's the right number:
image
Now how to do the decomposition in order to assign a button variable with its state?
For example with the previous SMS, I would like to have the result:
image
What do you think you are the best to do it?
Thanks.

Hmm, it looks complicated or impossible with MI2! I will consider with another more accessible software.

YEah, its very complicated

Not really, the blocks to get the data from the SMS messages is not correct.

Export your .aia file and upload it here.

Hi and thanks @ABG for help.
Poor file here : Buttons_States.aia (2.2 KB)
Regards.

Here is my take on the message processing.
(I did not bother with checking if the phone number is on the builtin list.
It will respond to any phone text.)

(Warning: I actually do not use a smart phone, only a flip phone, so I am working from the docs here.)

SMS_Text Properties
The Receiving Enabled attribute looks important.
According to http://code.appinventor.mit.edu/reference/components/social.html#Texting
it needs to be set to the right number.

So I added


a List Picker to let the user set the SMSEnabled property from a friendly list:
OFF,FOREGROUND,ALWAYS

I also added a test button and a log, for debugging:

Since you use similar switch handling, we can use lists and generic blocks:

A common procedure handles all input:

It is set up to scan for each different on/off message for each different contact in its incoming message. This lets you send all or some switch messages in the same text, regardless.
If the SMS contains and ON and OFF message for the same switch, the last takes precedence.

Buttons_States_ABG.aia (4.8 KB)

P.S. I tried to test this on a MemuPlay emulator, and immediately ran into a permission error.
I will have to leave this to some one with SMS capability and Permission experience to test.
Alternatively, just drop the SMS component and use the text input to test the string and switch handling.

Hello and thank you @ABG for code the details.
If I understood everything, you have to disable the properties of the SMS and put it on Off by default on Designer. When launching the APS we activate the reception of SMS and the "ListPicker".
At initialization, we place the reception of SMS and the LPKSMsenabled in the foreground.
It's a good idea to put a test button.
On (my) simulator is not visible :


Then initialization of the global "switches" for the 5 cases.
If click "Test" button, We send the text & number to the textbox.
For each message with the corresponding number, the text is replaced by the number: "1234567890" plus the text of the SMS and a carriage return.
For each "contact" of 1 at the end of the list, one by one, the list of "switch" is filled with its index.
If the contents of the switch contain "C" and "O." So we switch one is true and we change the background in green.
If the contents of the switch contain "C" and "F." Then we switch one is wrong and we change the background in red.
The last state SMS of a switch takes over!
I tested with my smartphone using my number by sending me an SMS (C1O.) With APS active, nothing happens.
I'll investigate .... Thanks again for support !

No, that's just a coincidence, because I left it as it arrived in the Designer from the components pallette. In Screen1.Initialize, I set it to 2 to allow messages to be received by the app, but not always. There is a big HELP doc in the tooltip for that block, which you should read. (I have no experience with this, just reading.)

Same here. I did not play with the Screen to show everything, since I don't know how many switches you want. (10?) Either set Screen1 scrollable, or use proportional heights for everything to fit.

That's the logging feature. I never use your constant "1234567890". That should be removed. (If in doubt, rip it out)

The message should have appeared in the log.
Try typing C1O. into the text box and hit the TEST button to process it, to test my logic. (I should remove my SMS component and just use the text box for my testing, after I make my rounds on the board.)

Buttons_States_Test.aia (3.9 KB) Capture Capture2

As promised, this is the test-only version of the app, with the log and switch handling.

I leave it to you to add the SMS part to call the procedure with incoming phone numbers and SMS messages. You probably don't need to bother checking the incoming phone numbers against any lists. Who would care to spam your phone with messages including the constants "C1O.", "C1F.", ... ?

Ok, thanks for the details, I understood, for first question, 1 is OFF, 2 is FOREGROUND and 3 ALLWAYS.
To test, I have reduced to 2, the number of contacts. Like this all items are visible on the simulation screen. I'm trying first with tiny, without effect, the text appears in the log. With capital letters, it works. The Change Color button and the box checks!


Same on my phone.
Now, I would like to test with real SMS, I need to tell the APS the number that will send the orders (and ignore the other SMS) so I need somewhere to say what is this number?

Yes good, sorry with cross message ....