DeviceP2PIntercom Playback
Project: Pet Feeder | page_id: 1725
Device Module Authentication Interface Documentation - P2P Interfaces
Overview
- Base path: /api
- Documentation scope: P2P proxy interfaces in the device module
- Authentication method: request header X-Token
- Content-Type: application/json
Document Split
- This document only retains the P2P proxy interfaces
- For device basic interfaces, see device-auth.md
- For live address and recording address interfaces, see device-auth-address.md
Authentication Header
| Field | Type | Required | Description |
|---|---|---|---|
| X-Token | string | Yes | The JWT Token obtained after the user logs in |
Response Description
- The interfaces in this document are proxied directly by the server to the device's local interfaces.
- These interfaces do not use the unified code/msg/data wrapper.
- The server transparently forwards the device's original response body and HTTP status code.
- If the server fails at the parameter validation stage, a unified error structure is returned.
Server Unified Error Format
{
"code": 400,
"msg": "Parameter error",
"data": null
}
1. P2P Connection Establishment
- Path: /api/device/p2p/connect
- Method: POST
- Authentication required: Yes
Query Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| deviceId | string | Yes | Unique device identifier |
| onlyPlay | string | No | Whether to play only, default 0 |
| ringing | string | No | Device ringing control parameter |
Body Parameters
The server currently does not validate the body field structure and transparently forwards the original request body to the device. An empty body or JSON data required by the device protocol can be passed.
Request Example
POST /api/device/p2p/connect?deviceId=dev_001&onlyPlay=0
X-Token: <token>
Content-Type: application/json
{}
Response Parameter Description
- The server transparently forwards the response of the device-side /xsw/api/p2p/connect.
- The specific returned fields are determined by the device protocol and usually include session information, connection status and other fields.
Server Failure Response Example
{
"code": 400,
"msg": "deviceId cannot be empty",
"data": null
}
2. P2P Sending SDP
- Path: /api/device/p2p/sdp
- Method: POST
- Authentication required: Yes
Query Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| deviceId | string | Yes | Unique device identifier |
| sessionId | string | Yes | P2P session ID |
| channelId | string | No | Channel ID, default 1 |
| connectType | string | No | Connection type, default 1 |
Body Parameters
The server currently does not validate the body field structure and transparently forwards the original request body to the device. It is usually the SDP JSON data required by the device side.
Request Example
POST /api/device/p2p/sdp?deviceId=dev_001&sessionId=s123&channelId=1&connectType=1
X-Token: <token>
Content-Type: application/json
{
"sdp": "offer-sdp-content"
}
Response Parameter Description
- The server transparently forwards the response of the device-side /xsw/api/p2p/sdp.
- The specific returned fields are determined by the device protocol.
Server Failure Response Example
{
"code": 400,
"msg": "deviceId and sessionId cannot be empty",
"data": null
}
3. P2P Sending Candidate
- Path: /api/device/p2p/candidate
- Method: POST
- Authentication required: Yes
Query Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| deviceId | string | Yes | Unique device identifier |
| sessionId | string | Yes | P2P session ID |
Body Parameters
The server currently does not validate the body field structure and transparently forwards the original request body to the device. It is usually candidate-related JSON data.
Request Example
POST /api/device/p2p/candidate?deviceId=dev_001&sessionId=s123
X-Token: <token>
Content-Type: application/json
{
"candidate": "candidate:..."
}
Response Parameter Description
- The server transparently forwards the response of the device-side /xsw/api/p2p/candidate.
- The specific returned fields are determined by the device protocol.
Server Failure Response Example
{
"code": 400,
"msg": "deviceId and sessionId cannot be empty",
"data": null
}
4. P2P Keepalive
- Path: /api/device/p2p/keepalive
- Method: POST
- Authentication required: Yes
Query Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| deviceId | string | Yes | Unique device identifier |
| sessionId | string | Yes | P2P session ID |
Body Parameters
The server currently does not validate the body field structure and transparently forwards the original request body to the device. An empty body can be passed.
Request Example
POST /api/device/p2p/keepalive?deviceId=dev_001&sessionId=s123
X-Token: <token>
Content-Type: application/json
{}
Response Parameter Description
- The server transparently forwards the response of the device-side /xsw/api/p2p/keepalive.
- The specific returned fields are determined by the device protocol.
Server Failure Response Example
{
"code": 400,
"msg": "deviceId and sessionId cannot be empty",
"data": null
}
5. P2P Disconnect
- Path: /api/device/p2p/disconnect
- Method: POST
- Authentication required: Yes
Query Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| deviceId | string | Yes | Unique device identifier |
| sessionId | string | Yes | P2P session ID |
Body Parameters
The server currently does not validate the body field structure and transparently forwards the original request body to the device. An empty body can be passed.
Request Example
POST /api/device/p2p/disconnect?deviceId=dev_001&sessionId=s123
X-Token: <token>
Content-Type: application/json
{}
Response Parameter Description
- The server transparently forwards the response of the device-side /xsw/api/p2p/disconnect.
- The specific returned fields are determined by the device protocol.
Server Failure Response Example
{
"code": 400,
"msg": "deviceId and sessionId cannot be empty",
"data": null
}
6. P2P Play Prompt Tone
- Path: /api/device/p2p/play
- Method: POST
- Authentication required: Yes
Query Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| deviceId | string | Yes | Unique device identifier |
| name | string | No | Playback file name, default connected.wav |
| times | string | No | Number of times to play, default 1 |
Body Parameters
The server currently does not validate the body field structure and transparently forwards the original request body to the device. An empty body can be passed.
Request Example
POST /api/device/p2p/play?deviceId=dev_001&name=connected.wav×=1
X-Token: <token>
Content-Type: application/json
{}
Response Parameter Description
- The server transparently forwards the response of the device-side /xsw/api/p2p/play.
- The specific returned fields are determined by the device protocol.
Server Failure Response Example
{
"code": 400,
"msg": "deviceId cannot be empty",
"data": null
}
Appendix
Description
- The P2P-related interfaces currently still pass parameters such as deviceId and sessionId through query, and have not been changed to read from the body.
- The request body is transparently forwarded by the server to the device's local interface.
- The internal forwarding targets on the server side are /xsw/api/p2p/connect、/xsw/api/p2p/sdp、/xsw/api/p2p/candidate、/xsw/api/p2p/keepalive、/xsw/api/p2p/disconnect、/xsw/api/p2p/play.
- The content returned by the device is transparently forwarded by the server, and the field structure depends on the device protocol.