Changes between Version 8 and Version 9 of ZigbeeGateway


Ignore:
Timestamp:
Sep 20, 2010, 8:51:49 AM (14 years ago)
Author:
Sensei
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ZigbeeGateway

    v8 v9  
    12121. Through a Zigbee USB dongle attached to the PC. In this case the PC needs to be in the rario coverage of the Zigbee island.
    13132. Through IP connection to an external concentrator. This concentrator is an element that simple translates the Zigbee binary message into IP and transports it using a TCP/IP socket.
    14 [[Image(zb2senseigw_mainsreen.jpg, 50%, center)]]
     14 [[Image(zb2senseigw_connection.JPG, 50%, center)]]
    1515 
    1616
     
    4141The sources are written in C# language. Microsoft Visual Studio 2010.
    4242Open "ZB2SenseiGW.sln" solution and compile the project.
    43 The executable files will be located on ".\bin\release" or ".\bin\debug" (depending on the configuration) directory.
     43The executable files will be located on ".\bin\release" or ".\bin\debug" directory (depending on the configuration).
    4444
    4545== Specification ==
     
    4848
    4949The software engage to the island, discovers nodes, and for each node it discovers sensors and actuators. This software operates under the following Zigbee configuration:
    50 * It has been tested upon Zigbee 2007. Zigbee Pro should work depending on the Zigbee dongle or concentrator
    51 * It is needed to known a priori physical Zigbee parameters
    52        * Frequency channel number (1 to 26)
    53        * Zigbee net password 
     50* It has been tested upon Zigbee 2007. Zigbee Pro should work depending on the Zigbee dongle or concentrator.
     51* It is needed to known a priori physical Zigbee parameters:
     52       * Frequency channel number (11 to 26).
     53       * Zigbee net password.
    5454       * extended PAN Identification helps but not needed.
    55 * Not all the Zigbee profiles are detected. It have been tested under temperature, light, human presence, acceleration sensors and electricity on/off actuator.
    56 
    57 The Gateway has the following features regarding Resource End Point implementation
    58 * Allows **publication** against a Resource Directory
    59 * Allows **getting** data from sensor and **acting** over an actuator using **RESTful** access
     55* Not all the Zigbee profiles are detected. It have been tested under temperature, light, human presence, acceleration sensors, proprietary location sensors and electricity on/off actuator.
     56
     57The Gateway has the following features regarding **Resource End Point implementation**:
     58* Allows **publication** of individual resources (sensors and actuators) against a Resource Directory.
     59* Allows **getting** data from resources and **acting** over them using **RESTful** access.
    6060* Allows **subscription** to resources. Notification can be requested upon one or several of the following conditions:
    61        * Periodic time. If active, it sends a new notification after the period time passes without having sent a notification.
    62        * Value change. If active, it sends a notification when detected that the value has changed
    63        * Threshold. When the value goes beyond a threshold a notification is sent.
    64 * Allows **mobility**. Several gateways can be located in the vicinity and in case the Zigbee island allows nodes to move, both gateway communicates each other to properly handle the mobility.
    65 
    66 In order to not saturate the islands with possible huge requests coming from the internet world, the gateway do not bypass the entire requests to the island. For that reason the gateways stores the last value of the resources in order to respond by itself to requests targeting the same resource that arrives in a short period of time.
    67 
    68 
     61       * **Periodic time**. If active, it sends a new notification after "period time" passes without having sent a notification.
     62       * **Value change**. If active, it sends a notification when detected that the value has changed.
     63       * **Threshold**. When the value goes beyond a threshold a notification is sent.
     64* Allows **mobility**. Several gateways can be located in the vicinity and in the case that the Zigbee island allows nodes to move, both gateways communicate each other to properly handle the mobility.
     65
     66In order to not saturate the islands with possible huge requests coming from the internet world, the gateway do not bypass the entire requests to the island. For that reason the gateways stores the last value of the resources in order to respond by itself to several requests targeting the same resource that arrives at the same time.
    6967
    7068== Configuration ==
     
    7371Remember that these files are read when application starts. If you change a value, it will not be considered after restarting the application.
    7472
    75 It is not needed special editor for changing these files. Whichever text editor used is enough. But special care should be followed for not modifying the overall xml structure, and the rest of the tags. Read this manual before proceed to edit the files.
    76 
    77 Do not worry if you are not familiar with **xml basis**. Look for the target name that follow "//key=//", and you must **edit only** the text between double apostrophes after the "//value=//" text.
     73It is not needed special editor for changing these files. Whichever text editor used is enough. But special care should be followed for not modifying the overall xml structure, and the rest of the tags. Read this section before proceed to edit the files.
     74
     75Do not worry if you are not familiar with **xml basis**. Look for the target name that follow the text "//key=//", and you must **edit only** the text between double apostrophes after the "//value=//" text.
    7876
    7977=== Zb2SenseiGw.exe.config file===
     
    8381* "//off//": do not connect automatically. Manually connection needed after application start. "//autoConnectIndexCh//" value is ignored.
    8482* "//ch//": connect automatically using Zigbee dongle. "//autoConnectIndexCh//" indicates the frequency channel; allowed values are from 11 to 26.
    85 * "//ip//": connect automatically to a //ip// Zigbee gateway. "//autoConnectIndexCh//" indicates the index "**//<netConn>//**" list to be used. The first index is 0.
     83* "//ip//": connect automatically to a //ip// Zigbee concentrator. "//autoConnectIndexCh//" indicates the index of "**//<netConn>//**" list to be used. The first index is 0.
    8684
    8785"**//<netConn>//**" list. It contains a list of ip address that the gateway can connect to an external concentrator. Each element in the list contains:
     
    8987* "//remoteip//": ip adress.
    9088* "//remoteport//": remote server tcp port.
    91 * "//localport//": local server tcp port to be used when connected. Used for receiving responses. Beware not to use local ports used by other software in the computer.
     89* "//localport//": local server tcp port to be used when connected. Used for receiving responses. Beware not to choose local ports used by other software in the computer.
    9290
    9391"**//netPassword//**": Zigbee net key in hexadecimal format. Leave empty if this security options is not used.
    9492
    95 "**//netExtPANid//**": target Zigbee extended PAN identifier in hexadecimal format: leave empty for any (example: "//20DB765432144010//").
     93"**//netExtPANid//**": target Zigbee extended PAN identifier in hexadecimal format: leave empty for any. (example: "//20DB765432144010//").
    9694
    9795"**//Sensei_RPI_ProxiHost//**","**//Sensei_RPI_ProxiPort//**","**//Sensei_RPI_ProxiBypass//**": If proxy is used for accessing internet both for publication and notification, proper configuration is needed here. If not, leave empty. Insert Host as name or IP address, TCP port to be used and bypass contains local IP address ranges that do not use the proxy, as for example "//192.168.0.0/192.168.255.255//"
    9896
    99 "**//Sensei_RAI_BaseURL//**": Base URL for the SENSEI RAI Resource Access Interface server. For example "//http://myIP:8081/sensei/rai/resources/ //". If empty, the application will not implement the RAI server. It is mandatory to include the port event if the default port is used. It is also mandatory to end in "/". "//myIP//" text will be replaced by first real computer IP address. If the computer has several IP address and you want to use another, put it explicitly. Each resource is acceded throw BaseURL/ //nodeID/[s or a]/number // (see [RaiInterface RAI Interface] for more details).
    100 
    101 "**//Sensei_RPI_URL//**": SENSEI Target Resource Directory URL for Publishing. Leave Empty for not publishing resources into Resource Directory. End with "/". Application will add "rpi", "rli" or "rd" suffix when needed. For example "//http://sensei-dev1.grid.pub.ro:8184/ //".
    102 
    103 "**//Sensei_RPI_RAIBaseURL//**": URL published in "<Rai-Description> <REP-Locator>" into Resource Directory for each resource.  If empty it will take Sensei_RAI_BaseURL, but it can be different if needed for example if the gateway access through a proxy or a router that changes the local IP into a public IP. End with "/". Application will append "//nodeID/[s or a]/number//" to this URL. "//myIP//" text will be replaced by first real computer IP address.
    104 
    105 "**//Sensei_RPI_ExpirationTime//**": Expiration date for each resource published into the Resource Directory, in hours from first publication. If empty, one week will apply.
     97"**//Sensei_RAI_BaseURL//**": Base URL for the SENSEI RAI Resource Access Interface server. For example "//http://myIP:8081/sensei/rai/resources/ //". If empty, the application will not implement the RAI server. It is mandatory to include the port event if the default port is used. It is also mandatory to end in "/". The text "//myIP//" will be replaced by first computer IP address. If the computer has several IP addresses and you want to use another, put it explicitly instead of "//myIP//". Each resource is acceded through **BaseURL/ //nodeID/[s or a]/number//** (see [#RAIinterface RAI Interface] for more details).
     98
     99"**//Sensei_RPI_RAIBaseURL//**": Base URL that will contain the "<Rai-Description> <REP-Locator>" tag when a resource is published in the Resource Directory.  If empty it will take previous //Sensei_RAI_BaseURL// variable, but it can be different. It is needed for example if the gateway access through a proxy or a router that changes the local IP (used when mounting an http RAI server) into a public IP (that is the IP seen from outside). Same rules as before apply: End with "/", application will append "//nodeID/[s or a]/number//" to this URL; and "//myIP//" text will be replaced by first computer IP address.
     100
     101"**//Sensei_RPI_URL//**": Target SENSEI Resource Directory URL for publishing. Leave Empty for not publishing resources into Resource Directory. End always with "/". Application will add "rpi", "rli" or "rd" suffix when needed. For example "//http://sensei-dev1.grid.pub.ro:8184/ //".
     102
     103"**//Sensei_RPI_ExpirationTime//**": Expiration time for each resource published into the Resource Directory, in hours from first publication. If empty, one week will apply.
    106104
    107105"**//ZB2SenseiGw_Password//**": This is used in case of mobility. It contains a text password that is needed to provide credentials between gateways. The gateways that take part in the mobility of a node need to have the same password.
    108106
     107For a dongle connection, "**//timeWaitNodes//**" is the timeout in milliseconds of a node response, adjust to the maximum node latency in the net. "**//timeLinkedGateway//**" is the timeout in milliseconds while linking to the net. "**//timeExecuteOrder//**" is the timeout of a dongle response.
     108
     109For a external concentrator connection "**//timeSleepNodes//**", "**//timeConnection//**" and "**//timeReadMessages//**" respectively have the same meaning as before.
     110
     111"**// Retries //**": Number of retries that will be done when a Zigbee node does not respond before discarding this node.
     112
    109113=== rpi.xml file===
    110 The **// rpi.xml //** file indicates what exactly format should be sent to the resource directory for publishing a resource. In that way format can be completely changed for new versions without the need of compilation.
    111 
    112 In addition "**// rpi.xml //**" is a generic file for all the resources, but you can specify individual files for each resource. Simple insert a file with the same structure in the package directory and with the name equals to "//**nodeID**s**number.xml**//" for a sensor or "//**nodeID**a**number**.xml//" for an actuator. Where "//**nodeID**//" is the node MAC address in hexadecimal format, (16 characters), and "//**number**//" is the index of the sensor or actuator starting by 0. If an individual file is present it will be considered, if not, the generic one is considered.
    113 
    114 The "**//*.xml //**" file can include the following text variables that will be replaced with the proper values by the application (case sensitive):
     114The **// rpi.xml //** file contains the xml text that will be sent to the Resource Directory when publishing a resource. In that way format can be completely changed for new versions without the need of compilation.
     115
     116In addition "**// rpi.xml //**" is a generic file for all the resources, but you can specify individual files for each resource. This can be done by inserting just a text file with the same structure in the package directory and with the name equals to (without blanks) "//**nodeID X number . xml**//", where:
     117* "//**nodeID**//" is the node MAC address in hexadecimal format, (exactly 16 characters).
     118* replace "//**X**//" with "s" for a sensor or "a" for an actuator.
     119* "//**number**//" is the index of the sensor or actuator starting by 0.
     120 If an individual file is presented it will be considered, if not the generic "rpi.xml" file is considered.
     121
     122In the "**//*.xml //**" file the following text variables will be replaced with the proper values by the application (case sensitive):
    115123* "//**_ResT**//": name of the resource, for example temperature, light, etc.
    116124* "//**_NODE**//": node id, that is, the MAC address in hexadecimal format with capital letters (16 characters).
     
    120128* "//**_TYPE**//": will be replaced by "actuator" for an actuator or "sensor" for a sensor.
    121129* "//**_TIME**//": expiration time contained in the "//Sensei_RPI_ExpirationTime//" variable of the "//Zb2SenseiGw.exe.config//" file.
    122 * "//**_ RAI**//": value of the "// Sensei_RPI_URL //" variable of the "//Zb2SenseiGw.exe.config//" file.
     130* "//**_ RAI**//": value of the "//Sensei_RPI_RAIBaseURL//" variable of the "//Zb2SenseiGw.exe.config//" file.
    123131
    124132== User manual ==
    125133
    126134Figure shows the main screen of the application.
    127 [[Image(zb2senseigw_connection.JPG, 50%, center)]]
    128  On the upper side, appears the type of connection to the Zigbee island. The "**USB**" is through a dongle and the "**IP**" through an external concentrator. The "**IP/Ch**" select box contains the Zigbee channel for USB or the connection name (see [#Configuration <netConn> idNet in Configuration]) for IP. The button "**Connect**" and "**Disconnect**" allows to attach or detach to the Zigbee island.
     135[[Image(zb2senseigw_mainsreen.jpg, 50%, center)]]
     136 
     137
     138On the upper side, appears the type of connection to the Zigbee island. The "**USB**" is through a dongle and the "**IP**" through an external concentrator. The "**IP/Ch**" select box contains the Zigbee channel for USB or the connection name (see [#Zb2SenseiGw.exe.config <netConn> idNet in Configuration]) for IP. The button "**Connect**" and "**Disconnect**" starts the attaching or detaching to the Zigbee island.
    129139
    130140The connection process takes a while, firtsly it engages in the Zigbee island. Secondly it discovers the nodes and resources. The node list appears on the "**Tree of nodes**" tree box.
     
    139149For every sensor, actuator or counter (sensor) additional details are shown in the corresponding tags on the "**Node Description**"
    140150
    141 The upper side tags are used for debugging. It contains traces about orders receives from SENSEI, events receives from WS&AN, and commands that can be raised manually to the island.
     151The upper side tags are used for debugging. It contains **commands** that can be raised manually to the island for testing purposes, **events** receives from WS&AN, and traces of **orders** receives from SENSEI.
    142152
    143153== Troubleshooting ==
    144 **Appears the message error //"Error while connecting to Zigbee dongle"//:** Ensure that a zigbee dongle is properly inserted in the PC. Ensure that no other application is using the dongle. Remove and insert again.
     154**It appears the error message: //"Error while connecting to Zigbee dongle"//:** Ensure that a zigbee dongle is properly inserted in the PC. Ensure that no other application is using the dongle. Remove and insert it again.
    145155
    146156**The gateway do not connect to the Zigbee net:** Ensure that you have enter right extender PAN id, password, and channel frequency.
    147157
    148 **Not all the resources appear in the "tree list":** Ensure you have properly dimensioned the timeout variables in the configuration file according with the nodes latency. It can also happen that nodes have profiles or attributes not recognize by this version of application.
    149 
    150 **No publish the resources in the Resource Directory:** Ensure the proxy variables are properly adjusted depending on your internet connection, and the resource directory URL is properly adjusted.
     158**Not all the resources appear in the "tree list":** Ensure you have properly dimensioned the timeout variables in the configuration file according with the nodes latency. It can also happen that nodes have profiles or attributes not recognize by this version of the application.
     159
     160**It does not publish the resources in the Resource Directory:** Ensure the proxy variables are properly adjusted depending on your internet connection, and the resource directory URL is properly filled in the configuration file.
    151161
    152162== Mobility ==
    153 Zigbee gateway resolves the mobility of a node between several gateways. In the case of Zigbee there is no possibility of storing information in nodes that helps to the mobility. So gateways need to resolve the problem by themselves.
    154 Figure shows how mobility is resolved by Zigbee gateways.
     163Zigbee gateway resolves the mobility of a node between several gateways. In the case of Zigbee there is no possibility of storing information inside nodes that helps to the mobility. So gateways need to resolve the problem by themselves.
     164Figure shows how mobility is treated by Zigbee gateways.
     165
    155166[[Image(zb2senseigw_mobility.jpg, 25%, center)]]
    156167
     
    158169
    159170
    160 1. (and 4.) Resource identification formed by the gateway is always the same independently of the gateway. The identification depends only on node parameters. In our case it is used the MAC address and the sensor number position. When the node connects to a new island, the gateway forms the Resource End Point of the nodes resources.
    161 2. (and 5.) Previously to publish in the Resource Directory, it discovers if the resource already is present using RLI interface.
    162 3. If the resource does not exist, it is published into the Resource Directory  …
    163 4. see 1
    164 5. see 2
    165 6. But if it exists, it is updated. No replication of the same resource is found in the Resource Directory.
    166 7. The new gateway informs the old gateway about the new location (URL) of the resource. The URL of the old gateway is obtained when getting resource parameters from the Resource Directory (5.) In the response, the old gateway sends all the subscriptions information that this resource has, and these are implemented by the new gateway.
     1711. (and 4.) **Resource identification** formed by the gateway is **always the same** independently of the gateway. The identification depends only on node parameters. In our case it is used the MAC address and the sensor number position. When the node connects to a new island, the gateway forms the Resource End Point of the nodes resources.
     1722. (and 5.) Previously to publish in the Resource Directory, it discovers if the resource is already present using the RLI interface.
     1733. If the resource does not exist, it is published into the Resource Directory.
     1744. Node moves to gateway B. See 1
     1755. See 2
     1766. But if the resource exists in the Resource Directory, it is updated. No replication of the same resource can be found in the Resource Directory.
     1777. The new gateway informs the old gateway about the new location (URL) of the resource. The URL of the old gateway is obtained when consulting the Resource Directory (5.) In the response, the old gateway sends all the subscriptions information that this resource has, and these are implemented by the new gateway.
    1671788. The old gateway in addition will redirect whatever access to this resource to the new URL using the http redirect response. This redirection is transparent to applications.
    168179The result is that applications do not notice at all (if they do not want) that a resource has been moved.
    169180
    170 For optimization, mobility commands interchanged between gateways are not sent resource by resource, but only once for all the resources of a node.
     181For optimization, mobility commands interchanged between gateways are not sent at a resource basis, but only once for all the resources of a node.
    171182=== Mobility format interchanged between gateways===
    172 The new gateway informs the all gateway with a PUT http method addressing node id (not resource id) with the following xml content
     183The new gateway informs about node mobility to the old gateway with a PUT http method addressing the node id (not resource id) with the following xml content:
    173184{{{
    174185<Mobility>
    175186        <newREP-Locator> newURL </newREP-Locator>
    176187        <Credentials>
    177                 <URL ZB2SENSEI_PASSWD> password </URL ZB2SENSEI_PASSWD>
     188                < ZB2SENSEI_PASSWD> password </ZB2SENSEI_PASSWD>
    178189        </Credentials>
    179190</Mobility>
     
    191202                <Subscription>
    192203        </SubscriptionInfo>
     204        <SubscriptionInfo sensor="1">
     205                         …
     206        </SubscriptionInfo>
    193207        <SubscriptionInfo actuator="0">
    194208                <Subscription>
     
    201215
    202216== RAI interface ==
    203 This Gateway uses a REST interface for iterate with the Zigbee island. This interface is defined here (**PUT LINK** to the xml specification).
    204 Each resource has its one URL, which format is "//**BASE_URL/nodeMAC/X/number**//"
     217This Gateway creates a REST interface for allowing applications to iterate with the Zigbee island. This interface is defined here (**PUT LINK to the xml specification**).
     218Each resource has its one URL, with the following format: "//**BASE_URL/nodeMAC/X/number**//"
    205219* //nodeMAC// is the node MAC address in hexadecimal capital letters (16 characters).
    206220* //X// is the letter "s" for a sensor or "a" for an actuator.
    207221* //number// is the number of sensor or actuator, starting with "0".
    208222
    209 Over this URL the following operations can be done:
    210 GET http method is used for getting a sensor or actuator value
    211 PUT http method is used for changing a value; logically it works only in actuators.
     223Over this resource URL the following operations can be done:
     224* GET http method is used for getting a "xml" with the sensor or actuator value.
     225* PUT http method is used for changing a value, a parameter, or acting over an actuator.
    212226
    213227=== Subscriptions ===
    214 A POST http method over the resource URL is used for adding a new subscription. In this case it should be add at the end of the resource URL the subscription identity: 
    215 "//**BASE_URL/nodeMAC/X/number/SubscriptionID**//"
    216 * SubscriptionID is whatever text allowed in the URL names. The xml format for a subscription is **PUT A LINK TO XML SUBSCRIPTION FORMAT**
    217 
    218 A PUT http method over this subscription URL is used for modify it.
    219 A GET http method over this subscription URL returns the subscription xml information.
    220 A DELETE http method over this subscription URL is used for deleting it.
    221 A POST http method over this subscription URL returns an error.
    222 
    223 GET over "//**BASE_URL/nodeMAC/X/number?Subscription**//" for getting the list of subscriptions of a resource.
    224 GET over "//**BASE_URL/nodeMAC **//" returns an html page with node information, sensors and actuators, and links for the subscriptions. Ideally for a browser
    225 
    226 
    227 
    228 
    229 
    230 
     228A POST http method over the resource URL is used for adding a new subscription. In this the URL must contain at the end of the resource URL the subscription identity: 
     229"//**BASE_URL/nodeMAC/X/number/SubscriptionID**//". //"SubscriptionID"// is whatever text allowed in the URL names. The xml format for a subscription request is **PUT A LINK TO XML SUBSCRIPTION FORMAT**.
     230* A PUT http method over this subscription URL is used for modifying it.
     231* A GET http method over this subscription URL returns the subscription xml information.
     232* A DELETE http method over this subscription URL is used for deleting it.
     233* A POST http method over this subscription URL returns an error if it exist or add a new subscription if it does not exist.
     234
     235GET over "//BASE_URL/nodeMAC/X/number**?Subscription**//" can be used for getting the list of subscriptions of a resource.
     236
     237GET over "//**BASE_URL/nodeMAC **//" returns an html page with node information, sensors and actuators, and links for the subscriptions.
     238
     239