xively status:400 with arduino and sim900 gprs shield - arduino

Im using a cheap Sim900 GPRS shield with arduino and hopefully xively. I'm able to connect to xively with tcp but when i send in the data i get this response "status":400,"body":"Syntax Error: parse error: ".
I'm using the sample from http://www.seeedstudio.com/wiki/GPRS_Shield_V1.0#SoftwareSerial_library_Notes and I've tried some modifications without any luck. I don't find documentation on how this string should look like.
My serial string looks like this:
{"method": "put","resource": "/feeds/feednumber-removed/","params": {},"headers": {"X-PachubeApiKey":"device key removed"},"body": {"version": "1.0.0","datastreams": {"id": "Sensor1","current_value": "1031"}]},"token": "123"}
Can someone please help me on this subject?

Looks like your JSON may be missing some brackets. You also have some arguments that you dont need. Try something like this instead:
{
"method": "put",
"resource": "/feeds/FEED_ID_HERE",
"params": {},
"headers": {"X-ApiKey":"API_KEY_HERE"},
"body": {
"version" : "1.0.0",
"datastreams": [
{
"id": "Sensor1",
"current_value": "1031"
}
]
}
}
I have tried to make the bracketing as verbose and aligned as possible so you can see where the brackets need to be in order to conform to the Xively JSON format, and just correct JSON in general. I also updated the header name which has changed since the Pachube days.

Related

Can fluentbit forward fluentbit_metrics as plain text instead of a JSON object to a port?

