GET ending in '?' character behaves strangely

I am using the GET action on the WEB component to send a request to an Arduino acting as a web server. The URL consists of the Arduino's IP address, followed by a '/' and a command (from a command set implemented on the Arduino). I've noticed that if the command ends with a '?' character (e.g. "http://192.168.50.100/T?") weird things happen. Clearly that's NOT what's being received by the Arduino (based on its behavior). I know the problem is not in the Arduino sketch, because I can send the same URL from a browser, and it works fine. Is there some special way App Inventor handles the '?' character ?

Rusty, read your post again and try to be in our shoes. Would you be able to solve your problem? I think not.
So, tell us more about what you are trying to do, what the weird things are and why they are weird. And what you expect instead. Show also your blocks.

Hope this helps ...

I've defined a command set on my Arduino. I want my app to issue commands to the Arduino, using GET requests. So the URL sent to Arduino looks like "http://192.168.50.100/<command>", where "command" is the command defined in the Arduino. Some of my commands in my command set end with '?'. For those, the '?' is dropped; if the command embeds the '?' with other characters, it is not dropped. I know this is what is happening, because the Arduino prints the received URL (on the Serial Monitor tool in Arduino IDE).

The block simply looks like this. 'Sendget' is a procedure to which I pass the command I want to send (as 'getreq'). And 'global ard_url' is just "http://192.168.50.100/".

blocks

and an example or examples of the commands you send in getreq ? Ones that work and ones that do not?

T? does not work (T is received)
T. does work (T. is received)
FOO? does not work (FOO is received)
FO?O does work (FO?O is received)

(By "work" I mean that the Arduino receives the intended URL, which is simply one of these commands prefaced by the IP address etc.)

You may need to put the command in quotes, or escape the ? when at the end. As with other programming languages ? is probably a special / reserved character in arduino code (don't know enough about it to say for certain).

The Arduino is doing the right thing. For example, if I send the 'T?' command from a browser, it works fine. I'm pretty sure that the problem is with App Inventor.

Which isn't to say that escaping or quoting it might not be a solution. But it isn't. T? gets sent as T/. "T?" gets set as %22T?%22.

Anyways, not that hard to change the commands on the Arduino, just thought somebody would know off the top of their head.

Dear @RustyShackleford,
could you use the Serial Monitor of Arduino to print "exactly" (the raw characters, preferably in HEX, or ASCII, so to see if there are some ghost characters sent in the string) what it is received by your app ?
I mean: if you think that the app treats in some weird way the "?" probably by printing out at receiver side what Arduino is effectively receiving will help in finding the root cause ?
It's just a hint (not the solution obviously :slight_smile: )
Best wishes.
EDIT anyway, a look to your Arduino receiving procedure could also help..... :thinking:

Try Web1.Url + Web1.UriEncode + Join

1 Like

As already said above, this is probably a character set issue.
I hope you are using the AI companion to develop your app, so you could make some debug labels showing what you are really sending or use DoIt on some global variables that keep your commands.
Anyway, as it seems that you can define your own commands, it seems most practical to use commands without a ?

So if you noticed that AppInventor has problems with "?" then just change the code in arduino and don't use "?". The simplest and fastest solution.

That's what I'm going to do.