IOTC Platform  Ver: 4.3.6.2-0-ge1f616e
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
NebulaNode.h File Reference
#include "NebulaDevice.h"

Data Structures

struct  NebulaNodeCtx
 

Typedefs

typedef struct NebulaNodeCtx NebulaNodeCtx
 
typedef int(__stdcall * NebulaNodeCommandHandleFn )(NebulaNodeCtx *node, const char *identity, const char *func, const TUTKJsonObject *args, TUTKJsonObject **response)
 The prototype of node command handle callback function.
 
typedef int(__stdcall * NebulaNodeSettingsChangeHandleFn )(NebulaNodeCtx *node_ctx, const char *settings)
 Node settings change callback function.
 

Functions

NEBULA_API int Nebula_Node_New (const char *udid, const char *profile, NebulaNodeCommandHandleFn command_handler, NebulaNodeSettingsChangeHandleFn settings_change_handler, NebulaNodeCtx **node_ctx)
 Create Nebula node.
 
NEBULA_API int Nebula_Node_Load_Settings (NebulaNodeCtx *ctx, const char *settings)
 Nebula node load settings.
 
NEBULA_API int Nebula_Node_Delete (NebulaNodeCtx *node_ctx)
 Destroy Nebula node.
 
NEBULA_API int Nebula_Device_Add_Node (NebulaDeviceCtx *device_ctx, NebulaNodeCtx *node_ctx, unsigned int timeout_msec, unsigned int *abort_flag)
 Add node to device.
 
NEBULA_API int Nebula_Device_Find_Node (NebulaDeviceCtx *device_ctx, const char *udid, NebulaNodeCtx **node_ctx)
 Get node in deivce.
 
NEBULA_API int Nebula_Device_Remove_Node (NebulaDeviceCtx *device_ctx, NebulaNodeCtx *node_ctx)
 Remove node from device.
 
NEBULA_API int Nebula_Device_Remove_Node_By_Udid (NebulaDeviceCtx *device_ctx, const char *udid)
 Remove node from device by node udid.
 
NEBULA_API int Nebula_Node_Push_Notification (NebulaNodeCtx *ctx, TUTKJsonObject *notification_obj, unsigned int timeout_msec, unsigned int *abort_flag)
 Nebula node push notification to server.
 

Detailed Description

This file describes Nebula module APIs for device.

Typedef Documentation

typedef int(__stdcall * NebulaNodeCommandHandleFn)(NebulaNodeCtx *node, const char *identity, const char *func, const TUTKJsonObject *args, TUTKJsonObject **response)

The prototype of node command handle callback function.

This callback function is called when Nebula client send request to Nebula node. Nebula node should handle the request and send an appropriate response.

Parameters
node[in] Node's context generate by Nebula_Device_New()
fun[out] The json object name
args[out] The json object
response[in] The json response object
See Also
Nebula_Node_New()
typedef struct NebulaNodeCtx NebulaNodeCtx
typedef int(__stdcall * NebulaNodeSettingsChangeHandleFn)(NebulaNodeCtx *node_ctx, const char *settings)

Node settings change callback function.

This callback function is called when settings of node changes. Node settings should be stored in non-volatile memory in order to be loaded when device restarts.

Parameters
device[in] node's context generate by Nebula_Node_New()
settings[in] the encrypted settings string of node
See Also
Nebula_Node_New() Nebula_Node_Load_Settings()

Function Documentation

NEBULA_API int Nebula_Device_Add_Node ( NebulaDeviceCtx device_ctx,
NebulaNodeCtx node_ctx,
unsigned int  timeout_msec,
unsigned int *  abort_flag 
)

Add node to device.

Add node for receiving forward commands.

