How to Subscribe to Power Change Events


Subscribing to events

BB-Core enables users to subscribe to events. These events provide information about the change in LEDs and power on the BB-400.
The user can subscribe to these events by using the following curl command:

sudo curl --no-buffer -XGET --unix-socket /var/run/bb-core.sock http://localhost/events

[email protected]:~ $ sudo curl --no-buffer -XGET --unix-socket /var/run/bb-core.sock http://localhost/events

{"ETH0_LINK": "ON", "DIO1": "OFF", "DIO4": "OFF", "ETH1_LINK": "OFF", "DIO6": "OFF", "WIFI_LINK": "FLASH", "DIO0": "OFF", "DIO3": "OFF", "DIO2": "OFF", "LABEL_C": "OFF", "ETH1_STATUS": "OFF", "WIFI_WEB": "FLASH", "DIO7": "OFF", "ETH0_WEB": "ON", "LABEL_A": "OFF", "LABEL_D": "OFF", "LABEL_B": "OFF", "DIO5": "OFF"}{"POWER": "RUNNING"}

By subscribing to the events path, the user gets updated whenever there is a change in the BB-400’s LEDs on the front of the panel. It also reports about changes in the power state.

The 4 possible power states are:

    The capacitors in the BB-400 are charging. The BB-400 is not running.
    The device boots up and starts to run. The capacitors are charged.
    BB-400 goes into UPS Alert when the power is lost or switched off. The capacitors are discharging. The Ethernet, WiFi and DIO will no longer work. If the power is restored, then the Ethernet, WiFi and DIO will start working again.
    The capacitors have reached a threshold level and the BB-400 will start to shutdown.

GET request

Users can also use the GET request commands to get information about the LEDs and power states.

  • Power state: To get the current power state

sudo curl -X GET --unix-socket /var/run/bb-core.sock http://localhost/power

It returns the current power state as a JSON.


[email protected]:~ $ sudo curl -X GET --unix-socket /var/run/bb-core.sock http://localhost/power

[email protected]:~ $
  • LED states: To get the current LED states.

sudo curl -X GET --unix-socket /var/run/bb-core.sock http://localhost/leds


[email protected]0b0:~ $ sudo curl -X GET --unix-socket /var/run/bb-core.sock http://localhost/leds
{"ETH0_LINK": "ON", "DIO1": "OFF", "DIO4": "OFF", "ETH1_LINK": "OFF", "DIO6": "OFF", "WIFI_LINK": "FLASH", "DIO0": "OFF", "DIO3": "OFF", "DIO2": "OFF", "LABEL_C": "OFF", "ETH1_STATUS": "OFF", "WIFI_WEB": "FLASH", "DIO7": "OFF", "ETH0_WEB": "ON", "LABEL_A": "OFF", "LABEL_D": "OFF", "LABEL_B": "OFF", "DIO5": "OFF"}

[email protected]:~ $

POST request

Users can use this command to do an action.

  • Locate: Flashes the A, B, C and D LEDs on the BB-400.

sudo curl -X POST --unix-socket /var/run/bb-core.sock http://localhost/locate