Hi! In my application, I send strings from my ESP32 to my application via bluetooth. I need to compare the text I receive and only get part of it. For example:
-String sent: "v:2500"
I need to compare if my String contains "v:", then assign the value "2500" to a variable. How can I do this?
(Canned reply)
If you want to send your temperature and humidity on separate lines, you could alternatively send tag:value pairs, like
T:98.6\n
H:100\n
which would arrive individually if you use Delimiter 10 (\n).
Your AI2 logic would look like
if BT.bytesAvailable > 0 then
set local message to BT.ReadText(-1) (to get only 1 line)
if contains(message, ":") then
set local splits to split message at ":"
If (select item 1 of splits) = "T" then
set LabelTemperature.Text to (select item 2 of splits)
else if (select item 1 of splits) = "H" then
set LabelHumidity.Text to (select item 2 of splits)
else set LabelWhatHappenned to local message
end if