Calculate Xively client downtime - xively

Am trying to calculate how long my IoT device is offline. MQTT has feature called Last Will and Testament. Is there a way to track how long the client has been down using Xively dashboard.

Using MQTT's last will testament feature is certainly one of the ways to do it. Alternatively you could send "pulse" updates into a datastream and determine downtime if gap between pulses is greater then set period.

Related

How to acces the data from a website 50-100 times a second using raspberry Pi?

I want to fetch the data of a stock. Since the data changes very fast, is there any way to pull the data like 50-100 times a second from trading websites?
And can we implement that using a raspberry Pi 4 8gig model.
RasPi4 should be more than adequate for this task. Both the ethernet and WiFi hardware is capable of connections at these speeds. (Unless you’re running a bunch of other stuff on it.) Consider where your bottlenecks may be, likely ISP or other network traffic). Consider avoiding WiFi in favor of cat5e or cat6. Consider hanging this device off your router (edge) to keep lan traffic lower and consider QOS settings if you think this traffic may compete with other lan traffic.
This appears to be a general question with no specific platform in mind. For stocks, there are lots of platforms to choose from.
APIs for trading platforms often include a method to open a stream. Instead of a full TCP conversation for each price check, a stream tells the server to just keep on sending data. There are timeout mechanisms of course, but it is good to close that stream gracefully (It’s polite since you’re consuming server resources at a different scale. I’ve seen some financial APIs monitor and throttle stream subscribers who leave sessions open.).
For some APIs/languages you can find solid classes already built on GitHub. Although, if simply pulling and reading a stream then the platform API doc code snippets should be enough to get you going.
Be sure to find out what other overhead may be implicated. For example, if an account or API key is needed to open a stream then either a session must be opened first or the creds must be passed with the stream being opened. The API docs will say. If you’re new to this sort of thing, just be a detective and try to infer what is needed. API docs usually try to be precise and technically correct with the absolute minimum word count.
Simply checking the steam should be easy. Depending on how that steam can be handled by your code/script, it may be harder to perform logic on the stream while it is being updated. That’s usually a thread issue or a variable scope issue depending on the script/code. For what you’re doing I would consider Python or PowerShell depending on your skill-set and other design parameters.

Can I send data over my Arduino ethernet without "blocking" my sketch?

Sorry for my bad english first.
I'm currently working on an Arduino project which is really simple.
I'm working on an attendance logger for my school to know how much time students are spending studying.
The RFID Reader part is working fine. When a tag is detected, I'm storing the value and the time in a SD Card.
Every hour, my system have to send the logs to a web server to store it in a database and here come my problem. I'm struggling with the ethernet part.
Indeed, when I'm performing a HTTP Request, my sketch is "blocked" and students can't use the system anymore.
It's a real big problem, because if there are like 200 lines in my logs, sending those throught a request, one by one, will take really long.
I'm already aware of using millis() to use "multi-tasking".
I have absolutly no idea about how to send requests without "blocking" my sketch.. I'm not looking for someone to write my sketch. I just want to know if there is a way to avoid the "blocking" effect of the ethernet shield when I'm performing a request.
Thanks for your help.
Even if you send one by one, you dont have control over the server side. you have no gurantee that the server will Always response within a certain timeframe.
if your system is very busy, then this may not be your perfect solution.
on other hand, just a thought though, (I dont have personal experience with ethernet shield.)
you could send data serially from first arduino to second ardiuno, individually, every time RFID is detected. This should not take much time compare to the time to send 100 lines of logs. Now, one by one, second ardiuno can save these data in its memory until it is finally sent to server.
now when second arduino is busy sending data to server, we can collect some those RFID reading in first arduino's memory, and pass to, when the things with server is done.
to check if second arduino is bg, we could set a pin high in second arduino until the server part is done.
but still, I dont see why do you have to send it every one hour. I am asuming you have your reason.
If you still want to save some time, the make a parallel data transfer between two arduino, instead of serially.

How do I measure ping?

I get how to calculate ping - current time minus the time stamp of the packet - but how do I create a time stamp in the first place? What synchronized concept of time can I use? Note: I use .NET 2.0.
It could be as simple as when you issue your ping request (I will explain this in more detail in a moment), you make note of the current time, and then, when the server/client responds with a pong, you make note of the time again. Subtracting the pong time from the ping time gives you the amount of time for the communication to go between the two applications.
Wikipedia describes ping in the following way:
In multiplayer online video games, MMOs, MMORPGs, MMOFPSs and FPSs ping (not to be confused with frames per second) refers to the network latency between a player's computer (client), and either the game server or another client (i.e. peer). This could be reported quantitatively as an average time in milliseconds... Rather than using the traditional ICMP echo request and reply packets to determine ping times, game programmers often instead build their own latency detection into existing game packets
What I like to do, is when I make a client and a server, I always write in a simple 'ping/pong' command. In short, a ping request is made by one application, when the other application receives it, and sends back a pong confirmation command. This is good for debugging, but for actual development and depending on the game, I usually piggy back this with a heart beat to make sure everything is running as it should. Hope that helps!

isn't so called push really pull?

Ever since the introduction of push services in IOS I wonder how it works.
From what I found out the push function is basically an open connection that does not close serverside.
But mobiles are connecting at different points of the internet, the only way for a server to know where the mobile is connected is when the mobile tells the server where that it has changed location.
I read something about polling a connection so it stays open.
What advantage is there to manage and keep a changing open connection alive vs just checking if something is to pull?
Internally yes, push is implemented by having your phone poll for new data. The thing that makes push notifications attractive is that they are routed over Apple's service and that has many advantages.
From the phone's point of view, it only has to poll from one service, which means it can conserve bandwidth and piggyback on the normal operations of keeping a cellphone online. That means a lot less battery is used, and you can do things like set your phone to only receive push notifications every half hour, which means that 29 minutes out of every half hour you can turn off the data connection.
From the server's point of view, you no longer need to cache messages or provide quality-of-service guarantees. If you want to send a push notification to a phone that's out of range of a cell-tower for a few minutes, you may need to store the message for a considerable amount of time until the phone comes back online. Apple handles all this for you, and lets your server just be in charge of creating notifications, not storing and relaying them.

Retransmitting data from an iOS device that failed to transmit it the first time

From the Getting Started with Game Center doc...
Always check for network errors when reporting achievement progress to Game Center. If there
was an error, it is important for your app to store any progress updates for later retransmission.
This retransmission should occur at the soonest opportunity and without requiring separate
user action.
I'm about to begin building a game for the iPhone that leverages the Game Center capabilities and I'll need to monitor the transmission of the data as I attempt to send it to the Game Center. I'm relatively new to iOS development and I would probably handle this using some polling approach and periodically checking if there's any data that needs to be retransmitted. I'm about to begin researching some good ways to handle this and thought I'd post this question in the meantime. What are some good ways to handle network errors when sending data to the Game Center server? Are there any APIs or design patterns I should use for this?
Thanks so much in advance for your wisdom!
So I found out that most of the Game Center objects (including achievements and scores) support the NSCoding protocol. As such, the suggested approach to recovering from a network error during transmission is to archive the data (using NSCoding protocol) and un-archive the data when your app is next launched.

Resources