Difference between revisions of "IoTGateway/WiseSnail"
Fred.chang (talk | contribs) (→Configure) |
Fred.chang (talk | contribs) (→Connect) |
||
Line 205: | Line 205: | ||
==Connect== | ==Connect== | ||
+ | *'''WiseSnail_Connect''' | ||
+ | <div style="margin-left:0.847cm;margin-right:0cm;"> | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | | int '''WiseSnail_Connect'''(char *'''server_url''', int '''port''', char *'''username''', char *'''password''', WiseSnail_InfoSpec *'''infospec''', int '''count'''); | ||
+ | |} | ||
+ | <div style="margin-left:0.847cm;margin-right:0cm;"> | ||
+ | {| class="wikitable" width="50%" | ||
+ | |- | ||
+ | ! Parameter !! Description | ||
+ | |- | ||
+ | | align="center" width="40%" | server_url || The address of mqtt broker. | ||
+ | |- | ||
+ | | align="center" | port || The port of mqtt broker. | ||
+ | |- | ||
+ | | align="center" | username || The username of mqtt broker.("" for none) | ||
+ | |- | ||
+ | | align="center" | password|| The password of mqtt broker.("" for none) | ||
+ | |- | ||
+ | | align="center" | infospec || connect parameter array. | ||
+ | |- | ||
+ | | align="center" | count|| The size of infospec. | ||
+ | |} | ||
+ | </div> | ||
+ | </div> | ||
+ | |||
==Update== | ==Update== | ||
==Tool== | ==Tool== |
Revision as of 07:22, 8 September 2016
Contents
Introduction
WiseSnail is the short name of Wise Sensor Network Abstract Interactive Layer. It is a layer to define the topology and behavior of sensor network. A complete device represented in WiseSnail includes one virtual gateway, one sensor connectivity interface and several sensor hubs. WiseSnail provides a form-like array which we call it infospec array to define tha parameters of sensor hub. And a form-like data array updates your real time data. So, you can easy to represent your device by creating several arrays.
OS
- Ubuntu 14.04
- OpenWRT
Requirements
Configure
Optional
--disable-paho | Disable Paho support. |
--disable-mosquitto | Disable Mosquitto support. |
Compile
You can perform the following steps to build this library.
./configure Or ./configure --host=<your cross compiler> --prefix=<install path> make make install
Compile script
./snailconf.sh
Structures
Infospec
Description
The infospec structure defines your parameters in sensor hub. Those parameter structures will represented in Wise-Paas like a tag. this structure includes two callback functions. You can use the callbacks to define your own get and set function. The parameter button on Wise-Paas will different by whether the set function is defined or not. If the set function is defined, the value is writeable by users on Wise-Paas. |
struct WiseSnail_InfoSpec{ WiseSnail_DataType type; char *name; char *unit; union { float value; char *string; }; float min; float max; char *resourcetype; WiseSnail_SetValue setValue; WiseSnail_GetValue getValue; }; |
Example |
{ WISE_VALUE, //WiseSnail_DataType "Temperature", //name "Cel", //unit 0, //value or string -100, //min 200, //max "ucum.Cel", //resourcetype, optional NULL, //set function NULL //get function } |
Data
Description
The data structure defines your value you want to update in sensor hub. the cliendId and info is for internal used and will be assigned while your callback function(like set) is called. |
struct WiseSnail_Data{ WiseSnail_DataType type; char *name; union { float value; char *string; }; char *clientId; //internal WiseSnail_InfoSpec *info; //internal } |
Example |
{ WISE_VALUE, //WiseSnail_DataType "Temperature", //name 100 //value or string } |
Callbacks
Set Callback |
typedef int (*WiseSnail_SetValue)(WiseSnail_Data *data); |
Get Callback |
typedef int (*WiseSnail_GetValue)(WiseSnail_Data *data); |
Functions
Initial & Uninitial
- WiseSnail_Init
void WiseSnail_Init(char *productionName, char *wanIp, unsigned char *parentMac, WiseSnail_InfoSpec *infospec, int count); |
Parameter | Description |
---|---|
productionName | Name for device. |
wanIp | Ip address. |
parentMac | The mac address of parent device. |
infospec | Optional parameter array. |
count | The size of infospec. |
- WiseSnail_Uninit
void WiseSnail_Uninit(); |
Parameter | Description |
---|---|
None | None |
Register
- WiseSnail_RegisterInterface
void WiseSnail_RegisterInterface(char *ifMac, char *ifName, int ifNumber, WiseSnail_InfoSpec *infospec, int count); |
Parameter | Description |
---|---|
ifMac | The mac address of interface. |
ifName | The name of interface. |
ifNumber | The index number of interface. |
infospec | Interface parameter array. |
count | The size of infospec. |
- WiseSnail_RegisterSensor
void WiseSnail_RegisterSensor(char *deviceMac, char *defaultName, WiseSnail_InfoSpec *infospec, int count); |
Parameter | Description |
---|---|
deviceMac | The mac address of sensor hub. |
defaultName | The default name of sensor hub. |
infospec | Sensor hub parameter array. |
count | The size of infospec. |
Connect
- WiseSnail_Connect
int WiseSnail_Connect(char *server_url, int port, char *username, char *password, WiseSnail_InfoSpec *infospec, int count); |
Parameter | Description |
---|---|
server_url | The address of mqtt broker. |
port | The port of mqtt broker. |
username | The username of mqtt broker.("" for none) |
password | The password of mqtt broker.("" for none) |
infospec | connect parameter array. |
count | The size of infospec. |