-
Notifications
You must be signed in to change notification settings - Fork 4
updatePinApi
The Update Pin State API authorizes users to securely modify microcontroller pin states. It requires JWT authentication, facilitating specific pin updates and enabling real-time changes to the displayed state. Developers utilizing this API should consider integrating WebSocket functionality for seamless web experiences and immediate UI updates, including handling offline notifications. This supports direct state alterations and ensures prompt notifications to all connected clients upon successful updates, enhancing the overall user experience.
-
URL:
https://industrialiot.onrender.com/api/updatepin
-
Method:
PUT
-
Headers:
-
Authorization:
Bearer <ACCESS_TOKEN>
-
Content-Type:
application/json
-
Authorization:
- Body Parameters:
Parameter | Type | Description |
---|---|---|
pin |
String | PIN for switch querying (required) |
state |
String | New state value (0 or 1) (required) |
-
Success Response:
- Status Code: 200 OK
-
Response Body:
{ "success": "pin updated successfully" }
- Description: Indicates that the pin state was updated successfully.
-
Error Responses:
-
Status Code: 400 Bad Request
-
Response Body:
{ "error": "invalid pin name or number" }
- Description: Indicates an invalid or unrecognized pin number or name provided.
-
Response Body:
-
Status Code: 503 Service Unavailable
-
Response Body:
{ "Alert": "ESP is offline, can't update" }
- Description: Indicates that the ESP is offline, and the pin state cannot be updated.
-
Response Body:
-
When the pin state is successfully updated, the server emits a socket message to connected clients with the following information:
-
Socket Message: webUpdate
-
Payload:
{ "stateUpdated": "<NEW_STATE>" }
Notifies connected clients when the ESP is offline, providing information about the unknown current state.
-
Socket Message: offline
-
Payload:
{ "Alert": "Esp is offline. Current state unknown" }
-
Request Method:
PUT
-
Endpoint URL:
https://industrialiot.onrender.com/api/updatepin
-
Header:
Authorization: Bearer <JWT> Content-Type: application/json
-
Request Body:
{ "pin": "<PIN_NUMBER>", "state": "<DESIRED_STATE}>" }
Note: The
state
field in the request body should only contain either0
or1
to represent the desired state.
- For details on consumed pins and functions, check here.
- For more error message and causes, check here.
- For other real time communication socket handler, check here