screen on/off broadcast events in Firefox OS - firefox-os

In Android, we can use "Intent.ACTION_SCREEN_OFF" and "Intent.ACTION_SCREEN_ON" to receive the screen on/off broadcast events.
But in firefox OS, does the same way to receive the screen on/off broadcast events??

You can look at the visibilitychange event.
https://developer.mozilla.org/en-US/docs/Web/Events/visibilitychange

Related

How to keep splash screen befor network connet untill the network is ok by backgm and enter the youtube page

At normal, when the network is not ok, launch cobalt, it will show the splash screen and pop a network error dialog, and exit the launch flow.
So how to keep splash screen(no network) and enter the youtube page(after the network is ok)? So it can keep splash screen about 15s and enter youtube page when the network is ok by backgm. In other words, keep splash screen until the network is ok, and enter youtube page.
So cobalt can retry to judge the network connection?
I recommend you to have options on your network error dialog like "troubleshoot network", "retry", "close" when the network issue happens. Users might select "retry" and if the network is recovered in the mean time, it will work.
As far as I understand, you load Cobalt when the network is down and you want it to keep retrying to load YouTube forever, without user interaction. For that, immediately call SbSystemPlatformErrorCallback with kSbSystemPlatformErrorResponsePositive from your implementation of SbSystemRaisePlatformError.
Obviously, you only want to do it when Cobalt is running in background. Make sure that your implementation of SbSystemRaisePlatformError present an actual dialog box when Cobalt is interactive.

get the lamp status of Onvif camera

I have an onvif camera and a toggle button to turn the lamp on and off. I use the tt:lamp|on style of commands sent to the Onvif endpoint. Is there a way to query the status of the camera and retrieve weather or not the lamp is on?
You should subscribe to the camera side events via the ONVIF event service and check if the camera is sending the current lamp status in the event stream. Most devices will give you a full initial state of all the things they can report through the event service as a response to the first PullMessage request.

Possible to control garage door with Garmin IQ?

I'd like my Fenix 3 to do the following:
Trigger = hold down start button (i.e. shortcut)
Send message via BT or WiFi to a server (Linux or Windows or Arduino or whatever)
I'll take care of the message and open/close my garage door.
After a bike tour I'd like to easily and safely open my garage door. I have a VmWare server running at home. I could use one of the machines on this server to listen to the messages or I could set up an Arduino or similar.
The main question is: Can I write an IQ app that utilizes the shortcut concept on the clock, i.e. triggered by long click on start or lap button?
Clarification: There seems to be some kind of global actions for long press. I can for example assign "Save position" to long press on start/stop. This works even from inside of other apps.
Can the clock communicate with sensors (i.e. Arduino or other BT client) even if not in training mode?
Clarification: I need to communicate directly with my Arduino via Bluetooth, i.e. not via my iPhone.
Thanks in advance.
Short answer: Yes
Long answer: If you record the time a keydown event comes in, and then check for a "long" press when the key is let up based on the time difference, you can fake it. There is not an event for a long press of a physical key though. I am also pretty sure your app needs to be the current one for this to work.
Link to the InputDelegate event options: http://developer.garmin.com/downloads/connect-iq/monkey-c/doc/Toybox/WatchUi/InputDelegate.html
As for the sensors question, I am not sure exactly what you are asking. Your app can do whatever you want, and it is my understanding that only one app will be running at a time.
Disclaimer: Thus far I have only been working with the emulator, I'm still waiting for my watch to get here.
You cannot write anything that hijacks user input events from another active application (including the watch face). You could make your own watch face, but it wouldn't have the ability to send network messages and it has only one way to accept user input (the look-at-watch gesture).
This is something that you can do pretty easily from a watch-app or a widget. Assuming that your fenix3 is connected to your phone via bluetooth, you can send http get requests as you see fit.
I've written a simple app that I call GIFTTT that uses the IFTTT Maker channel to open/close my garage door (and all sorts of other things).

How to handle external events in CQRS?

Supposed I have a CQRS-based system with a web UI that I want to integrate with some external device, let's say an Arduino board.
Basically, I can think of three scenarios:
When the user clicks on a button in the web UI, the Arduino shall do something.
When the user pushes a hardware button, the domain shall react and the UI shall update.
When the user pushes a hardware button, the UI shall update.
How do I model these scenarios?
This is quite easy IMHO: UI emits a command, business logic runs, emits an event, and Arduino is listening for events. Basically, the Arduino is nothing but an event denormalizer. Is this the correct approach?
This is quite easy IMHO as well: Arduino emits a command, sends it to the command bus, and the same procedure runs as with scenario 1. Basically, there's no difference for the CQRS-system whether the command comes from the web UI of from anything else.
This is where I'm really unsure: Supposed the Arduino handles the button press itself, and flashes an LED in response. I just want to make sure that my application takes notice of "the LED has been flashing". This is no command (as the flashing already happened), instead it's an event. What do I do with this event? Do I simply store it in the event store and bypass my domain? This seems horribly wrong to me. Do I emit a pseudo-command which is turned 1:1 into a matching event? This will work and does not bypass the domain, but it feels wrong as well, as it actually is no command. What should I do?
Any advice on these things?
1.Just use an event handler( updating ui maybe using websocket ) listening on Arduino event if no state should change in your domain.
2. Use a saga listening on Arduino event and fire a command if state should change in your domain.
UI is not a domain concern. So I prefer option 1.

Close event for chrome.app.window

When a chrome app window is closed, is it possible to detect the event? and do an action before the window is closed?
chrome.app.window.current().onClosed allows you to register an event listener for when a window is closed.
Vincent's answer will work in some cases, but the documentation warns that some chrome api functionality will be lost by the time the onClosed event is fired.
Note, this should be listened to from a window other than the window
being closed, for example from the background page
To listen for this event from the background page, do something like this:
chrome.app.window.get(windowIDUsedToCreateChildWindow).onClosed.addListener(function(){...})

Resources