Problem using ArduinoHTTPClient sending GET requests with ESP32 - http

Board : ESP32 T-Call SIM800L
Code Functioning
Collect Data from phone -> Put Into URL -> Send to Server
CollectQualitativeData() -> AppendQueryParameters() -> http.get(resource)
My code allows me to enter 4 different strings in my android app which my ESP32 receives via bluetooth and stores as an array of char arrays QualArray[4][30] (eg. {"string1","string2"....) . It then adds these strings in the URL query parameters for which I send data to my google sheets web app with a GET request (I know i'm posting data but the get request is what is used for the google apps script when posting data).
Problem
The code works when I pre-define the URL to be sent, although the issue seems to be that adding the strings obtained from the android app to the URL returns an HTTP response of -3 and doesn't upload to the google sheets server. This confuses me as the strings are stored okay because I print them out and they are correct, and then adding them to the URL and printing the URL it looks correct (and identical to the pre-defined URL that works) but for some reason it doesn't work. I thought it could be memory related so I pre-defined all the char arrays with set buffers but still didn't work
Code
https://github.com/Conwon99/4th-Year-Project/blob/main/ESP32_HTTP_REQUEST
The functions to look at are CollectQualitativeData() which is called in setup and AppendQueryParameters() which is called in the loop, then http.get(resource) is called afterwards in the loop which makes the GET request.

Related

Rpyc - Is it possible to get the original type back from rypc?

I am using Rpyc and have setup a client server model. The server sends Python objects but I’m having trouble working with them on the client side as their types changed (eg a dict won’t be a dict but a netref.something) - is it possible to get the original type back?

Server error upon adding new device leads to duplicate devices

TL;DR -
I have erroneously created a load of duplicate devices in Xively. How do I delete them, using only my browser? Or do I need to write a Perl script?
I have just opened a new Xively personal account, and was running through the Test Drive.
Upon step 2
I added a new device
Upon clicking Add Device, I received a server error
After repeated attempts (clicking on the browser's back button and trying again), I clicked on the Develop link at the top of the page, only to be shown multiple duplicate devices:
If I click on a device, to open its Workbench, I get another server error (note that the URL is different from the first):
Is there currently a server error - nothing is mentioned about the server being down in the Twitter feed? How do I delete the duplicate devices, or edit them? Is there a way of managing them? I don't appear to be able to find a link to contact the support desk. Is there actually a support desk available?
Is my account now "ruined"? Should I give it up as a bad job and open a new account?
P.S. When I was adding the devices I was running through a VPN (TunnelBlick on OS X), but surely this should not have caused the issue..?
I have tried following the information from Delete a Device:
Method DELETE
Base URL https://api.xively.com
API Endpoint /v2/products/PRODUCT_ID/devices/SERIAL_NUMBER
However I do not know what the PRODUCT_ID is, and I am only guessing that the SERIAL_NUMBER is the code at the end of the device URL?
Click on one of the duplicate devices to obtain the device URL (even though it still leads to the server error page): https://personal.xively.com/develop/sfStgqRmlqymGIFeHleB
Forming the delete URL:
https://api.xively.com/v2/products/PRODUCT_ID/devices/sfStgqRmlqymGIFeHleB
After logging in to confirm the delete action, I get the message
{"title":"Not found","errors":"Couldn't find Product with product_id = PRODUCT_ID"}
How do I discover the PRODUCT_ID?
So, from List All Products:
Method GET
Base URL https://api.xively.com
API Endpoint /v2/products
I used the URL:
https://api.xively.com/v2/products
and I get a list of all of my Products, which are actually of the duplicate devices, and a series of different PRODUCT_IDs. (It seems a bit odd that the devices have PRODUCT_IDs and not device SERIAL_NUMBERs):
{"totalResults":7,"products":[{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"sfStgqRmlqymGIFeHleB","secret":"41aad0ab3fec62efd94fc7d54f77a911f232522d","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"},{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"luXVnI1ymGHW4SonH-37","secret":"e923aad16dce33e6635e7a8620243110ba93e9cc","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"},{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"4NV5BvCmx54q84AcVCLB","secret":"13e624cececcecf9af6e558874cdf78e65049fe8","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"},{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"l8S8kBZWWG_s1YRrytwW","secret":"5a476bc550055d8ab7dc7c72ceb0433fd39e451f","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"},{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"jWWRuW_JhkXqKUA0F769","secret":"b3a5d78b51dca5d3ef56268141e7c25c8d00a61a","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"},{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"3nXDH0DV6z3_y5cr47qA","secret":"7793d8607194fec4a7e85c0091df93642fc68069","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"},{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"TWF2T_IXpS7sDZxSlc2f","secret":"9f03403167b467ec7fec295c87c6260b3a4074cc","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"}]}
Following on from that, from Delete a Product:
Method DELETE
Base URL https://api.xively.com
API Endpoint /v2/products/PRODUCT_ID
I create the URL
https://api.xively.com/v2/products/TWF2T_IXpS7sDZxSlc2f
Where TWF2T_IXpS7sDZxSlc2f is the last PRODUCT_ID in the product list generated above. However, this just returns the data for that PRODUCT_ID:
{"product":{"description":"A sPhone by Smapple","name":"SplunkinsPhone","product_id":"TWF2T_IXpS7sDZxSlc2f","secret":"9f03403167b467ec7fec295c87c6260b3a4074cc","state":"develop","devices_count":0,"activated_devices_count":0,"feed_defaults":{"title":"SplunkinsPhone","private":"true"},"user":"splunkins"}}
The issue is now that how do I perform a DELETE method, through my browser, as the URL is just a GET and is basically performing a Read a Product instead of a Delete?
The answer is to, recursively for each PRODUCT_ID, use curl
curl -X DELETE 'api.xively.com/v2/products/3nXDH0DV6z3_y5cr47qA' -u 'username:password'

basic firebase URL structure?

I am building a very simple cron job backup system for a friend's firebase app;
I have PHP code, using firebase-php that can communicate with the firebase and the API docs state that adding the'?format=export" parameter will retrieve a .json file. Cool, so far.
My question is this: What path (after the firebase URL) is required?
The API doc appears to state that it should be /.json but it returns a 404 /json/ works on the simulator, but also returns a 404 in testing
(note: looking for a single text file, similar to the "Export json" data dashboard, if possible)
Thanks in advance.
The path defined the portion of the Firebase data tree that is being loaded. That means that you can load /any/possible/string and it will return a value, though that value is likely to be null unless you've written data to that path. Also note that without a defined extension (i.e. .json) you'll be attempting to load Firebase's in-browser graphical debugger.
In short, if you're using the REST API, you'll always want to end your paths in .json, but nothing else is required, i.e. https://<your-firebase>.firebaseio.com/.json is perfectly valid, and would download your entire Firebase. The format=export parameter ensures that any Firebase priority values are preserved in your JSON output, under the key .priority at any node, where they would normally be excluded.

Is it possible to get an S3 file url before it's uploaded?

So, here's the scenario. I have a site which allows you to perform certain operations on files, which take on the order of seconds. I don't want the client to have to wait that long before the server returns a response so they way we have it now is that
User performs an operation in their browser (client)
Client sends a POST request to server with parameters
Server adds operation to job queue and sends back the expected url of the result
Client pings server until file is available then serves it
Currently these files are being stored in my ec2 server but I want to move this to S3. I was wondering if this type of flow is possible.
The server knows what the file will be saved and to where way before it actually is, so is that the same case with S3? Is there a way of knowing the file URL if I know all the information beforehand (bucket, filename, etc)?
All S3 object URLs follow patterns, so it's easy to know what the URL will be ahead of time.
If the bucket name is DNS-compliant (required of all regions except for US Standard), then it'll look like this:
<bucket>.s3.amazonaws.com/<object-path>
The U.S. Standard region is a bit more lax in it's bucket name rules (they aren't required to be DNS-compliant), so some may look like this:
s3.amazonaws.com/<bucket>/<object-path>
So, if your bucket name is something DNS-compliant (e.g., example), and your file is abc/123/file.txt, then your object URL will be:
example.s3.amazonaws.com/abc/123/file.txt
So, if your bucket name is NOT DNS-compliant (e.g., EXAMPLE_123), and your file is abc/123/file.txt, then your object URL will be:
s3.amazonaws.com/EXAMPLE_123/abc/123/file.txt
Here's an example of the DNS-compliant logic from the official PHP SDK.
https://github.com/aws/aws-sdk-php/blob/master/src/Aws/S3/S3Client.php#L293-L317

Google Geocoding API, HTTP, CSV-data in API v3

I'm developing embedded software for a gps-tracker. Until this time I used Google Maps v2 for reverse geocoding (to convert GPS-coordinates to address string). I used http-request and a short-response-form (csv) (http://maps.googleapis.com/maps/geo?q=&output=csv&...). Now, when the support of API v2 is almost over, I try to migrate to v3, but I can't find a csv response-format in http-request settings. The response-size is a critical parameter for the device. How do I solve this problem? Thank you.
According to the documentation you're stuck with JSON or XML.
A Geocoding API request must be of the following form:
http://maps.googleapis.com/maps/api/geocode/output?parameters
where output may be either of the following values:
json (recommended) indicates output in JavaScript Object Notation (JSON)
xml indicates output as XML
Example: the query should look like this:
http://maps.googleapis.com/maps/api/geocode/json?sensor=true&address=Your+address+here
or
http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=Your+address+here
where required parameter sensor indicates you are calling from a location sensor enabled device or not.

Resources