Skip to content

Commit 1ff6bad

Browse files
committed
Stop an Earthquake test alarm
Signed-off-by: John Walicki <[email protected]>
1 parent 0d4e200 commit 1ff6bad

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

FIRMWARE.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,27 @@ This section describes the various commands that can be sent to the OpenEEW firm
123123
124124
### ALARM
125125
126-
Tell the firmware to make the device blink the LEDs the color red and bleep a warning of an impending earthquake.
126+
Tell the firmware to make the device blink the LEDs and bleep a warning of an impending earthquake.
127+
- "true" : Blink the LEDs the color RED / bleep warning
128+
- "test" : Blink the LEDs the color ORANGE / bleep warning
129+
- "false" : Stop an in-progress Alarm - turn off the LEDs and sound
127130
128131
#### Local MQTT Broker
129132
130133
```sh
131-
mosquitto_pub -h 192.168.1.101 -t iot-2/cmd/earthquake/fmt/json -i cmd:earthquake -m {Alarm:true}
134+
mosquitto_pub -h 192.168.1.101 -t iot-2/cmd/earthquake/fmt/json -i cmd:earthquake -m '{Alarm:"true"}'
135+
mosquitto_pub -h 192.168.1.101 -t iot-2/cmd/earthquake/fmt/json -i cmd:earthquake -m '{Alarm:"test"}'
136+
mosquitto_pub -h 192.168.1.101 -t iot-2/cmd/earthquake/fmt/json -i cmd:earthquake -m '{Alarm:"false"}'
132137
```
133138

134139
#### Watson IoT Platform
135140

136141
```sh
137-
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}
142+
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"}'
143+
144+
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"}'
145+
146+
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"}'
138147
```
139148

140149
### SENDACCEL

WatsonIoT/src/main.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,12 @@ int breatheintensity = 1;
162162
#define LED_SAFE_MODE 7 // Magenta breath
163163
#define LED_FIRMWARE_DFU 8 // Yellow
164164
#define LED_ERROR 9 // Red
165+
#define LED_ORANGE 10 // Orange
165166

166167
// --------------------------------------------------------------------------------------------
167168
// Buzzer Alarm
168-
void EarthquakeAlarm();
169+
bool bStopEarthquakeAlarm = false;
170+
void EarthquakeAlarm( int );
169171
void AlarmBuzzer();
170172
int freq = 4000;
171173
int channel = 0;
@@ -242,8 +244,22 @@ void callback(char* topic, byte* payload, unsigned int length) {
242244
} else {
243245
JsonObject cmdData = jsonMQTTReceiveDoc.as<JsonObject>();
244246
if ( strcmp(topic, MQTT_TOPIC_ALARM) == 0 ) {
245-
// Sound the Buzzer & Blink the LED
246-
EarthquakeAlarm();
247+
// {Alarm:[true|test|false]}
248+
String AlarmType = cmdData["Alarm"].as<String>() ;
249+
Serial.println( "Alarm received: " + AlarmType );
250+
if ( AlarmType.equalsIgnoreCase("true") ) {
251+
// Sound the Buzzer & Blink the LED RED
252+
bStopEarthquakeAlarm = false;
253+
EarthquakeAlarm( LED_ERROR);
254+
bStopEarthquakeAlarm = false;
255+
} else if ( AlarmType.equalsIgnoreCase("test") ) {
256+
// Sound the Buzzer & Blink the LED ORANGE
257+
bStopEarthquakeAlarm = false;
258+
EarthquakeAlarm( LED_ORANGE );
259+
bStopEarthquakeAlarm = false;
260+
}else if ( AlarmType.equalsIgnoreCase("false") ) {
261+
bStopEarthquakeAlarm = true;
262+
}
247263
} else if ( strcmp(topic, MQTT_TOPIC_FWCHECK) == 0 ) {
248264
// Remote message received to check for new firmware
249265
// If a device is running for many months it might fall behind on the version of the
@@ -1254,6 +1270,10 @@ void NeoPixelStatus( int status ) {
12541270
strip.fill( strip.Color(255,255,0), 0, 3); // Yellow
12551271
Serial.println("LED_FIRMWARE_DFU - Yellow");
12561272
break;
1273+
case LED_ORANGE :
1274+
strip.fill( strip.Color(255,165,0), 0, 3); // Red
1275+
Serial.println("LED_ORANGE - Orange");
1276+
break;
12571277
case LED_ERROR :
12581278
strip.fill( strip.Color(255,0,0), 0, 3); // Red
12591279
Serial.println("LED_ERROR - Red");

0 commit comments

Comments
 (0)