AWS IoT: When to use thing attribute over Shadow - amazon-web-services

I saw that there was an question already, but I receive a page not found error when accessing it: https://stackoverflow.com/questions/57284026/aws-iot-thing-attrubite-vs-shadow-property?S_TACT=
So I've got the same question.
I've got some fields which could definitely be an attribute as they're not changing: DeviceId, SerialNumber and some others.
But I also want to store/update :
rather seldomly updated fields: e.g. the status from (Created -> Registered -> Unregistered)
frequently updated fields: e.g. lastSeen timestamp when the last message was sent
Should I now use Device Shadow for everything, Thing Attributes for everything or mix it?

Related

AWS SNS filtered subscription with exists = false for messages without attributes set

I am setting up subscriptions to a topic that a number of different apps publish to. I want to filter the subscription of one particular app so that it doesn't receive back messages that it sends.
I tried adding an attribute with a value identifying the app, eg x-forwarded-by=myapp and set the filter policy as:
{
"x-forwarded-by": [{"anything-but": ["myapp"]}]
}
That correctly prevented the app receiving these however it also didn't receive any messages where there was no x-forwarded-by attribute, nor did it receive any messages whether there were either no attributes or there was an empty attribute object, eg, I would have expected to see messages with:
"MessageAttributes": null
"MessageAttributes": {}
"MessageAttributes": {"someOtherAttribute":{"DataType":"string", "StringValue": "SomeValue"}}
I also tried using an exists filter so that if the app set that attribute, it could filter it out later, eg:
{
"x-forwarded-by-my-app": [{"exists":false}]
}
This only worked if there was at least one other attribute set, and this would require me updating every app that publishes to include a dummy attribute.
I tried combining them, as in:
{
"x-forwarded-by": [
{"exists":false},
{"anything-but":["myapp"]}
}
And this worked slightly better as it handled the case of the x-forwarded-by header either not being present or having a different value. It doesn't however handle the case of no attributes being set.
Is there a way to achieve this with a filtered subscription or do I have to just have the app receive these notifications and have the app check for and ignore them?
It seems there is some issue with "anything-but", I tried this with { {"exists":false},"anything-but":["myapp", ""]} and it works.
In my case I went ahead with: {{"exists":false},"positiveCase"}.

How to create a stop-filter (instead of a pass-filter) when reading CAN messages? [C++, Linux]

I am using a SocketCAN to access the CAN bus.
I have successfully created pass-filters like this:
struct can_filter m_Filter;
// ... setting up m_Filters
setsockopt(m_CanSockId, SOL_CAN_RAW, CAN_RAW_FILTER, m_Filter,
sizeof(struct can_filter));
This instructs to let CAN messages pass when meeting the filter settings.
Now I want to create a stop-filter but I do not know how to do it.
For example: I wish to let all CAN messages pass except the ones with ID 0x18DAF101.
Does anybody know how to do it?
You have to set the bit CAN_INV_FILTER in your filter to invert the filter logic.
From the documentation behind the link you have provided:
The filter can be inverted in this semantic, when the CAN_INV_FILTER
bit is set in can_id element of the can_filter structure.

ELMAH noYsod attribute when emailing?

I am new to ELMAH and am configuring it to send email. I cannot find any documentation on what the noYsod attribute means. I have omitted it and am getting email sent successfully, but I'd just like to know what this mystery attribute does.
Extra points...unclear on the priority attribute as well. Prioritizes sending from ELMAH, or tags the sent email with a priority?
<errorMail
from="elmah#example.com"
to="admin#example.com"
subject="..."
priority="Low|Normal|High"
async="true|false"
smtpPort="25"
smtpServer="smtp.example.com"
useSsl="true|false"
userName="johndoe"
password="secret"
noYsod="true|false" />
For those who don't want to browse through source code:
noYsod: Indicates whether YSOD is attached to the e-mail or not. If true, the YSOD is not attached. Default is false.
priority: Sets the MailPriority of the email message. Default is Normal.

Retrieve service information from WFS GetCapabilities request with GeoExt

This is probably a very simple question but I just can't seem to figure it out.
I am writing a Javascript app to retrieve layer information from a WFS server using a GetCapabilities request using GeoExt. GetCapabilities returns information about the WFS server -- the server's name, who runs it, etc., in addition to information on the data layers it has on offer.
My basic code looks like this:
var store = new GeoExt.data.WFSCapabilitiesStore({ url: serverURL });
store.on('load', successFunction);
store.on('exception', failureFunction);
store.load();
This works as expected, and when the loading completes, successFunction is called.
successFunction looks like this:
successFunction = function(dataProxy, records, options) {
doSomeStuff();
}
dataProxy is a Ext.data.DataProxy object, records is a list of records, one for each layer on the WFS server, and options is empty.
And here is where I'm stuck: In this function, I can get access to all the layer information regarding data offered by the server. But I also want to extract the server information that is contained in the XML fetched during the store.load() (see below). But I can't figure out how to get it out of the dataProxy object, where I'm sure it must be squirreled away.
Any ideas?
The fields I want are contained in this snippet:
<ows:ServiceIdentification>
<ows:Title>G_WIS_testIvago</ows:Title>
<ows:Abstract/>
<ows:Keywords>
<ows:Keyword/>
</ows:Keywords>
<ows:ServiceType>WFS</ows:ServiceType>
<ows:ServiceTypeVersion>1.1.0</ows:ServiceTypeVersion>
<ows:Fees/>
<ows:AccessConstraints/>
Apparently,GeoExt currently discards the server information, undermining the entire premise of my question.
Here is a code snippet that can be used to tell GeoExt to grab it. I did not write this code, but have tested it, and found it works well for me:
https://github.com/opengeo/gxp/blob/master/src/script/plugins/WMSSource.js#L37

Failing to fetch CategorizedFacebookType

I have an application which I developed about a year ago and I'm
fetching facebook accounts like this:
facebookClient = new DefaultFacebookClient(access_token);
Connection<CategorizedFacebookType> con = facebookClient.fetchConnection("me/accounts", CategorizedFacebookType.class);
fbAccounts = con.getData();
It worked fine until about a month ago, but now it returns the
fbAccounts list empty. Why is that?
I was hoping moving from restfb-1.6.2.jar to restfb-1.6.9.jar would
help but no luck, it comes up empty on both.
What am I missing?
EDIT, to provide the code for another error I have with this API. The following code used to work:
String id = page.getFbPageID(); // (a valid facebook page id)
FBInsightsDaily daily = new FBInsightsDaily(); // an object holding some insights values
try {
Parameter param = Parameter.with("asdf", "asdf"); // seems like the param is required
JsonObject allValues = facebookClient.executeMultiquery(createQueries(date, id), JsonObject.class, param);
daily.setPageActiveUsersDaily((Integer)(((JsonArray)allValues.opt("page_active_users_daily")).getJsonObject(0)).opt("value"));
...
This throws the following exception:
com.restfb.json.JsonException: JsonArray[0] not found.
at com.restfb.json.JsonArray.get(JsonArray.java:252)
at com.restfb.json.JsonArray.getJsonObject(JsonArray.java:341)
Again, this used to work fine but now throws this.
You need the manage_pages permission from the user to access their list of adminned pages - a year ago I'm not sure you did - check that you're obtaining that permission from your users
{edit}
Some of the insights metrics were also deprecated, the specific values you're checking may no longer exist - https://developers.facebook.com/docs/reference/fql/insights/ should have the details of what is available now
Try to check your queries manually in the Graph API Explorer to eliminate any issues in your code and hopefully get more detailed error messages that your SDK may be swallowing