[zb4osgi-changeset] [scm] ZigBee 4 OSGi repository change: r597 - in /projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL: ./ curl-7.27.0/ curl/ iniparser/src/ libupnp-1.6.15/ libupnp/ linuxgal/ zigbee/src/

scm-notify at zb4osgi.aaloa.org scm-notify at zb4osgi.aaloa.org
Thu Jan 10 10:57:04 CET 2013


Author: andrea.ranalli
Date: Thu Jan 10 10:57:04 2013
New Revision: 597

Log:
GAL's updates:
- Updated the README file merging the previous .txt and .rtf into a unique document 8thanks Christopher for the precious suggestion provided to update this file)
- renamed some internal subfolder to avoid further editing of the main Makefile file
- updated different files in zigbee and linuxgal folders
- updated the iniparser to the 3.1 release

Added:
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/README
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/curl/
      - copied from r534, projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/curl-7.27.0/
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/iniparser/src/
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/iniparser/src/dictionary.h
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/iniparser/src/iniparser.h
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/libupnp/
      - copied from r534, projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/libupnp-1.6.15/
Removed:
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/curl-7.27.0/
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/libupnp-1.6.15/
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/readme.rtf
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/readme.txt
Modified:
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/Makefile
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/Notice.license
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CDiscoveryAgent.cpp
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CHTTPClient.cpp
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CHTTPClient.h
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CLocalNode.cpp
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CRESTBroker.cpp
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CRESTClient.cpp
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CRESTServer.cpp
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CServiceAgent.cpp
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/GalZbIf.cpp
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/ZbNetDb.cpp
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/config.ini
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/configure.ac
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/freescale_if.c
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/freescale_ser.c
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/zb_conn.c
    projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/zigbee.cpp

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/Makefile
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/Makefile (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/Makefile Thu Jan 10 10:57:04 2013
@@ -1,25 +1,22 @@
 include Makefile.rules
 
-SUBDIRS = libupnp-1.6.15
+SUBDIRS = libupnp
 SUBDIRS += iniparser
 SUBDIRS += shttpd
 SUBDIRS += zigbee
 SUBDIRS += tinyxml
-#ifneq ($(strip $(TARGET_PLATFORM)),cygwin)
-#SUBDIRS += curl
-SUBDIRS += curl-7.27.0
-#endif
+SUBDIRS += curl
 SUBDIRS += linuxgal
 
 #export EMBER_STACK_PROFILE=1
 
 SUBDIRS_ALL = \
-	libupnp-1.6.15 \
+	libupnp \
 	iniparser \
 	zigbee \
 	tinyxml \
 	shttpd \
-	curl-7.27.0 \
+	curl \
 	linuxgal
 
 all:

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/Notice.license
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/Notice.license (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/Notice.license Thu Jan 10 10:57:04 2013
@@ -6,9 +6,9 @@
 This software does use open source software developed by 3rd parties:
 -	libupnp (current release 1.6.15). This product uses software downloaded at Sourceforge (http://sourceforge.net/projects/pupnp/files/pupnp/libUPnP%201.6.15/libupnp-1.6.15.tar.bz2/download)licensed under the BSD License.
 -	curl (current release 7.27.0). This product uses software developed Sourceforge (http://curl.haxx.se/download/curl-7.27.0.tar.gz) licensed under the MIT License.
--	Shttpd (release 1.42) This product uses software developed Sourceforge (http://sourceforge.net/projects/shttpd/files/shttpd/1.42/shttpd-1.42.tar.gz/download ) licensed under the Public Domain License. This project has been ported to a new project called mongoose (current release 3.1), licensed under the MIT License (but not used by GAL)
+-	shttpd (release 1.42) This product uses software developed Sourceforge (http://sourceforge.net/projects/shttpd/files/shttpd/1.42/shttpd-1.42.tar.gz/download ) licensed under the Public Domain License. This project has been ported to a new project called mongoose (current release 3.1), licensed under the MIT License (but not used by GAL)
 -	tinyxml (release 2.5.3). This product uses software developed at Sourceforge (http://sourceforge.net/projects/tinyxml/files/tinyxml/2.5.3/tinyxml_2_5_3.tar.gz/download) licensed under the zlib/libpng License.
-
+-	iniparser (release 3.1). This product uses software developed and licensed under the MIT License, freely downloadable at http://ndevilla.free.fr/iniparser/iniparser-3.1.tar.gz
 
 
 II. Specification used

Added: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/README
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/README (added)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/README Thu Jan 10 10:57:04 2013
@@ -1,0 +1,295 @@
+Gateway Abstraction Layer (GAL) - A standard ZigBee Gateway Device implementation
+Copyright 2008-2013 TELECOM ITALIA S.p.A. - http://www.telecomitalia.it
+Part of this computer programs(s) may be used, reproduced, stored in any retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, under the Apache License 2.0 with the implicit approval of TELECOM ITALIA.
+ 
+*****************************
+***** I - Introduction ******
+*****************************
+
+This software is called Gateway Abstraction Layer (GAL), and it implements a standard ZigBee Gateway Device. It is released by TELECOM ITALIA S.p.A. (www.telecomitalia.it) and the code may be used, reproduced, stored in any retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, under the Apache License 2.0 with the implicit approval of TELECOM ITALIA.
+
+The software uses the following open source software developed by 3rd parties:
+- libupnp (current release 1.6.15). This product uses software downloaded at Sourceforge (http://sourceforge.net/projects/pupnp/files/pupnp/libUPnP%201.6.15/libupnp-1.6.15.tar.bz2/download ) licensed under the BSD License.
+- curl (current release 7.27.0). This product uses software developed Sourceforge (http://curl.haxx.se/download/curl-7.27.0.tar.gz) licensed under the MIT License.
+- shttpd (release 1.42) This product uses software developed Sourceforge (http://sourceforge.net/projects/shttpd/files/shttpd/1.42/shttpd-1.42.tar.gz/download ) licensed under the Public Domain License. This project has been ported to a new project called mongoose (current release 3.1), licensed under the MIT License (but not used by GAL at the moment)
+- tinyxml (release 2.5.3). This product uses software developed at Sourceforge (http://sourceforge.net/projects/tinyxml/files/tinyxml/2.5.3/tinyxml_2_5_3.tar.gz/download )licensed under the zlib/libpng License.
+-	iniparser (release 3.1). This product uses software developed and licensed under the MIT License, freely downloadable at http://ndevilla.free.fr/iniparser/iniparser-3.1.tar.gz
+
+Also, part of this software is based on the specification provided by the ZigBee Alliance (http://www.zigbee.org), licensed under ZigBee specific license for non-member of the ZigBee Alliance.
+
+License Summary:
+	- Apache License 2.0
+	- ZigBee Non-Member License
+
+	
+*****************************
+***** II - References *******
+*****************************
+
+For any information related on the usage and the installation of this code please contact Andrea Ranalli (andrea.ranalli at telecomitalia.it) or Nicola Portinaro (nicola.portinaro at telecomitalia.it).
+
+
+*****************************
+*** III - Installation ******
+*****************************
+
+This short guide will describes how to configure the environment in order to use the GAL using a cygwin environment. However, any other Unix-based system can be used (clearly some steps shall be skipped or slightly edited to fit the target operating system).
+
+----- Downloading phase -----
+
+1) Please download the latest version of cygwin from www.cygwin.com, the install it by including all the following packages (please note that the releases are based on Cygwin DLL 1.7.7-1, but more update versions could be available):
+
+automake wrapper (4-10) and 1.11.1-1
+autoconf wrapper (10-1) and 2.68-1
+gcc-g++ 3.4.4-999
+openssl-devel 0.8.8r-1
+libcurl-dlevel 7.19.6-1
+[all their dependencies]
+
+Note: “libcurl-dlevel 7.19.6-1”  could be avoid to be installed if we decide to configure and use the local folder 'curl' (it is recommented to use the local folder for linux O.S.)
+
+2) Download the latest release of GAL from the repository (https://svn.aaloa.org/projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL is the currently path available but this could be changed in the future) and copy the whole folder into cygwin's user home folder (or wherever you like).
+
+3) Download the open source software developed by 3rd parties companies:
+- libupnp-1.6.15	- http://sourceforge.net/projects/pupnp/files/pupnp/libUPnP%201.6.15/libupnp-1.6.15.tar.bz2/download
+- curl-7.27.0 		- http://curl.haxx.se/download/curl-7.27.0.tar.gz
+- shttpd-1.42 		- http://sourceforge.net/projects/shttpd/files/shttpd/1.42/shttpd-1.42.tar.gz/download
+- tinyxml-2.5.3 	- http://sourceforge.net/projects/tinyxml/files/tinyxml/2.5.3/tinyxml_2_5_3.tar.gz/download
+- iniparser-3.1 	- http://ndevilla.free.fr/iniparser/iniparser-3.1.tar.gz
+
+4) Unpack each of the above files and put them into GAL's subfolders, according to their name. Please be aware to maintain the Makefile.cross file present in each of those subfolders. Also, just for the iniparser, be aware that the files dictionary.h and iniparser.h has been changed to support the cross compilation for the C++ environment. In particular, the following lines has been added at the beginning and at the end of each file:
+
+	#ifdef __cplusplus
+	extern "C" {
+	#endif
+
+	#ifdef __cplusplus
+	}
+	#endif
+
+----- Automatic installation -----
+
+If you're lucky enough and if all the files have been properly downloaded and put in the right folders, starting from the gal root directory and typing the following commands should be enough:
+. setup.bash
+gal_cygwin			//here "gal_something" could be typed, depending on your O.S. (please verify it inside the setup.bash file) 
+cd linuxgal
+make -f Makefile.cross genmake
+cd ..
+make all
+
+The output generated by the previous commands is the gal file, present in linuxgal for debugging, and another gal present in [...]/fs/usr/ti/bin, that has been stripped and that shall be used as executable file for a trial. The macro called 'galfs' brings you where the files has been installed:
+bin -> exe gal
+lib -> librerie
+etc -> config.ini
+
+Please note that:
+- In zigbee/Makefile.cross, the user could set the EMBER_STACK_PROFILE according to the ZigBee or ZigBeePRO stack required
+- To enable/disable the debug, go to linuxgal/Makefile.cross and add/remove the following line in the "config" section:
+
+	--enable-debug \		--with-debug-flags=RB:SB:DA:MESSAGE:SA:RESTSERVER:XMLMSGCOMPOSER:GALZB:XMLMSGPARSER
+
+----- Manual installation -----
+
+If this is the first time that the GAL has been downloaded, it shall be compiled all the following packages:
+	- go to "libupnp" folder and run "make clean" and "make"
+	- go to "initparser" folder and run "make clean" and "make"
+	- go to "\http\shttpd\src" folder and run "make" (for cygwin type "SSL_VER=0.9.8 make cygwin")
+	- go to "tinyxml\src" folder and run "make clean" and "make"
+
+Once those steps are accomplished, you're ready to compile the GAL, focusing on the two main folder, "linuxgal" and "zigbee".
+	- linuxgal contains all the main files responsible to compile and execute the gal
+	- zigbee contains all the file needed to setup the ZigBee or ZigBeePRO stack
+
+A list of the command that shall be execute is reported below:
+
+export EMBER_STACK_PROFILE=1		//CHOOSE THE EMBER STACK PROFILE: 1=ZigBee or 2=ZigBeePRO
+cd zigbee/
+make clean
+make
+cd ..
+cd linuxgal
+make clean
+aclocal
+autoheader
+automake -a
+autoconf
+./configure --enable-zigbee-pro --with-local-libs=.. --with-upnp-cflags=-I/usr/local/include/upnp --with-upnp-libs=/usr/local/lib OR
+./configure --enable-zigbee-pro --with-local-libs=.. --with-upnp-cflags=-I/usr/local/include/upnp --with-upnp-libs=/usr/local/lib --enable-debug --with-debug-flags=RB:SB:DA:MESSAGE:SA:RESTSERVER:XMLMSGCOMPOSER:GALZB:XMLMSGPARSER
+make
+
+
+----- Typical errors -----
+
+Some useful commands that could be used to solve some initial problems are:
+make distclean		- It will clean everything and force the execution of configure scripts when 'make all' is issued again
+ldd gal.exe			- This is useful to figure out which dll are needed to let the gal work properly and what is still missing
+make -f Makefile.cross clean all install	- Command needs to compile after modifies made in "linuxgal" or "zigBee" folders
+
+If some error occurs in "make config" or "make all", this is probably due to the fact that the curl library are not found yet by the GAL (that means they're not compiled yet). To fix this problem, launch again "make config" and "make all" and this second time it should work (alternatively run "make -f Makefile.cross all install" in linuxgal).
+
+The most typical error that a user could encounter is the wrong path for the upnp library so it must be checked first if this library is installed correctly and where it has been placed. Under the linux O.S., for example, a valid path that could be used is:
+./configure --enable-zigbee-pro --with-local-libs=.. --with-upnp-cflags=-I/usr/include/upnp --with-upnp-libs=/usr/lib
+This one will fix issues relater to the wrong position of the upnp library
+Another typical problem is related to the curl library, and for this case a useful path could be:
+./configure --enable-zigbee-pro --with-local-libs=../libs --with-upnp-cflags=-I/usr/include/upnp --with-curl-cflags=-I/usr/include/curl --with-curl-libs=/usr/lib  --enable-debug
+Also, if not present, the file libcurl.so under /usr/lib shall be created using a soft link (ln -s libcurl.so.4 libcurl.so)
+
+Finally, when the gal is executed it needs to know the correct path for the upnp library. Two alternative ways to reach this goal are:
+  a) use the export command: export LD_LIBRARY_PATH=[...]/trunk/targets/freescale/fs/usr/ti/lib  (use the "pwd" command to find the right path...)
+  b) copy the whole content of [...]/trunk/targets/freescale/fs/usr/ti/lib  in /usr/lib
+
+
+*****************************
+******* IV - Usage **********
+*****************************
+
+The easiest way to run a GAL is by tipying the following path:
+gal.exe -s on -c config.ini 'zigbee:///dev/com9?dongle=ezsp'
+where:
+	- gal.exe is the result of the previous step (the compiling phase)
+	- config.ini is the file containing precious information regarding the configuration of the ZigBee network (like channel, panId, extendedPanID, security, etc...)
+	- 'zigbee:///dev/com9?dongle=ezsp' specify at which port your dondle is installed and that you're using a Ember firmware (called EZSP: Ember ZigBee Serial Protocol)
+
+For the Linux OS the Teleesis dongle could be found using the path 'zigbee:///dev/ttyUSB0?dongle=ezsp'.
+To run a Freescale dongle type ./gal -c config.ini 'zigbee:///dev/ttyUSB0?dongle=freescale'
+To run the GAL using the MicroSD type instead ./gal -c config.ini "zigbee:///dev/com8?dongle=microSD&speed=115200"
+
+
+*****************************
+*** V - Stack firmware ******
+*****************************
+
+Depending on the dongle used, there are different firmware that could be used. In this short tutorial we will describe only where to find the firmware for the Ember/SiliconLabs and Freescale dongles. Other stack vendors are supported as well, but they have not been updated since a while.
+
+a) Freescale
+Freescale released a software called BeeStack, that can be defined as a firmware specifically released for ZigBee dongles.
+First of all it is recommended to download the latest driver of the USB dongle from http://www.ftdichip.com/Drivers/VCP.htm, and then download the Test Tool software (currently at the revision 12) from Freescale’s website). This latter tool will allow the user to test single API and to eventually load a firmware (later on it will be introduced a tool, FlexLoader, released by the company CEDACa gateway/module manufaturer , that will do this job). 
+The first thing to do is to open Test Tool, then go to "Communication setting" -> "Add Internal" and specify the COM assigned to the dongle by Windows . Then we shall check at which baud rate the firmware works (generally 115.200), select the correct value and inserting a Length equals to 1. Finally we can connect to the dongle using "View" -> "Command Console". To verify that everything works, we could create for example a ZigBee network inserting those 4 commands:
+•	ZTC-CPU_Reset.Request (optional)
+•	ZTC-ModeSelect.Request
+•	ZTC-WriteExtAddr.Request
+•	ZTC-StartNwkEx.Request
+All those commands generate a log with useful “Tx” and “Rx” line that can help us to log and debug what is happening. 
+Another important file to get is the official documentation, present in one of the folder of Test Tool, where the developer can get a manual reference that explains how to use the APIs.
+
+To install a new firmware, we need to request to Freescale an updated binary file, since they are periodically update based on different Telecom Italia’s requirement, or just due to bug fixing. However, it is possible that, especially at the beginning, Telecom Italia (or the company CEDAC) will provide that firmware that is typically labeled as “BlackBox_combo_StdSecLinkKey_20120914.bin”. To update a new firmware the tool “FlexLoader” previously just cited needs to be downloaded from CEDACthe hardware manufacturer of the gateway (e.g. CEDAC/FlexGrid). The usage of this tool is quite simple, and here we report some cases:
+•	To flash from zero and with a new MacAddress:
+FlexLoader.exe -brd key -prot hw -mac 00:11:22:33:44:55:66:77 myFile.bin
+•	To flash a new firmware but maintain the previous Mac Address just launch
+FlexLoader -brd key -prot ztctlc my_binary.bin
+•	Finally, if we want to maintain the MacAddress but we want to erase the NotVolatileMemory:
+FlexLoader -brd key -prot ztctlc -nvm erase my_binary.bin
+
+b) Ember/Silicon Labs (EZSP)
+The Ember Company has been recently acquired by Silicon Labs and thus wherever in this document the word “Ember” is found, a probable translation to the new company could be applied. Once registered to the Ember’s support web site, it is possible to download the latest release of the EM260 firmware. In particular, we are looking for the file named “em260-uart-rts-cts-with-serial-bootloader.hex”, present in the subdirectory \em260\build\em260-images of the “Ember-stack-Z3.4.x.x-em260-dev.exe” setup file .
+Finally, we are able to install the EZSP (Ember ZigBee Serial Protocol) firmware into a Telegesis dongle:
+1.	Get a Telegesis dongle and connect its SIF port to the Ember Breakout board
+2.	Open "InSight Desktop" tool (another tool that you can download from the Ember website) and upload the selected hex file and leave unchecked the option “Include bootloader image in upload”
+3.	Set the correct baud rate by open a DOS windows, go to C:\Program Files\Ember\xIDE_EM250\SIF\bin, and launch the following two commands:
+em2xx_patch -sid 192.168.1.10 -Override -Mfg @0080=0x0008 (0x0008 means 19.2kbps)
+em2xx_read -sid 192.168.1.10 -Mfg 0x80 (use to verify that the token has been correctly written)
+where the appropriate speed can be choose selecting one of the following values:
+Value 	Speed (kbps)
+0x0008	19.2
+0x000A	38.4
+0x000C	57.6
+0x000F	115.2
+0x0010	230.4
+
+Please note that the "sid" option is the IP Address where the Ember Breakout board is located. To find out this parameter go to Insight Desktop and then locate the field "IP address" under the breakout board selected to do this job. Alternatively, it is easier to buy an Insight USB Link and use the following commands:
+cd "C:\Program Files\Ember\InSight USB Link"
+EM2USBLoad.exe -Run -Override em260-uart-xon-xoff-with-serial-bootloader.hex
+EM2USBPatch.exe -Override -Mfg @0080=0x000F
+EM2USBRead.exe -Mfg 0x80
+
+*****************************
+***** VI - Config.ini *******
+*****************************
+
+The current Telecom Italia’s gateway (GAL) has a useful configuration file (config.ini) which is quite important to allow the user/administrator to configure ad hoc settings before to start the gateway . In order to simplify the understanding and settings of all those variables, we will report a description for each of those parameters, followed by an important section that describes in more details what that variable stand for and how/why/if implement it.
+
+---------------------------------------------------------
+Variable	-	Description		-	Implementation status
+---------------------------------------------------------
+Platform	Hardware platform desired: integration (0), zsdio/EZSP/Freescale/MicroSD (1)	Since the gateway shall support different stack vendors, a variable is probably needed to do some specific calls due to the different internal architectures. Clearly this is a development-specific variable so it could be not inserted.
+---------------------------------------------------------
+autostart	Autostart the ZigBee network: 0 to disable (it will wait for a StartGatewayDevice command), 1 to enabled	This in an important variable useful to automatically call the StartGatewayDevice procedure using the default parameters stored in the configuration file, enabling the gateway to startup without wait any external interaction.
+---------------------------------------------------------
+startupMode	Three possible scenario to startup the network:
+#0 - StartupSetMode=0x18 (CommissioningMode) AND StartupControlMode=0x00 (Association) --> To be used the first time, when the network is created
+#1 - StartupSetMode=0x00 (use NVM) AND StartupControlMode=0x04 (SilentStart) --> To be used at running time
+#2 - StartupSetMode=0x18 (CommissioningMode) AND StartupControlMode=0x04 (SilentStart) --> To be used for TC Replacement	Depending of the stack vendor that will be supported, specific startup settings could be necessary: the user/administrator of the gateway shall have the possibility to decide if startup the network using a brand new ZigBee setting (commissioning mode) or if recycle an existing setting. This second part could differs from the current GAL and thus it shall be considered with attention: all the main ZigBee setting like channel radio, extendedPANId, PANId, DeviceType, etc
 shall we stored in a configuration file together with an image file of the current status of the stack vendor’s memory. It shall thus be possible to reused any time a configuration before a crash, using a Not-Volatile-Memory (NVM) if it is supported by the stack, or by “flashing” those setting in a way that the node does not start a new network.
+---------------------------------------------------------
+localRegToDAnnce
+	Enable a local registration to device announcement events (1 to enable, 0 to disable)
+	The new gateway shall have this requirements always enabled so this variable can be eliminated. The target here is to be sure that any time a new node joins the network, an announcement event shall be generated to inform the upper level about this event.
+---------------------------------------------------------
+keepAliveThreshold
+	Specify how long to wait (in seconds) before to start polling each node to verify if they're still alive ('0' to disable)	Please refer to paragraph 7.38.3.
+---------------------------------------------------------
+keepAliveNumberOfAttempt
+	Once keepAliveThreshold is reached, GAL tries to ping the node for 'keepAliveNumberOfAttempt' before considering it dead	Please refer to paragraph 7.38.3.
+---------------------------------------------------------
+forcePingTimeout	Specify in seconds a timeout before to force the gateway to send a ping (MGMT_LQI_Req) to the nodes (0 to disable)	Please refer to paragraph 7.2 8.4.
+---------------------------------------------------------
+autoDiscoveryUnknownNodes
+	Automatic discovery unknown nodes before sending or after receiving a message (1 to enable, 0 to disable)	This is an important feature: every time the gateway receives messages from nodes that has not been yet recognized/included in the neighbors table entry shall be polled in order to find out more information (in particular all those details needed by the gateway to have a valid entry into its database)
+---------------------------------------------------------
+gwStatusChanged_DefaultURIListener	[Optional] "Callback URI listener" address. It represent the "GW Status Changed event" default URI Listener	This is a development-specific variable inserted to inform an external application about the status of the gateway and its possible changes. It is an important feature but it could be implemented using API commands (a registration to this event would be enough)
+---------------------------------------------------------
+apscMaxWindowSize
+	APS level parameters (required for fragmentation services)	This is a variable that solve a specific need (fragmentation) and thus probably needs to be maintained.
+---------------------------------------------------------	
+apsInterframeDelay	APS level parameters (required for fragmentation services)	This is a variable that solve a specific need (fragmentation) and thus probably needs to be maintained.
+---------------------------------------------------------
+debugEnabled (HTTPServerDL, HTTPSessionContextDL, RESTClientDL, RESTBrokerDL, DiscoveryAgentDL, ManagementAgentDL, LocalNodeDL)	To enable debug messages select "1"  (0 to disable)
+Printing levels for class debugging - 0 (DEBUGGING), 1 (TEST), 3 (PRODUCTION)	This is a typical variable used for debugging purpose: it allows the developer to decide what to print and which specific classes to enable. The current gateway has 3 different debug levels, but at the end only two of them are mainly used.
+---------------------------------------------------------
+DeviceType	Device Type (0 =Current device type; 1=Coordinator; 2=Router; 3=End Device)	Fundamental setting to decide if the gateway shall be a coordinator or router (end device is not a standard setting anymore)
+---------------------------------------------------------
+ChannelMask	Default Channel Mask [valid range: 11 - 26]	ZigBee channel mask: an optional feature could be to insert a mask or an “OR” symbol to allow multiple channel choice, useful in case we are a router able to join any channel or a coordinator that shall create a network where the noise is the lowest.
+---------------------------------------------------------
+PANId	ZigBee Network PANId ('0xFFFF' = generate random value)	Typical ZigBee setting (optionally it could be generated randomly)
+---------------------------------------------------------
+ExtendedPANId	Extended PAN Id (big-endian order)	Typical ZigBee setting (optionally it could be generated randomly)
+---------------------------------------------------------
+StartUpControl	StartupControl (0=Association; 1=Orphan Rejoin; 2=Network Rejoin; 3=Find and Rejoin; 4=Silent Start)	Typical ZigBee setting
+---------------------------------------------------------
+SecurityLevel	SecurityLevel (0=Disabled, 5=Enabled)	This variable is not needed anymore since all the ZigBee PRO stack shall mandatory support the security
+---------------------------------------------------------
+freescaleMACAddressValue	MAC Address mode: 0=use manufacture address (stored within the dongle), 1= generate random address	Any gateway shall be produced with a specific and not-editable IEEE Address, but if the stack vendor allows changing it this setting could be used.
+---------------------------------------------------------
+networkKey	Default Network Key	Typical ZigBee setting (optionally it could be generated randomly)
+---------------------------------------------------------
+preconfiguredLinkKey	Default Trust Center Link Key - 'ZigBeeAlliance09'	Typical ZigBee setting (optionally it could be generated randomly)
+---------------------------------------------------------
+DefaultEndPoint	Default End Point	This setting shall be expanded. In ZigBee an endpoint is linked with a SimpleDescriptor and thus this part shall be changed so that the user can specify the default simple descriptor to be used.
+---------------------------------------------------------
+TCKeyTableSize (IEEEAddressXX, TCLinkKeyXX)	TCKeyTableSize - Zero to disable the TrustCenterLinkKeytable - Note: maximum number of entries is 12 for Ember, 9 for Freescale	Typical ZigBee setting. If the gateway is a coordinator, this feature gives the possibility to specify special security requirements for ad hoc nodes.
+---------------------------------------------------------
+IEEE_ADDRESS	Insert the Trust Center IEEE Address	Trust Center setting that could be reviewed.
+---------------------------------------------------------
+JOINREQUESTPROCESSING	Decide if the local ACL Conf shall be used (INSERT true) or if the WSN-C access is required (INSERT false)	Trust Center setting that could be reviewed.
+---------------------------------------------------------
+LEAVENOTIFICATIONPROCESSING	Decide if process locally the leave notifications without warning the WSN-C (SELECT true). Otherwise insert false	Trust Center setting that could be reviewed.
+---------------------------------------------------------
+ACLFILENAME	File name containing the Access Control List	Trust Center setting that could be reviewed.
+---------------------------------------------------------
+NETWORKKEY	The network master key, 16-bytes long	Trust Center setting that could be reviewed.
+---------------------------------------------------------
+APPSECURITYTIMEOUTPERIOD	The Security Timeout period (expressed in milliseconds)	Trust Center setting that could be reviewed.
+---------------------------------------------------------
+UseDefaultNWKRootURI	Decide if the Network Root URI can be obtained by appending the net/default' suffix (SELECT 1), or by appending the net/<ExtendedPANId>' suffix (SELECT 0)	This setting could be avoided (unless it is required to certify a gateway device as standard) and keep by default the “/net/default” path since so far the gateway has been thought to be used only for one network at time.
+---------------------------------------------------------
+HelloMsgNotifyPeriod, HelloMsg_WSNCAttached_NotifyPeriod
+	Gateway Descriptor Asynchronous notification period (expressed in seconds), respectively before and after a WSN-C is attached. Note: This is like an "Hello" message to the WSN-C platform address	This is an obsolete setting that could be implemented into a new API to periodically inform an application (registered to this event) about the status of the gateway. See also ‘gwStatusChanged_DefaultURIListener’ since this is a similar feature that could be implemented in a unique API.
+---------------------------------------------------------
+serverPorts	Port server where to receive REST commands	This is an important setting since it specifies where the gateway expects to receive REST commands.
+---------------------------------------------------------
+Ssl, sslCertFile, httpDigestAuth, httpDigestAuthPwdFile	RESTServer parameters
+	Development-specific settings that depending on the new architecture could be avoided to be inserted.
+---------------------------------------------------------	
+httpOptTimeout
+	libcurl HTTP option application timeout (in seconds) - Note: for remote connection between GW and IPHA insert a value higher than 1. Set to zero to completely disable caching	This is a libcurl setting that the new gateway could not use in case the developer decide to manage the HTTP communication in a different way.
+--------------------------------------------------------
+txPeriod	Select the txPeriod used during the Performance tests	Obsolete setting used for performance tests, not needed anymore.

Added: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/iniparser/src/dictionary.h
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/iniparser/src/dictionary.h (added)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/iniparser/src/dictionary.h Thu Jan 10 10:57:04 2013
@@ -1,0 +1,173 @@
+
+/*-------------------------------------------------------------------------*/
+/**
+   @file    dictionary.h
+   @author  N. Devillard
+   @brief   Implements a dictionary for string variables.
+
+   This module implements a simple dictionary object, i.e. a list
+   of string/string associations. This object is useful to store e.g.
+   informations retrieved from a configuration file (ini files).
+*/
+/*--------------------------------------------------------------------------*/
+
+#ifndef _DICTIONARY_H_
+#define _DICTIONARY_H_
+
+/*---------------------------------------------------------------------------
+                                Includes
+ ---------------------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*---------------------------------------------------------------------------
+                                New types
+ ---------------------------------------------------------------------------*/
+
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Dictionary object
+
+  This object contains a list of string/string associations. Each
+  association is identified by a unique string key. Looking up values
+  in the dictionary is speeded up by the use of a (hopefully collision-free)
+  hash function.
+ */
+/*-------------------------------------------------------------------------*/
+typedef struct _dictionary_ {
+    int             n ;     /** Number of entries in dictionary */
+    int             size ;  /** Storage size */
+    char        **  val ;   /** List of string values */
+    char        **  key ;   /** List of string keys */
+    unsigned     *  hash ;  /** List of hash values for keys */
+} dictionary ;
+
+
+/*---------------------------------------------------------------------------
+                            Function prototypes
+ ---------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Compute the hash key for a string.
+  @param    key     Character string to use for key.
+  @return   1 unsigned int on at least 32 bits.
+
+  This hash function has been taken from an Article in Dr Dobbs Journal.
+  This is normally a collision-free function, distributing keys evenly.
+  The key is stored anyway in the struct so that collision can be avoided
+  by comparing the key itself in last resort.
+ */
+/*--------------------------------------------------------------------------*/
+unsigned dictionary_hash(const char * key);
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Create a new dictionary object.
+  @param    size    Optional initial size of the dictionary.
+  @return   1 newly allocated dictionary objet.
+
+  This function allocates a new dictionary object of given size and returns
+  it. If you do not know in advance (roughly) the number of entries in the
+  dictionary, give size=0.
+ */
+/*--------------------------------------------------------------------------*/
+dictionary * dictionary_new(int size);
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Delete a dictionary object
+  @param    d   dictionary object to deallocate.
+  @return   void
+
+  Deallocate a dictionary object and all memory associated to it.
+ */
+/*--------------------------------------------------------------------------*/
+void dictionary_del(dictionary * vd);
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Get a value from a dictionary.
+  @param    d       dictionary object to search.
+  @param    key     Key to look for in the dictionary.
+  @param    def     Default value to return if key not found.
+  @return   1 pointer to internally allocated character string.
+
+  This function locates a key in a dictionary and returns a pointer to its
+  value, or the passed 'def' pointer if no such key can be found in
+  dictionary. The returned character pointer points to data internal to the
+  dictionary object, you should not try to free it or modify it.
+ */
+/*--------------------------------------------------------------------------*/
+char * dictionary_get(dictionary * d, const char * key, char * def);
+
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Set a value in a dictionary.
+  @param    d       dictionary object to modify.
+  @param    key     Key to modify or add.
+  @param    val     Value to add.
+  @return   int     0 if Ok, anything else otherwise
+
+  If the given key is found in the dictionary, the associated value is
+  replaced by the provided one. If the key cannot be found in the
+  dictionary, it is added to it.
+
+  It is Ok to provide a NULL value for val, but NULL values for the dictionary
+  or the key are considered as errors: the function will return immediately
+  in such a case.
+
+  Notice that if you dictionary_set a variable to NULL, a call to
+  dictionary_get will return a NULL value: the variable will be found, and
+  its value (NULL) is returned. In other words, setting the variable
+  content to NULL is equivalent to deleting the variable from the
+  dictionary. It is not possible (in this implementation) to have a key in
+  the dictionary without value.
+
+  This function returns non-zero in case of failure.
+ */
+/*--------------------------------------------------------------------------*/
+int dictionary_set(dictionary * vd, const char * key, const char * val);
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Delete a key in a dictionary
+  @param    d       dictionary object to modify.
+  @param    key     Key to remove.
+  @return   void
+
+  This function deletes a key in a dictionary. Nothing is done if the
+  key cannot be found.
+ */
+/*--------------------------------------------------------------------------*/
+void dictionary_unset(dictionary * d, const char * key);
+
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Dump a dictionary to an opened file pointer.
+  @param    d   Dictionary to dump
+  @param    f   Opened file pointer.
+  @return   void
+
+  Dumps a dictionary onto an opened file pointer. Key pairs are printed out
+  as @c [Key]=[Value], one per line. It is Ok to provide stdout or stderr as
+  output file pointers.
+ */
+/*--------------------------------------------------------------------------*/
+void dictionary_dump(dictionary * d, FILE * out);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Added: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/iniparser/src/iniparser.h
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/iniparser/src/iniparser.h (added)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/iniparser/src/iniparser.h Thu Jan 10 10:57:04 2013
@@ -1,0 +1,316 @@
+
+/*-------------------------------------------------------------------------*/
+/**
+   @file    iniparser.h
+   @author  N. Devillard
+   @brief   Parser for ini files.
+*/
+/*--------------------------------------------------------------------------*/
+
+#ifndef _INIPARSER_H_
+#define _INIPARSER_H_
+
+/*---------------------------------------------------------------------------
+                                Includes
+ ---------------------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+ * The following #include is necessary on many Unixes but not Linux.
+ * It is not needed for Windows platforms.
+ * Uncomment it if needed.
+ */
+/* #include <unistd.h> */
+
+#include "dictionary.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Get number of sections in a dictionary
+  @param    d   Dictionary to examine
+  @return   int Number of sections found in dictionary
+
+  This function returns the number of sections found in a dictionary.
+  The test to recognize sections is done on the string stored in the
+  dictionary: a section name is given as "section" whereas a key is
+  stored as "section:key", thus the test looks for entries that do not
+  contain a colon.
+
+  This clearly fails in the case a section name contains a colon, but
+  this should simply be avoided.
+
+  This function returns -1 in case of error.
+ */
+/*--------------------------------------------------------------------------*/
+
+int iniparser_getnsec(dictionary * d);
+
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Get name for section n in a dictionary.
+  @param    d   Dictionary to examine
+  @param    n   Section number (from 0 to nsec-1).
+  @return   Pointer to char string
+
+  This function locates the n-th section in a dictionary and returns
+  its name as a pointer to a string statically allocated inside the
+  dictionary. Do not free or modify the returned string!
+
+  This function returns NULL in case of error.
+ */
+/*--------------------------------------------------------------------------*/
+
+char * iniparser_getsecname(dictionary * d, int n);
+
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Save a dictionary to a loadable ini file
+  @param    d   Dictionary to dump
+  @param    f   Opened file pointer to dump to
+  @return   void
+
+  This function dumps a given dictionary into a loadable ini file.
+  It is Ok to specify @c stderr or @c stdout as output files.
+ */
+/*--------------------------------------------------------------------------*/
+
+void iniparser_dump_ini(dictionary * d, FILE * f);
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Save a dictionary section to a loadable ini file
+  @param    d   Dictionary to dump
+  @param    s   Section name of dictionary to dump
+  @param    f   Opened file pointer to dump to
+  @return   void
+
+  This function dumps a given section of a given dictionary into a loadable ini
+  file.  It is Ok to specify @c stderr or @c stdout as output files.
+ */
+/*--------------------------------------------------------------------------*/
+
+void iniparser_dumpsection_ini(dictionary * d, char * s, FILE * f);
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Dump a dictionary to an opened file pointer.
+  @param    d   Dictionary to dump.
+  @param    f   Opened file pointer to dump to.
+  @return   void
+
+  This function prints out the contents of a dictionary, one element by
+  line, onto the provided file pointer. It is OK to specify @c stderr
+  or @c stdout as output files. This function is meant for debugging
+  purposes mostly.
+ */
+/*--------------------------------------------------------------------------*/
+void iniparser_dump(dictionary * d, FILE * f);
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Get the number of keys in a section of a dictionary.
+  @param    d   Dictionary to examine
+  @param    s   Section name of dictionary to examine
+  @return   Number of keys in section
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_getsecnkeys(dictionary * d, char * s);
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Get the number of keys in a section of a dictionary.
+  @param    d   Dictionary to examine
+  @param    s   Section name of dictionary to examine
+  @return   pointer to statically allocated character strings
+
+  This function queries a dictionary and finds all keys in a given section.
+  Each pointer in the returned char pointer-to-pointer is pointing to
+  a string allocated in the dictionary; do not free or modify them.
+
+  This function returns NULL in case of error.
+ */
+/*--------------------------------------------------------------------------*/
+char ** iniparser_getseckeys(dictionary * d, char * s);
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Get the string associated to a key
+  @param    d       Dictionary to search
+  @param    key     Key string to look for
+  @param    def     Default value to return if key not found.
+  @return   pointer to statically allocated character string
+
+  This function queries a dictionary for a key. A key as read from an
+  ini file is given as "section:key". If the key cannot be found,
+  the pointer passed as 'def' is returned.
+  The returned char pointer is pointing to a string allocated in
+  the dictionary, do not free or modify it.
+ */
+/*--------------------------------------------------------------------------*/
+char * iniparser_getstring(dictionary * d, const char * key, char * def);
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Get the string associated to a key, convert to an int
+  @param    d Dictionary to search
+  @param    key Key string to look for
+  @param    notfound Value to return in case of error
+  @return   integer
+
+  This function queries a dictionary for a key. A key as read from an
+  ini file is given as "section:key". If the key cannot be found,
+  the notfound value is returned.
+
+  Supported values for integers include the usual C notation
+  so decimal, octal (starting with 0) and hexadecimal (starting with 0x)
+  are supported. Examples:
+
+  - "42"      ->  42
+  - "042"     ->  34 (octal -> decimal)
+  - "0x42"    ->  66 (hexa  -> decimal)
+
+  Warning: the conversion may overflow in various ways. Conversion is
+  totally outsourced to strtol(), see the associated man page for overflow
+  handling.
+
+  Credits: Thanks to A. Becker for suggesting strtol()
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_getint(dictionary * d, const char * key, int notfound);
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Get the string associated to a key, convert to a double
+  @param    d Dictionary to search
+  @param    key Key string to look for
+  @param    notfound Value to return in case of error
+  @return   double
+
+  This function queries a dictionary for a key. A key as read from an
+  ini file is given as "section:key". If the key cannot be found,
+  the notfound value is returned.
+ */
+/*--------------------------------------------------------------------------*/
+double iniparser_getdouble(dictionary * d, const char * key, double notfound);
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Get the string associated to a key, convert to a boolean
+  @param    d Dictionary to search
+  @param    key Key string to look for
+  @param    notfound Value to return in case of error
+  @return   integer
+
+  This function queries a dictionary for a key. A key as read from an
+  ini file is given as "section:key". If the key cannot be found,
+  the notfound value is returned.
+
+  A true boolean is found if one of the following is matched:
+
+  - A string starting with 'y'
+  - A string starting with 'Y'
+  - A string starting with 't'
+  - A string starting with 'T'
+  - A string starting with '1'
+
+  A false boolean is found if one of the following is matched:
+
+  - A string starting with 'n'
+  - A string starting with 'N'
+  - A string starting with 'f'
+  - A string starting with 'F'
+  - A string starting with '0'
+
+  The notfound value returned if no boolean is identified, does not
+  necessarily have to be 0 or 1.
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_getboolean(dictionary * d, const char * key, int notfound);
+
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Set an entry in a dictionary.
+  @param    ini     Dictionary to modify.
+  @param    entry   Entry to modify (entry name)
+  @param    val     New value to associate to the entry.
+  @return   int 0 if Ok, -1 otherwise.
+
+  If the given entry can be found in the dictionary, it is modified to
+  contain the provided value. If it cannot be found, -1 is returned.
+  It is Ok to set val to NULL.
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_set(dictionary * ini, const char * entry, const char * val);
+
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Delete an entry in a dictionary
+  @param    ini     Dictionary to modify
+  @param    entry   Entry to delete (entry name)
+  @return   void
+
+  If the given entry can be found, it is deleted from the dictionary.
+ */
+/*--------------------------------------------------------------------------*/
+void iniparser_unset(dictionary * ini, const char * entry);
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Finds out if a given entry exists in a dictionary
+  @param    ini     Dictionary to search
+  @param    entry   Name of the entry to look for
+  @return   integer 1 if entry exists, 0 otherwise
+
+  Finds out if a given entry exists in the dictionary. Since sections
+  are stored as keys with NULL associated values, this is the only way
+  of querying for the presence of sections in a dictionary.
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_find_entry(dictionary * ini, const char * entry) ;
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Parse an ini file and return an allocated dictionary object
+  @param    ininame Name of the ini file to read.
+  @return   Pointer to newly allocated dictionary
+
+  This is the parser for ini files. This function is called, providing
+  the name of the file to be read. It returns a dictionary object that
+  should not be accessed directly, but through accessor functions
+  instead.
+
+  The returned dictionary must be freed using iniparser_freedict().
+ */
+/*--------------------------------------------------------------------------*/
+dictionary * iniparser_load(const char * ininame);
+
+/*-------------------------------------------------------------------------*/
+/**
+  @brief    Free all memory associated to an ini dictionary
+  @param    d Dictionary to free
+  @return   void
+
+  Free all memory associated to an ini dictionary.
+  It is mandatory to call this function before the dictionary object
+  gets out of the current context.
+ */
+/*--------------------------------------------------------------------------*/
+void iniparser_freedict(dictionary * d);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CDiscoveryAgent.cpp
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CDiscoveryAgent.cpp (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CDiscoveryAgent.cpp Thu Jan 10 10:57:04 2013
@@ -3283,7 +3283,7 @@
 	if (taskStarted) {
 		taskStarted = false;
 		pthread_join(tid, NULL);
-
+		pthread_detach(tid);
 		DiscoveryAgent* pDAgent;
 		pDAgent = DiscoveryAgent<T>::Instance();
 		pDAgent->functionsContext.freshness.unlock(Canceled);

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CHTTPClient.cpp
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CHTTPClient.cpp (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CHTTPClient.cpp Thu Jan 10 10:57:04 2013
@@ -29,7 +29,7 @@
 #ifdef DEBUG_ACTIVE_HTTPCLIENT
 	printf("HTTPClient Constructor\n");
 #endif
-
+	curl = NULL;	//TEST_MULTI_CURL
 	// CURLOPT_TIMEOUT default value = 3
 	this->setOptTimeout(3);
 }
@@ -46,6 +46,7 @@
 	printf("HTTPClient Destructor\n");
 #endif
 
+	curl_easy_cleanup(curl);	//TEST_MULTI_CURL
 	curl_global_cleanup();
 }
 
@@ -62,6 +63,7 @@
  @return Status.
  */
 
+/*
 int HTTPClient::postData(std::string *URL, std::string *buffer,
 		void *listener) {
 	CURL *curl;
@@ -116,3 +118,73 @@
 	}
 	return -1;
 }
+*/
+
+//TEST_MULTI_CURL
+// Version that tries to mantaina  keepalive communication!
+int HTTPClient::postData(
+	std::string *URL,
+	std::string *buffer,
+	void *listener
+)
+{
+	// A good reference where to start is here: http://curl.haxx.se/libcurl/c/curl_easy_pause.html
+	CURLcode res, resultList;
+	struct curl_slist *headers=NULL;
+	char error_buffer[256];
+
+	if (curl == NULL){
+		// Initialize a new session!
+		curl_global_init(CURL_GLOBAL_ALL);
+		curl = curl_easy_init();
+		if (curl == NULL){
+			//#ifdef DEBUG_ACTIVE_HTTPCLIENT
+			printf("postData - ERROR: curl_easy_init didn't initialized the session!\n");
+			//#endif
+			// Prepare curl to be set up again at the next postData
+			curl_easy_cleanup(curl);	//End a libcurl easy session
+			curl= NULL;
+			return -1;
+		}
+		// If it is ok finish to set other values
+		headers = curl_slist_append(headers, "Expect:");
+		curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
+		curl_easy_setopt(curl, CURLOPT_VERBOSE, CURLOPT_VERBOSE_DISABLED);
+		curl_easy_setopt(curl, CURLOPT_NOSIGNAL, CURLOPT_NOSIGNAL_ENABLED);
+	}
+	curl_easy_setopt(curl, CURLOPT_URL, URL->c_str());
+	curl_easy_setopt(curl, CURLOPT_TIMEOUT, this->optTimeout);
+	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, buffer->c_str());
+	curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(buffer->c_str()));		// If POSTFIELDSIZE is not set, libcurl will strlen() by itself
+	if ( listener != NULL)
+	{
+		resultList = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, listener);
+		if (resultList == CURL_WRITEFUNC_PAUSE){			// This part works only with curl 7.18 or superior releases
+			//#ifdef DEBUG_ACTIVE_HTTPCLIENT
+			printf("postData -  ERROR: No possible to establish a listener to get the POST response\n");
+			//#endif
+			// Writing to this connection has been paused! Try to recovery it. See http://curl.haxx.se/libcurl/c/curl_easy_pause.html
+			curl_easy_pause(listener,CURLPAUSE_CONT);	//CURLPAUSE_CONT: Convenience define that unpauses both directions
+		}
+		curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);
+		curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buffer );	//Note:  If the CURLOPT_ERRORBUFFER was set with curl_easy_setopt there will be a readable error message in the error buffer when non-zero is returned.
+	}
+	#ifdef DEBUG_ACTIVE_HTTPCLIENT
+		printf("postData - Sending POST to %s\n",URL->c_str());
+	#endif
+	// Send the message
+	res = curl_easy_perform(curl);
+	if (res)
+	{
+		//#ifdef DEBUG_ACTIVE_HTTPCLIENT
+		printf("WARNING: POST to %s returned an error: %d --> %s\n", URL->c_str(), res,error_buffer);
+		//#endif
+		// Since there was an error, let's close the libcurl easy session!
+		curl_easy_cleanup(curl);	//End a libcurl easy session
+		curl= NULL;
+		// Free the header list (refer to libcurl library).
+		curl_slist_free_all(headers);	//removes all traces of a previously built curl_slist linked list.
+	}
+	return res;
+}
+

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CHTTPClient.h
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CHTTPClient.h (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CHTTPClient.h Thu Jan 10 10:57:04 2013
@@ -44,6 +44,8 @@
 
 	///	Pointer to a Debug object -> logger
 	Debug *pLogger;
+	/// Pointer to a libcurl easy session
+	CURL *curl;	//TEST_MULTI_CURL
 
 	int optTimeout;
 

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CLocalNode.cpp
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CLocalNode.cpp (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CLocalNode.cpp Thu Jan 10 10:57:04 2013
@@ -78,8 +78,7 @@
 		printf("LocalNode - Killing threadPool...\n");
 		threadPoolResult = ThreadPoolShutdown(&threadPool);
 	}
-
-	free(gwDescriptor);
+	//free(gwDescriptor);
 }
 
 /**
@@ -1303,6 +1302,7 @@
 	if (taskStarted) {
 		taskStarted = false;
 		pthread_join(tid, NULL);
+		pthread_detach(tid);
 	}
 }
 

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CRESTBroker.cpp
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CRESTBroker.cpp (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CRESTBroker.cpp Thu Jan 10 10:57:04 2013
@@ -5312,6 +5312,7 @@
 	if (taskStarted) {
 		taskStarted = false;
 		pthread_join(tid, NULL);
+		pthread_detach(tid);
 	}
 }
 
@@ -5531,7 +5532,7 @@
 	std::map<ushort, Node *>::const_iterator iter;
 	std::map<ushort, Node *> nodes;
 	std::string xmlNotification;
-	const char *detail;
+	//const char *detail;
 	AgentError status;
 	DiscoveryAgent<RESTBroker>::MgmtLQICtxt rpcContext(sessionId, this,
 			(DiscoveryAgent<RESTBroker>::MgmtLQIResponseCb) &RESTBroker::MgmtLQI_RspCb,

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CRESTClient.cpp
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CRESTClient.cpp (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CRESTClient.cpp Thu Jan 10 10:57:04 2013
@@ -68,8 +68,10 @@
 	std::list<postMessage>::iterator bufIt;
 	//delete httpClient;
 	running = false;
-	for (j = pthread_tMap.begin(); j != pthread_tMap.end(); j++)
+	for (j = pthread_tMap.begin(); j != pthread_tMap.end(); j++){
 		pthread_join(j->second, NULL);
+		pthread_detach(j->second);
+	}
 	for (i = httpClientPool.begin(); i != httpClientPool.end(); i++)
 		delete i->second;
 	if (pLogger != NULL) {
@@ -223,13 +225,15 @@
 				pLogger->info("dispatchPostData - postMsg to URL %s",bufIt->URL.c_str());
 				const char * temp = bufIt->data.c_str();
 				for (ushort i=0; i < strlen(temp);i++)
-				printf("%c",temp[i]);
+					printf("%c",temp[i]);
 				printf("\r\n");
 #endif
 				httpClientPool[bufferId]->postData(&bufIt->URL, &bufIt->data,
 						(void *) (&receivePostResponse_SW));
-				// Remove post message from POST Messagge Buffer.
+				// Remove post message from POST Message Buffer
 				pthread_mutex_lock(&mux);
+				//free(&bufIt->URL);
+				//free(&bufIt->data);
 				this->postMessagesBuffers[bufferId].pop_front();
 				pthread_mutex_unlock(&mux);
 			}

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CRESTServer.cpp
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CRESTServer.cpp (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CRESTServer.cpp Thu Jan 10 10:57:04 2013
@@ -525,7 +525,7 @@
 #ifdef DEBUG_ACTIVE_RESTSERVER
 		const char * temp = xmlResponse.c_str();
 		for (ushort i=0; i < strlen(temp);i++)
-		printf("%c",temp[i]);
+			printf("%c",temp[i]);
 #endif
 		printf("\r\n");
 	}
@@ -676,7 +676,7 @@
 #ifdef DEBUG_ACTIVE_RESTSERVER
 			const char * temp = xmlResponse.c_str();
 			for (ushort i=0; i < strlen(temp);i++)
-			printf("%c",temp[i]);
+				printf("%c",temp[i]);
 #endif
 			printf("\r\n");
 		}

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CServiceAgent.cpp
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CServiceAgent.cpp (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/CServiceAgent.cpp Thu Jan 10 10:57:04 2013
@@ -2400,7 +2400,7 @@
 	if (debugEnabled == true) {
 		timeval tp;
 		gettimeofday(&tp, NULL);
-		pLogger->debug("[%lu.%06lu] - messageReceived_Cb - Received message from 0x%04x",tp.tv_sec,tp.tv_usec, nodeFound->get_nwk_addr());
+		printf("[%lu.%06lu] - messageReceived_Cb - Received message from 0x%04x\n",tp.tv_sec,tp.tv_usec,nodeFound->get_nwk_addr());
 	}
 	if (nodeFound->getIsActive() == false
 			&& nodeFound->get_nwk_addr() != pGalDb->root->get_nwk_addr()) {

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/GalZbIf.cpp
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/GalZbIf.cpp (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/GalZbIf.cpp Thu Jan 10 10:57:04 2013
@@ -122,8 +122,8 @@
 		tmpList.clear();
 	}
 	listeners.clear();
-
 	delete pLogger;
+	pLogger = NULL;
 }
 
 /**
@@ -512,9 +512,18 @@
 			pGalDb = getDb();
 			//Save the root local node!
 			pGalDb->clearAllButRoot();
+			int mode = pGalDb->getStartModeSetting();
 			printf(
-					"\n*************\nGateway initialized (waiting for startup) - StartupMode = 0x%02x\n*************\n",
-					pGalDb->getStartModeSetting());
+					"\n*************\nGateway initialized (waiting for startup) - StartupMode = 0x%02x",
+					mode);
+			if (mode == 0x00)
+				printf(" (Commissioning)\n*************\n");
+			else if (mode == 0x01)
+				printf(" (NotVolatileMemory)\n*************\n");
+			else if (mode == 0x02)
+				printf(" (TC Replacement)\n*************\n");
+			else
+				printf("\n*************\n");
 		}
 	}
 }
@@ -727,7 +736,7 @@
 		//Prepare the next SimpleDescriptor to set
 		simple_descr[0] = sd->end_point; // endpoint value
 #ifdef DEBUG_ACTIVE_GALZB
-				pLogger->debug("setSimpleDescriptor - endpoint %d",simple_descr[0]);
+		pLogger->debug("setSimpleDescriptor - endpoint %d",simple_descr[0]);
 #endif
 		simple_descr[1] = LSB_USHORT(sd->profile_id);
 		simple_descr[2] = MSB_USHORT(sd->profile_id);
@@ -859,7 +868,7 @@
 			 #endif
 			 */
 			// Last (but not least), ask for the GAL's IEEEAddress
-			APSME_GET_request (ZB_ATTR_GET_EUI64);
+			APSME_GET_request(ZB_ATTR_GET_EUI64);
 		} else if (attr == ZB_ATTR_GET_EUI64) {
 #ifdef DEBUG_ACTIVE_GALZB
 			pLogger->debug("APSME_GET_confirm: ZB_ATTR_GET_EUI64" );
@@ -872,7 +881,7 @@
 			}
 			pGalDb->root->set_ieee_addr(tmpIEEEAddr);
 #ifdef DEBUG_ACTIVE_GALZB
-			pLogger->debug("\n\nRoot node: IEEEAddress Set!");
+			pLogger->debug("Root node: IEEEAddress Set!");
 #endif
 			// Trigger StartGatewayDevice Response or Event, GWStatusChanged Event
 			this->setGWStatus(GW_RUNNING, GW_SUCCESS);
@@ -904,9 +913,9 @@
 					tmpIEEEAddr[1], tmpIEEEAddr[2], tmpIEEEAddr[3],
 					tmpIEEEAddr[4], tmpIEEEAddr[5], tmpIEEEAddr[6],
 					tmpIEEEAddr[7], assignedChannelMask);
