提交 72b704f5 authored 作者: blu's avatar blu

big refacting of communitation architect

上级 69046a88
### evcloudsvc restful api
#### GET /config
##### description
query configuration for edge device with specified sn
##### params
- sn: string. device serial
##### return
- type: json
- field "code": 0 - success; otherwise failed.
- field "msg": string, readable string for "code"
- field "data": configuration for sn.
- example
```
{
"code": 0,
"data": {
"NMXH73Y2": {
"addr": "127.0.0.1",
"api-cloud": "http://127.0.0.1:8089",
"ipcs": [
{
"addr": "172.31.0.51",
"modules": {
"evml": [
{
"area": 300,
"enabled": 1,
"iid": 1,
"post": 30,
"pre": 3,
"sn": "NMXH73Y2",
"thresh": 80,
"type": "motion"
}
],
"evpuller": [
{
"addr": "127.0.0.1",
"enabled": 1,
"iid": 1,
"port-pub": 5556,
"sn": "NMXH73Y2"
}
],
"evpusher": [
{
"enabled": 1,
"iid": 1,
"password": "",
"sn": "NMXH73Y2",
"token": "",
"urlDest": "rtsp://40.73.41.176:554/test1",
"user": ""
}
],
"evslicer": [
{
"enabled": 1,
"iid": 1,
"path": "slices",
"sn": "NMXH73Y2"
}
]
},
"password": "FWBWTU",
"port": 554,
"proto": "rtsp",
"user": "admin"
}
],
"mqtt-cloud": "<cloud_addr>",
"port-cloud": 5556,
"port-router": 5550,
"proto": "zmq",
"sn": "NMXH73Y2"
}
},
"msg": "ok"
}
```
#### POST /config
##### description
set or change configuration for edge device
##### params
- none
##### return
- type: json
- example:
```
{
"data":{
"NMXH73Y2":{
"addr":"127.0.0.1",
"api-cloud":"http://127.0.0.1:8089",
"ipcs":[
{
"addr":"172.31.0.51",
"modules":{
"evml":[
{
"area":300,
"enabled":1,
"iid":1,
"post":30,
"pre":3,
"sn":"NMXH73Y2",
"thresh":80,
"type":"motion"
}
],
"evpuller":[
{
"addr":"127.0.0.1",
"iid":1,
"enabled": 1,
"port-pub":5556,
"sn":"NMXH73Y2"
}
],
"evpusher":[
{
"enabled":1,
"iid":1,
"password":"",
"sn":"NMXH73Y2",
"token":"",
"urlDest":"rtsp://40.73.41.176:554/test1",
"user":""
}
],
"evslicer":[
{
"enabled":1,
"iid":1,
"path":"slices",
"sn":"NMXH73Y2"
}
]
},
"password":"FWBWTU",
"port":554,
"proto":"rtsp",
"user":"admin"
}
],
"mqtt-cloud":"<cloud_addr>",
"port-cloud":5556,
"port-router":5550,
"proto":"zmq",
"sn":"NMXH73Y2"
}
},
"lastupdated":1567669674
}
```
#### GET /keys
##### description
query all keys in cloud db
##### params
- none
##### return
- type: json array
- example
```
[
"NMXH73Y2",
"NMXH73Y2_bak",
"SN",
"configmap",
"configmap_bak"
]
```
#### GET /value
##### description
get value for specified key in cloud db. keys list is queried by /keys api
##### params
- key: string
##### return
- type: json
- example
```
# GET /value?key=configmap
{
"NMXH73Y2": "NMXH73Y2",
"code": 0,
"mod2mgr": {
"NMXH73Y2:evml:motion": "NMXH73Y2",
"NMXH73Y2:evpuller": "NMXH73Y2",
"NMXH73Y2:evpusher": "NMXH73Y2",
"NMXH73Y2:evslicer": "NMXH73Y2"
},
"sn2mods": {
"NMXH73Y2": [
"NMXH73Y2:evml:motion",
"NMXH73Y2:evpuller",
"NMXH73Y2:evpusher",
"NMXH73Y2:evslicer"
]
}
}
```
#### POST /factory-reset
##### description
*[NOT IMPLEMENTED]* total reset edge terminal
##### params
- sn: string
##### return
- type: json
- example
```
{"code": 0, "msg":"ok", ...}
```
#### GET /sysinfo
##### description
*[NOT IMPLEMENTED]* get edge terminal hw & os infomation including resource usage of CPU, RAM, IO, DISK etc...
#### POST /debug
##### description
*[NOT IMPLEMENTED]* turn on/off debug tunnel
##### params
- sn: string
- op: on|off
- addr: string. tcp socket on cloud. eg: x.com:8899
##### return
- type: json
- example
```
{"code":0, "msg":"ok"}
```
...@@ -498,7 +498,6 @@ public: ...@@ -498,7 +498,6 @@ public:
ret["code"] = 1; ret["code"] = 1;
ret["msg"] = "no config for sn " + sn + ", module " + module; ret["msg"] = "no config for sn " + sn + ", module " + module;
} }
} }
else if(!sn.empty() && module.empty()) { else if(!sn.empty() && module.empty()) {
ret = getConfigForDevice(sn); ret = getConfigForDevice(sn);
......
...@@ -442,7 +442,7 @@ protected: ...@@ -442,7 +442,7 @@ protected:
} }
string getBaseName(string &fname) { string getBaseName(const string &fname) {
string ret; string ret;
auto posS = fname.find_last_of('/'); auto posS = fname.find_last_of('/');
if(posS == string::npos) { if(posS == string::npos) {
...@@ -562,8 +562,8 @@ protected: ...@@ -562,8 +562,8 @@ protected:
} }
try{ try{
auto ftime = fs::last_write_time(i.get_path()); auto ftime = fs::last_write_time(lastFile);
auto baseName = getBaseName(i.get_path()); auto baseName = self->getBaseName(lastFile);
auto ts = decltype(ftime)::clock::to_time_t(ftime); auto ts = decltype(ftime)::clock::to_time_t(ftime);
auto oldTs = self->vTsActive[self->segHead]; auto oldTs = self->vTsActive[self->segHead];
self->vTsActive[self->segHead] = ts; self->vTsActive[self->segHead] = ts;
...@@ -571,13 +571,14 @@ protected: ...@@ -571,13 +571,14 @@ protected:
// erase old ts to save memory // erase old ts to save memory
self->mapTs2BaseName.erase(oldTs); self->mapTs2BaseName.erase(oldTs);
self->segHead++; self->segHead++;
spdlog::info("evslicer {} fileMonHandler video seg done :{}/{}.mp4, ts:{}", self->selfId, self->urlOut, baseName, ts); spdlog::info("evslicer {} fileMonHandler video seg done: {}/{}.mp4, ts:{}", self->selfId, self->urlOut, baseName, ts);
}catch(exception &e) { }catch(exception &e) {
spdlog::error("evslicer {} fileMonHandler exception: {}", self->selfId, e.what()); spdlog::error("evslicer {} fileMonHandler exception: {}", self->selfId, e.what());
} }
}else{ }else{
//nop //nop
} }
lastFile = i.get_path();
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论