Mosfet Control API
MOSFET Control API Documentation
This guide explains how to use the MOSFET Control APIs to enable or disable the charging and discharging MOSFETs of a battery, check their current states, and retrieve the status of previously sent commands.
Base URL
All API calls use the following base URL:
https://apiplatform.intellicar.inWhen we mention an endpoint such as /api/mosfetcontrol/enable, the full URL is:
https://apiplatform.intellicar.in/api/mosfetcontrol/enable1. Enable MOSFET
Endpoint
POST /api/mosfetcontrol/enableDescription
Enables (turns ON) the MOSFET(s) for:
Charging
Discharging
Both (charge + discharge)
Request Body (JSON)
batteryid: Unique ID of the battery.
type:
chargeto enable charging MOSFETdischargeto enable discharging MOSFETchargendischargeto enable both
token: Security token for authorization
Response Body (JSON)
status:
SUCCESSif the command is acceptedFAILUREif something went wrong
data.cmdId: The command ID. Use this to track the command status later.
err: Error details if any.
msg: A message describing the outcome.
Example
Request:
Response:
2. Disable MOSFET
Endpoint
Description
Disables (turns OFF) the MOSFET(s) for:
Charging
Discharging
Both (charge + discharge)
Request Body (JSON)
batteryid: Unique ID of the battery.
type:
chargeto disable charging MOSFETdischargeto disable discharging MOSFETchargendischargeto disable both
token: Security token for authorization
Response Body (JSON)
status:
SUCCESSif the command is acceptedFAILUREif an error occurred
data.cmdId: The command ID for later status checks.
err: Error details if any.
msg: A message describing the result.
Example
Request:
Response:
3. Get MOSFET Current State
Endpoint
Description
Returns the current ON/OFF state of the charging and discharging MOSFETs.
Request Body (JSON)
batteryid: Unique ID of the battery.
token: Security token for authorization.
Response Body (JSON)
status:
SUCCESSif the state is retrievedFAILUREif an error occurred
data.charging:
1→ charging MOSFET is ON0→ charging MOSFET is OFF
data.discharging:
1→ discharging MOSFET is ON0→ discharging MOSFET is OFF
err: Error information if any.
msg: Description or additional info.
Example
Request:
Response:
4. Check MOSFET Command Status
Endpoint
Description
Returns the current status of a previously sent command (enable/disable).
Request Body (JSON)
batteryid: Unique ID of the battery.
cmdid: The ID of the command (from the
cmdIdyou received when calling enable/disable).token: Security token for authorization.
Response Body (JSON)
status:
SUCCESSif the status is retrievedFAILUREif an error occurred
data.batteryid: Battery ID.
data.cmd.type:
charge,discharge, orchargendischarge.data.cmd.mode:
enableordisable.data.cmdid: ID of the command.
data.cmdsrc: Typically
"SERVER".data.createdby: Who initiated the command.
data.status: A list of updates about the command’s progression. Each item includes:
timestamp: When the event happened (in epoch).
cmdstatus: The status code at that time.
Command Status Codes
CMD_PICKED_UP_BY_SERVER: Server has acknowledged the command.
CMD_RECEIVED_BY_DEVICE: Device has received the command.
DEVICE_CMD_EXECUTION_SUCCESS: Device executed the command successfully.
DEVICE_CMD_EXECUTION_FAILED: Device tried to execute but failed.
CMD_DROPPED_BY_SERVER: Command was not processed by the server.
CMD_IN_QUEUE: Command is in the queue, waiting to be processed.
Example
Request:
Response:
Summary
Enable MOSFET:
POST /api/mosfetcontrol/enableTurn on charging, discharging, or both MOSFETs.Disable MOSFET:
POST /api/mosfetcontrol/disableTurn off charging, discharging, or both MOSFETs.Current State:
POST /api/mosfetcontrol/currentstateCheck if the charging/discharging MOSFETs are currently on or off.Command Status:
POST /api/mosfetcontrol/cmdstatusTrack the status of your enable/disable commands.
Remember:
Always include your battery ID and token in each request.
Store the
cmdIdfrom the Enable or Disable command responses to check those commands later with the Command Status API.
Last updated