Difference between revisions of "IoTGateway/DataProcess"
From ESS-WIKI
Eric.liang (talk | contribs) |
Eric.liang (talk | contribs) (→Example) |
||
(13 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | ::Data Format and SQL Field is designed for Data e-motion, Mqtt Reliability Data Channel. | |
+ | =SQL Field= | ||
{| style="border-spacing:0;width:17.477cm;" | {| style="border-spacing:0;width:17.477cm;" | ||
|- style="background-color:#ffffff;border:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | |- style="background-color:#ffffff;border:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | ||
Line 30: | Line 31: | ||
| align=center style="background-color:#ffffff;border-top:none;border-bottom:0.5pt solid #00000a;border-left:none;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;">Optional</span> | | align=center style="background-color:#ffffff;border-top:none;border-bottom:0.5pt solid #00000a;border-left:none;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;">Optional</span> | ||
| align=center style="background-color:#ffffff;border-top:none;border-bottom:0.5pt solid #00000a;border-left:none;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;">JSON</span> | | align=center style="background-color:#ffffff;border-top:none;border-bottom:0.5pt solid #00000a;border-left:none;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;">JSON</span> | ||
− | | style="background-color:#ffffff;border-top:0.5pt solid #00000a;border-bottom:0.5pt solid #00000a;border-left:none;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;"> | + | | style="background-color:#ffffff;border-top:0.5pt solid #00000a;border-bottom:0.5pt solid #00000a;border-left:none;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;">Refer to "Protocol Params in JSON Format"</span> |
|- | |- | ||
| align=center style="background-color:#ffffff;border-top:none;border-bottom:0.5pt solid #00000a;border-left:0.5pt solid #00000a;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;">4</span> | | align=center style="background-color:#ffffff;border-top:none;border-bottom:0.5pt solid #00000a;border-left:0.5pt solid #00000a;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;">4</span> | ||
Line 61: | Line 62: | ||
|- | |- | ||
|} | |} | ||
− | |||
− | |||
Line 96: | Line 95: | ||
| align=center style="background-color:#ffffff;border-top:none;border-bottom:0.5pt solid #00000a;border-left:none;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;">Optional</span> | | align=center style="background-color:#ffffff;border-top:none;border-bottom:0.5pt solid #00000a;border-left:none;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;">Optional</span> | ||
| align=center style="background-color:#ffffff;border-top:none;border-bottom:0.5pt solid #00000a;border-left:none;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;">JSON</span> | | align=center style="background-color:#ffffff;border-top:none;border-bottom:0.5pt solid #00000a;border-left:none;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;">JSON</span> | ||
− | | style="background-color:#ffffff;border-top:0.5pt solid #00000a;border-bottom:0.5pt solid #00000a;border-left:none;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;"> | + | | style="background-color:#ffffff;border-top:0.5pt solid #00000a;border-bottom:0.5pt solid #00000a;border-left:none;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;">Refer to "Protocol Params in JSON Format"</span> |
|- | |- | ||
| align=center style="background-color:#ffffff;border-top:none;border-bottom:0.5pt solid #00000a;border-left:0.5pt solid #00000a;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;">4</span> | | align=center style="background-color:#ffffff;border-top:none;border-bottom:0.5pt solid #00000a;border-left:0.5pt solid #00000a;border-right:0.5pt solid #00000a;padding-top:0cm;padding-bottom:0cm;padding-left:0.049cm;padding-right:0.049cm;" | <span style="color:#000000;">4</span> | ||
Line 127: | Line 126: | ||
|- | |- | ||
|} | |} | ||
− | |||
− | |||
Line 178: | Line 175: | ||
|- | |- | ||
|} | |} | ||
+ | |||
+ | |||
+ | ==Protocol Params in JSON Format== | ||
+ | |||
+ | '''<big>MQTT</big>''' | ||
+ | { | ||
+ | "Protocol":"MQTT", | ||
+ | "MQTT":{ | ||
+ | "Method":"Publish", | ||
+ | "Topic":"/cagent/admin/<devID>/agentactionreq", | ||
+ | "QoS":2, | ||
+ | "Retain":0 | ||
+ | } | ||
+ | } | ||
+ | |||
+ | =Data Extend Information and SQL Structures for Handler pass to Manager= | ||
+ | |||
+ | '''<big>SQL Params structure. This stuucture is designed for Hanlder pass its log behavior.</big>''' | ||
+ | typedef struct SQLParams | ||
+ | { | ||
+ | int nVer; // Version of SQL Param : 1 | ||
+ | int nAction; // 0: Insert or Update, 1: Delete, 2: Query | ||
+ | char *pszPrimaryKey; // NULL => Auto Index | ||
+ | char **pszOutDataPoint; // Pass this point to save result of query | ||
+ | char *pszGeneralInfo; // | ||
+ | int *pnStatus; // status code | ||
+ | void *pExtend1; | ||
+ | void *pExtend2; | ||
+ | }SQL_PARAMS, SQL_Params; | ||
+ | |||
+ | |||
+ | '''<big>Data extened Information Structure. Handler can add more information while sending data to WISE Manager.</big>''' | ||
+ | typedef struct DataExInfo | ||
+ | { | ||
+ | int nVer; // Data Ex Info version: 1 | ||
+ | void *pSqlParams; // address of SQL parameters structure | ||
+ | void *pExtend1; // Reserved | ||
+ | void *pExtend2; // Reserved | ||
+ | }DATAEX_INFO, DataEx_Info; | ||
+ | |||
+ | =Example= | ||
+ | '''<big>SenHub's Info Spec</big>'''<br /> | ||
+ | Topic: /cagent/admin/<devID>/agentactionreq<br /> | ||
+ | |||
+ | Msg: | ||
+ | { "susiCommData": { | ||
+ | "infoSpec": { | ||
+ | "SenHub": { | ||
+ | "SenData": { | ||
+ | "e": [{"n": "Temperature","u": "Cel","v": 0,"min": -100,"max": 200,"asm": "r","type": "d","rt": "ucum.Cel","st": "ipso","exten": ""}, | ||
+ | {"n": "Humidity","u": "%","v": 0,"min": 0,"max": 100,"asm": "r","type": "d","rt": "ucum.%","st": "ipso","exten": ""}], | ||
+ | "bn": "SenData" | ||
+ | }, | ||
+ | "Info": {"e": [{"n": "Name","sv": "SenHub1","asm": "rw"},{"n": "sw","sv": "1.0.00","asm": "r"}], | ||
+ | "bn": "Info" | ||
+ | }, | ||
+ | "Net": {"e": [{"n": "sw","sv": "1.0.00","asm": "r"},{"n": "Neighbor","sv": "","asm": "r"},{"n": "Health","v": "100.000000","asm": "r"}], | ||
+ | "bn": "Net" | ||
+ | } | ||
+ | } | ||
+ | }, | ||
+ | "commCmd": 2052, | ||
+ | "requestID": 2001, | ||
+ | "agentID": "0017000E40000000", | ||
+ | "handlerName": "general", | ||
+ | "sendTS": 160081024 | ||
+ | } | ||
+ | } | ||
+ | |||
+ | :'''<big>DataEx</big>''' | ||
+ | nVer: 1 | ||
+ | |||
+ | :'''<big>SqlParams:</big>''' | ||
+ | nAction: 0 | ||
+ | pszPrimaryKey: /cagent/admin/<devID>/agentactionreq | ||
+ | pszOutData: NULL | ||
+ | pszGeneralInfo: NULL | ||
+ | pExtend1: NULL | ||
+ | pExtend2: NULL | ||
+ | |||
+ | SQL Table IoTGWHandler_UniqueKey | ||
+ | Key: /cagent/admin/<devID>/agentactionreq | ||
+ | SecondKey: IoTGWHandler | ||
+ | Protocol_Param: Refer above | ||
+ | Message: Refer above | ||
+ | Send: - | ||
+ | Time: UTC | ||
+ | General: - |
Latest revision as of 05:39, 6 September 2016
- Data Format and SQL Field is designed for Data e-motion, Mqtt Reliability Data Channel.
Contents
SQL Field
SQLite Table Fields ( Auto Index) | |||||
Item | Field Name | Type | Need | Format | Example |
1 | Key | Unsigned Int | Must | 6886 (serial number) | |
2 | SecondKey | Text | Optional | Default: Hanle Name: SUSHandler | |
3 | Protocol_Param | Text | Optional | JSON | Refer to "Protocol Params in JSON Format" |
4 | Message | Text | Optional | {IoTGW { …. } ) | |
5 | Send | Flag | Optional | 0 or 1 | 1 or 0 |
6 | Time | Unsigned Int | Must | 33325 ( UTC in sec ) | |
7 | General | Text | Optional | any type format |
SQLite Table Fields ( User Assign Key ) | |||||
Item | Field Name | Type | Need | Format | Example |
1 | Key | Text | Must | /cagent/admin/infoack | |
2 | SecondKey | Text | Optional | Default: Hanle Name: SUSHandler | |
3 | Protocol_Param | Text | Optional | JSON | Refer to "Protocol Params in JSON Format" |
4 | Message | Text | Optional | {IoTGW { …. } ) | |
5 | Send | Flag | Optional | 0 or 1 | 1 or 0 |
6 | Time | Unsigned Int | Must | 33325 ( UTC in sec ) | |
7 | General | Text | Optional | any type format |
SQLite Methods | |||||
Item | Method | Note | |||
1 | Insert | *by Primary key
*by Second key ( ex: HandlerName ) ( primary key => auto index ) | |||
2 | Update | by Primary key | |||
3 | Query | * by Primary key
* by Search rules ( like or updatetime or latest item / order by ? (time ...) ) * All ( order by time ) | |||
4 | Clean | *by Primary Key
*by Search rules ( like or updatetime or latest item / order by ? (time ...) ) *All items of Table | |||
5 | Create Table | *AutoIndex
*UniqueKey |
Protocol Params in JSON Format
MQTT
{ "Protocol":"MQTT", "MQTT":{ "Method":"Publish", "Topic":"/cagent/admin/<devID>/agentactionreq", "QoS":2, "Retain":0 } }
Data Extend Information and SQL Structures for Handler pass to Manager
SQL Params structure. This stuucture is designed for Hanlder pass its log behavior.
typedef struct SQLParams { int nVer; // Version of SQL Param : 1 int nAction; // 0: Insert or Update, 1: Delete, 2: Query char *pszPrimaryKey; // NULL => Auto Index char **pszOutDataPoint; // Pass this point to save result of query char *pszGeneralInfo; // int *pnStatus; // status code void *pExtend1; void *pExtend2; }SQL_PARAMS, SQL_Params;
Data extened Information Structure. Handler can add more information while sending data to WISE Manager.
typedef struct DataExInfo { int nVer; // Data Ex Info version: 1 void *pSqlParams; // address of SQL parameters structure void *pExtend1; // Reserved void *pExtend2; // Reserved }DATAEX_INFO, DataEx_Info;
Example
SenHub's Info Spec
Topic: /cagent/admin/<devID>/agentactionreq
Msg: { "susiCommData": { "infoSpec": { "SenHub": { "SenData": { "e": [{"n": "Temperature","u": "Cel","v": 0,"min": -100,"max": 200,"asm": "r","type": "d","rt": "ucum.Cel","st": "ipso","exten": ""}, {"n": "Humidity","u": "%","v": 0,"min": 0,"max": 100,"asm": "r","type": "d","rt": "ucum.%","st": "ipso","exten": ""}], "bn": "SenData" }, "Info": {"e": [{"n": "Name","sv": "SenHub1","asm": "rw"},{"n": "sw","sv": "1.0.00","asm": "r"}], "bn": "Info" }, "Net": {"e": [{"n": "sw","sv": "1.0.00","asm": "r"},{"n": "Neighbor","sv": "","asm": "r"},{"n": "Health","v": "100.000000","asm": "r"}], "bn": "Net" } } }, "commCmd": 2052, "requestID": 2001, "agentID": "0017000E40000000", "handlerName": "general", "sendTS": 160081024 } }
- DataEx
nVer: 1
- SqlParams:
nAction: 0 pszPrimaryKey: /cagent/admin/<devID>/agentactionreq pszOutData: NULL pszGeneralInfo: NULL pExtend1: NULL pExtend2: NULL
SQL Table IoTGWHandler_UniqueKey
Key: /cagent/admin/<devID>/agentactionreq SecondKey: IoTGWHandler Protocol_Param: Refer above Message: Refer above Send: - Time: UTC General: -