Skip to content

Commit

Permalink
Stop an Earthquake test alarm
Browse files Browse the repository at this point in the history
Signed-off-by: John Walicki <johnwalicki@gmail.com>
  • Loading branch information
johnwalicki committed Apr 15, 2021
1 parent 0d4e200 commit 1ff6bad
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
15 changes: 12 additions & 3 deletions FIRMWARE.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,27 @@ This section describes the various commands that can be sent to the OpenEEW firm
### ALARM
Tell the firmware to make the device blink the LEDs the color red and bleep a warning of an impending earthquake.
Tell the firmware to make the device blink the LEDs and bleep a warning of an impending earthquake.
- "true" : Blink the LEDs the color RED / bleep warning
- "test" : Blink the LEDs the color ORANGE / bleep warning
- "false" : Stop an in-progress Alarm - turn off the LEDs and sound
#### Local MQTT Broker
```sh
mosquitto_pub -h 192.168.1.101 -t iot-2/cmd/earthquake/fmt/json -i cmd:earthquake -m {Alarm:true}
mosquitto_pub -h 192.168.1.101 -t iot-2/cmd/earthquake/fmt/json -i cmd:earthquake -m '{Alarm:"true"}'
mosquitto_pub -h 192.168.1.101 -t iot-2/cmd/earthquake/fmt/json -i cmd:earthquake -m '{Alarm:"test"}'
mosquitto_pub -h 192.168.1.101 -t iot-2/cmd/earthquake/fmt/json -i cmd:earthquake -m '{Alarm:"false"}'
```

#### Watson IoT Platform

```sh
mosquitto_pub -h OrgID.messaging.internetofthings.ibmcloud.com -p 8883 --cafile messaging.pem -u $WIOTP_APIKEY -P $WIOTP_TOKEN -i "a:OrgID:mosquitto" -t iot-2/type/OpenEEW/id/A8032A4DD5F0/cmd/earthquake/fmt/json -m {Alarm:true}
mosquitto_pub -h OrgID.messaging.internetofthings.ibmcloud.com -p 8883 --cafile messaging.pem -u $WIOTP_APIKEY -P $WIOTP_TOKEN -i "a:OrgID:mosquitto" -t iot-2/type/OpenEEW/id/A8032A4DD5F0/cmd/earthquake/fmt/json -m '{Alarm:"true"}'

mosquitto_pub -h OrgID.messaging.internetofthings.ibmcloud.com -p 8883 --cafile messaging.pem -u $WIOTP_APIKEY -P $WIOTP_TOKEN -i "a:OrgID:mosquitto" -t iot-2/type/OpenEEW/id/A8032A4DD5F0/cmd/earthquake/fmt/json -m '{Alarm:"test"}'

mosquitto_pub -h OrgID.messaging.internetofthings.ibmcloud.com -p 8883 --cafile messaging.pem -u $WIOTP_APIKEY -P $WIOTP_TOKEN -i "a:OrgID:mosquitto" -t iot-2/type/OpenEEW/id/A8032A4DD5F0/cmd/earthquake/fmt/json -m '{Alarm:"false"}'
```

### SENDACCEL
Expand Down
26 changes: 23 additions & 3 deletions WatsonIoT/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ int breatheintensity = 1;
#define LED_SAFE_MODE 7 // Magenta breath
#define LED_FIRMWARE_DFU 8 // Yellow
#define LED_ERROR 9 // Red
#define LED_ORANGE 10 // Orange

// --------------------------------------------------------------------------------------------
// Buzzer Alarm
void EarthquakeAlarm();
bool bStopEarthquakeAlarm = false;
void EarthquakeAlarm( int );
void AlarmBuzzer();
int freq = 4000;
int channel = 0;
Expand Down Expand Up @@ -242,8 +244,22 @@ void callback(char* topic, byte* payload, unsigned int length) {
} else {
JsonObject cmdData = jsonMQTTReceiveDoc.as<JsonObject>();
if ( strcmp(topic, MQTT_TOPIC_ALARM) == 0 ) {
// Sound the Buzzer & Blink the LED
EarthquakeAlarm();
// {Alarm:[true|test|false]}
String AlarmType = cmdData["Alarm"].as<String>() ;
Serial.println( "Alarm received: " + AlarmType );
if ( AlarmType.equalsIgnoreCase("true") ) {
// Sound the Buzzer & Blink the LED RED
bStopEarthquakeAlarm = false;
EarthquakeAlarm( LED_ERROR);
bStopEarthquakeAlarm = false;
} else if ( AlarmType.equalsIgnoreCase("test") ) {
// Sound the Buzzer & Blink the LED ORANGE
bStopEarthquakeAlarm = false;
EarthquakeAlarm( LED_ORANGE );
bStopEarthquakeAlarm = false;
}else if ( AlarmType.equalsIgnoreCase("false") ) {
bStopEarthquakeAlarm = true;
}
} else if ( strcmp(topic, MQTT_TOPIC_FWCHECK) == 0 ) {
// Remote message received to check for new firmware
// If a device is running for many months it might fall behind on the version of the
Expand Down Expand Up @@ -1254,6 +1270,10 @@ void NeoPixelStatus( int status ) {
strip.fill( strip.Color(255,255,0), 0, 3); // Yellow
Serial.println("LED_FIRMWARE_DFU - Yellow");
break;
case LED_ORANGE :
strip.fill( strip.Color(255,165,0), 0, 3); // Red
Serial.println("LED_ORANGE - Orange");
break;
case LED_ERROR :
strip.fill( strip.Color(255,0,0), 0, 3); // Red
Serial.println("LED_ERROR - Red");
Expand Down

0 comments on commit 1ff6bad

Please # to comment.