Get actual state of the smartthing's smart device programatically from web service smartApp - smart-device

I am developing a web application which shows the status of the all available smart devices in my hub. and I can also control the devices from this application.
For example, if I want to turn on the switch I send "on" commands with appropriate contexts to smartthings API.
In order the send commands, the devices should be active (it should respond to commands).
And I got the state of the device through API call (device.status) but this state found with the device object is not accurate.
For example, the Econet valve is actually responding to my commands.but it states shows INACTIVE.
So I can't trust on the values get from "device.status" parameter. is there any other approach?
Update: In order to know the current value of devices and take actions according to the current value, we need to know whether the device is responding or not. Currently, we cannot rely on the device status like ACTIVE, ONLINE because even after disconnecting the devices from networks the states doesn't change.

Related

iOS detect user modifying device clock time

My App requires correct time (can not rely on device time since the user can change it + carrier might be not available or doesnt support APIWorldClock). Initially I use http calls to a trusted server, however there are situations when network is not available.
Is there any other option I can use?
Can I rely on API World Clock to detect that the user modified the device clock? Does my app always need to be running in order to get this notification (this I would like to avoid)?

Rediscovering services in connected devices?

I have a hidden service/characteristic on a BLE device, that only becomes visible if you send the "right" command to another characteristic. However, if I stay connected, and just call "discoverServices:nil" or "discoverServices:service-i-care-about", it won't find it once enabled.
I changed my firmware to make the device not hide the service on disconnection (which is what I would want), but to stick around, and I know the service is getting enabled, because I can reconnect to device, and the service shows up.
I don't want to do this, because the whole point of hiding the service is you have to send the right command to enable the service (for the record, it is a firmware update service provided by a MCU vendor, so I can't change the service to be one of "mine" or put any security around the service itself)
Is this the intended bluetooth behavior? Or is iOS perhaps caching something and I have to do something to make it not get the cached values?
iOS caches any discovered peripheral and the corresponding services and characteristics for performance reasons. If you need to change the GATT table of your peripheral at any given time you have two options to tell the centrals:
tell the central via the Services Changed characteristic
change the mac address of your peripheral (not recommended but some chipset makers use this workaround, e.g., NordicSemi in the BLE bootloader)
We came across this problem as well because we need to hide the firmware update service of our embedded device until we jump to the bootloader.

How to run ios app continuously in background with user's permission

I'm developing one iOS application which is related with OBD2. The app provides feature like connecting with obd2 device and read out data.
With user's permission, I want to implement below feature even if app is not running at all :
Now I want to do When user enters car, connection to obd2 device is to be done automatically and check for some params if i gets failure on those data then i need to send data to cloud for analysis.
How can i know about user enter car ? I'm thinking one way like continuously checking the Wifi Availability to OBD2 device and if i get wifi available then i can say "user is nearer to car or in the car".
But again problem is that if app is not running in the background then how can trigger this kind of event.My app is not supporting any background mode like voip, audio, location, newstand etc..
Is there any other way like local notification or any other way by which i can trigger event that user has entered in car even if app is not running at all ?
Can Background mode like Receive updates from External Accessory mode or External Accessory framework support me in this feature implementation ?
Can i develop this feature in such way that Apple approves this feature ?
Any other feedback or suggestion will be appreciated !

Would my application be accepted in the app store if it used location as a UIBackgroundMode?

I have a requirment for an application to be capable of having information pushed to it from a server while it is in the background (this information will get displayed to the user, but it should be downloaded first before the user knows it is available therefore Apple Push notifications cannot be used - because with this mechanism a) the user would get the notification from the push server b) they will accept and launch the app c) the app will do a http fetch from a server. Thus there could and probably would be a delay while the client fetches the data, however it is a requirment that as soon as the user is informed there is new data it is instantly available).
A possible way this could be achieved is if the client periodically polls the server to see if there is anything for it (yes I know that's not ideal, polling never is, but is there an alternative?).
However polling could not be implemented unless the client has the ability to execute in the background. And the only way the application can execute in the background is if its a voip/music/location/newstand application.
The application would make use of location awareness sometimes, however location is not is primary focus (the application would be a means of information being pushed/displayed to the user, some of the information, but not all, may be dependant upon location i.e. moving to some area might trigger some information to be displayed).
If this application was submitted to the app store with a UIBackgroundMode of location, would it be accepted? Does an application's main functional focus have to be location based in order to execute in the background with this mode, or is it acceptable for location to be secondary side functionality?)
I don't have an account to access it, but the App Store Review Guidelines should give you a hint. Keep in mind that they are guidelines, i.e., Apple can for any reason deny your app. No one here can definitively say if they'll take it or not.

iPhone multitasking and webservice calls

Within my iPhone application I periodically make calls to a webservice, providing the endpoint with a list of numeric IDs. The webservice then returns information relating to the IDs it receives.
This is all well and good. However, I would like to be able to provide functionality whereby the user will receive a local/push notification when these changes occur, regardless of whether the application is open or not.
I'm just looking for guidance on my options in this scenario. As I see it, there are two main approaches: calculate any data changes on my webserver and send a push notification to all devices, or query the webservice from the device itself.
The second option seems ideal, as not all devices will need each push notification, but I'm unsure as to whether this is possible with the current state of iOS' multitasking APIs. Any advice would be appreciated.
Bad news: it's not possible. Apps can only run in the background for a short period of time after the user has exited unless it fits into a small number of categories (GPS, VoIP, etc).
Web services, unfortunately, do not count. So this would have to be performed on the server side and with push notifications.

Resources