-			// Reset the deadingNodeList in CDiscoveryAgent (this was the only place where I've found an easy way to clean it) :-(
-			DiscoveryAgent<GalZbIf> *pDAgent;
-			pDAgent = DiscoveryAgent<GalZbIf>::Instance();
+			// Reset the deadingNodeList in CDiscoveryAgent	//TO delete!
+			//DiscoveryAgent<GalZbIf> *pDAgent;
+			//pDAgent = DiscoveryAgent<GalZbIf>::Instance();
 		} else {
 			pLogger->fatal("Received a APSME_GET_confirm from an unsupported attribute: %02x", attr);
 		}
@@ -1792,7 +1801,8 @@
 		uchar capability) {
 	ZbNetDb *pGalDb;
 
-	if (this->gwStatus != GW_RUNNING)
+	if (this->gwStatus != GW_RUNNING
+		)
 		// Ignore any incoming messages until the GAL is up!
 		return;
 
@@ -1939,7 +1949,7 @@
 	srcNode->setKANodeTimer((long) curtime);
 #ifdef DEBUG_ACTIVE_GALZB
 	if (this->debugEnabled)
-	pLogger->debug("manageNodeTimeouts - timer updated for node 0x%04x!",srcNode->get_nwk_addr());
+		pLogger->debug("manageNodeTimeouts - timer updated for node 0x%04x!",srcNode->get_nwk_addr());
 #endif
 }
 
