botletics / SIM7000-LTE-Shield

Botletics SIM7000 LTE CAT-M1/NB-IoT Shield for Arduino
https://www.botletics.com/products/sim7000-shield
GNU General Public License v3.0
481 stars 216 forks source link

Best way to grab (parse) data returned from web application #242

Open mduiop opened 3 years ago

mduiop commented 3 years ago

Can anyone provide an example . . . Ultimately I'd like to pull variable values (name/value) pairs from a web page (custom php script). I could send a GET request from the sim7000a to the web app, but am not sure how to parse the response to get the name/value pairs and store the values in a variable(s) on the Arduino. Maybe there's a better way all together? I am competent with PHP so can do what I need to on the web server side, but Arduino/C++ is new to me. Thanks if anyone has a suggestion.

Edit: to clarify and be more specific, I'll have variables in my c++ on the arduino. I want to get the values for these vars dynamically from the web page.

mduiop commented 3 years ago

I just noticed that there is a 'read website URL' function in the LTE_Demo sketch. It seems like the contents of the webpage is read, and there's a loop which iterates for every character returned from the webpage and prints it to the monitor. I will play with that and use strtok() or substr() (if that exists in C/C++) . . . to parse out name/value pairs delineated by some token I can create, and assign those values to the appropriate variables in my sketch. If anyone has already done something like this, and wants to share some methods for accomplishing this, or some example code that would be great, but I can probably pull it off now that I see this . . . unless I am missing something here. Thanks