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.in

When we mention an endpoint such as /api/mosfetcontrol/enable, the full URL is:

https://apiplatform.intellicar.in/api/mosfetcontrol/enable

1. Enable MOSFET

Endpoint

POST /api/mosfetcontrol/enable

Description

Enables (turns ON) the MOSFET(s) for:

  • Charging

  • Discharging

  • Both (charge + discharge)

Request Body (JSON)

  • batteryid: Unique ID of the battery.

  • type:

    • charge to enable charging MOSFET

    • discharge to enable discharging MOSFET

    • chargendischarge to enable both

  • token: Security token for authorization

Response Body (JSON)

  • status:

    • SUCCESS if the command is accepted

    • FAILURE if 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:

    • charge to disable charging MOSFET

    • discharge to disable discharging MOSFET

    • chargendischarge to disable both

  • token: Security token for authorization

Response Body (JSON)

  • status:

    • SUCCESS if the command is accepted

    • FAILURE if 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:

    • SUCCESS if the state is retrieved

    • FAILURE if an error occurred

  • data.charging:

    • 1 → charging MOSFET is ON

    • 0 → charging MOSFET is OFF

  • data.discharging:

    • 1 → discharging MOSFET is ON

    • 0 → 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 cmdId you received when calling enable/disable).

  • token: Security token for authorization.

Response Body (JSON)

  • status:

    • SUCCESS if the status is retrieved

    • FAILURE if an error occurred

  • data.batteryid: Battery ID.

  • data.cmd.type: charge, discharge, or chargendischarge.

  • data.cmd.mode: enable or disable.

  • 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

  1. Enable MOSFET: POST /api/mosfetcontrol/enable Turn on charging, discharging, or both MOSFETs.

  2. Disable MOSFET: POST /api/mosfetcontrol/disable Turn off charging, discharging, or both MOSFETs.

  3. Current State: POST /api/mosfetcontrol/currentstate Check if the charging/discharging MOSFETs are currently on or off.

  4. Command Status: POST /api/mosfetcontrol/cmdstatus Track the status of your enable/disable commands.

Remember:

  • Always include your battery ID and token in each request.

  • Store the cmdId from the Enable or Disable command responses to check those commands later with the Command Status API.

Last updated