Parameters
device_ctx[in]The device's context created by Nebula_Device_New()
node_ctx[in]The node's context created by Nebula_Node_New()
timeout_msec[in]The timeout for this function in unit of millisecond, give 0 means block forever
abort_flag[in] set *abort_flag to 1 if you need to abort this function
Returns
NEBULA_ER_NoERROR if node is successfully added to device
Error code if return value < 0
See Also
Nebula_Node_New(), Nebula_Device_Find_Node(), Nebula_Device_Remove_Node()
NEBULA_API int Nebula_Device_Find_Node ( NebulaDeviceCtx device_ctx,
const char *  udid,
NebulaNodeCtx **  node_ctx 
)

Get node in deivce.

Get node's context with specified udid

Parameters
device_ctx[in]The device's context created by Nebula_Device_New()
udid[in]The udid of node
node_ctx[out]The node's context with specified udid
Returns
NEBULA_ER_NoERROR if the node's context exists
Error code if return value < 0
See Also
Nebula_Node_New(), Nebula_Device_Add_Node(), Nebula_Device_Remove_Node()
NEBULA_API int Nebula_Device_Remove_Node ( NebulaDeviceCtx device_ctx,
NebulaNodeCtx node_ctx 
)

Remove node from device.

Remove node's context from device

Parameters
device_ctx[in]The device's context created by Nebula_Device_New()
node_ctx[in]The node's context created by Nebula_Node_New()
Returns
Error code if return value < 0
See Also
Nebula_Node_New(), Nebula_Device_Add_Node(), Nebula_Device_Find_Node()
NEBULA_API int Nebula_Device_Remove_Node_By_Udid ( NebulaDeviceCtx device_ctx,
const char *  udid 
)

Remove node from device by node udid.

Remove node's context from device

Parameters
device_ctx[in]The device's context created by Nebula_Device_New()
udid[in]The udid of node
Returns
Error code if return value < 0
See Also
Nebula_Node_New(), Nebula_Device_Add_Node()
NEBULA_API int Nebula_Node_Delete ( NebulaNodeCtx node_ctx)

Destroy Nebula node.

Free node context that created by Nebula_Node_New()

Parameters
node_ctx[in] Nebula context of node
Returns
NEBULA_ER_NoERROR if node context is successfully deleted
Error code if return value < 0
See Also
Nebula_Node_New()
NEBULA_API int Nebula_Node_Load_Settings ( NebulaNodeCtx ctx,
const char *  settings 
)

Nebula node load settings.

Restore node settings.

Parameters
ctx[in]node's context generate by Nebula_Device_New()
settings[in]the encrypted settings string of Nebula node
Returns
NEBULA_ER_NoERROR if load settings successfully
Error code if return value < 0
See Also
NebulaNodeSettingsChangeHandleFn
NEBULA_API int Nebula_Node_New ( const char *  udid,
const char *  profile,
NebulaNodeCommandHandleFn  command_handler,
NebulaNodeSettingsChangeHandleFn  settings_change_handler,
NebulaNodeCtx **  node_ctx 
)

Create Nebula node.

Create Node context for Nebula module. Node API for Nebula module need this context to work.

Parameters
udid[in] node's udid for Nebula module
profile[in] node's profile for client to use.
command_handler[in] Nebula command handler callback function
node_ctx[out] node's context created
Returns
NEBULA_ER_NoERROR if node context is successfully created
Error code if return value < 0
See Also
Nebula_Node_Delete()
NEBULA_API int Nebula_Node_Push_Notification ( NebulaNodeCtx ctx,
TUTKJsonObject notification_obj,
unsigned int  timeout_msec,
unsigned int *  abort_flag 
)

Nebula node push notification to server.

This function is used by node to push notification to server in order to notify Nebula client.

Parameters
ctx[in]node's context generate by Nebula_Node_New()
notification_obj[in]The json object contains a list of key value pair for push server to generate the push message. The key and value should be a string.
timeout_msec[in]The timeout for this function in unit of millisecond, give 0 means block forever
abort_flag[in] set *abort_flag to 1 if you need to abort this function
Returns
NEBULA_ER_NoERROR if push to server successfully
Error code if return value < 0
Attention
(1) Recommended value of timeout: 1000 millisecond ~ 30000 millisecond