diff --git a/FIRMWARE.md b/FIRMWARE.md index 84acbdd..38b44b4 100644 --- a/FIRMWARE.md +++ b/FIRMWARE.md @@ -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 diff --git a/WatsonIoT/src/main.cpp b/WatsonIoT/src/main.cpp index 326fbd8..8ba77a1 100644 --- a/WatsonIoT/src/main.cpp +++ b/WatsonIoT/src/main.cpp @@ -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; @@ -242,8 +244,22 @@ void callback(char* topic, byte* payload, unsigned int length) { } else { JsonObject cmdData = jsonMQTTReceiveDoc.as(); if ( strcmp(topic, MQTT_TOPIC_ALARM) == 0 ) { - // Sound the Buzzer & Blink the LED - EarthquakeAlarm(); + // {Alarm:[true|test|false]} + String AlarmType = cmdData["Alarm"].as() ; + 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 @@ -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");