Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update device write docs in mapper-framework #646

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 51 additions & 5 deletions docs/developer/mapper-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ Now we provide Influx2,Redis,TDengine database interfaces, we will add more data

#### Pull
The HTTP server was created to provide API services. It supports directly obtaining device data from the device.
The URLs listed below are given in the form of local IP. You can use these services from any network accessible to mapper.
The URLs listed below are given in the form of local IP. You can use these services from any network accessible to Mapper.

Port `7777` is enabled by default.
Port `7777` is enabled by default. User can change the Mapper API port in [config file](https://github.com/kubeedge/kubeedge/blob/master/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/config.yaml).

`deviceInstance-ID` according to your own CRD definition.
`deviceInstance-ID` according to your own CRD definition.
`propertyName` according to your own CRD definition.

#### Ping
Expand All @@ -119,7 +119,7 @@ Port `7777` is enabled by default.
#### Device Data
1. Get device's Data
Method=**GET**
Url: https://127.0.0.1:7777/api/v1/device/deviceInstance-ID/propertyName
Url: https://127.0.0.1:7777/api/v1/device/{deviceInstance-ID}/{propertyName}
Response:
```json
{
Expand All @@ -138,7 +138,7 @@ Port `7777` is enabled by default.
#### Device MetaData
1. Get device's Model
Method=**GET**
Url: https://127.0.0.1:7777/api/v1/meta/model/deviceInstance-ID
Url: https://127.0.0.1:7777/api/v1/meta/model/{deviceInstance-ID}
Response:
```json
{
Expand All @@ -159,6 +159,52 @@ Port `7777` is enabled by default.
}
```

#### Device Write
In version 1.19, the feature of Mapper supporting device writing is implemented, which enhances the original Mapper API capabilities.
Users can obtain all the device methods of a device that can be called externally through the API, and initiate a write request to
the device through the returned call command.

The URLs listed below are given as local IPs. You can use these services from any network accessible to Mapper.

Port `7777` is enabled by default. User can change the Mapper API port in [config file](https://github.com/kubeedge/kubeedge/blob/master/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/config.yaml).

`deviceInstance-ID` according to your own CRD definition.
`propertyName` according to your own CRD definition.

1. Get all device methods of a device
Url: https://127.0.0.1:7777/api/v1/devicemethod/{deviceInstance-ID}
Response:
```json
{
"Data": {
"Methods": [
{
"Name": "setValue",
"Path": "/api/v1/devicemethod/default/random-instance-01/setValue/{propertyName}/{data}",
"Parameters": [
{
"PropertyName": "random-int",
"ValueType": "int"
}
]
}
]
}
}
```

After obtaining the calling command of the device method, the user can create a device write request:

2. Create device write request
Url: https://127.0.0.1:7777/api/v1/devicemethod/{deviceInstance-ID}/{deviceMethodName}/{propertyName}/{data}
Response:
```json
{
"statusCode": 200,
"Message": "Write data ** to device ** successfully."
}
```




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ spec:
#### 拉取数据
我们创建HTTP服务用以提供API拉取功能,支持直接从设备拉取设备数据。下面列出的 URL 以本地 IP 的形式给出。你可以从Mapper可访问的任何网络使用这些服务。

默认情况下启用端口“7777”。
默认情况下启用端口“7777”。你可以在Mapper的[config文件](https://github.com/kubeedge/kubeedge/blob/master/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/config.yaml)中自行设置端口号。

`deviceInstance-ID` 根据你自己的 CRD 定义。

Expand All @@ -109,7 +109,7 @@ spec:
#### 设备数据处理
1. 获取设备数据
Method=**GET**
Url: https://127.0.0.1:7777/api/v1/device/deviceInstance-ID/propertyName
Url: https://127.0.0.1:7777/api/v1/device/{deviceInstance-ID}/{propertyName}
Response:
```json
{
Expand All @@ -128,7 +128,7 @@ spec:
#### 设备元数据
1. 获取设备模型
Method=**GET**
Url: https://127.0.0.1:7777/api/v1/meta/model/deviceInstance-ID
Url: https://127.0.0.1:7777/api/v1/meta/model/{deviceInstance-ID}
Response:
```json
{
Expand All @@ -149,6 +149,52 @@ spec:
}
```

#### 设备写入
在1.19版本中实现了Mapper支持设备写入的特性,增强了原有Mapper API能力。用户能够通过API获取某个设备所有可供外部调用的设备方法,通过返回的调用命令向设备发起写入请求。
下面列出的 URL 以本地 IP 的形式给出。你可以从Mapper可访问的任何网络使用这些服务。

默认情况下启用端口“7777”。你可以在Mapper的[config文件](https://github.com/kubeedge/kubeedge/blob/master/staging/src/github.com/kubeedge/mapper-framework/_template/mapper/config.yaml)中自行制定端口号

`deviceInstance-ID` 根据你自己的 CRD 定义。

`propertyName` 根据你自己的 CRD 定义。

1. 获取设备的所有设备方法
Url: https://127.0.0.1:7777/api/v1/devicemethod/{deviceInstance-ID}
Response:
```json
{
"Data": {
"Methods": [
{
"Name": "setValue",
"Path": "/api/v1/devicemethod/default/random-instance-01/setValue/{propertyName}/{data}",
"Parameters": [
{
"PropertyName": "random-int",
"ValueType": "int"
}
]
}
]
}
}
```

获取设备方法的调用命令后,用户可以创建设备写入请求:

2. 创建设备写入请求
Url: https://127.0.0.1:7777/api/v1/devicemethod/{deviceInstance-ID}/{deviceMethodName}/{propertyName}/{data}
Response:
```json
{
"statusCode": 200,
"Message": "Write data ** to device ** successfully."
}
```






Expand Down