Help with "Expression" and "Web Link" syntax


#1

Are there any examples on how to use the “Expression” element in the Application view? I know how to use regular expressions but not sure how to use this IDE element to accomplish a simple task.

I want to check if the string value I am getting from the Buzzer via the BLE Characteristic is “true” or “false”.
I tried setting the expression field to true or readData=="true" but no luck.

I would share the .atmo file but this form won’t let me add anything other than image files. Here is a screenshot of what I mean:

In the above example, the Label field correctly updates to true or false depending on the buzzer state that I set by pushing a button. I am using the same thing to feed the Expression element.

Any ideas or help would be greatly appreciated.


#2

First thing I notice is the argument you are passing to the Set Text ability of Text you want to be a static string so you will want to wrap that in quotes so it should have "Buzzer is ON"

So you can use a expression to do this, how ever a condition element would be easier. You can just in the connector going into the Condition element handle the conversion to a boolean and then use the Condition True, and Condition False triggers. Also you might just want the set the BLE Characteristic’s read type as a Boolean instead of a string then you wouldn’t need to do the string comparison in that app.


#3

Thank you @kieron.gillespie for the detailed response. Although I couldn’t get the Expression block to work, I was able to get the Condition block to work.

Next, I want to trigger opening a URL that plays a message on my speaker. I’ve confirmed that calling it directly in Safari on my phone and desktop works as expected. I made a google URL shortened link to track how many times it gets called.

I know that there is a WebIO block for more complex actions but I used a Web Link block since all I wanted was to open a URL. This however did not work. I am using this configuration:

I see the trigger succeed on the Label but no URL is opened. Can you please help?

The element’s description says:

The web link element is used to call the browser from within the interface to open a website.

Does this mean that the NXP Rapid IoT app will launch Safari and open the link in an external Safari Browser app? Or will it just open it locally inside the NXP app using a UIWebView?

FYI, Before using the URL shortener, I tried using the original link. It also failed so I thought it might be that it was too long for the Web Link block to handle (almost 200 characters).


#4

When passing arguments in the connectors the static values need to be formatted as proper javascript. So in this case you would make the url value be "https://goo.gl/". What will happen is that the default web browser will be pulled up taking the user to the specified website. There is no known limit to the length of the URL except for the W3C standards of 2,083 characters, though I don’t think that is actually enforced by most browsers.


#5

Thank you @kieron.gillespie. That did the trick.
May I suggest some clarification to the documentation. It appears to omit the quotes in the examples.

Here:


and here:

image

In fact, the examples in the documentation would be more meaningful if they included a screenshot of the Web Link Element and of the Connector properties. An .atmo file using them would clear up any confusion too.