syncEmergencyApi - n1lby73/industrial-IOT GitHub Wiki

Overview

Exclusively designed for microcontroller integration, the Synchronize Emergency State API manages emergencies triggered by the microcontroller's emergency button. Utilizing the PUT method, it communicates the state via the request's emergency field, initiating a broadcast through socketio.emit to update the web interface.

Developers have the capability to disable all trigger buttons on the homepage until the emergency state (set by emitting 0) is reset. This ensures continual enforcement of safety protocols until manual deactivation, reaffirming its sole purpose for microcontroller operations.

Endpoint URL

  • URL: https://industrialiot.onrender.com/api/emergency
  • **Method:**PUT

Request Parameters

  • Headers:

    • Content-Type: application/json
  • Body Parameters:
Parameter Type Description
emergency String Emergency state (required)

Responses

  • Success Response:
    • Status Code: 200 OK
    • Response Body:
      {
          "success": "Broadcast successful"
      }
      
      • Description: Indicates successful broadcasting of the emergency state to update the web interface.

Real-time Updates

On actuating the emergency pushbutton connected to the microcontroller, the server emits a socket message to connected clients with the following information:

  • Socket Message: emergency

  • Payload:

    {
      "emergency": "<EMERGENCY_STATUS>"
    }
    

Usage

  1. Request Method: PUT

  2. Endpoint URL: https://industrialiot.onrender.com/api/emergency

  3. Header:

     Content-Type: application/json
    
  4. Request Body:

    {
        "emergency": "<CURRENT_STATE>"
    }
    

    Note: The emergency field within the request body should strictly contain either 0 or 1 to signify the current emergency state.