Difference between revisions of "EIS Service SDK"

From ESS-WIKI
Jump to: navigation, search
 
(52 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Definition =
+
= Introduction =
  
== Service Return Code ==
+
  This is a SDK for receiving and sending control command to EdgeSense system. Application can use the SDK to communication with EdgeSense southbound devices.
 +
 
 +
= Device Service SDK =
 +
 
 +
 Device service SDK supports cross-platform / OS and multiple language as below. User can ealy to get/set southbound services by it. 
 +
 
 +
OS: Windows, Linux
 +
 
 +
CPU: x86/x64 and ARM / RISC
 +
 
 +
Language: C/C++, Node.JS
 +
 
 +
= How To =
 +
 
 +
== Soure Code ==
 +
 
 +
=== C/C++ ===
 +
 
 +
git@advgitlab.eastasia.cloudapp.azure.com:EdgeSense/Service-SDK.git
 +
 
 +
Node.JS
 +
 
 +
git@advgitlab.eastasia.cloudapp.azure.com:EdgeSense-Open/device-service-sdk-node.js.git
 +
 
 +
 
 +
 
 +
== Definition ==
 +
 
 +
=== Service Return Code ===
 
<pre>typedef enum {                                                         
 
<pre>typedef enum {                                                         
 
     SV_ER_NOT_IMPLEMENT                = -13,  /*        Does Not Support this command        (501)        */
 
     SV_ER_NOT_IMPLEMENT                = -13,  /*        Does Not Support this command        (501)        */
Line 20: Line 48:
 
} SV_CODE;</pre>
 
} SV_CODE;</pre>
  
== Service Status ==
+
=== Service Status ===
 
<pre>typedef enum
 
<pre>typedef enum
 
{
 
{
Line 29: Line 57:
 
}SV_STATUS;</pre>
 
}SV_STATUS;</pre>
  
== Service Event Callback Function ==
+
== Service Event ==
<pre>typedef SV_CODE (SVCALL *Service_Cb) ( SV_EVENT e, char *ServiceName, void *inData, int dataLen, void *UserData )</pre>
+
 
 +
=== Callback Function ===
 +
<pre>typedef SV_CODE (SVCALL *Service_Cb) ( SV_EVENT e, char *ServiceName, void *inData, int dataLen, void *pUserData )</pre>
  
== Service Event Type ==
+
=== Service Event Type ===
 
<pre>typedef enum
 
<pre>typedef enum
 
{
 
{
     SV_E_JoinServiceSystem,       // Connected to the Service System
+
     SV_E_JoinServiceSystem       = 0, // Connected to the Service System
     SV_E_LeaveServiceSystem,       // Disconnected from the Service System
+
     SV_E_LeaveServiceSystem     = 1, // Disconnected from the Service System
     SV_E_RegisterService,         // Registed a new Service ( ex: HDD_PMQ Plugin )
+
     SV_E_RegisterService         = 2, // Registed a new Service ( ex: HDD_PMQ Plugin )
     SV_E_DeregisterService,       // Deregisted a Service
+
     SV_E_DeregisterService       = 3, // Deregisted a Service
     SV_E_UpdateServiceCapability, // Update Service's Capability
+
     SV_E_UpdateServiceCapability = 4, // Update Service's Capability
     SV_E_UpdateData,               // Update Service's data value
+
     SV_E_UpdateData             = 5, // Update Service's data value
     SV_E_ActionResult,             // Get / Set Reply
+
     SV_E_ActionResult           = 6, // Reply Message of Get / Set
     SV_E_EventNotify,             // EventNotify
+
     SV_E_EventNotify             = 7, // EventNotify
 
}SV_EVENT;</pre>
 
}SV_EVENT;</pre>
  
= Functions =
+
=== '''Example''' ===
 +
 
 +
{| border="1" cellspacing="1" cellpadding="1" style="width: 1129px;"
 +
|-
 +
| style="width: 235px;" | '''e'''
 +
| style="width: 161px;" | '''ServiceName'''
 +
| style="width: 354px;" | '''inData'''
 +
| style="width: 127px;" | '''dataLen'''
 +
| style="width: 211px;" | '''pUserData'''
 +
|-
 +
| style="width: 235px;" | '''<span style="color:#0000FF;">SV_E_JoinServiceSystem</span>'''<br/>
 +
| style="width: 161px;" | ServiceSystem<br/>
 +
| style="width: 354px;" | ""
 +
| style="width: 127px;" | 0
 +
| style="width: 211px;" | point of user data<br/>
 +
|-
 +
| style="width: 235px;" | '''<span style="color:#0000FF;">SV_E_LeaveServiceSystem</span>'''<br/>
 +
| style="width: 161px;" | ServiceSystem<br/>
 +
| style="width: 354px;" | ""
 +
| style="width: 127px;" | 0
 +
| style="width: 211px;" | point of user data<br/>
 +
|-
 +
| style="width: 235px;" | '''<span style="color:#0000FF;">SV_E_RegisterService</span>'''<br/>
 +
| style="width: 161px;" | HDD_PMQ<br/>
 +
| style="width: 354px;" | InfoSpec of Service refer to [[Agent_Communication_Protocol_in_MQTT#Info_or_Update_Device.27s_Capability|SenHub]]<br/>
 +
| style="width: 127px;" | Length of&nbsp;data<br/>
 +
| style="width: 211px;" | point of user data<br/>
 +
|-
 +
| style="width: 235px;" | <span style="color:#0000FF;">'''SV_E_DeregisterService'''</span><br/>
 +
| style="width: 161px;" | HDD_PMQ<br/>
 +
| style="width: 354px;" | ""
 +
| style="width: 127px;" | 0
 +
| style="width: 211px;" | point of user data<br/>
 +
|-
 +
| style="width: 235px;" | '''<span style="color:#0000FF;">SV_E_UpdateServiceCapability</span>'''<br/>
 +
| style="width: 161px;" | HDD_PMQ<br/>
 +
| style="width: 354px;" | InfoSpec of Service refer to [[Agent_Communication_Protocol_in_MQTT#Info_or_Update_Device.27s_Capability|SenHub]]<br/>
 +
| style="width: 127px;" | Length of&nbsp;data<br/>
 +
| style="width: 211px;" | point of user data<br/>
 +
|-
 +
| style="width: 235px;" | '''<span style="color:#0000FF;">SV_E_UpdateData</span>'''<br/>
 +
| style="width: 161px;" | HDD_PMQ<br/>
 +
| style="width: 354px;" | data value of Service refer to [[Agent_Communication_Protocol_in_MQTT#Info_or_Update_Device.27s_Capability|SenHub]]<br/>
 +
| style="width: 127px;" | Length of&nbsp;data<br/>
 +
| style="width: 211px;" | point of user data<br/>
 +
|-
 +
| style="width: 235px;" | '''<span style="color:#0000FF;">SV_E_ActionResult</span>'''<br/>
 +
| style="width: 161px;" | HDD_PMQ<br/>
 +
| style="width: 354px;" | result of action<br/>
 +
| style="width: 127px;" | Length of&nbsp;data<br/>
 +
| style="width: 211px;" | point of user data<br/>
 +
|-
 +
| style="width: 235px;" | '''<span style="color:#0000FF;">SV_E_EventNotify</span>'''<br/>
 +
| style="width: 161px;" | HDD_PMQ<br/>
 +
| style="width: 354px;" | event notify refer&nbsp;to [[Agent_Communication_Protocol_in_MQTT#EventNotify|EventNotify]]<br/>
 +
| style="width: 127px;" | Length of&nbsp;data<br/>
 +
| style="width: 211px;" | point of user data<br/>
 +
|}
  
== Initial & Uninitial&nbsp; ==
+
'''&nbsp;'''
  
Description: Initialize the Service SDK
+
== Functions ==
<pre>'''​SV_CODE SV_Initialize'''( Service_Cb fn, void *pInUserData )</pre>
 
  
*Parameter:
+
{| border="1" cellspacing="1" cellpadding="1" style="width: 679px;"
 +
|-
 +
| style="width: 72px; text-align: center;" | Item
 +
| style="width: 197px; text-align: center;" | Function Name
 +
| style="width: 396px; text-align: center;" | Description
 +
|-
 +
| style="width: 72px; text-align: center;" | 1
 +
| style="width: 197px;" | SV_Initialize
 +
| style="width: 396px;" | Initialize the Service SDK<br/>
 +
|-
 +
| style="width: 72px; text-align: center;" | 2
 +
| style="width: 197px;" | SV_Uninitialize<br/>
 +
| style="width: 396px;" | UnInitialize the Service SDK<br/>
 +
|-
 +
| style="width: 72px; text-align: center;" | 3
 +
| style="width: 197px;" | SV_GetVersion<br/>
 +
| style="width: 396px;" | Get version of Service SDK<br/>
 +
|-
 +
| style="width: 72px; text-align: center;" | 4
 +
| style="width: 197px;" | SV_GetServiceStatus<br/>
 +
| style="width: 396px;" | Get status of Service System<br/>
 +
|-
 +
| style="width: 72px; text-align: center;" | 5
 +
| style="width: 197px;" | SV_Query_Service<br/>
 +
| style="width: 396px;" | Query All of Service Name<br/>
 +
|-
 +
| style="width: 72px; text-align: center;" | 6
 +
| style="width: 197px;" | SV_GetCapability<br/>
 +
| style="width: 396px;" | Get Service's Capability<br/>
 +
|-
 +
| style="width: 72px; text-align: center;" | 7
 +
| style="width: 197px;" | SV_AutoReportStart<br/>
 +
| style="width: 396px;" | Start Auto Report<br/>
 +
|-
 +
| style="width: 72px; text-align: center;" | 8
 +
| style="width: 197px;" | SV_AutoReportStop<br/>
 +
| style="width: 396px;" | Stop Auto Report<br/>
 +
|-
 +
| style="width: 72px; text-align: center;" | 9
 +
| style="width: 197px;" | SV_Action<br/>
 +
| style="width: 396px;" | Function for Get / Set Command<br/>
 +
|}
 +
 
 +
 
 +
 
 +
=== Initial & Uninitial&nbsp; ===
 +
 
 +
<span style="font-size:large;">'''<span style="color:#FF0000;">SV_CODE SV_Initialize( Service_Cb fn, void *pInUserData )</span>'''</span>
 +
 
 +
*'''Description:'''Initialize the Service SDK
 +
*'''Parameter''':
  
 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Service_Cb&nbsp;&nbsp;&nbsp;&nbsp; fn: point of callback function
 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Service_Cb&nbsp;&nbsp;&nbsp;&nbsp; fn: point of callback function
Line 58: Line 194:
 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void* pInUserData: user data will pass when callback
 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void* pInUserData: user data will pass when callback
  
*Return value:
+
*'''Return value''':
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SV_CODE&nbsp; - SV_OK &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: Successful<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SV_ER_FAILED &nbsp;: Failed to call
 +
 
 +
*'''History''':&nbsp;&nbsp; 06/26/2017 Modified
 +
 
  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SV_CODE&nbsp; - SV_OK&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;: Successful<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SV_ER_FAILED&nbsp;: Failed to call
 
  
*History:&nbsp;&nbsp; 06/26/2017 Modified
+
<span style="font-size:large;">'''<span style="color:#FF0000;">SV_CODE SV_Uninitialize( );</span>'''</span>
  
 +
*'''Description''': UnInitialize the Service SDK
 +
*'''Parameter''':&nbsp;NONE
 +
*'''Return value''':
  
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SV_CODE&nbsp; - SV_OK &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: Successful<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SV_ER_FAILED &nbsp;: Failed to call
  
'''SV_CODE SV_Uninitialize( ); &nbsp;'''
+
*'''History''':&nbsp;&nbsp; 06/26/2017 Modified
<pre> *=============================================================================
+
 
* Function name: SV_'''Uninitialize'''
+
=== Information ===
* Description: UnInitialize the Service SDK
+
 
* Parameter:
+
<span style="font-size:large;">'''<span style="color:#FF0000;">SV_CODE SV_GetVersion(char *outVersion, int bufSize );&nbsp;</span>'''</span>
*     - NONE
+
 
*
+
*'''Description''': Get version of Service SDK
* Return value:
+
*'''Parameter''':
* SV_CODE - SV_OK       &nbsp;: Successful
+
 
*          - SV_ER_FAILED&nbsp;: Failed to call
+
&nbsp; &nbsp; &nbsp; - char * outVersion (out): point of result buffer size ( recomd: 128 bytes ) =>v1.0.1<br/>&nbsp; &nbsp; &nbsp; - int&nbsp;&nbsp;&nbsp; bufsize&nbsp;&nbsp;&nbsp;&nbsp; (in): max size of buffer
*
+
 
* History:   06/26/2017 Modified
+
*'''Return value''':
* =============================================================================
+
 
</pre>
+
&nbsp; &nbsp; &nbsp; &nbsp; SV_CODE&nbsp; - SV_OK &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;: Successful<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- SV_ER_FAILED: Failed to call
 +
 
 +
*'''History''':&nbsp;&nbsp; 06/26/2017 Modified
 +
*'''Example''':&nbsp;
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'''outVersion''': "v1.0.1"
 +
 
 +
 
 +
 
 +
 
 +
 
 +
<span style="font-size:large;"><span style="color:#FF0000;">'''SV_STATUS SV_GetServiceStatus( );'''</span></span>
 +
 
 +
*'''Description''': Get status of Service System
 +
*'''Parameter''':
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NONE
 +
 
 +
*'''Return value:'''
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SERVICE_STATUS - SV_UNINIT: SDK NOT Initilize<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - SV_INIT &nbsp; &nbsp;&nbsp;: Init Status<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - SV_JOINED: Joined to Service System<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - SV_LEAVED: Leaved from Service System
 +
 
 +
*'''History''':&nbsp;&nbsp; 06/26/2017 Modified
 +
 
 +
 
 +
 
 +
 
 +
 
 +
<span style="color:#FF0000;"><span style="font-size:large;">'''SV_CODE SV_Query_Service( char *outBuf, int bufSize );'''</span></span>
 +
 
 +
*'''Description''': Query All of Service Name
 +
*'''Parameter''':
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - char * outBuf &nbsp;(out): &nbsp;point of result buffer size ( recomd: 1024 bytes ) => { "Service":{"e":[{"n":"HDD_PMQ},{"n":"Modebus"}] }
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&nbsp;int &nbsp; &nbsp; bufsize &nbsp; &nbsp; &nbsp;(in): &nbsp;max size of buffer
 +
 
 +
*'''Return value:'''
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SV_CODE&nbsp; - SV_OK &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;: Successful<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- SV_ER_FAILED: Failed to call
 +
 
 +
*'''History''':&nbsp;&nbsp; 06/26/2017 Modified
 +
*'''Example:'''
 +
 
 +
'''&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outBuf=>&nbsp;'''{"Service":{"e":[ ] }} or'''&nbsp;'''{"Service":{"e":[{"n":"HDD_PMQ},{"n":"Modebus"}]}}
 +
 
 +
=== Function for Service ===
 +
 
 +
=== '''<span style="color:#FF0000;"><span style="font-size:larger;">SV_CODE SV_GetCapability( const char *ServiceName, char *outBuffer,&nbsp; int bufSize )</span></span>''' ===
 +
 
 +
*'''Description''': Get Service's Capability
 +
*'''Parameter''':
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- const char * ServiceName (in): &nbsp; &nbsp;Service Name => HDD_PMQ
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- char * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;outBuffer &nbsp; &nbsp; (out): &nbsp; &nbsp; buffer point for Service's Info Spec&nbsp;( Recommend:4096 characters&nbsp;)
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- int &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bufSize &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(in): &nbsp; &nbsp; Max buffer size ( Recommend: 4096 )&nbsp;
 +
 
 +
*'''Return value:'''
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SV_CODE&nbsp; - SV_OK &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;: Successful<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- SV_ER_FAILED: Failed to call
 +
 
 +
*'''History''':&nbsp;&nbsp; 06/26/2017 Modified
 +
*'''Example''':
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '''ServiceName'''&nbsp;: HDD_PMQ
 +
 
 +
'''&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;outBuffer&nbsp;''': Capability of Serice refer to&nbsp;[[Agent_Communication_Protocol_in_MQTT#Info_or_Update_Device.27s_Capability|SenHub]]
 +
 
 +
 
 +
 
 +
 
 +
 
 +
'''<span style="color:#FF0000;"><span style="font-size:larger;">SV_CODE SV_AutoReportStart( const char *ServiceName , char *inData, int inDataLen&nbsp; );</span></span>'''
 +
 
 +
*'''Description''': Start Auto Report
 +
*'''Parameter''':
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- const char * ServiceName (in): &nbsp; &nbsp;Service Name => HDD_PMQ
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- char * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;inData (in): &nbsp; &nbsp; Start JSON Data
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- int &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; inDataLen (in): &nbsp; &nbsp; Data Length
 +
 
 +
*'''Return value:'''
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SV_CODE&nbsp; - SV_OK &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;: Successful<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- SV_ER_FAILED: Failed to call
 +
 
 +
*'''History''':&nbsp;&nbsp; 06/26/2017 Modified
 +
<pre>{
 +
    "susiCommData":{
 +
        "requestID":1001,
 +
        "catalogID": 4,
 +
        "commCmd": 2053, //general_start_auto_upload_req
 +
        “handlerName”:”general”,
 +
        "requestItems":{"All":{}}       
 +
        "autoUploadIntervalSec": 30
 +
    }
 +
}</pre>
 +
 
 +
 
 +
 
 +
 
 +
 
 +
<span style="color:#FF0000;"><span style="font-size:larger;">'''SV_CODE&nbsp; SV_AutoReportStop( const char *ServiceName, char *inData, int inDataLen );'''</span></span>
 +
 
 +
*'''Description''': Stop Auto Report
 +
*'''Parameter''':
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- const char * ServiceName (in): &nbsp; &nbsp;Service Name => HDD_PMQ
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- char * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;inData (in): &nbsp; &nbsp; Start JSON Data
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- int &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; inDataLen (in): &nbsp; &nbsp; Data Length
 +
 
 +
*'''Return value:'''
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SV_CODE&nbsp; - SV_OK &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;: Successful<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- SV_ER_FAILED: Failed to call
 +
 
 +
*'''History''':&nbsp;&nbsp; 06/26/2017 Modified
 +
*'''Example''':
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;'''ServiceName'''&nbsp;: HDD_PMQ
 +
 
 +
'''&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;inData&nbsp;''':
 +
<pre> {
 +
    "susiCommData": {
 +
        "requestID":1001,
 +
        "catalogID": 4,       
 +
        "commCmd": 2056, //general_stop_auto_upload_req
 +
        “handlerName”:”general”
 +
        "requestItems":{"All":{}}
 +
    }
 +
}</pre>
 +
 
 +
 
 +
 
 +
 
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '''&nbsp;Reply:'''
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Topic:&nbsp;/cagent/admin/&lt;devID&gt;/agentcallbackreq
 +
<pre>{
 +
    "susiCommData":{
 +
        "requestID":1001,
 +
        "catalogID": 4,
 +
        "commCmd": 2054, //general_start_auto_upload_rep
 +
        “handlerName”:”general”,
 +
        “result”:”SUCCESS”
 +
    }
 +
}</pre>
 +
 
 +
<span style="color:#FF0000;">'''<span style="font-size:larger;">SV_CODE SV_Action( const char *ServiceName , char *szAction,&nbsp; void *pUserData );</span>'''</span>
 +
 
 +
*'''Description''': Action function for Get / Set&nbsp;Command
 +
*'''Parameter''':
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- const char * ServiceName (in)&nbsp;: &nbsp; &nbsp;Service Name => HDD_PMQ
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;- char * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; szAction (in)&nbsp;: &nbsp; &nbsp;Action Command with JSON
 +
 
 +
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;- void * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pUserData ( in): &nbsp; &nbsp;User data will return when result is callbacked
  
== Information ==
+
*'''Return value:'''
<pre>/*
 
*=============================================================================
 
* Function name: SV_GetVersion
 
* Description: Get version of Service SDK
 
* Parameter:
 
*      - char * outVersion (out): point of result buffer size ( recomd: 128 bytes ) =>v1.0.1
 
*      - int    bufsize    (in): max size of buffer
 
*
 
* Return value:
 
* SV_CODE  - SV_OK      &nbsp;: Successful
 
*          - SV_ER_FAILED&nbsp;: Failed to call
 
*
 
* History:  06/26/2017 Modified
 
* =============================================================================
 
*/</pre>
 
  
'''SV_CODE SV_GetVersion(char *outVersion, int bufSize );'''&nbsp;
+
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SV_CODE&nbsp; - SV_OK &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;: Successful<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- SV_ER_FAILED: Failed to call
<pre>/*
 
*=============================================================================
 
* Function name: SV_GetServiceStatus
 
* Description: Get status of Service System
 
* Parameter:
 
*      NONE
 
*
 
* Return value:
 
* SERVICE_STATUS - SV_UNINIT&nbsp;: SDK NOT Initilize
 
*                - SV_INIT  &nbsp;: Init Status
 
*                - SV_JOINED&nbsp;: Joined to Service System
 
*                - SV_LEAVED&nbsp;: Leaved from Service System
 
*
 
* History:  06/26/2017 Modified
 
* =============================================================================
 
*/</pre>
 
  
'''SV_STATUS SV_GetServiceStatus( );'''
+
*'''History''':&nbsp;&nbsp; 06/26/2017 Modified
 +
*'''Example''':
  
'''SV_CODE SV_Query_Service( char *outBuf, int bufSize );'''
+
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;'''ServiceName'''&nbsp;: HDD_PMQ
  
== Function for Service ==
+
'''&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;szAction''':
 +
<pre>{ 
 +
  "susiCommData":{ 
 +
    "sessionID":"2746E3B65BAB115338B9668CDC5C35C4",
 +
    "sensorIDList":{ 
 +
        "e":[ 
 +
          { 
 +
              "n":"SenHub/Info/sw"
 +
          }
 +
        ]
 +
    },
 +
    "commCmd":523,
 +
    "requestID":0,
 +
    "agentID":"",
 +
    "handlerName":"SenHub",
 +
    "sendTS":1466057267
 +
  }
 +
}</pre>
  
SV_CODE SV_GetCapability( const char *ServiceName, char *outBuffer, &nbsp;int bufSize )
+
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '''&nbsp;Reply:&nbsp;'''
  
SV_CODE SV_AutoReportStart( const char *ServiceName , char *inData, int inDataLen&nbsp; );
+
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'''Topic''':&nbsp;/cagent/admin/&lt;devID&gt;/agentactionreq
 +
<pre>{ 
 +
  "susiCommData":{ 
 +
    "commCmd":524,
 +
    "handlerName":"SenHub",
 +
    "sessionID":"2746E3B65BAB115338B9668CDC5C35C4",
 +
    "sensorInfoList":{ 
 +
        "e":[ 
 +
          { 
 +
              "n":"/Info/sw",
 +
              "sv":"1.0.00",
 +
              "StatusCode":200
 +
          }
 +
        ]
 +
    }
 +
  }
 +
}
 +
</pre>
  
SV_CODE &nbsp;SV_AutoReportStop( const char *ServiceName, char *inData, int inDataLen );
+
= Release & Sample Code =
  
SV_CODE SV_Action( const char *ServiceName , char *szAction, &nbsp;void *pUserData );
+
{| border="1" cellspacing="1" cellpadding="1" style="width: 799px;"
[[Category:Editor]]
+
|-
 +
| style="width: 74px;" | Item
 +
| style="width: 159px;" | Package Name
 +
| style="width: 105px;" | Date
 +
| style="width: 235px;" | Note
 +
| style="width: 223px;" | Download ( Windows )
 +
|-
 +
| style="width: 74px;" | 1
 +
| style="width: 159px;" | ServiceSDK_v1.0.1beta_20170704.zip<br/>
 +
| style="width: 105px;" | 2017/07/04
 +
| style="width: 235px;" | initial beta release
 +
| style="width: 223px;" | [[Media:ServiceSDK_v1.0.1beta_20170704.zip|v1.0.1_beta]]
 +
|-
 +
| style="width: 74px;" | 2
 +
| style="width: 159px;" | EISServiceSDKSetup_1.0.3.zip<br/>
 +
| style="width: 105px;" | 2017/12/28
 +
| style="width: 235px;" | <br/>
 +
| style="width: 223px;" | [[EISServiceSDKSetup_1.0.3.zip|v1.0.3]]
 +
|}

Latest revision as of 08:47, 31 July 2019

Introduction

  This is a SDK for receiving and sending control command to EdgeSense system. Application can use the SDK to communication with EdgeSense southbound devices.

Device Service SDK

 Device service SDK supports cross-platform / OS and multiple language as below. User can ealy to get/set southbound services by it. 

OS: Windows, Linux

CPU: x86/x64 and ARM / RISC

Language: C/C++, Node.JS

How To

Soure Code

C/C++

git@advgitlab.eastasia.cloudapp.azure.com:EdgeSense/Service-SDK.git

Node.JS

git@advgitlab.eastasia.cloudapp.azure.com:EdgeSense-Open/device-service-sdk-node.js.git


Definition

Service Return Code

typedef enum {                                                        
    SV_ER_NOT_IMPLEMENT                = -13,   /*        Does Not Support this command        (501)        */
    SV_ER_TIMEOUT                      = -12,   /*        Request Timeout                      (408)        */
    SV_ER_SYS_BUSY                     = -11,   /*        System is busy                       (503)        */
    SV_ER_VALUE_OUT_OF_RNAGE           = -10,   /*        Value is out of range                (416)        */
    SV_ER_SYNTAX_ERROR                 =  -9,   /*        Format is correct but syntax error   (422)        */
    SV_ER_FORMAT_ERROR                 =  -8,   /*        Format error                         (415)        */
    SV_ER_REQUEST_ERROR                =  -7,   /*        Request error                        (400)        */
    SV_ER_RESOURCE_LOSE                =  -6,   /*        SenHub disconnect                    (410)        */
    SV_ER_RESOURCE_LOCKED              =  -5,   /*        Resource is in setting               (426)        */
    SV_ER_NOT_FOUND                    =  -4,   /*        Resource Not Found                   (404)        */
    SV_ER_WRITE_ONLY                   =  -3,   /*        Read Only                            (405)        */
    SV_ER_READ_ONLY                    =  -2,   /*        Write Only                           (405)        */
    SV_ER_FAILED                       =  -1,   /*        Failed                               (500)        */
    SV_OK                              =   0,   /*        Success                              (200)        */
    SV_INITILIZED                      =   1,   /*        Library had initilized                            */
} SV_CODE;

Service Status

typedef enum
{
    SV_UNINIT = 0,
    SV_INIT   = 1,
    SV_JOINED = 2,
    SV_LEAVED = 3,
}SV_STATUS;

Service Event

Callback Function

typedef SV_CODE (SVCALL *Service_Cb) ( SV_EVENT e, char *ServiceName, void *inData, int dataLen, void *pUserData )

Service Event Type

typedef enum
{
    SV_E_JoinServiceSystem       = 0, // Connected to the Service System
    SV_E_LeaveServiceSystem      = 1, // Disconnected from the Service System
    SV_E_RegisterService         = 2, // Registed a new Service ( ex: HDD_PMQ Plugin )
    SV_E_DeregisterService       = 3, // Deregisted a Service
    SV_E_UpdateServiceCapability = 4, // Update Service's Capability
    SV_E_UpdateData              = 5, // Update Service's data value
    SV_E_ActionResult            = 6, // Reply Message of Get / Set
    SV_E_EventNotify             = 7, // EventNotify
}SV_EVENT;

Example

e ServiceName inData dataLen pUserData
SV_E_JoinServiceSystem
ServiceSystem
"" 0 point of user data
SV_E_LeaveServiceSystem
ServiceSystem
"" 0 point of user data
SV_E_RegisterService
HDD_PMQ
InfoSpec of Service refer to SenHub
Length of data
point of user data
SV_E_DeregisterService
HDD_PMQ
"" 0 point of user data
SV_E_UpdateServiceCapability
HDD_PMQ
InfoSpec of Service refer to SenHub
Length of data
point of user data
SV_E_UpdateData
HDD_PMQ
data value of Service refer to SenHub
Length of data
point of user data
SV_E_ActionResult
HDD_PMQ
result of action
Length of data
point of user data
SV_E_EventNotify
HDD_PMQ
event notify refer to EventNotify
Length of data
point of user data

 

Functions

Item Function Name Description
1 SV_Initialize Initialize the Service SDK
2 SV_Uninitialize
UnInitialize the Service SDK
3 SV_GetVersion
Get version of Service SDK
4 SV_GetServiceStatus
Get status of Service System
5 SV_Query_Service
Query All of Service Name
6 SV_GetCapability
Get Service's Capability
7 SV_AutoReportStart
Start Auto Report
8 SV_AutoReportStop
Stop Auto Report
9 SV_Action
Function for Get / Set Command


Initial & Uninitial 

SV_CODE SV_Initialize( Service_Cb fn, void *pInUserData )

  • Description:Initialize the Service SDK
  • Parameter:

           Service_Cb     fn: point of callback function

            void* pInUserData: user data will pass when callback

  • Return value:

           SV_CODE  - SV_OK                : Successful
                                SV_ER_FAILED  : Failed to call

  • History:   06/26/2017 Modified


SV_CODE SV_Uninitialize( );

  • Description: UnInitialize the Service SDK
  • Parameter: NONE
  • Return value:

           SV_CODE  - SV_OK                : Successful
                                SV_ER_FAILED  : Failed to call

  • History:   06/26/2017 Modified

Information

SV_CODE SV_GetVersion(char *outVersion, int bufSize ); 

  • Description: Get version of Service SDK
  • Parameter:

      - char * outVersion (out): point of result buffer size ( recomd: 128 bytes ) =>v1.0.1
      - int    bufsize     (in): max size of buffer

  • Return value:

        SV_CODE  - SV_OK               : Successful
                           - SV_ER_FAILED: Failed to call

  • History:   06/26/2017 Modified
  • Example

                 outVersion: "v1.0.1"



SV_STATUS SV_GetServiceStatus( );

  • Description: Get status of Service System
  • Parameter:

             NONE

  • Return value:

                  SERVICE_STATUS - SV_UNINIT: SDK NOT Initilize
                                                  - SV_INIT     : Init Status
                                                  - SV_JOINED: Joined to Service System
                                                  - SV_LEAVED: Leaved from Service System

  • History:   06/26/2017 Modified



SV_CODE SV_Query_Service( char *outBuf, int bufSize );

  • Description: Query All of Service Name
  • Parameter:

            - char * outBuf  (out):  point of result buffer size ( recomd: 1024 bytes ) => { "Service":{"e":[{"n":"HDD_PMQ},{"n":"Modebus"}] }

            - int     bufsize      (in):  max size of buffer

  • Return value:

           SV_CODE  - SV_OK               : Successful
                               - SV_ER_FAILED: Failed to call

  • History:   06/26/2017 Modified
  • Example:

              outBuf=> {"Service":{"e":[ ] }} or {"Service":{"e":[{"n":"HDD_PMQ},{"n":"Modebus"}]}}

Function for Service

SV_CODE SV_GetCapability( const char *ServiceName, char *outBuffer,  int bufSize )

  • Description: Get Service's Capability
  • Parameter:

           - const char * ServiceName (in):    Service Name => HDD_PMQ

           - char *            outBuffer     (out):     buffer point for Service's Info Spec ( Recommend:4096 characters )

           - int                  bufSize            (in):     Max buffer size ( Recommend: 4096 ) 

  • Return value:

           SV_CODE  - SV_OK               : Successful
                               - SV_ER_FAILED: Failed to call

  • History:   06/26/2017 Modified
  • Example:

            ServiceName : HDD_PMQ

             outBuffer : Capability of Serice refer to SenHub



SV_CODE SV_AutoReportStart( const char *ServiceName , char *inData, int inDataLen  );

  • Description: Start Auto Report
  • Parameter:

           - const char * ServiceName (in):    Service Name => HDD_PMQ

           - char *                      inData (in):     Start JSON Data

           - int                      inDataLen (in):     Data Length

  • Return value:

           SV_CODE  - SV_OK               : Successful
                               - SV_ER_FAILED: Failed to call

  • History:   06/26/2017 Modified
{
    "susiCommData":{
        "requestID":1001,
        "catalogID": 4,
        "commCmd": 2053, //general_start_auto_upload_req
        “handlerName”:”general”,
        "requestItems":{"All":{}}        
        "autoUploadIntervalSec": 30
    }
}



SV_CODE  SV_AutoReportStop( const char *ServiceName, char *inData, int inDataLen );

  • Description: Stop Auto Report
  • Parameter:

           - const char * ServiceName (in):    Service Name => HDD_PMQ

           - char *                      inData (in):     Start JSON Data

           - int                      inDataLen (in):     Data Length

  • Return value:

           SV_CODE  - SV_OK               : Successful
                               - SV_ER_FAILED: Failed to call

  • History:   06/26/2017 Modified
  • Example:

            ServiceName : HDD_PMQ

             inData :

 {
    "susiCommData": {
        "requestID":1001,
        "catalogID": 4,        
        "commCmd": 2056, //general_stop_auto_upload_req
        “handlerName”:”general”
        "requestItems":{"All":{}}
    }
}



               Reply:

                 Topic: /cagent/admin/<devID>/agentcallbackreq

{
    "susiCommData":{
        "requestID":1001,
        "catalogID": 4,
        "commCmd": 2054, //general_start_auto_upload_rep
        “handlerName”:”general”,
        “result”:”SUCCESS”
    }
}

SV_CODE SV_Action( const char *ServiceName , char *szAction,  void *pUserData );

  • Description: Action function for Get / Set Command
  • Parameter:

           - const char * ServiceName (in) :    Service Name => HDD_PMQ

            - char *                     szAction (in) :    Action Command with JSON

            - void *                 pUserData ( in):    User data will return when result is callbacked

  • Return value:

           SV_CODE  - SV_OK               : Successful
                               - SV_ER_FAILED: Failed to call

  • History:   06/26/2017 Modified
  • Example:

            ServiceName : HDD_PMQ

             szAction:

{  
  "susiCommData":{  
     "sessionID":"2746E3B65BAB115338B9668CDC5C35C4",
     "sensorIDList":{  
        "e":[  
           {  
              "n":"SenHub/Info/sw"
           }
        ]
     },
     "commCmd":523,
     "requestID":0,
     "agentID":"",
     "handlerName":"SenHub",
     "sendTS":1466057267
  }
}

             Reply: 

                 Topic: /cagent/admin/<devID>/agentactionreq

{  
  "susiCommData":{  
     "commCmd":524,
     "handlerName":"SenHub",
     "sessionID":"2746E3B65BAB115338B9668CDC5C35C4",
     "sensorInfoList":{  
        "e":[  
           {  
              "n":"/Info/sw",
              "sv":"1.0.00",
              "StatusCode":200
           }
        ]
     }
  }
}

Release & Sample Code

Item Package Name Date Note Download ( Windows )
1 ServiceSDK_v1.0.1beta_20170704.zip
2017/07/04 initial beta release v1.0.1_beta
2 EISServiceSDKSetup_1.0.3.zip
2017/12/28
v1.0.3