Is there a better way than brute force to maintain hub state? (Smart Home Group API) - logitech

Is there a better way to maintain hub state sync than periodic random checks? The physical remote gets a notification nearly instantaneously of a state change on the hub so I assume it's subscribed somehow to push-updates. Is the best approach to just send a GET request for the hub state every 30 seconds to a minute while idle, and every 5-10 seconds after an activity change? I don't want to bombard the servers with lots of requests but I'm not sure how to know when to unlock the UI after a successful activity initiation.

The current Smart Home Group API does not provide notifications of Activity or device state changes. This is something Logitech expects to implement later this calendar year.

Related

How exactly do Firebase Analytics handle session duration / timeouts?

I'm implementing some basic usage statistics for the first time in an Android/iOS app using Firebase Analytics, but the docs seem a little ambiguous to me on how exactly session durations are calculated and how sessions are timed out, and the 24-hour cycle for seeing results does not help in understanding by trial-and-error.
I'm only interested in a very simple statistic for now - the time users spend in the app. What exactly happens when the app is "minimised"/"in the background" - does that count as active usage or the same as the app being closed - is not so important right now, but if you have something to add in this regard in the context of the question, please do.
From what I understand such an easy statistic should probably be available out-of-the-box with Firebase Analytics, so I'm currently not using any custom events or anything fancier than simply linking Firebase Analytics into the projects, adding the configuration files, and calling FirebaseAnalytics.getInstance(this); on Android and [FIRApp configure]; on iOS.
I'm seeing first_open, session_start and app_remove events show up in the console as expected, some aggregate session data in the dashboard, etc, and I also know there is a configurable session timeout available.
But what is unclear to me is, when exactly does a user session expire - does Firebase automatically keep it open as long as the app is open, or do I need to make sure to post some artificial "keep-alive" events to prevent user sessions from expiring while a user is still actually using the app.
Assuming the following:
I send no explicit custom events using Firebase, as this is not
explicitly required by the app.
I only touch Firebase once during a single run of the app - initialising it on startup.
The user stays in the app for a long time (let's say 2 hours - much longer than the default 30 minute session timeout), without interacting with it - e.g. reading something, watching a video, etc, none of this generates any events that Firebase can see, but the app prevents the screen from locking, the app remains in foreground.
Will that count as a single 2 hour session for the user? Will it only count as a 30 minute session since the session expires after 30 minutes and no events are generated to keep it alive? Will something else happen?
Bonus question: what happens if the user exits the app for a time shorter/longer than the session timeout?
Bonus bonus question: does something change if instead of exiting from the app, it is simply put into background?
Thanks!
Quick answer: The scenario you describe will result in a single 2-hour session.
Sessions are based on the time that an app's activity is the current activity. There is no need to send events; the period from the time an activity resumes to the time it is suspended is counted as engagement time. At the end of an hour of continuous engagement an engagement event will be logged but this does not end the session. A session expires when there is a continuous period (30 minutes by default) that none of the app's activities is the current activity.
If the user exits the app for a shorter period than the session timeout and then restarts it, the session continues. If the user exits the app for longer than the session timeout, then the session ends. No change between exiting the app and putting it in the background. If it's not the thing the user is looking at, it doesn't count as engagement for the app to be running.

socket.io interrupted by incoming phone call

I am trying to collect GPS location every 5 seconds from a smart phone by using socket.io.
I notice that when users pick up a phone call, socket.io will stop emitting messages. When users switching tabs in the browser, socket.io will stop emitting messages too.
Does anyone know how to solve this problem?
Thanks very much!
Your best bet would be to package the website in a native app. Use a service such as http://build.phonegap.com or Intel XDK. There are configuration options to keep your app alive in the background. As for it disconnecting during phone calls, this is a carrier limitation. If the user was connected to WIFI, most phones will that for data while simultaneously on a call.
Some networks (such as Verizon) do not have the capability to do voice and data at the same time. Thus, when a call is made, data is suspended until the call is finished. AT&T does not have this limitation.
The operation of background tabs will vary by mobile browser and is likely done for battery conservation reasons. It is unlikely there is a work-around to keep the background tab running (because that would defeat the whole battery management purpose).

Windows Phone Background Application Service

In my windows phone 8 application, I would like to refresh/load some data periodically (less than 10 minutes) from server, while application running in background (ie, in dormant and tombstoned). I tried scheduled task agent and resource intensive task agent, but they are called at rate of 30 minutes gap. Please let me know is there any other solution for implementing the above said requirement.
Thanks and Regards
#nish
If you need to get data more frequently than the default available in Windows Phone, you should think about using push notifications. This won't be suitable for a full data push, but if you use it correctly, you can get a user experience that you can live with.
One common approach to this is to set up your server to send a notification to the device when there is something new to report instead of pushing a "nothing has changed" message every 10 minutes or so. If you push out a tile update notification to say, for example, "You have x unread items", the user may then click on the tile for your app and you can poll the server for new items on launch/resume. If you want a more intrusive option, you can send a toast notification as well, but in most cases the tile update will be sufficient.
This method has a few advantages.
You won't be burning through battery power polling every 10 minutes while the user is asleep
Your server will have significantly less load since it is not having to process full data requests every 10 minutes per client.
This fits in with the design philosophy of Phone apps - you are surfacing the required data to the user, while at the same time preserving battery life.
Do I understand correctly that your primary goal is to keep some host session alive by having the phone make a query periodically? If so...
I would not recommend this approach: 1) you cannot count on the phone having network connectivity when it tries to send its query. If the user puts the phone away in a pocket or purse, the odds worsen. 2) it's probably bad from a security perspective, and wasteful from a host resources perspective.
You might instead add logic to your app to resume a timed-out host session as seamlessly as possible. This would add real utility value to the mobile app value proposition over raw HTTP access to the same host.

How to send GPS data to server every 5 minutes?

I am planning to write WP7 app, which needs to send to server phones GPS position every 5 minutes. Data must be sent to server even if app is not running. One way to do that is to use Background agents (I am using 7.5 Mango), but in that case app will send data only every 30 minutes, which is not acceptable in my case.
Is there any other solution?
Thanks in advice.
No, this is not a supported usecase for WP7 apps on Mango. Also, it's important to mention that the location you'll get for GeoCoordinateWatcher on a background agent is a cached geolocation from approximately the last 15 minutes and not the real-time geolocation.
What exactly are you trying to build if you don't mind me asking? This sounds oddly close to spyware. Even if it's innocuous and meant for a good purpose, I'd be careful walking in any direction that constantly shares GeoLoc with a remote server.
Your only choices are sending the data every 5 minutes while application is running (even when the phone is locked) and/or send the data once every 30 minutes by registering a PeriodicTask.
Having said that, I agree with Justin in that what you are describing sounds nefarious.

Ntp synchronization video WP7

I guys:)
I am doing an windows phone application that presents videos, but presents when syncronized with an ntp server. I already have a variable with the time but i donĀ“t know now what to do. I try search in google but i dont find anything.. I want to make an application to present the same video at the same time in different phones..
Any help? Examples?
The simplest way to get multiple devices doing something in sync is to define a time at which they should all start (do this on a central server) and then have each device request the amount of time to wait until the start. Each device should then start playback when that period has elapsed.
If you need to have different devices join in at specific ppoints when some are already playing the video your central point will need to send the point to start playing as well as the amount of time to wait until playback shoudl begin.
Due to the latency of the network communication you won't be able to get perfect sync though.

Resources