I am trying to send fluentbit metrics to an external source for processing. My understanding from the documentation is that the fluentbit_metrics input is intended to be used with output plugins that are for specific telemetry solutions like Prometheus, OpenTelemetry, etc. However, for my purposes, I cannot actually use any of those solutions and instead have to use a different bespoke metrics solution. For this to work, I would like to just send lines of text to a port that my metrics solution is listening on.
I am trying to use the fluentbit forward output to send data to this endpoint, but I am getting an error in response from my metrics solution because it is receiving a big JSON object which it can't parse. However, when I output the same fluentbit_metrics input to a file or to stdout, the contents of the file is more like what I would expect, where each metric is just a line of text. If these text lines were what was being sent to my metrics endpoint, I wouldn't have any issue ingesting them.
I know that I could take on the work to change my metrics solution to parse and process this JSON map, but before I do that, I wanted to check if this is the only way forward for me. So, my question is, is there a way to get fluentbit to send fluentbit_metrics to a forward output where it does not convert the metrics into a big JSON object? Is the schema for that JSON object specific to prometheus? Is there a reason why the outputs differ so substantially?
Here is a copy of an example config I am using with fluentbit:
[SERVICE]
# This is a commented line
Daemon off
log_level info
log_file C:\MyFolder\fluentlog.txt
flush 1
parsers_file .\parsers.conf
[INPUT]
name fluentbit_metrics
tag internal_metrics
scrape_interval 2
[OUTPUT]
Name forward
Match internal_metrics
Host 127.0.0.1
Port 28232
tag internal_metrics
Time_as_Integer true
[OUTPUT]
name stdout
match *
And here is the output from the forward output plugin:
{
"meta": {
"cmetrics": {},
"external": {},
"processing": {
"static_labels": []
}
},
"metrics": [
{
"meta": {
"ver": 2,
"type": 0,
"opts": {
"ns": "fluentbit",
"ss": "",
"name": "uptime",
"desc": "Number of seconds that Fluent Bit has been running."
},
"labels": [
"hostname"
],
"aggregation_type": 2
},
"values": [
{
"ts": 1670884364820306500,
"value": 22,
"labels": [
"myHostName"
],
"hash": 16603984480778988994
}
]
}, etc.
and here is the output of the same metrics from stdout:
2022-12-12T22:02:13.444100300Z fluentbit_uptime{hostname="myHostName"} = 2
2022-12-12T22:02:11.721859000Z fluentbit_input_bytes_total{name="tail.0"} = 1138
2022-12-12T22:02:11.721859000Z fluentbit_input_records_total{name="tail.0"} = 12
2022-12-12T22:02:11.444943400Z fluentbit_input_files_opened_total{name="tail.0"} = 1

Post Request Returning {"error": "Expecting a string", "result":87}

I am trying to interface with the Chroma SDK released by Razer and have been running into some issues. Following the documentation that razer provides, I have been trying to change the color of my RGB mouse for a while now, and hope that someone has the answer for me. I can successfully check to see if the ChromaSDK is working through:
url = 'http://localhost:54235/razer/chromasdk'
x = requests.get(url)
print(x.text)
Then, I can initialize the connection by sending a post to the URL, following the template given on their website:
data = {
"title": "Razer Chroma SDK RESTful Test Application",
"description": "This is a REST interface test application",
"author": {
"name": "Chroma Developer",
"contact": "www.razerzone.com"
},
"device_supported": [
"keyboard",
"mouse",
"headset",
"mousepad",
"keypad",
"chromalink"],
"category": "application"
}
x = requests.post(url, json=data)
print(x.text)
This post request returns:
{"sessionid":55105,"uri":"http://localhost:55105/chromasdk"}
Then, since the connection is initialized, I SHOULD be able to change the colors of the connected Razer devices using endpoints such as /mouse or /headset. This is where it gets funky, if I were to use the url(s): http://localhost:54235/chromasdk/mouse, http://localhost:54235/razer/mouse, or http://localhost:54235/mouse then I get the error "Not Implemented", whereas if I use the URI provided by the previous post request and tag /mouse onto the end of it, it get this error:
{"error":"Expecting a string","result":87}
Or if I use http://localhost:54235/razer/chromasdk/mouse, I get:
{"author":null,"category":null,"description":null,"device_supported":null,"error":"The parameter is incorrect.","result":87,"title":null}
The endpoints SHOULD follow the URL http://localhost:54235/razer/chromasdk, and I am following the documentation to a T, so what am I doing wrong??

How to decode extrinsic at json-RPC call's data(byte code)

I call json-RPC through the terminal and get the data as below.
extrinsics is raw byte, but I'm using polkadot-js(SCALE codec?) to decode it.
But I don't know which method to call.
"block": {
"extrinsics": [
"0x280402000be1da78d37e01","0xd91f..(too long haha)..580"
],
"header": { "digest": { ... }
#polkadot/crypto-util? #polkadot/util? Which module and which method should I use? I want input string(raw data) and get string(json or human data)
please help..

jsonPath and email address

I am using jsonpath.com to try to use an email address as the KEY.
so my data might look like this:
"phoneNumbers": [
{
"type" : "iPhone",
"bob#gmail.com": 123456,
"number": "0123-4567-8888"
},
however, i am unable to reference the email address:
$.phoneNumbers[0]['type'] // iPhone
$.phoneNumbers[0]['number'] // 0123-4567-8888
$.phoneNumbers[0]['bob#gmail.com'] // no match
$.phoneNumbers[0]['bob\#gmail.com'] // no match
$.phoneNumbers[0]['bob\#gmail\.com'] // no match
how may i specify a jsonPath key using an email address?
The dot in .com is the problem. See this SO answer. It would seem that it should be possible to do $.phoneNumbers[0]['bob#gmail.com'], but not on jsonpath.com
The key statement in that answer:
jsonpath.com is based on an outdated version of JSONPath and is not
reliable for previewing what current libraries would provide you with.

Get unique device id for amazon echo

I am writing a custom skill for the amazon echo and I need to get a unique device id so I can register then product to my service. Everything I read says that you cannot get the id from the device. Has amazon changed this? Is there a work around to get a device id?
This week Amazon added the Device ID (unique) to the LaunchRequest JSON payload in Alexa Skills.
{
"session": {
"new": true,
"sessionId": "string",
"application": {
"applicationId": "string"
},
},
"context": {
"device": {
"deviceId": "string",
},
"request": {}
}
You can use the context->device->deviceId string to uniquely identify the device from which the request came.
Read more # https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#request-body-syntax
There is no way to get a unique device ID. All you can do is get a unique User ID. There is no known workaround.
If you're looking for how to get Alexa Device ID?
Use the below snippet, It will work like a charm.
device_id = handler_input.request_envelope.context.system.device.device_id
I hope this helps you.

Resources