Send different messages depending on the value

I have a bluetooth conection between Arduino and an app that I created that receives 3 signals, one for an emergency call and other two for a gas leak and an open door, after that, for the gas leak or the open door the app must send a SMS to three contacts. The problem is in the sms section which only sends the messages when receives the info from the gas sensor, but with the door sensor the app still marks "GENERIC FAILURE: MESSAGE NOT SENT".
It's my first time using App Inventor so I don't have much experience about it, could you help me?
Best regards.

Welcome Daniel.

Your issue is probably the same as this issue Error 908 not sending SMS message and Permissions Do Not Allow to ask for SMS

This is probably a serious bug MIT is aware introduced with the latest release of App Inventor . They they have not fixed it yet. :cry:

Thanks for your response, but I think is another problem. My app has all the permissions about sms and call, actually is capable of send messages but the main problem is that only sends with the condition of the gas sensor. In the image the message with the red circle arrow is for the door sensor, and the other messages which don't have that arrow are for the gas sensor (the messages are in Spanish)

Please post your Arduino code here, so we can compare line delimiter usage on both sides of the BlueTooth connection.

I suspect you are violating:

Please see the Delimiter article in FAQ

Be sure to use println() at the end of each message to send from the sending device, to signal end of message. Do not rely on timing for this, which is unreliable.

In the AI2 Designer, set the Delimiter attribute of the BlueTooth Client component to 10 to recognize the End of Line character.
Also, return data is not immediately available after sending a request,
you have to start a Clock Timer repeating and watch for its arrival in the Clock Timer event. The repeat rate of the Clock Timer should be faster than the transmission rate in the sending device, to not flood the AI2 buffers.

In your Clock Timer, you should check

  Is the BlueTooth Client still Connected?
  Is Bytes Available > 0?
     IF Bytes Available > 0 THEN
       set message var  to BT.ReceiveText(-1) 

This takes advantage of a special case in the ReceiveText block:

Receive text from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.

If you are sending multiple data values per message separated by | or comma, have your message split into a local or global variable for inspection before trying to select list items from it. Test if (length of list(split list result) >= expected list length) before doing any select list item operations, to avoid taking a long walk on a short pier. This bulletproofing is necessary in case your sending device sneaks in some commentary messages with the data values.

I guess you're right, in the Arduino code I'm using only print instead of println and I didn't set the attribute.
In the code I'm receiving data from two nodes, the first one from the gas sensor and the second from the door sensor, Also the master node has a button so it works as a third node. for the print I wrote one Print after the Arduino reads the value of the button while the second and third Print are declared at the end of the code.

I miss the last print, I'm programming it in spanish and didn't change the last print. Instead of "state_puerta" it must be state_door

You were missing this.

Also, you were missing length of list checking in AI2.

Sorry that I didn't understand but, what do you mean for this?

Also, you were missing length of list checking in AI2.