Rule to send mail when device (thing) is disconnected from AWS IoT - email

I am working on an IoT based project, where I get data from raspberryPi and send it to AWS IoT cloud.
I have created a couple of rules to save data in DynamoDB and send emails on certain conditions. But I am struggling with how to send an email if the device gets DISCONNECTED.
Basically I was wondering if there is any way to get the eventType: disconnected
Screenshot and perform an action upon this event.
Any kind of help would be greatly appreciated.
Thank you !

I found the solution, basically you have to create a rule that gets executed when the disconnected lifecycle event is triggered.
In my case its like this
For more reference you can follow this link:
http://docs.aws.amazon.com/iot/latest/developerguide/life-cycle-events.html

You need to make a rule that periodically attempts to connect with your device and, in the instance of a failure, sends you an email. Your device is not going to send a message as it disconnects because that would require it to know in advance that it was going to disconnect.
Pseudo code:
Run every x amount of time:
if connectionTest == false
sendEmail()
To clarify - you will not get an event type "disconnected" because if your device is disconnected it will not be able to return an event object. You will instead get an error which you will have to catch.

Related

Problem using signalr for chat application flutter

I had made a whole chat application using signalr as a socket with the online and offline facility. I am facing a few problems,
Signalr connection is always time out after some time, to overcome that I had condition if hubconnection is not connected then create new hubconnection (onResume app), but still it get hubconnection._callback got increased when sending message and not moving to server side socket. Again need to refresh whole app.
Can someone tell me whether this is problem because there are lot of operations going on and so signalr loses its connection as flutter is single thread and it cannot handle much? or should I use Isolate or inherit widget.
Summary problem:
I cannot send message in chat after sometime. It stores all message in hubconnection._callback and not going for server.
Is anything better solution to keep alive in both Android+iOS.
I had used https://pub.dev/packages/signalr_netcore package.
Please do not mention about firebase.
Any other logic suggestion is appreciable.
Thank you.
I've been using a different package, https://pub.dev/packages/signalr_core, which works fine without any particular issues what I have observed at the moment.
I'm only running about 10 listeners simultaneously, not sure if that is more or less than you. In the package I'm running you can establish connection with automatic reconnect. It looks like this:
HubConnectionBuilder().withAutomaticReconnect().withUrl(....)
It seems like your package have the same functionality... Have you tried that?

What does a "unselected carrier" error message mean?

The message goes like this:
We're sorry this is an unselected carrier. This call cannot be completed as dialed. You may designate a carrier to handle this type of call by calling that company or your Verizon business office during regular business hours. To place this call in an emergency, just dial zero.
Any help understanding the underlying process that creates this error would be appreciated.
It is a telephone service message for the end user.
It could be provided when multiple carriers are necessary to complete the call.
You always have at least the local carrier directly managing the phone.
For long-distance calls, it is possible to select another carrier where both carriers cooperate for the call completion.
In your instance, I guess an automatic selection is used but has been disabled.
Or it could be also that a wrong carrier code has been dialed for this particular call.

How to receive data from an api without any user interaction

I'm trying to receive some data from an API call and do some task based on the received data.
Let's say I have my flutter app opened and in that opened state without any click or any interaction I get some data or do any function when I send something through the API.
I used Firebase FCM to do such task - When I send something through the API the firebase notification captures that data and doing the tasks I want on the flutter app.
But I want to do without Firebase. How can I do that. Any solution/suggestions would be great. Thanks!
At first, let's put Flutter aside. Your problem is to pull data from API and do a specific task OR your API should notify the app through API.
For the first problem, a simple data polling should work: when the app is opened, you just start some kind of timer and periodically pull data from the API and do something. However, this method is not perfect, it drains the battery and in general, there are better ways to achieve the same thing, for instance using sockets or push notifications (as some of the answers already state that).
For your second problem - "or do any function when I send something through the API" - you need some kind of mechanism to notify your app for it to react and process the data. This one could be handled using the same mechanism as for the first problem.
So, probably you need to use some kind of push notification service (for instance OneSignal or Pusher, or any other similar service) or web sockets (https://flutter.dev/docs/cookbook/networking/web-sockets).
Your question is little bit unclear. Whatever if you want to do some network call even without any interaction by user you can call network in your onInit method. This method runs at the very beginning for individual screen. Then do your task based on the response
You need stream API for this,look into socket programming
You can use webs socket or pusher for this. When web socket is connected with your server that time you received some data and you can do your task.

SIM800l - Disable "SMS Ready" and "Call Ready" unsolicited messages

My problem is related to SIM800 connection messages.
I use the module with STM32 developlment board. Sometimes module is reporting SMS Ready and Call Ready messages respectively. When I start to send AT commands to the module, it may send these messages (it doesn't happens all the times).
However, the commands I previously sent are apparently unrelated (for example HTTP commands), and SMS Ready / Call Ready messages is coming while they are not expected.
Because of this reason, Keil is reporting "Can not access" message in the debug session. Is it possible that disabling these messages when the connection is established? Or it means that module has an unexpected reset?
According to SIM800x modules AT commands guide, SMS ready and Call ready are URCs (unsolicited result codes) sent at startup as soon as the capabilities to deal with SMS and to perform calls respectively are correctly initialized and available.
So this is the first bad news for you: if you see them it probably means that your device reset due to a bug or as a consequence of one of the commands you previously provided.
The second bad news is that on the AT command guide linked above there's no mention of the capability to disable SMS Ready URC.
There's fortunately at least a good news: Call ready can be disabled by means of AT+CIURC command:
AT+CIURC (Enable or Disable Initial URC Presentation)
Syntax: AT+CIURC=<mode>
<mode> : 0 Disable URC presentation - 1 Enable URC presentation
Note: When module is powered on and initialization procedure is over URC "Call Ready" will be presented if is 1.
The guide also mentions the fact that this setting is saved in the profile area. So, in order to make sure it is persistent to reboot, after issuing the command store active profile:
AT&W
OK
For me, receiving a lot of messagens Call and SMS ready was a problem on current not enough to keep the module working.
(You can check it too watching the led blinking, if it blinks 6/7 times and stop for a while and restart over again, you have the same problem)
Just to SIM800 keep working is necessary at least 700mA.
Ps.: You can connect directly to your battery 18650 (3.7V-4.2V).
If you are using TP4056 module, you must remember there is 1A max current. try to connect in parallel more than 1 TP4056.

How to detect a lost connection via chrome.hid API?

I don't see a way to register a callback when a connection is lost in the chrome.hid API. E.g. an onConnectionLost method.
How am I supposed to detect a user accidentally pulling the cable in the middle of a process? Are we expected to poll, somehow?
You should star this issue: https://code.google.com/p/chromium/issues/detail?id=349473. When it's implemented you'll be able to do what you want.