4

I must develop an iPhone app to monitor a device.

The device is a boat light control system. Using the iPhone app I can control lights on/off. Lights can be turned on/off from the device touchscreen or using the iPhone app.

It's important that the application is notified of lights status change (someone has turned on a light form wall interrupter or from the device touchscreen). But is important that device/iPhone status update procedure is power optimized (I don't want to drain the iPhone battery using polling to continuously read status from the device). It's not a problem to add a Bluetooth to the device if this can optimize the system.

Device and App are on the same LAN (the solution must work without internet connection).

The device expose a rest service to read/change lights on/off status.

In the app I need to display in near-real-time the device status changes.

Are there any better solution for the device to notify the iPhone app a status change than do a call every n seconds by the App for checking?

A kind of local device->iPhone notification? Maybe some feature of homekit may came in help?

1
  • I've moved this conversation to chat as this is starting to exceed the limits of comments; feel free to continue there. – Aurora0001 Dec 13 '18 at 17:56
3

I'm guessing your best bet is actually using BLE beacon and notifications. Why? Because there are very few things that can wake iOS from backgrounded mode, and the list is even more limited if you can't use internet. Beacon and location services is one of them.

Here's a good article that talks about how to do this over BLE with all the gotchas. But basically you have to implement iBeacon service, ensure it's correctly waking the phone from even when the app isn't running. This will give you the best battery life.

It also flips the mechanism from phone-initated poll, to device initiated notification.

In theory, using external-accesory framework and MFI is possible, but it's far more challenging to implement. Implement on the device-side, that is. If you somehow do get your system to act as HomeKit accessory, then Accessory framework registerForLocalNotifications lets you monitor events while backgrounded.

For turning your system into a HomeKit-like device, you might try HomeBridge to prototype it.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.