@@ -1971,7 +1981,8 @@
 #endif
 
 	pGalDb = getDb();
-	if (this->gwStatus != GW_RUNNING)
+	if (this->gwStatus != GW_RUNNING
+		)
 		// Ignore any incoming messages until the GAL is up!
 		return;
 	//#ifdef DEBUG_ACTIVE_GALZB
@@ -1979,7 +1990,8 @@
 		printf("GalZbIf::APSDE_DATA_indication - Message from ");
 		if (dst_addr_mode == ZB_AM_DIRECT) {
 			printf("%02x%02x, ", src_addr[1], src_addr[0]);
-		} else if (dst_addr_mode == ZB_AM_DIRECT_EX)
+		} else if (dst_addr_mode == ZB_AM_DIRECT_EX
+			)
 			printf("%s (printed in reverse order), ", src_addr);
 		printf("EndPoint %02x, profId %04x, clusId %04x, payload ", dst_ep,
 				profile_id, cluster_id);
@@ -2159,7 +2171,9 @@
 
 	} else {
 #ifdef DEBUG_ACTIVE_GALZB
-		pLogger->debug("GW_STATUS_CHANGED_event - Map Listeners empty");
+		if (pLogger != NULL
+			)
+			pLogger->debug("GW_STATUS_CHANGED_event - Map Listeners empty");
 #endif
 	}
 

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/ZbNetDb.cpp
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/ZbNetDb.cpp (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/ZbNetDb.cpp Thu Jan 10 10:57:04 2013
@@ -318,7 +318,7 @@
  */
 
 ZbNetDb::ZbNetDb() :
-		root(NULL), locked(false) {
+		locked(false), root(NULL)  {
 }
 
 ZbNetDb::~ZbNetDb() {

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/config.ini
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/config.ini (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/config.ini Thu Jan 10 10:57:04 2013
@@ -3,13 +3,13 @@
 Platform = 1
 
 # Autostart the ZigBee network: 0 to disable (it will wait for a StartGatewayDevice command), 1 to enabled
-autostart = 1
+autostart = 0
 
 # [Freescale only] Three possible scenario to startup the network:
 #0 - StartupSetMode=0x18 (CommissioningMode) AND StartupControlMode=0x00 (Association) --> To be used the first time, when the network is created
 #1 - StartupSetMode=0x00 (use NVM) AND StartupControlMode=0x04 (SilentStart) --> To be used at running time
 #2 - StartupSetMode=0x18 (CommissioningMode) AND StartupControlMode=0x04 (SilentStart) --> To be used for TC Replacement
-startupMode = 1
+startupMode = 0
 
 # Enable a local registration to device announcement events (1 to enable, 0 to disable)
 localRegToDAnnce = 1

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/configure.ac
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/configure.ac (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/linuxgal/configure.ac Thu Jan 10 10:57:04 2013
@@ -1,6 +1,6 @@
 dnl Process with autoconf to obtain a configuration script
 
-m4_define(linuxgal_version, 5.3.11)
+m4_define(linuxgal_version, 5.3.13)
 
 AC_INIT([Linux GAL], linuxgal_version)
 AM_INIT_AUTOMAKE(linuxgal, linuxgal_version)

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/freescale_if.c
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/freescale_if.c (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/freescale_if.c Thu Jan 10 10:57:04 2013
@@ -37,7 +37,8 @@
 
 unsigned char out_buf[300];
 uchar attr_prev = 0x00;
-ushort nwkShortAddress = 0x0000;
+ushort nwkShortAddress = 0xFFFC; //0xFFFF could be used, this one instead cannot never be assigned and it indicated that the shortAddress is unknown!
+int sendStartConfirmWhenShortAddrIsKnown = 0x00; // TRUE (0x01) when the shortAddress is correctly set and thus we can send the Start_Confirm!
 uchar DevType;
 // This variable is used to know if restart the Gateway or just init it
 uchar restartGWafterReset = 0x00; //by default do not restart the network
@@ -1778,22 +1779,22 @@
 					dst_addr_8, //Dst ieee addr
 					p[24]); //Dst End point
 			break;
-/*
-		case 0x08:
-			for (i= 0; i < 8; i++)
-			{
-				src_addr_8[i] = p[ 4 + i];
-				dst_addr_8[i] = p[16 + i];
-			}
-			zbifCbs->APSME_UNBIND_confirm(zbif_handle,
-					p[3], //Status
-					src_addr_8,//Src ieee Addr
-					p[12],//Src End point
-					p[14] | p[13] << 8,//Cluster Id
-					dst_addr_8,//Dst ieee addr
-					p[24]);//Dst End point
-			break;
-*/
+			/*
+			 case 0x08:
+			 for (i= 0; i < 8; i++)
+			 {
+			 src_addr_8[i] = p[ 4 + i];
+			 dst_addr_8[i] = p[16 + i];
+			 }
+			 zbifCbs->APSME_UNBIND_confirm(zbif_handle,
+			 p[3], //Status
+			 src_addr_8,//Src ieee Addr
+			 p[12],//Src End point
+			 p[14] | p[13] << 8,//Cluster Id
+			 dst_addr_8,//Dst ieee addr
+			 p[24]);//Dst End point
+			 break;
+			 */
 		case 0xC0:
 			zb_print("APSME-TRANSPORT-KEY.Confirm: ");
 			printBytes(p);
@@ -2300,18 +2301,40 @@
 			case 0x04:
 				zb_print(
 						"ZDO-NetworkState.Event - Device in Router Running state\n");
-				// Send a ZDO_START_confirm since concluded the startup procedure!
-				if (zbifCbs->ZDO_START_confirm)
-					zbifCbs->ZDO_START_confirm(zbif_handle, 0x00,
-							nwkShortAddress);
+				if (nwkShortAddress == 0xFFFC) {
+					zb_print("ShortAddress not know yet - Waiting...\n");
+					sendStartConfirmWhenShortAddrIsKnown = 0x01;
+					// Request again, just to be sure to receive an answer, the short address!
+					unsigned char cmd[7] = { 0xa3, 0x22, 0x04, 0x96, 0x00, 0x00,
+							0x00 };
+					zb_print_bytes("NLME-GET.Request: ", cmd, cmd[2] + 3);
+					zb_conn_send(((zbif_status_t *) zbif_handle)->zb_conn_h,
+							cmd, cmd[2] + 3);
+				} else {
+					// Send a ZDO_START_confirm since concluded the startup procedure!
+					if (zbifCbs->ZDO_START_confirm)
+						zbifCbs->ZDO_START_confirm(zbif_handle, 0x00,
+								nwkShortAddress);
+				}
 				break;
 			case 0x05:
 				zb_print(
 						"ZDO-NetworkState.Event - Device in End Device Running state\n");
-				// Send a ZDO_START_confirm since concluded the startup procedure!
-				if (zbifCbs->ZDO_START_confirm)
-					zbifCbs->ZDO_START_confirm(zbif_handle, 0x00,
-							nwkShortAddress);
+				if (nwkShortAddress == 0xFFFC) {
+					zb_print("ShortAddress not know yet - Waiting...\n");
+					sendStartConfirmWhenShortAddrIsKnown = 0x01;
+					// Request again, just to be sure to receive an answer, the short address!
+					unsigned char cmd[7] = { 0xa3, 0x22, 0x04, 0x96, 0x00, 0x00,
+							0x00 };
+					zb_print_bytes("NLME-GET.Request: ", cmd, cmd[2] + 3);
+					zb_conn_send(((zbif_status_t *) zbif_handle)->zb_conn_h,
+							cmd, cmd[2] + 3);
+				} else {
+					// Send a ZDO_START_confirm since concluded the startup procedure!
+					if (zbifCbs->ZDO_START_confirm)
+						zbifCbs->ZDO_START_confirm(zbif_handle, 0x00,
+								nwkShortAddress);
+				}
 				break;
 
 			case 0x09:
@@ -2356,8 +2379,7 @@
 				}
 				// Send a ZDO_START_confirm since concluded the startup procedure!
 				if (zbifCbs->ZDO_START_confirm)
-					zbifCbs->ZDO_START_confirm(zbif_handle, 0x00,
-							nwkShortAddress);
+					zbifCbs->ZDO_START_confirm(zbif_handle, 0x00, 0x0000);
 				break;
 
 			case 0x13:
@@ -2641,11 +2663,18 @@
 		case 0x22:
 			if (p[3] == 0x00 && p[4] == 0x96) { //0x96 is the nwkShortAddress
 				zb_print("NLME-GET.Confirm: ");
-				ushort nwk_addr = (p[10] << 8) + p[11];
-				if (nwk_addr == 0xFFFF)
+				nwkShortAddress = p[10] + (p[11] << 8);
+				if (nwkShortAddress == 0xFFFF)
 					zb_print("The shortAddress is not yet assigned!\n");
-				else
-					zb_print("shortAddress 0x%04x\n", nwk_addr);
+				else {
+					zb_print("shortAddress 0x%04x\n", nwkShortAddress);
+					//If this response arrived too late, send a notification!
+					if (sendStartConfirmWhenShortAddrIsKnown == 0x01) {
+						sendStartConfirmWhenShortAddrIsKnown = 0x00;
+						zbifCbs->ZDO_START_confirm(zbif_handle, 0x00,
+								nwkShortAddress);
+					}
+				}
 			} else if (p[3] == 0x00 && p[4] == 0xA1) {
 				//nwkSecurityMaterial
 				zb_print("NLME-GET.Confirm - nwkSecurityMaterial\n");

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/freescale_ser.c
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/freescale_ser.c (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/freescale_ser.c Thu Jan 10 10:57:04 2013
@@ -226,7 +226,7 @@
 	}
 
 	//Verify if we're using a CEDAC board or a Freescale USB dongle
-	int zigbee_usb_dongle = 1;
+	//int zigbee_usb_dongle = 1;
 	test = fopen("/sys/devices/platform/zigbee-gpio.0/cmd", "r");
 	if (test != NULL) {
 		zb_print("**** This is a CEDAC BOARD ****\n");
@@ -234,7 +234,7 @@
 		// Execute the hard reset!
 		system("echo reset > /sys/devices/platform/zigbee-gpio.0/cmd");
 		usleep(2000000);
-		zigbee_usb_dongle = 0;
+		//zigbee_usb_dongle = 0;
 	}
 	// Now open the connection
 	fd = open(device, O_RDWR | O_NOCTTY);
@@ -299,7 +299,8 @@
 
 int MC13226_transmit(const unsigned char *data) {
 	unsigned char frm[255];
-	int size, sent_size, i;
+	int size;
+	//int sent_size;
 
 	pthread_mutex_lock(&mux);
 
@@ -317,7 +318,7 @@
 		//pr_debug("MC13226 :%s: Starting TX state %d\n", __func__, MC13226_dongle->state);
 		size = freescale_zigbb_make_frame(data, frm);
 		//pr_debug("MC13226 :%s: TX %d bytes\n",__func__,size);
-		sent_size = write(MC13226_dongle->fd, frm, size);
+		write(MC13226_dongle->fd, frm, size);		//sent_size =
 		//printf("Bytes frm[1]=%02x,frm[2]=%02x,frm[3]=%02x\n",frm[1],frm[2],frm[3]);
 		// Check if we shall enter in a resetting mode state
 		if ((frm[1] == 0xa3) && (frm[2] == 0x08) && (frm[3] == 0x00)) {

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/zb_conn.c
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/zb_conn.c (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/zb_conn.c Thu Jan 10 10:57:04 2013
@@ -156,6 +156,8 @@
 	/* the pointer to the close function is in the status */
 	zb_conn_status_t *status = (zb_conn_status_t *) zb_conn_h;
 	pthread_cancel(rcv_thread);
+	//pthread_join(status->tid, NULL);
+	pthread_detach(status->tid);
 	sts = (status->close)(status->handle);
 	free(status);
 	return sts;

Modified: projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/zigbee.cpp
==============================================================================
--- projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/zigbee.cpp (original)
+++ projects/zb4osgi/sandbox/telecomItalia/initialContribution/GAL/zigbee/src/zigbee.cpp Thu Jan 10 10:57:04 2013
@@ -369,7 +369,7 @@
 int CZbIf::ZBIFDisconnect(void) {
 	if (zbif_handle != NULL) {
 // Original line
-//		return ::ZBIFDisconnect(zbif_handle);
+//		return ZBIFDisconnect(zbif_handle);
 // Modifications inserted ...
 		int result = ::ZBIFDisconnect(zbif_handle);
 		zbif_handle = NULL;




More information about the Commit mailing list