merged control bridge changes
authorTonyCave <t-cave@ti.com>
Thu, 28 Nov 2013 11:30:05 +0000 (11:30 +0000)
committerTonyCave <t-cave@ti.com>
Thu, 28 Nov 2013 11:30:05 +0000 (11:30 +0000)
18 files changed:
client/AndroidClients/LightingController/bin/LightingController.apk [deleted file]
client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/groupSelect$waitRspTask$1.class [deleted file]
client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/groupSelect$waitRspTask.class [deleted file]
client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/sceneSelect$waitRspTask$1.class [deleted file]
client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/sceneSelect$waitRspTask.class [deleted file]
client/CClients/Source/socket_client.c.bak [deleted file]
client/CClients/lightFlashCmdLine/linux-gnu/makefile [moved from client/CClients/lightFlashCmdLine/i486-linux-gnu/makefile with 100% similarity, mode: 0644]
client/CClients/listDevsCmdLine/linux-gnu/makefile [moved from client/CClients/listDevsCmdLine/i486-linux-gnu/makefile with 100% similarity, mode: 0644]
client/CClients/openNetwork/linux-gnu/makefile [moved from client/CClients/openNetwork/i486-linux-gnu/makefile with 100% similarity, mode: 0644]
server/Source/SimpleDB.c
server/Source/SimpleDB.h
server/Source/SimpleDBTxt.c
server/Source/SimpleDBTxt.h
server/Source/zllSocCmd-TH.c [deleted file]
server/Source/zllSocCmd.c [deleted file]
server/Source/zllSocCmd.h [deleted file]
server/Source/zll_controller.c [deleted file]
server/linux-gnu/makefile [moved from server/i486-linux-gnu/Makefile with 100% similarity, mode: 0644]

diff --git a/client/AndroidClients/LightingController/bin/LightingController.apk b/client/AndroidClients/LightingController/bin/LightingController.apk
deleted file mode 100644 (file)
index b9a659e..0000000
Binary files a/client/AndroidClients/LightingController/bin/LightingController.apk and /dev/null differ
diff --git a/client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/groupSelect$waitRspTask$1.class b/client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/groupSelect$waitRspTask$1.class
deleted file mode 100644 (file)
index 66df729..0000000
Binary files a/client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/groupSelect$waitRspTask$1.class and /dev/null differ
diff --git a/client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/groupSelect$waitRspTask.class b/client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/groupSelect$waitRspTask.class
deleted file mode 100644 (file)
index ccf8883..0000000
Binary files a/client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/groupSelect$waitRspTask.class and /dev/null differ
diff --git a/client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/sceneSelect$waitRspTask$1.class b/client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/sceneSelect$waitRspTask$1.class
deleted file mode 100644 (file)
index d08fab8..0000000
Binary files a/client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/sceneSelect$waitRspTask$1.class and /dev/null differ
diff --git a/client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/sceneSelect$waitRspTask.class b/client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/sceneSelect$waitRspTask.class
deleted file mode 100644 (file)
index 84eb088..0000000
Binary files a/client/AndroidClients/LightingController/bin/classes/com/lightingcontroller/sceneSelect$waitRspTask.class and /dev/null differ
diff --git a/client/CClients/Source/socket_client.c.bak b/client/CClients/Source/socket_client.c.bak
deleted file mode 100644 (file)
index 97b8aad..0000000
+++ /dev/null
@@ -1,658 +0,0 @@
- /**************************************************************************************************
-  Filename:       socket_client.c
-  Revised:        $Date: 2012-03-21 17:37:33 -0700 (Wed, 21 Mar 2012) $
-  Revision:       $Revision: 246 $
-
-  Description:    This file contains Linux platform specific RemoTI (RTI) API
-                  Surrogate implementation
-
-  Copyright (C) {2012} Texas Instruments Incorporated - http://www.ti.com/
-
-
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions
-   are met:
-
-     Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-     Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the
-     distribution.
-
-     Neither the name of Texas Instruments Incorporated nor the names of
-     its contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-  The following guide and a small portion of the code from Beej's Guide to Unix 
-  IPC was used in the development of this software:  
-  http://beej.us/guide/bgipc/output/html/multipage/intro.html#audience. 
-  The code is Public Domain   
-**************************************************************************************************/
-
-/**************************************************************************************************
- *                                           Includes
- **************************************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <pthread.h>
-#include <poll.h>
-#include <sys/time.h>
-#include <unistd.h>
-
-#ifndef NPI_UNIX
-#include <netdb.h>
-#include <arpa/inet.h>
-#endif
-
-#include "socket_client.h"
-
-#define __BIG_DEBUG__
-#ifdef __BIG_DEBUG__
-#define debug_printf(fmt, ...) printf( fmt, ##__VA_ARGS__)
-#else
-#define debug_printf(fmt, ...)
-#endif
-
-#define msg_memcpy(src, dst, len)      memcpy(src, dst, len)
-
-/**************************************************************************************************
- *                                        Externals
- **************************************************************************************************/
-
-/**************************************************************************************************
- *                                           Constant
- **************************************************************************************************/
-
-/**************************************************************************************************
- *                                        Type definitions
- **************************************************************************************************/
-
-struct LinkedMsg
-{
-       msgData_t message;
-       void *nextMessage;
-};
-
-typedef struct LinkedMsg linkedMsg;
-
-#define TX_BUF_SIZE                    (2 * (sizeof(msgData_t)))
-
-
-/**************************************************************************************************
- *                                        Global Variables
- **************************************************************************************************/
-
-/**************************************************************************************************
- *                                        Local Variables
- **************************************************************************************************/
-
-// Client socket handle
-int sClientFd;
-// Client data transmission buffers
-char socketBuf[2][TX_BUF_SIZE];
-// Client data received buffer
-linkedMsg *rxBuf;
-// Client data processing buffer
-linkedMsg *rxProcBuf;
-
-// Message count to keep track of incoming and processed messages
-static int messageCount = 0;
-
-static pthread_t RTISThreadId;
-static void *rxThreadFunc (void *ptr);
-static void *handleThreadFunc (void *ptr);
-
-// Mutex to handle rx
-pthread_mutex_t clientRxMutex = PTHREAD_MUTEX_INITIALIZER;
-
-// conditional variable to notify that the AREQ is handled
-static pthread_cond_t clientRxCond;
-
-#ifndef NPI_UNIX
-struct addrinfo *resAddr;
-#endif
-
-socketClientCb_t socketClientRxCb;
-
-/**************************************************************************************************
- *                                     Local Function Prototypes
- **************************************************************************************************/
-static void initSyncRes(void);
-static void delSyncRes(void);
-
-
-
-/**************************************************************************************************
- *
- * @fn          socketClientInit
- *
- * @brief       This function initializes RTI Surrogate
- *
- * input parameters
- *
- * @param       ipAddress - path to the NPI Server Socket
- *
- * output parameters
- *
- * None.
- *
- * @return      1 if the surrogate module started off successfully.
- *              0, otherwise.
- *
- **************************************************************************************************/
-int socketClientInit(const char *devPath, socketClientCb_t cb)
-{
-       int res = 1, i = 0;
-       const char *ipAddress = "", *port = "";
-       char *pStr, strTmp[128];
-       
-       socketClientRxCb = cb;
-       
-       strncpy(strTmp, devPath, 128);
-       // use strtok to split string and find IP address and port;
-       // the format is = IPaddress:port
-       // Get first token
-       pStr = strtok (strTmp, ":");
-       while ( pStr != NULL)
-       {
-               if (i == 0)
-               {
-                       // First part is the IP address
-                       ipAddress = pStr;
-               }
-               else if (i == 1)
-               {
-                       // Second part is the port
-                       port = pStr;
-               }
-               i++;
-               if (i > 2)
-                       break;
-               // Now get next token
-               pStr = strtok (NULL, " ,:;-|");
-       }
-
-       /**********************************************************************
-        * Initiate synchronization resources
-        */
-       initSyncRes();
-
-       /**********************************************************************
-        * Connect to the NPI server
-        **********************************************************************/
-
-#ifdef NPI_UNIX
-    int len;
-    struct sockaddr_un remote;
-
-    if ((sClientFd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
-        perror("socket");
-        exit(1);
-    }
-#else
-    struct addrinfo hints;
-
-    memset(&hints, 0, sizeof(hints));
-    hints.ai_family = AF_UNSPEC;
-    hints.ai_socktype = SOCK_STREAM;
-
-//    ipAddress = "192.168.128.133";
-//    if ((res = getaddrinfo(NULL, ipAddress, &hints, &resAddr)) != 0)
-       if (port == NULL)
-       {
-               // Fall back to default if port was not found in the configuration file
-               printf("Warning! Port not sent to RTIS. Will use default port: %s", DEFAULT_PORT);
-
-           if ((res = getaddrinfo(ipAddress, DEFAULT_PORT, &hints, &resAddr)) != 0)
-           {
-               fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(res));
-               res = 2;
-           }
-           else
-           {
-               // Because of inverted logic on return value
-               res = 1;
-           }
-       }
-       else
-       {
-           printf("Port: %s\n\n", port);
-           if ((res = getaddrinfo(ipAddress, port, &hints, &resAddr)) != 0)
-           {
-               fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(res));
-               res = 2;
-           }
-           else
-           {
-               // Because of inverted logic on return value
-               res = 1;
-           }
-       }
-
-    printf("IP addresses for %s:\n\n", ipAddress);
-
-    struct addrinfo *p;
-    char ipstr[INET6_ADDRSTRLEN];
-    for(p = resAddr;p != NULL; p = p->ai_next) {
-        void *addr;
-        char *ipver;
-
-        // get the pointer to the address itself,
-        // different fields in IPv4 and IPv6:
-        if (p->ai_family == AF_INET) { // IPv4
-            struct sockaddr_in *ipv4 = (struct sockaddr_in *)p->ai_addr;
-            addr = &(ipv4->sin_addr);
-            ipver = "IPv4";
-        } else { // IPv6
-            struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)p->ai_addr;
-            addr = &(ipv6->sin6_addr);
-            ipver = "IPv6";
-        }
-
-        // convert the IP to a string and print it:
-        inet_ntop(p->ai_family, addr, ipstr, sizeof ipstr);
-        printf("  %s: %s\n", ipver, ipstr);
-    }
-
-
-    if ((sClientFd = socket(resAddr->ai_family, resAddr->ai_socktype, resAddr->ai_protocol)) == -1) {
-        perror("socket");
-        exit(1);
-    }
-#endif
-
-    printf("Trying to connect...\n");
-
-#ifdef NPI_UNIX
-    remote.sun_family = AF_UNIX;
-    strcpy(remote.sun_path, ipAddress);
-    len = strlen(remote.sun_path) + sizeof(remote.sun_family);
-    if (connect(sClientFd, (struct sockaddr *)&remote, len) == -1) {
-        perror("connect");
-        res = 0;
-    }
-#else
-    if (connect(sClientFd, resAddr->ai_addr, resAddr->ai_addrlen) == -1) {
-        perror("connect");
-        res = 0;
-    }
-#endif
-
-    if (res == 1)
-       printf("Connected.\n");
-
-
-       int no = 0;
-       // allow out-of-band data
-       if (setsockopt(sClientFd, SOL_SOCKET, SO_OOBINLINE, &no, sizeof(int)) == -1)
-       {
-               perror("setsockopt");
-               res = 0;
-       }
-
-       /**********************************************************************
-        * Create thread which can read new messages from the NPI server
-        **********************************************************************/
-
-       if (pthread_create(&RTISThreadId, NULL, rxThreadFunc, NULL))
-       {
-               // thread creation failed
-               printf("Failed to create RTIS LNX IPC Client read thread\n");
-               return -1;
-       }
-
-       /**********************************************************************
-        * Create thread which can handle new messages from the NPI server
-        **********************************************************************/
-
-       if (pthread_create(&RTISThreadId, NULL, handleThreadFunc, NULL))
-       {
-               // thread creation failed
-               printf("Failed to create RTIS LNX IPC Client handle thread\n");
-               return -1;
-       }
-
-       return res;
-}
-
-static void *handleThreadFunc (void *ptr)
-{
-       int done = 0, tryLockFirstTimeOnly = 0;
-       
-       // Handle message from socket
-       do {
-
-    if (tryLockFirstTimeOnly == 0)
-               {
-                       // Lock mutex
-                       debug_printf("[MUTEX] Lock AREQ Mutex (Handle)\n");
-                       pthread_mutex_lock(&clientRxMutex);
-
-                       debug_printf("\n[MUTEX] AREQ Lock (Handle)\n");
-                       tryLockFirstTimeOnly = 1;
-               }
-               
-               // Conditional wait for the response handled in the Rx handling thread,
-               debug_printf("[MUTEX] Wait for Rx Cond (Handle) signal...\n");
-               pthread_cond_wait(&clientRxCond, &clientRxMutex);
-
-               debug_printf("[MUTEX] (Handle) has lock\n");
-
-               // Walk through all received AREQ messages before releasing MUTEX
-               linkedMsg *searchList = rxProcBuf, *clearList;
-               while (searchList != NULL)
-               {
-                       debug_printf("\n\n[DBG] Processing \t@ 0x%.16X next \t@ 0x%.16X\n",
-                                       (unsigned int)searchList,
-                                       (unsigned int)(searchList->nextMessage));
-
-      if( socketClientRxCb != NULL)
-      {
-                         debug_printf("[MUTEX] Calling socketClientRxCb (Handle)...\n");
-                         socketClientRxCb((msgData_t *)&(searchList->message));
-                       }
-
-                       debug_printf("[MUTEX] (Handle) (message @ 0x%.16X)...\n", (unsigned int)searchList);
-
-                       clearList = searchList;
-                       // Set search list to next message
-                       searchList = searchList->nextMessage;
-                       // Free processed buffer
-                       if (clearList == NULL)
-                       {
-                               // Impossible error, must abort
-                               done = 1;
-                               printf("[ERR] clearList buffer was already free\n");
-                               break;
-                       }
-                       else
-                       {
-                               messageCount--;
-                               debug_printf("[DBG] Clearing \t\t@ 0x%.16X (processed %d messages)...\n",
-                                               (unsigned int)clearList,
-                                               messageCount);
-                               memset(clearList, 0, sizeof(linkedMsg));                                
-                               free(clearList);                                                                
-                       }
-               }
-               debug_printf("[MUTEX] Signal message(s) handled (Handle) (processed %d messages)...\n", messageCount);
-
-               debug_printf("[DBG] Finished processing (processed %d messages)...\n",
-                               messageCount);
-
-       } while (!done);
-
-       return ptr;
-}
-
-static void *rxThreadFunc (void *ptr)
-{
-       int done = 0, n;
-
-       /* thread loop */
-
-       struct pollfd ufds[1];
-       int pollRet;
-       ufds[0].fd = sClientFd;
-       ufds[0].events = POLLIN | POLLPRI;
-
-       // Read from socket
-       do {
-               pollRet = poll((struct pollfd*)&ufds, 1, 1);
-               if (pollRet == -1)
-               {
-                       // Error occured in poll()
-                       perror("poll");
-               }
-               else if (pollRet == 0)
-               {
-                       // Timeout, could still be AREQ to process
-               }
-               else
-               {                 
-                       if (ufds[0].revents & POLLIN) {
-                               n = recv(sClientFd,
-                                               socketBuf[0],
-                                               SRPC_FRAME_HDR_SZ,
-                                               0); // normal data
-                       }
-                       if (ufds[0].revents & POLLPRI) {
-                               n = recv(sClientFd,
-                                               socketBuf[0],
-                                               SRPC_FRAME_HDR_SZ,
-                                               MSG_OOB); // out-of-band data
-                       }
-                       if (n <= 0)
-                       {
-                               if (n < 0)
-                                       perror("recv");
-                               done = 1;
-                       }
-                       else if (n == SRPC_FRAME_HDR_SZ)
-                       {
-                               // We have received the header, now read out length byte and process it
-                               n = recv(sClientFd,
-                                               (uint8_t*)&(socketBuf[0][SRPC_FRAME_HDR_SZ]),
-                                               ((msgData_t *)&(socketBuf[0][0]))->len,
-                                               0);
-                               if (n == ((msgData_t *)&(socketBuf[0][0]))->len)
-                               {
-                                       int i;
-                                       debug_printf("Received %d bytes,\t cmdId 0x%.2X, pData:\t",
-                                                       ((msgData_t *)&(socketBuf[0][0]))->len,
-                                                       ((msgData_t *)&(socketBuf[0][0]))->cmdId);
-                                       for (i = SRPC_FRAME_HDR_SZ; i < (n + SRPC_FRAME_HDR_SZ); i++)
-                                       {
-                                               debug_printf(" 0x%.2X", (uint8_t)socketBuf[0][i]);
-                                       }
-                                       debug_printf("\n");
-
-                               // Allocate memory for new message
-                                       linkedMsg *newMessage = (linkedMsg *) malloc(sizeof(linkedMsg));
-                                       
-                                       //debug_printf("Freeing new message (@ 0x%.16X)...\n", (unsigned int)newMessage);
-                                       //free(newMessage);
-                                       
-                                       if (newMessage == NULL)
-                                       {
-                                               // Serious error, must abort
-                                               done = 1;
-                                               printf("[ERR] Could not allocate memory for AREQ message\n");
-                                               break;
-                                       }
-                                       else
-                                       {
-                                               messageCount++;
-                                               memset(newMessage, 0, sizeof(linkedMsg));
-                                               debug_printf("\n[DBG] Allocated \t@ 0x%.16X (received\040 %d messages), size:%x...\n",
-                                                               (unsigned int)newMessage,
-                                                               messageCount,
-                                                               sizeof(linkedMsg));
-                                       }
-                                       
-                                       debug_printf("Filling new message (@ 0x%.16X)...\n", (unsigned int)newMessage);
-
-                                       // Copy AREQ message into AREQ buffer
-                                       memcpy(&(newMessage->message),
-                                                       (uint8_t*)&(socketBuf[0][0]),
-                                                       (((msgData_t *)&(socketBuf[0][0]))->len + SRPC_FRAME_HDR_SZ));
-
-                                       // Place message in read list
-                                       if (rxBuf == NULL)
-                                       {
-                                               // First message in list
-                                               rxBuf = newMessage;                             
-                                       }
-                                       else
-                                       {
-                                               linkedMsg *searchList = rxBuf;
-                                               // Find last entry and place it here
-                                               while (searchList->nextMessage != NULL)
-                                               {
-                                                       searchList = searchList->nextMessage;
-                                               }
-                                               searchList->nextMessage = newMessage;
-                                       }
-                               }
-                               else
-                               {
-                                       // Serious error
-                                       printf("ERR: Incoming Rx has incorrect length field; %d\n",
-                                                       ((msgData_t *)&(socketBuf[0][0]))->len);
-
-                                       debug_printf("[MUTEX] Unlock Rx Mutex (Read)\n");
-                                       // Then unlock the thread so the handle can handle the AREQ
-                                       pthread_mutex_unlock(&clientRxMutex);
-                               }
-                 }
-                 else
-                 {
-                       // Impossible. ... ;)
-                 }
-               }
-
-               // Handle thread must make sure it has finished its list. See if there are new messages to move over
-               if (rxBuf != NULL)
-               {
-                   pthread_mutex_lock(&clientRxMutex);
-                   
-                               // Move list over for processing
-                               rxProcBuf = rxBuf;                      
-                               
-                               // Clear receiving buffer for new messages
-                               rxBuf = NULL;
-
-                               debug_printf("[DBG] Copied message list (processed %d messages)...\n",
-                                               messageCount);
-                               
-                               debug_printf("[MUTEX] Unlock Mutex (Read)\n");
-                               // Then unlock the thread so the handle can handle the AREQ
-                               pthread_mutex_unlock(&clientRxMutex);
-                               
-                               debug_printf("[MUTEX] Signal message read (Read)...\n");
-                               // Signal to the handle thread an AREQ message is ready
-                               pthread_cond_signal(&clientRxCond);
-                               debug_printf("[MUTEX] Signal message read (Read)... sent\n");
-               }
-
-       } while (!done);
-
-
-       return ptr;
-}
-
-/* Initialize thread synchronization resources */
-static void initSyncRes(void)
-{
-  // initialize all mutexes
-  pthread_mutex_init(&clientRxMutex, NULL);
-
-  // initialize all conditional variables
-  pthread_cond_init(&clientRxCond, NULL);
-}
-
-/* Destroy thread synchronization resources */
-static void delSyncRes(void)
-{
-  // In Linux, there is no dynamically allocated resources
-  // and hence the following calls do not actually matter.
-
-  // destroy all conditional variables
-  pthread_cond_destroy(&clientRxCond);
-
-  // destroy all mutexes
-  pthread_mutex_destroy(&clientRxMutex);
-
-}
-
-/**************************************************************************************************
- *
- * @fn          socketClientClose
- *
- * @brief       This function stops RTI surrogate module
- *
- * input parameters
- *
- * None.
- *
- * output parameters
- *
- * None.
- *
- * @return      None.
- *
- **************************************************************************************************/
-void socketClientClose(void)
-{
-       // Close the NPI socket connection
-
-       close(sClientFd);
-
-       // Delete synchronization resources
-       delSyncRes();
-
-#ifndef NPI_UNIX
-       freeaddrinfo(resAddr); // free the linked-list
-#endif //NPI_UNIX
-
-}
-
-/**************************************************************************************************
- *
- * @fn          socketClientSendData
- *
- * @brief       This function sends a message asynchronously over the socket
- *
- * input parameters
- *
- * None.
- *
- * output parameters
- *
- * None.
- *
- * @return      None.
- *
- **************************************************************************************************/
-void socketClientSendData (msgData_t *pMsg)
-{
-       int i;
-       debug_printf("trying to send %d bytes,\t cmdId 0x%.2X, pData:",
-                       pMsg->len,
-                       pMsg->cmdId);
-       debug_printf("\t");
-       for (i = 0; i < pMsg->len; i++)
-       {
-               debug_printf(" 0x%.2X", pMsg->pData[i]);
-       }
-       debug_printf("\n");
-
-       if (send(sClientFd, ((uint8_t*)pMsg), pMsg->len + SRPC_FRAME_HDR_SZ , 0) == -1)
-       {
-               perror("send");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************
- **************************************************************************************************/
index bc486fe49c9b8b5a503da497c78a4d77dae010f2..9d175eb4ae912d12efb9d24e6ece8084959d1ccd 100755 (executable)
@@ -1,3 +1,41 @@
+/**************************************************************************************************
+ * Filename:       SimpleDB.c
+ * Description:    Simple Data Base
+ *
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ 
+ * 
+ * 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index f302968ae80c6568977cdfd77cbdce4368515444..7c4030c2dbf6bd386e4e83ca590bda50a7d0b009 100755 (executable)
@@ -1,3 +1,41 @@
+/**************************************************************************************************
+ * Filename:       SimpleDB.c
+ * Description:    Simple Data Base
+ *
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ 
+ * 
+ * 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
 #ifndef SIMPLE_DB_H
 #define SIMPLE_DB_H
 
index 02d64eedbf2e9ad3a2578e67f30d8479acbf091f..0c9fe8bba65f8191128c6c78106ce955efea01d9 100755 (executable)
@@ -1,4 +1,40 @@
-//This is a specific implemntation of a text-based db system, based on the SimpleDB module
+/**************************************************************************************************
+ * Filename:       SimpleDBTxt.c
+ * Description:    This is a specific implemntation of a text-based db system, based on the SimpleDB module.
+ *
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ 
+ * 
+ * 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
 
 #include <stdint.h>
 #include <string.h>
index e971fc4afc54b3de34ad17700997bfe89ae1e75b..84870f3071e84bab0b1df89b7bff2f9a8c03eb0a 100755 (executable)
@@ -1,3 +1,40 @@
+/**************************************************************************************************
+ * Filename:       SimpleDBTxt.h
+ * Description:    This is a specific implemntation of a text-based db system, based on the SimpleDB module.
+ *
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ 
+ * 
+ * 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
 #ifndef SIMPLE_DB_TXT_H
 #define SIMPLE_DB_TXT_H
 
diff --git a/server/Source/zllSocCmd-TH.c b/server/Source/zllSocCmd-TH.c
deleted file mode 100644 (file)
index 5391712..0000000
+++ /dev/null
@@ -1,473 +0,0 @@
-/*
- * zllSocCmd.c
- *
- * This module contains the API for the zll SoC Host Interface.
- *
- * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ 
- * 
- * 
- *  Redistribution and use in source and binary forms, with or without 
- *  modification, are permitted provided that the following conditions 
- *  are met:
- *
- *    Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer.
- *
- *    Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the 
- *    documentation and/or other materials provided with the   
- *    distribution.
- *
- *    Neither the name of Texas Instruments Incorporated nor the names of
- *    its contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
- *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
- *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
- *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-
-/*********************************************************************
- * INCLUDES
- */
-#include <termios.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-
-#include "zllSocCmd.h"
-
-
-/*********************************************************************
- * MACROS
- */
-
-/*********************************************************************
- * CONSTANTS
- */
-#define MAX_CONSOLE_CMD_LEN 128
-
-/************************************************************
- * TYPEDEFS
- */
-
-/*********************************************************************
- * GLOBAL VARIABLES
- */
-static uint16_t savedNwkAddr;    
-static uint8_t savedAddrMode;    
-static uint8_t savedEp;    
-static uint8_t savedValue;    
-static uint16_t savedTransitionTime; 
-static uint16_t savedDeviceId;
-static  uint16_t savedProfileId;  
-
-/*********************************************************************
- * LOCAL VARIABLES
- */
-zllSocCallbacks_t zllSocCb;
-
-/*********************************************************************
- * LOCAL FUNCTIONS
- */
-void commandUsage( void );
-void processConsoleCommand( void );
-void getConsoleCommandParams(char* cmdBuff, uint16_t *nwkAddr, uint16_t *deviceId, uint16_t *profileId, uint8_t *addrMode, uint8_t *ep, uint8_t *value, uint16_t *transitionTime);
-uint32_t getParam( char *cmdBuff, char *paramId, uint32_t *paramInt);
-
-/*********************************************************************
- * API FUNCTIONS
- */
-/*********************************************************************
- * @fn      zllSocOpen
- *
- * @brief   opens the serial port to the CC253x.
- *
- * @param   devicePath - path to the UART device
- *
- * @return  status
- */
-int32_t zllSocOpen( char *devicePath  )
-{
-  //do nothing, TH is going to read command from stdin to simulate a zll device  
-  return 0;
-}
-
-void zllSocClose( void )
-{
-  return;
-}
-
-/*********************************************************************
- * @fn      zllSocOpen
- *
- * @brief   opens the serial port to the CC253x.
- *
- * @param   devicePath - path to the UART device
- *
- * @return  status
- */
-void zllSocRegisterCallbacks( zllSocCallbacks_t zllSocCallbacks)
-{
-  //copy the callback function pointers
-  memcpy(&zllSocCb, &zllSocCallbacks, sizeof(zllSocCallbacks_t));
-  return;  
-}
-
-
-/*********************************************************************
- * @fn      zllSocTouchLink
- *
- * @brief   Send the touchLink command to the CC253x.
- *
- * @param   none
- *
- * @return  none
- */
-void zllSocTouchLink(void)
-{  
-}
-
-
-/*********************************************************************
- * @fn      zllSocResetToFn
- *
- * @brief   Send the reset to factory new command to the CC253x.
- *
- * @param   none
- *
- * @return  none
- */
-void zllSocResetToFn(void)
-{  
-}
-
-/*********************************************************************
- * @fn      zllSocSendResetToFn
- *
- * @brief   Send the reset to factory new command to a ZLL device.
- *
- * @param   none
- *
- * @return  none
- */
-void zllSocSendResetToFn(void)
-{  
-}
-
-/*********************************************************************
- * @fn      zllSocSetState
- *
- * @brief   Send the on/off command to a ZLL light.
- *
- * @param   state - 0: Off, 1: On.
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be controled.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocSetState(uint8_t state, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{
-}
-
-/*********************************************************************
- * @fn      zllSocSetLevel
- *
- * @brief   Send the level command to a ZLL light.
- *
- * @param   level - 0-128 = 0-100%
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be controled.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocSetLevel(uint8_t level, uint16_t time, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{
-}
-
-/*********************************************************************
- * @fn      zllSocSetHue
- *
- * @brief   Send the hue command to a ZLL light.
- *
- * @param   hue - 0-128 represent the 360Deg hue color wheel : 0=red, 42=blue, 85=green  
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be controled.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocSetHue(uint8_t hue, uint16_t time, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{
-}
-
-/*********************************************************************
- * @fn      zllSocSetSat
- *
- * @brief   Send the satuartion command to a ZLL light.
- *
- * @param   sat - 0-128 : 0=white, 128: fully saturated color  
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be controled.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocSetSat(uint8_t sat, uint16_t time, uint16_t dstAddr, uint8_t  endpoint, uint8_t addrMode)
-{
-}
-
-/*********************************************************************
- * @fn      zllSocSetHueSat
- *
- * @brief   Send the hue and satuartion command to a ZLL light.
- *
- * @param   hue - 0-128 represent the 360Deg hue color wheel : 0=red, 42=blue, 85=green  
- * @param   sat - 0-128 : 0=white, 128: fully saturated color  
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be controled.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocSetHueSat(uint8_t hue, uint8_t sat, uint16_t time, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{
-}
-
-/*********************************************************************
- * @fn      zllSocGetState
- *
- * @brief   Send the get state command to a ZLL light.
- *
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be sent the command.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocGetState(uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{        
-} 
-/*********************************************************************
- * @fn      zllSocGetLevel
- *
- * @brief   Send the get level command to a ZLL light.
- *
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be sent the command.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocGetLevel(uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{
-} 
-
-/*********************************************************************
- * @fn      zllSocGetHue
- *
- * @brief   Send the get hue command to a ZLL light.
- *
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be sent the command.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocGetHue(uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{
-} 
-
-/*********************************************************************
- * @fn      zllSocGetSat
- *
- * @brief   Send the get saturation command to a ZLL light.
- *
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be sent the command.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocGetSat(uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{
-} 
-
-/*************************************************************************************************
- * @fn      zllSocProcessRpc()
- *
- * @brief   read and process the RPC from the ZLL controller
- *
- * @param   none
- *
- * @return  length of current Rx Buffer
- *************************************************************************************************/
-void zllSocProcessRpc (void)
-{      
-  char cmdBuff[MAX_CONSOLE_CMD_LEN];
-  uint32_t bytesRead;      
-  uint16_t nwkAddr;
-  uint16_t deviceId;
-  uint16_t profileId;    
-  uint8_t addrMode;
-  uint8_t endpoint;
-  uint8_t value;
-  uint16_t transitionTime;
-    
-  //read stdin
-  bytesRead = read(0, cmdBuff, (MAX_CONSOLE_CMD_LEN-1));    
-  cmdBuff[bytesRead] = '\0';  
-  
-  getConsoleCommandParams(cmdBuff, &nwkAddr, &deviceId, &profileId, &addrMode, &endpoint, &value, &transitionTime);   
-     
-  if((strstr(cmdBuff, "touchlink")) != 0)
-  {      
-    printf("processRpcSysAppTlInd: %x:%x:%x:%x\n",  nwkAddr, endpoint, deviceId, profileId);
-    if(zllSocCb.pfnTlIndicationCb)
-    {
-      epInfo_t epInfo;
-      epInfo.nwkAddr = nwkAddr;
-      epInfo.endpoint = endpoint;
-      epInfo.deviceID = deviceId;
-      epInfo.profileID = profileId;      
-      zllSocCb.pfnTlIndicationCb(&epInfo);
-    }    
-  }    
-  return; 
-}
-
-void getConsoleCommandParams(char* cmdBuff, uint16_t *nwkAddr, uint16_t *deviceId, uint16_t *profileId, uint8_t *addrMode, uint8_t *ep, uint8_t *value, uint16_t *transitionTime)
-{ 
-  //set some default values
-  uint32_t tmpInt;     
-  
-  if( getParam( cmdBuff, "-n", &tmpInt) )
-  {
-    savedNwkAddr = (uint16_t) tmpInt;
-  }
-  if( getParam( cmdBuff, "-d", &tmpInt) )
-  {
-    savedDeviceId = (uint16_t) tmpInt;
-  }
-  if( getParam( cmdBuff, "-p", &tmpInt) )
-  {
-    savedProfileId = (uint16_t) tmpInt;
-  }    
-  if( getParam( cmdBuff, "-m", &tmpInt) )
-  {
-    savedAddrMode = (uint8_t) tmpInt;
-  }
-  if( getParam( cmdBuff, "-e", &tmpInt) )
-  {
-    savedEp = (uint8_t) tmpInt;
-  }
-  if( getParam( cmdBuff, "-v", &tmpInt) )
-  {
-    savedValue = (uint8_t) tmpInt;
-  }
-  if( getParam( cmdBuff, "-t", &tmpInt) )
-  {
-    savedTransitionTime = (uint16_t) tmpInt;
-  }        
-        
-  *nwkAddr = savedNwkAddr;    
-  *addrMode = savedAddrMode;    
-  *ep = savedEp;    
-  *value = savedValue;    
-  *transitionTime = savedTransitionTime;
-  *deviceId = savedDeviceId;
-  *profileId = savedProfileId;
-
-  return;         
-}
-
-uint32_t getParam( char *cmdBuff, char *paramId, uint32_t *paramInt)
-{
-  char* paramStrStart;
-  char* paramStrEnd;
-  //0x1234+null termination
-  char paramStr[7];    
-  uint32_t rtn = 0;
-  
-  memset(paramStr, 0, sizeof(paramStr));  
-  paramStrStart = strstr(cmdBuff, paramId);
-  
-  if( paramStrStart )
-  {
-    //index past the param idenentifier "-?"
-    paramStrStart+=2;
-    //find the the end of the param text
-    paramStrEnd = strstr(paramStrStart, " ");
-    if( paramStrEnd )
-    {
-      if(paramStrEnd-paramStrStart > (sizeof(paramStr)-1))
-      {
-        //we are not on the last param, but the param str is too long
-        strncpy( paramStr, paramStrStart, (sizeof(paramStr)-1));
-        paramStr[sizeof(paramStr)-1] = '\0';  
-      }
-      else
-      {
-        //we are not on the last param so use the " " as the delimiter
-        strncpy( paramStr, paramStrStart, paramStrEnd-paramStrStart);
-        paramStr[paramStrEnd-paramStrStart] = '\0'; 
-      }
-    }
-    
-    else
-    {
-      //we are on the last param so use the just go the the end of the string 
-      //(which will be null terminate). But make sure that it is not bigger
-      //than our paramStr buffer. 
-      if(strlen(paramStrStart) > (sizeof(paramStr)-1))
-      {
-        //command was entered wrong and paramStrStart will over flow the 
-        //paramStr buffer.
-        strncpy( paramStr, paramStrStart, (sizeof(paramStr)-1));
-        paramStr[sizeof(paramStr)-1] = '\0';
-      }
-      else
-      {
-        //Param is the correct size so just copy it.
-        strcpy( paramStr, paramStrStart);
-        paramStr[strlen(paramStrStart)-1] = '\0';
-      }
-    }
-    
-    //was the param in hex or dec?
-    if(strstr(paramStr, "0x"))   
-    {
-      //convert the hex value to an int.
-      sscanf(paramStr, "0x%x", paramInt);
-    }
-    else
-    {
-      //assume that it ust be dec and convert to int.
-      sscanf(paramStr, "%d", paramInt);
-    }         
-    
-    //paramInt was set
-    rtn = 1;
-         
-  }  
-    
-  return rtn;
-}
-
diff --git a/server/Source/zllSocCmd.c b/server/Source/zllSocCmd.c
deleted file mode 100644 (file)
index b0fd2f8..0000000
+++ /dev/null
@@ -1,1341 +0,0 @@
-/*
- * zllSocCmd.c
- *
- * This module contains the API for the zll SoC Host Interface.
- *
- * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ 
- * 
- * 
- *  Redistribution and use in source and binary forms, with or without 
- *  modification, are permitted provided that the following conditions 
- *  are met:
- *
- *    Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer.
- *
- *    Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the 
- *    documentation and/or other materials provided with the   
- *    distribution.
- *
- *    Neither the name of Texas Instruments Incorporated nor the names of
- *    its contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
- *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
- *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
- *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-
-/*********************************************************************
- * INCLUDES
- */
-#include <termios.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-
-#include <errno.h>
-#include <string.h>
-
-#include "zllSocCmd.h"
-
-
-/*********************************************************************
- * MACROS
- */
-
-#define APPCMDHEADER(len) \
-0xFE,                                                                             \
-len,   /*RPC payload Len                                      */     \
-0x29, /*MT_RPC_CMD_AREQ + MT_RPC_SYS_APP        */     \
-0x00, /*MT_APP_MSG                                                   */     \
-0x0B, /*Application Endpoint                                  */     \
-0x02, /*short Addr 0x0002                                     */     \
-0x00, /*short Addr 0x0002                                     */     \
-0x0B, /*Dst EP                                                             */     \
-0xFF, /*Cluster ID 0xFFFF invalid, used for key */     \
-0xFF, /*Cluster ID 0xFFFF invalid, used for key */     \
-
-#define BUILD_UINT16(loByte, hiByte) \
-          ((uint16_t)(((loByte) & 0x00FF) + (((hiByte) & 0x00FF) << 8)))
-          
-#define BUILD_UINT32(Byte0, Byte1, Byte2, Byte3) \
-          ((uint32_t)((uint32_t)((Byte0) & 0x00FF) \
-          + ((uint32_t)((Byte1) & 0x00FF) << 8) \
-          + ((uint32_t)((Byte2) & 0x00FF) << 16) \
-          + ((uint32_t)((Byte3) & 0x00FF) << 24)))
-          
-/*********************************************************************
- * CONSTANTS
- */
-#define ZLL_MT_APP_RPC_CMD_TOUCHLINK          0x01
-#define ZLL_MT_APP_RPC_CMD_RESET_TO_FN        0x02
-#define ZLL_MT_APP_RPC_CMD_CH_CHANNEL         0x03
-#define ZLL_MT_APP_RPC_CMD_JOIN_HA            0x04
-#define ZLL_MT_APP_RPC_CMD_PERMIT_JOIN        0x05
-#define ZLL_MT_APP_RPC_CMD_SEND_RESET_TO_FN   0x06
-
-#define MT_APP_RSP                           0x80
-#define MT_APP_ZLL_TL_IND                    0x81
-#define MT_APP_ZLL_NEW_DEV_IND               0x82
-
-#define MT_DEBUG_MSG                         0x80
-
-#define COMMAND_LIGHTING_MOVE_TO_HUE  0x00
-#define COMMAND_LIGHTING_MOVE_TO_SATURATION 0x03
-#define COMMAND_LEVEL_MOVE_TO_LEVEL 0x00
-
-/*** Foundation Command IDs ***/
-#define ZCL_CMD_READ                                    0x00
-#define ZCL_CMD_READ_RSP                                0x01
-#define ZCL_CMD_WRITE                                   0x02
-#define ZCL_CMD_WRITE_UNDIVIDED                         0x03
-#define ZCL_CMD_WRITE_RSP                               0x04
-
-// General Clusters
-#define ZCL_CLUSTER_ID_GEN_IDENTIFY                          0x0003
-#define ZCL_CLUSTER_ID_GEN_GROUPS                            0x0004
-#define ZCL_CLUSTER_ID_GEN_SCENES                            0x0005
-#define ZCL_CLUSTER_ID_GEN_ON_OFF                            0x0006
-#define ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL                     0x0008
-// Lighting Clusters
-#define ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL                0x0300
-
-// Data Types
-#define ZCL_DATATYPE_BOOLEAN                            0x10
-#define ZCL_DATATYPE_UINT8                              0x20
-#define ZCL_DATATYPE_INT16                              0x29
-#define ZCL_DATATYPE_INT24                              0x2a
-
-/*******************************/
-/*** Generic Cluster ATTR's  ***/
-/*******************************/
-#define ATTRID_ON_OFF                                     0x0000
-#define ATTRID_LEVEL_CURRENT_LEVEL                        0x0000
-
-/*******************************/
-/*** Lighting Cluster ATTR's  ***/
-/*******************************/
-#define ATTRID_LIGHTING_COLOR_CONTROL_CURRENT_HUE         0x0000
-#define ATTRID_LIGHTING_COLOR_CONTROL_CURRENT_SATURATION  0x0001
-
-
-/*******************************/
-/*** Scenes Cluster Commands ***/
-/*******************************/
-#define COMMAND_SCENE_STORE                               0x04
-#define COMMAND_SCENE_RECALL                              0x05
-
-/*******************************/
-/*** Groups Cluster Commands ***/
-/*******************************/
-#define COMMAND_GROUP_ADD                                 0x00
-
-/* The 3 MSB's of the 1st command field byte are for command type. */
-#define MT_RPC_CMD_TYPE_MASK  0xE0
-
-/* The 5 LSB's of the 1st command field byte are for the subsystem. */
-#define MT_RPC_SUBSYSTEM_MASK 0x1F
-
-#define MT_RPC_SOF         0xFE
-
-/*******************************/
-/*** Bootloader Commands ***/
-/*******************************/
-#define SB_FORCE_BOOT               0xF8
-#define SB_FORCE_RUN               (SB_FORCE_BOOT ^ 0xFF)
-
-typedef enum {
-  MT_RPC_CMD_POLL = 0x00,
-  MT_RPC_CMD_SREQ = 0x20,
-  MT_RPC_CMD_AREQ = 0x40,
-  MT_RPC_CMD_SRSP = 0x60,
-  MT_RPC_CMD_RES4 = 0x80,
-  MT_RPC_CMD_RES5 = 0xA0,
-  MT_RPC_CMD_RES6 = 0xC0,
-  MT_RPC_CMD_RES7 = 0xE0
-} mtRpcCmdType_t;
-
-typedef enum {
-  MT_RPC_SYS_RES0,   /* Reserved. */
-  MT_RPC_SYS_SYS,
-  MT_RPC_SYS_MAC,
-  MT_RPC_SYS_NWK,
-  MT_RPC_SYS_AF,
-  MT_RPC_SYS_ZDO,
-  MT_RPC_SYS_SAPI,   /* Simple API. */
-  MT_RPC_SYS_UTIL,
-  MT_RPC_SYS_DBG,
-  MT_RPC_SYS_APP,
-  MT_RPC_SYS_OTA,
-  MT_RPC_SYS_ZNP,
-  MT_RPC_SYS_SPARE_12,
-  MT_RPC_SYS_UBL = 13,  // 13 to be compatible with existing RemoTI.
-  MT_RPC_SYS_MAX        // Maximum value, must be last (so 14-32 available, not yet assigned).
-} mtRpcSysType_t;
-
-/************************************************************
- * TYPEDEFS
- */
-
-/*********************************************************************
- * GLOBAL VARIABLES
- */
-
-/*********************************************************************
- * LOCAL VARIABLES
- */
-int serialPortFd = 0;
-uint8_t transSeqNumber = 0;
-
-zllSocCallbacks_t zllSocCb;
-
-/*********************************************************************
- * LOCAL FUNCTIONS
- */
-void calcFcs(uint8_t *msg, int size);
-static void processRpcSysAppTlInd(uint8_t *TlIndBuff);
-static void processRpcSysAppNewDevInd(uint8_t *TlIndBuff);
-static void processRpcSysAppZcl(uint8_t *zclRspBuff);
-static void processRpcSysAppZclFoundation(uint8_t *zclRspBuff, uint8_t zclFrameLen, uint16_t clusterID, uint16_t nwkAddr, uint8_t endpoint);
-static void processRpcSysApp(uint8_t *rpcBuff);
-static void processRpcSysDbg(uint8_t *rpcBuff);
-
-/*********************************************************************
- * @fn      calcFcs
- *
- * @brief   populates the Frame Check Sequence of the RPC payload.
- *
- * @param   msg - pointer to the RPC message
- *
- * @return  none
- */
-void calcFcs(uint8_t *msg, int size)
-{
-       uint8_t result = 0;
-       int idx = 1; //skip SOF
-       int len = (size - 1);  // skip FCS
-       
-       while ((len--) != 0) {
-               result ^= msg[idx++];
-       }
-       
-       msg[(size-1)] = result;
-}
-
-/*********************************************************************
- * API FUNCTIONS
- */
-/*********************************************************************
- * @fn      zllSocOpen
- *
- * @brief   opens the serial port to the CC253x.
- *
- * @param   devicePath - path to the UART device
- *
- * @return  status
- */
-int32_t zllSocOpen( char *devicePath  )
-{
-  struct termios tio;
-
-  /* open the device to be non-blocking (read will return immediatly) */
-  serialPortFd = open(devicePath, O_RDWR | O_NOCTTY | O_NONBLOCK);
-  if (serialPortFd <0) 
-  {
-    perror(devicePath); 
-    printf("%s open failed\n",devicePath);
-    return(-1);
-  }
-  
-  //make the access exclusive so other instances will return -1 and exit
-  ioctl(serialPortFd, TIOCEXCL);
-
-  /* c-iflags
-     B115200 : set board rate to 115200
-     CRTSCTS : HW flow control (disabled below)
-     CS8     : 8n1 (8bit,no parity,1 stopbit)
-     CLOCAL  : local connection, no modem contol
-     CREAD   : enable receiving characters*/
-  tio.c_cflag = B38400 | CRTSCTS | CS8 | CLOCAL | CREAD;
-  /* c-iflags
-     ICRNL   : maps 0xD (CR) to 0x10 (LR), we do not want this.
-     IGNPAR  : ignore bits with parity erros, I guess it is 
-     better to ignStateore an erronious bit then interprit it incorrectly. */
-  tio.c_iflag = IGNPAR  & ~ICRNL; 
-  tio.c_oflag = 0;
-  tio.c_lflag = 0;
-
-  tcflush(serialPortFd, TCIFLUSH);
-  tcsetattr(serialPortFd,TCSANOW,&tio);
-  
-  //Send the bootloader force boot incase we have a bootloader that waits
-  uint8_t forceBoot = SB_FORCE_RUN;
-  write(serialPortFd,&forceBoot, 1);
-  tcflush(serialPortFd, TCOFLUSH);  
-  
-  return serialPortFd;
-}
-
-void zllSocClose( void )
-{
-  tcflush(serialPortFd, TCOFLUSH);
-  close(serialPortFd);
-
-  return;
-}
-
-/*********************************************************************
- * @fn      zllSocRegisterCallbacks
- *
- * @brief   opens the serial port to the CC253x.
- *
- * @param   devicePath - path to the UART device
- *
- * @return  status
- */
-void zllSocRegisterCallbacks( zllSocCallbacks_t zllSocCallbacks)
-{
-  //copy the callback function pointers
-  memcpy(&zllSocCb, &zllSocCallbacks, sizeof(zllSocCallbacks_t));
-  return;  
-}
-
-
-/*********************************************************************
- * @fn      zllSocTouchLink
- *
- * @brief   Send the touchLink command to the CC253x.
- *
- * @param   none
- *
- * @return  none
- */
-void zllSocTouchLink(void)
-{  
-       uint8_t tlCmd[] = {
-               APPCMDHEADER(13)
-               0x06, //Data Len
-               0x02, //Address Mode
-               0x00, //2dummy bytes
-               0x00,
-               ZLL_MT_APP_RPC_CMD_TOUCHLINK,
-               0x00,     //
-               0x00,     //
-               0x00       //FCS - fill in later
-    };
-         
-    calcFcs(tlCmd, sizeof(tlCmd));
-    write(serialPortFd,tlCmd, sizeof(tlCmd));
-    tcflush(serialPortFd, TCOFLUSH);   
-}
-
-/*********************************************************************
- * @fn      zllSocResetToFn
- *
- * @brief   Send the reset to factory new command to the CC253x.
- *
- * @param   none
- *
- * @return  none
- */
-void zllSocResetToFn(void)
-{  
-       uint8_t tlCmd[] = {
-               APPCMDHEADER(13)
-               0x06, //Data Len
-               0x02, //Address Mode
-               0x00, //2dummy bytes
-               0x00,
-               ZLL_MT_APP_RPC_CMD_RESET_TO_FN,
-               0x00,     //
-               0x00,     //
-               0x00       //FCS - fill in later
-    };
-         
-    calcFcs(tlCmd, sizeof(tlCmd));
-    write(serialPortFd,tlCmd, sizeof(tlCmd));
-    tcflush(serialPortFd, TCOFLUSH);   
-}
-
-/*********************************************************************
- * @fn      zllSocSendResetToFn
- *
- * @brief   Send the reset to factory new command to a ZLL device.
- *
- * @param   none
- *
- * @return  none
- */
-void zllSocSendResetToFn(void)
-{  
-       uint8_t tlCmd[] = {
-               APPCMDHEADER(13)
-               0x06, //Data Len
-               0x02, //Address Mode
-               0x00, //2dummy bytes
-               0x00,
-               ZLL_MT_APP_RPC_CMD_SEND_RESET_TO_FN,
-               0x00,     //
-               0x00,     //
-               0x00       //FCS - fill in later
-    };
-         
-    calcFcs(tlCmd, sizeof(tlCmd));
-    write(serialPortFd,tlCmd, sizeof(tlCmd));
-    tcflush(serialPortFd, TCOFLUSH);   
-}
-
-/*********************************************************************
- * @fn      zllSocOpenNwk
- *
- * @brief   Send the open network command to a ZLL device.
- *
- * @param   none
- *
- * @return  none
- */
-void zllSocOpenNwk(void)
-{  
-       uint8_t cmd[] = {
-               APPCMDHEADER(13)
-               0x06, //Data Len
-               0x02, //Address Mode
-               0x00, //2dummy bytes
-               0x00,
-               ZLL_MT_APP_RPC_CMD_PERMIT_JOIN,
-               60, // open for 60s
-               1,  // open all devices
-               0x00  //FCS - fill in later
-    };
-         
-    calcFcs(cmd, sizeof(cmd));
-    write(serialPortFd,cmd, sizeof(cmd));
-    tcflush(serialPortFd, TCOFLUSH);   
-}
-
-/*********************************************************************
- * @fn      zllSocSetState
- *
- * @brief   Send the on/off command to a ZLL light.
- *
- * @param   state - 0: Off, 1: On.
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be controled.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocSetState(uint8_t state, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{
-       uint8_t cmd[] = {
-               0xFE,                                                                                      
-               11,   /*RPC payload Len */          
-               0x29, /*MT_RPC_CMD_AREQ + MT_RPC_SYS_APP */          
-               0x00, /*MT_APP_MSG  */          
-               0x0B, /*Application Endpoint */          
-               (dstAddr & 0x00ff),
-               (dstAddr & 0xff00) >> 8,
-               endpoint, /*Dst EP */          
-               (ZCL_CLUSTER_ID_GEN_ON_OFF & 0x00ff),
-               (ZCL_CLUSTER_ID_GEN_ON_OFF & 0xff00) >> 8,
-               0x04, //Data Len
-               addrMode, 
-               0x01, //0x01 ZCL frame control field.  (send to the light cluster only)
-               transSeqNumber++,
-               (state ? 1:0),
-               0x00       //FCS - fill in later
-       };
-      
-       calcFcs(cmd, sizeof(cmd));
-       
-    write(serialPortFd,cmd,sizeof(cmd));
-    tcflush(serialPortFd, TCOFLUSH);
-}
-
-/*********************************************************************
- * @fn      zllSocSetLevel
- *
- * @brief   Send the level command to a ZLL light.
- *
- * @param   level - 0-128 = 0-100%
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be controled.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocSetLevel(uint8_t level, uint16_t time, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{
-       uint8_t cmd[] = {
-               0xFE,                                                                                                                                                                                    
-               14,   //RPC payload Len
-               0x29, //MT_RPC_CMD_AREQ + MT_RPC_SYS_APP
-               0x00, //MT_APP_MSG
-               0x0B, //Application Endpoint
-               (dstAddr & 0x00ff),
-               (dstAddr & 0xff00) >> 8,
-               endpoint, //Dst EP
-               (ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL & 0x00ff),
-               (ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL & 0xff00) >> 8,      
-               0x07, //Data Len
-               addrMode, 
-               0x01, //0x01 ZCL frame control field.  (send to the light cluster only)
-               transSeqNumber++,
-               COMMAND_LEVEL_MOVE_TO_LEVEL,
-               (level & 0xff),
-               (time & 0xff),
-               (time & 0xff00) >> 8,
-               0x00       //FCS - fill in later
-       };    
-    
-    calcFcs(cmd, sizeof(cmd));
-    
-    write(serialPortFd,cmd,sizeof(cmd));
-    tcflush(serialPortFd, TCOFLUSH);
-}
-
-/*********************************************************************
- * @fn      zllSocSetHue
- *
- * @brief   Send the hue command to a ZLL light.
- *
- * @param   hue - 0-128 represent the 360Deg hue color wheel : 0=red, 42=blue, 85=green  
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be controled.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocSetHue(uint8_t hue, uint16_t time, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{
-       uint8_t cmd[] = {
-               0xFE,                                                                                                                                                                                    
-               15,   //RPC payload Len          
-               0x29, //MT_RPC_CMD_AREQ + MT_RPC_SYS_APP          
-               0x00, //MT_APP_MSG          
-               0x0B, //Application Endpoint          
-               (dstAddr & 0x00ff),
-               (dstAddr & 0xff00) >> 8,
-               endpoint, //Dst EP
-               (ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL & 0x00ff),
-               (ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL & 0xff00) >> 8,                     
-               0x08, //Data Len
-               addrMode, 
-               0x01, //0x01 ZCL frame control field.  (send to the light cluster only)
-               transSeqNumber++,
-               COMMAND_LIGHTING_MOVE_TO_HUE,
-               (hue & 0xff),
-               0x00, //Move with shortest distance
-               (time & 0xff),
-               (time & 0xff00) >> 8,
-               0x00       //FCS - fill in later
-       };    
-
-  calcFcs(cmd, sizeof(cmd));
-  write(serialPortFd,cmd,sizeof(cmd));
-  tcflush(serialPortFd, TCOFLUSH);
-}
-
-/*********************************************************************
- * @fn      zllSocSetSat
- *
- * @brief   Send the satuartion command to a ZLL light.
- *
- * @param   sat - 0-128 : 0=white, 128: fully saturated color  
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be controled.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocSetSat(uint8_t sat, uint16_t time, uint16_t dstAddr, uint8_t  endpoint, uint8_t addrMode)
-{
-  uint8_t cmd[] = {
-               0xFE,                                                                                                                                                                                    
-               14,   //RPC payload Len          
-               0x29, //MT_RPC_CMD_AREQ + MT_RPC_SYS_APP         
-               0x00, //MT_APP_MSG          
-               0x0B, //Application Endpoint          
-               (dstAddr & 0x00ff),
-               (dstAddr & 0xff00) >> 8,
-               endpoint, //Dst EP         
-       (ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL & 0x00ff),
-       (ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL & 0xff00) >> 8,
-               0x07, //Data Len
-               addrMode, 
-               0x01, //0x01 ZCL frame control field.  (send to the light cluster only)
-    transSeqNumber++,
-               COMMAND_LIGHTING_MOVE_TO_SATURATION,
-               (sat & 0xff),
-               (time & 0xff),
-               (time & 0xff00) >> 8,
-               0x00       //FCS - fill in later
-       };
-       
-       calcFcs(cmd, sizeof(cmd));
-  write(serialPortFd,cmd,sizeof(cmd));
-  tcflush(serialPortFd, TCOFLUSH);
-}
-
-/*********************************************************************
- * @fn      zllSocSetHueSat
- *
- * @brief   Send the hue and satuartion command to a ZLL light.
- *
- * @param   hue - 0-128 represent the 360Deg hue color wheel : 0=red, 42=blue, 85=green  
- * @param   sat - 0-128 : 0=white, 128: fully saturated color  
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be controled.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocSetHueSat(uint8_t hue, uint8_t sat, uint16_t time, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{
-       uint8_t cmd[] = { 
-               0xFE, 
-               15, //RPC payload Len
-               0x29, //MT_RPC_CMD_AREQ + MT_RPC_SYS_APP
-               0x00, //MT_APP_MSG
-               0x0B, //Application Endpoint         
-               (dstAddr & 0x00ff),
-               (dstAddr & 0xff00) >> 8,
-               endpoint, //Dst EP
-       (ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL & 0x00ff),
-       (ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL & 0xff00) >> 8,
-               0x08, //Data Len
-    addrMode,
-               0x01, //ZCL Header Frame Control
-               transSeqNumber++,
-               0x06, //ZCL Header Frame Command (COMMAND_LEVEL_MOVE_TO_HUE_AND_SAT)
-               hue, //HUE - fill it in later
-               sat, //SAT - fill it in later
-               (time & 0xff),
-               (time & 0xff00) >> 8,
-               0x00 //fcs
-  }; 
-
-  calcFcs(cmd, sizeof(cmd));
-  write(serialPortFd,cmd,sizeof(cmd));
-  tcflush(serialPortFd, TCOFLUSH);        
-}
-
-/*********************************************************************
- * @fn      zllSocAddGroup
- *
- * @brief   Add Group.
- *
- * @param   groupId - Group ID of the Scene.
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be controled.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast. 
- *
- * @return  none
- */
-void zllSocAddGroup(uint16_t groupId, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{  
-       uint8_t cmd[] = {
-               0xFE,                                                                                      
-               14,   /*RPC payload Len */          
-               0x29, /*MT_RPC_CMD_AREQ + MT_RPC_SYS_APP */          
-               0x00, /*MT_APP_MSG  */          
-               0x0B, /*Application Endpoint */          
-               (dstAddr & 0x00ff),
-               (dstAddr & 0xff00) >> 8,
-               endpoint, /*Dst EP */          
-               (ZCL_CLUSTER_ID_GEN_GROUPS & 0x00ff),
-               (ZCL_CLUSTER_ID_GEN_GROUPS & 0xff00) >> 8,
-               0x07, //Data Len
-               addrMode, 
-               0x01, //0x01 ZCL frame control field.  (send to the light cluster only)
-               transSeqNumber++,
-               COMMAND_GROUP_ADD,
-               (groupId & 0x00ff),
-               (groupId & 0xff00) >> 8, 
-               0, //Null group name - Group Name not pushed to the devices     
-               0x00       //FCS - fill in later
-       };
-       
-       printf("zllSocAddGroup: dstAddr 0x%x\n", dstAddr);
-    
-       calcFcs(cmd, sizeof(cmd));
-       
-  write(serialPortFd,cmd,sizeof(cmd));
-  tcflush(serialPortFd, TCOFLUSH);
-}
-
-/*********************************************************************
- * @fn      zllSocStoreScene
- *
- * @brief   Store Scene.
- * 
- * @param   groupId - Group ID of the Scene.
- * @param   sceneId - Scene ID of the Scene.
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be controled.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast. 
- *
- * @return  none
- */
-void zllSocStoreScene(uint16_t groupId, uint8_t sceneId, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{  
-       uint8_t cmd[] = {
-               0xFE,                                                                                      
-               14,   /*RPC payload Len */          
-               0x29, /*MT_RPC_CMD_AREQ + MT_RPC_SYS_APP */          
-               0x00, /*MT_APP_MSG  */          
-               0x0B, /*Application Endpoint */          
-               (dstAddr & 0x00ff),
-               (dstAddr & 0xff00) >> 8,
-               endpoint, /*Dst EP */          
-               (ZCL_CLUSTER_ID_GEN_SCENES & 0x00ff),
-               (ZCL_CLUSTER_ID_GEN_SCENES & 0xff00) >> 8,
-               0x07, //Data Len
-               addrMode, 
-               0x01, //0x01 ZCL frame control field.  (send to the light cluster only)
-               transSeqNumber++,
-               COMMAND_SCENE_STORE,
-               (groupId & 0x00ff),
-               (groupId & 0xff00) >> 8,        
-               sceneId++,      
-               0x00       //FCS - fill in later
-       };
-    
-       calcFcs(cmd, sizeof(cmd));
-       
-  write(serialPortFd,cmd,sizeof(cmd));
-  tcflush(serialPortFd, TCOFLUSH);
-}
-
-/*********************************************************************
- * @fn      zllSocRecallScene
- *
- * @brief   Recall Scene.
- *
- * @param   groupId - Group ID of the Scene.
- * @param   sceneId - Scene ID of the Scene.
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be controled. 
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast. 
- * @return  none
- */
-void zllSocRecallScene(uint16_t groupId, uint8_t sceneId, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{  
-       uint8_t cmd[] = {
-               0xFE,                                                                                      
-               14,   /*RPC payload Len */          
-               0x29, /*MT_RPC_CMD_AREQ + MT_RPC_SYS_APP */          
-               0x00, /*MT_APP_MSG  */          
-               0x0B, /*Application Endpoint */          
-               (dstAddr & 0x00ff),
-               (dstAddr & 0xff00) >> 8,
-               endpoint, /*Dst EP */          
-               (ZCL_CLUSTER_ID_GEN_SCENES & 0x00ff),
-               (ZCL_CLUSTER_ID_GEN_SCENES & 0xff00) >> 8,
-               0x07, //Data Len
-               addrMode, 
-               0x01, //0x01 ZCL frame control field.  (send to the light cluster only)
-               transSeqNumber++,
-               COMMAND_SCENE_RECALL,
-               (groupId & 0x00ff),
-               (groupId & 0xff00) >> 8,        
-               sceneId++,      
-               0x00       //FCS - fill in later
-       };
-    
-       calcFcs(cmd, sizeof(cmd));
-       
-  write(serialPortFd,cmd,sizeof(cmd));
-  tcflush(serialPortFd, TCOFLUSH);
-}
-
-/*********************************************************************
- * @fn      zllSocBind
- *
- * @brief   Recall Scene.
- *
- * @param   
- *
- * @return  none
- */
-void zllSocBind(uint16_t srcNwkAddr, uint8_t srcEndpoint, uint8_t srcIEEE[8], uint8_t dstEndpoint, uint8_t dstIEEE[8], uint16_t clusterID )
-{  
-       uint8_t cmd[] = {
-               0xFE,                                                                                      
-               23,                           /*RPC payload Len */          
-               0x25,                         /*MT_RPC_CMD_SREQ + MT_RPC_SYS_ZDO */        
-               0x21,                         /*MT_ZDO_BIND_REQ*/        
-       (srcNwkAddr & 0x00ff),        /*Src Nwk Addr - To send the bind message to*/
-       (srcNwkAddr & 0xff00) >> 8,   /*Src Nwk Addr - To send the bind message to*/
-       srcIEEE[0],                   /*Src IEEE Addr for the binding*/
-       srcIEEE[1],                   /*Src IEEE Addr for the binding*/
-       srcIEEE[2],                   /*Src IEEE Addr for the binding*/
-       srcIEEE[3],                   /*Src IEEE Addr for the binding*/
-       srcIEEE[4],                   /*Src IEEE Addr for the binding*/
-       srcIEEE[5],                   /*Src IEEE Addr for the binding*/
-       srcIEEE[6],                   /*Src IEEE Addr for the binding*/
-       srcIEEE[7],                   /*Src IEEE Addr for the binding*/         
-       srcEndpoint,                  /*Src endpoint for the binding*/ 
-       (clusterID & 0x00ff),         /*cluster ID to bind*/
-       (clusterID & 0xff00) >> 8,    /*cluster ID to bind*/    
-       afAddr64Bit,                    /*Addr mode of the dst to bind*/
-       dstIEEE[0],                   /*Dst IEEE Addr for the binding*/
-       dstIEEE[1],                   /*Dst IEEE Addr for the binding*/
-       dstIEEE[2],                   /*Dst IEEE Addr for the binding*/
-       dstIEEE[3],                   /*Dst IEEE Addr for the binding*/
-       dstIEEE[4],                   /*Dst IEEE Addr for the binding*/
-       dstIEEE[5],                   /*Dst IEEE Addr for the binding*/
-       dstIEEE[6],                   /*Dst IEEE Addr for the binding*/
-       dstIEEE[7],                   /*Dst IEEE Addr for the binding*/         
-       dstEndpoint,                  /*Dst endpoint for the binding*/                  
-               0x00       //FCS - fill in later
-       };
-      
-       calcFcs(cmd, sizeof(cmd));
-       
-       /*printf("zllSocBind: srcNwkAddr=0x%x, srcEndpoint=0x%x, srcIEEE=0x%x:%x:%x:%x:%x:%x:%x:%x, dstEndpoint=0x%x, dstIEEE=0x%x:%x:%x:%x:%x:%x:%x:%x, clusterID:%x\n", 
-                 srcNwkAddr, srcEndpoint, srcIEEE[0], srcIEEE[1], srcIEEE[2], srcIEEE[3], srcIEEE[4], srcIEEE[5], srcIEEE[6], srcIEEE[7], 
-                 srcEndpoint, dstIEEE[0], dstIEEE[1], dstIEEE[2], dstIEEE[3], dstIEEE[4], dstIEEE[5], dstIEEE[6], dstIEEE[7], clusterID);*/
-       
-  write(serialPortFd,cmd,sizeof(cmd));
-  tcflush(serialPortFd, TCOFLUSH);
-}
-
-/*********************************************************************
- * @fn      zllSocGetState
- *
- * @brief   Send the get state command to a ZLL light.
- *
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be sent the command.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocGetState(uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{        
-       uint8_t cmd[] = {
-               0xFE,                                                                                      
-               13,   /*RPC payload Len */          
-               0x29, /*MT_RPC_CMD_AREQ + MT_RPC_SYS_APP */          
-               0x00, /*MT_APP_MSG  */          
-               0x0B, /*Application Endpoint */          
-               (dstAddr & 0x00ff),
-               (dstAddr & 0xff00) >> 8,
-               endpoint, /*Dst EP */          
-               (ZCL_CLUSTER_ID_GEN_ON_OFF & 0x00ff),
-               (ZCL_CLUSTER_ID_GEN_ON_OFF & 0xff00) >> 8,
-               0x06, //Data Len
-               addrMode, 
-               0x00, //0x00 ZCL frame control field.  not specific to a cluster (i.e. a SCL founadation command)
-               transSeqNumber++,
-               ZCL_CMD_READ,
-               (ATTRID_ON_OFF & 0x00ff),
-               (ATTRID_ON_OFF & 0xff00) >> 8,
-               0x00       //FCS - fill in later
-       };
-      
-       calcFcs(cmd, sizeof(cmd));
-       
-    write(serialPortFd,cmd,sizeof(cmd));
-    tcflush(serialPortFd, TCOFLUSH);
-} 
-/*********************************************************************
- * @fn      zllSocGetLevel
- *
- * @brief   Send the get level command to a ZLL light.
- *
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be sent the command.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocGetLevel(uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{
-       uint8_t cmd[] = {
-               0xFE,                                                                                      
-               13,   /*RPC payload Len */          
-               0x29, /*MT_RPC_CMD_AREQ + MT_RPC_SYS_APP */          
-               0x00, /*MT_APP_MSG  */          
-               0x0B, /*Application Endpoint */          
-               (dstAddr & 0x00ff),
-               (dstAddr & 0xff00) >> 8,
-               endpoint, /*Dst EP */          
-               (ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL & 0x00ff),
-               (ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL & 0xff00) >> 8,
-               0x06, //Data Len
-               addrMode, 
-               0x00, //0x00 ZCL frame control field.  not specific to a cluster (i.e. a SCL founadation command)
-               transSeqNumber++,
-               ZCL_CMD_READ,
-               (ATTRID_LEVEL_CURRENT_LEVEL & 0x00ff),
-               (ATTRID_LEVEL_CURRENT_LEVEL & 0xff00) >> 8,
-               0x00       //FCS - fill in later
-       };
-      
-       calcFcs(cmd, sizeof(cmd));
-       
-    write(serialPortFd,cmd,sizeof(cmd));
-    tcflush(serialPortFd, TCOFLUSH);
-} 
-
-/*********************************************************************
- * @fn      zllSocGetHue
- *
- * @brief   Send the get hue command to a ZLL light.
- *
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be sent the command.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocGetHue(uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{
-       uint8_t cmd[] = {
-               0xFE,                                                                                      
-               13,   /*RPC payload Len */          
-               0x29, /*MT_RPC_CMD_AREQ + MT_RPC_SYS_APP */          
-               0x00, /*MT_APP_MSG  */          
-               0x0B, /*Application Endpoint */          
-               (dstAddr & 0x00ff),
-               (dstAddr & 0xff00) >> 8,
-               endpoint, /*Dst EP */          
-               (ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL & 0x00ff),
-               (ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL & 0xff00) >> 8,
-               0x06, //Data Len
-               addrMode, 
-               0x00, //0x00 ZCL frame control field.  not specific to a cluster (i.e. a SCL founadation command)
-               transSeqNumber++,
-               ZCL_CMD_READ,
-               (ATTRID_LIGHTING_COLOR_CONTROL_CURRENT_HUE & 0x00ff),
-               (ATTRID_LIGHTING_COLOR_CONTROL_CURRENT_HUE & 0xff00) >> 8,
-               0x00       //FCS - fill in later
-       };
-      
-       calcFcs(cmd, sizeof(cmd));
-       
-    write(serialPortFd,cmd,sizeof(cmd));
-    tcflush(serialPortFd, TCOFLUSH);
-} 
-
-/*********************************************************************
- * @fn      zllSocGetSat
- *
- * @brief   Send the get saturation command to a ZLL light.
- *
- * @param   dstAddr - Nwk Addr or Group ID of the Light(s) to be sent the command.
- * @param   endpoint - endpoint of the Light.
- * @param   addrMode - Unicast or Group cast.
- *
- * @return  none
- */
-void zllSocGetSat(uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode)
-{
-       uint8_t cmd[] = {
-               0xFE,                                                                                      
-               13,   /*RPC payload Len */          
-               0x29, /*MT_RPC_CMD_AREQ + MT_RPC_SYS_APP */          
-               0x00, /*MT_APP_MSG  */          
-               0x0B, /*Application Endpoint */          
-               (dstAddr & 0x00ff),
-               (dstAddr & 0xff00) >> 8,
-               endpoint, /*Dst EP */          
-               (ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL & 0x00ff),
-               (ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL & 0xff00) >> 8,
-               0x06, //Data Len
-               addrMode, 
-               0x00, //0x00 ZCL frame control field.  not specific to a cluster (i.e. a SCL founadation command)
-               transSeqNumber++,
-               ZCL_CMD_READ,
-               (ATTRID_LIGHTING_COLOR_CONTROL_CURRENT_SATURATION & 0x00ff),
-               (ATTRID_LIGHTING_COLOR_CONTROL_CURRENT_SATURATION & 0xff00) >> 8,
-               0x00       //FCS - fill in later
-       };
-      
-       calcFcs(cmd, sizeof(cmd));
-       
-    write(serialPortFd,cmd,sizeof(cmd));
-    tcflush(serialPortFd, TCOFLUSH);
-} 
-
-/*************************************************************************************************
- * @fn      processRpcSysAppTlInd()
- *
- * @brief  process the TL Indication from the ZLL controller
- *
- * @param   none
- *
- * @return  length of current Rx Buffer
- *************************************************************************************************/
-static void processRpcSysAppTlInd(uint8_t *TlIndBuff)
-{
-  epInfo_t epInfo;    
-    
-  epInfo.nwkAddr = BUILD_UINT16(TlIndBuff[0], TlIndBuff[1]);
-  TlIndBuff+=2;      
-  epInfo.endpoint = *TlIndBuff++;
-  epInfo.profileID = BUILD_UINT16(TlIndBuff[0], TlIndBuff[1]);
-  TlIndBuff+=2;      
-  epInfo.deviceID = BUILD_UINT16(TlIndBuff[0], TlIndBuff[1]);
-  TlIndBuff+=2;   
-  epInfo.version = *TlIndBuff++;
-  epInfo.status = *TlIndBuff++;
-  
-  if(zllSocCb.pfnTlIndicationCb)
-  {
-    zllSocCb.pfnTlIndicationCb(&epInfo);
-  }    
-}        
-
-/*************************************************************************************************
- * @fn      processRpcSysAppNewDevInd()
- *
- * @brief  process the New Device Indication from the ZLL controller
- *
- * @param   none
- *
- * @return  length of current Rx Buffer
- *************************************************************************************************/
-static void processRpcSysAppNewDevInd(uint8_t *TlIndBuff)
-{
-  epInfo_t epInfo = {0};
-  uint8_t i;    
-    
-  epInfo.status = 0;
-  
-  epInfo.nwkAddr = BUILD_UINT16(TlIndBuff[0], TlIndBuff[1]);
-  TlIndBuff+=2;      
-  epInfo.endpoint = *TlIndBuff++;
-  epInfo.profileID = BUILD_UINT16(TlIndBuff[0], TlIndBuff[1]);
-  TlIndBuff+=2;      
-  epInfo.deviceID = BUILD_UINT16(TlIndBuff[0], TlIndBuff[1]);
-  TlIndBuff+=2;   
-  epInfo.version = *TlIndBuff++;
-  
-  for(i=0; i<8; i++)
-  {
-    epInfo.IEEEAddr[i] = *TlIndBuff++;
-  }
-  
-  //printf("processRpcSysAppNewDevInd: %x:%x\n",  epInfo.nwkAddr, epInfo.endpoint);
-  if(zllSocCb.pfnNewDevIndicationCb)
-  {
-    zllSocCb.pfnNewDevIndicationCb(&epInfo);
-  }    
-}
-
-/*************************************************************************************************
- * @fn      processRpcSysAppZcl()
- *
- * @brief  process the ZCL Rsp from the ZLL controller
- *
- * @param   none
- *
- * @return  length of current Rx Buffer
- *************************************************************************************************/
-static void processRpcSysAppZcl(uint8_t *zclRspBuff)
-{   
-  uint8_t zclHdrLen = 3;
-  uint16_t nwkAddr, clusterID; 
-  uint8_t endpoint, appEP, zclFrameLen, zclFrameFrameControl;
-    
-  //printf("processRpcSysAppZcl++\n");
-    
-  //This is a ZCL response
-  appEP = *zclRspBuff++;
-  nwkAddr = BUILD_UINT16(zclRspBuff[0], zclRspBuff[1]);
-  zclRspBuff+=2;
-
-  endpoint = *zclRspBuff++;
-  clusterID = BUILD_UINT16(zclRspBuff[0], zclRspBuff[1]);
-  zclRspBuff+=2;
-
-  zclFrameLen = *zclRspBuff++;
-  zclFrameFrameControl = *zclRspBuff++;
-  //is it manufacturer specific
-  if ( zclFrameFrameControl & (1 <<2) )
-  {
-    //currently not supported shown for reference
-    uint16_t ManSpecCode;
-    //manu spec code
-    ManSpecCode = BUILD_UINT16(zclRspBuff[0], zclRspBuff[1]);
-    zclRspBuff+=2;
-    //Manufacturer specif commands have 2 extra byte in te header
-    zclHdrLen+=2;
-  }      
-  
-  //is this a foundation command
-  if( (zclFrameFrameControl & 0x3) == 0)
-  {
-    //printf("processRpcSysAppZcl: Foundation messagex\n");
-    processRpcSysAppZclFoundation(zclRspBuff, zclFrameLen, clusterID, nwkAddr, endpoint);
-  }
-}
-    
-/*************************************************************************************************
- * @fn      processRpcSysAppZclFoundation()
- *
- * @brief  process the ZCL Rsp from the ZLL controller
- *
- * @param   none
- *
- * @return  length of current Rx Buffer
- *************************************************************************************************/
-static void processRpcSysAppZclFoundation(uint8_t *zclRspBuff, uint8_t zclFrameLen, uint16_t clusterID, uint16_t nwkAddr, uint8_t endpoint)
-{
-  uint8_t transSeqNum, commandID;
-  
-  transSeqNum = *zclRspBuff++;
-  commandID = *zclRspBuff++;
-  
-  if(commandID == ZCL_CMD_READ_RSP)
-  {
-    uint16_t attrID;
-    uint8_t status;
-    uint8_t dataType;
-    
-    attrID = BUILD_UINT16(zclRspBuff[0], zclRspBuff[1]);      
-    zclRspBuff+=2;
-    status = *zclRspBuff++;
-    //get data type;
-    dataType = *zclRspBuff++;
-
-
-    //printf("processRpcSysAppZclFoundation: clusterID:%x, attrID:%x, dataType=%x\n", clusterID, attrID, dataType);
-    
-    if( (clusterID == ZCL_CLUSTER_ID_GEN_ON_OFF) && (attrID == ATTRID_ON_OFF) && (dataType == ZCL_DATATYPE_BOOLEAN) )
-    {              
-      if(zllSocCb.pfnZclGetStateCb)
-      {
-        uint8_t state = zclRspBuff[0];            
-        zllSocCb.pfnZclGetStateCb(state, nwkAddr, endpoint);
-      }                       
-    }
-    else if( (clusterID == ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL) && (attrID == ATTRID_LEVEL_CURRENT_LEVEL) && (dataType == ZCL_DATATYPE_UINT8) )
-    {    
-      if(zllSocCb.pfnZclGetLevelCb)
-      {
-        uint8_t level = zclRspBuff[0];                             
-        zllSocCb.pfnZclGetLevelCb(level, nwkAddr, endpoint);
-      }                       
-    }
-    else if( (clusterID == ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL) && (attrID == ATTRID_LIGHTING_COLOR_CONTROL_CURRENT_HUE) && (dataType == ZCL_DATATYPE_UINT8) )
-    {
-      if(zllSocCb.pfnZclGetHueCb)      
-      {
-        uint8_t hue = zclRspBuff[0];            
-        zllSocCb.pfnZclGetHueCb(hue, nwkAddr, endpoint);
-      }    
-    }                   
-    else if( (clusterID == ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL) && (attrID == ATTRID_LIGHTING_COLOR_CONTROL_CURRENT_SATURATION) && (dataType == ZCL_DATATYPE_UINT8) )
-    {
-      if(zllSocCb.pfnZclGetSatCb)      
-      {
-        uint8_t sat = zclRspBuff[0];            
-        zllSocCb.pfnZclGetSatCb(sat, nwkAddr, endpoint);
-      }    
-    }
-    else                
-    {
-      //unsupported ZCL Read Rsp
-      printf("processRpcSysAppZclFoundation: Unsupported ZCL Rsp\n");
-    } 
-  }
-  else
-  {
-    //unsupported ZCL Rsp
-    printf("processRpcSysAppZclFoundation: Unsupported ZCL Rsp");;
-  }
-  
-  return;                    
-}  
-/*************************************************************************************************
- * @fn      processRpcSysApp()
- *
- * @brief   read and process the RPC App message from the ZLL controller
- *
- * @param   none
- *
- * @return  length of current Rx Buffer
- *************************************************************************************************/
-static void processRpcSysApp(uint8_t *rpcBuff)
-{
-  if( rpcBuff[1] == MT_APP_ZLL_TL_IND )
-  {
-    processRpcSysAppTlInd(&rpcBuff[2]);
-  }          
-  else if( rpcBuff[1] == MT_APP_ZLL_NEW_DEV_IND )
-  {
-    processRpcSysAppNewDevInd(&rpcBuff[2]);
-  }  
-  else if( rpcBuff[1] == MT_APP_RSP )
-  {
-    processRpcSysAppZcl(&rpcBuff[2]);
-  }    
-  else if( rpcBuff[1] == 0 )
-  {
-    if( rpcBuff[2] == 0)
-    {
-      //printf("processRpcSysApp: Command Received Successfully\n\n");
-    }
-    else
-    {
-      printf("processRpcSysApp: Command Error\n\n");
-    }    
-  }
-  else
-  {
-    printf("processRpcSysApp: Unsupported MT App Msg\n");
-  }
-    
-  return;   
-}
-
-/*************************************************************************************************
- * @fn      processRpcSysDbg()
- *
- * @brief   read and process the RPC debug message from the ZLL controller
- *
- * @param   none
- *
- * @return  length of current Rx Buffer
- *************************************************************************************************/
-static void processRpcSysDbg(uint8_t *rpcBuff)
-{
-  if( rpcBuff[1] == MT_DEBUG_MSG )
-  {
-    //we got a debug string
-    printf("lcd_debug message from zll controller: %s\n", (char*) &(rpcBuff[2]));
-  }              
-  else if( rpcBuff[1] == 0 )
-  {
-    if( rpcBuff[2] == 0)
-    {
-      //printf("processRpcSysDbg: Command Received Successfully\n\n");
-    }
-    else
-    {
-      printf("processRpcSysDbg: Command Error\n\n");
-    }    
-  }
-  else
-  {
-    printf("processRpcSysDbg: Unsupported MT App Msg\n");
-  }
-}
-
-/*************************************************************************************************
- * @fn      zllSocProcessRpc()
- *
- * @brief   read and process the RPC from the ZLL controller
- *
- * @param   none
- *
- * @return  length of current Rx Buffer
- *************************************************************************************************/
-void zllSocProcessRpc (void)
-{
-  uint8_t rpcLen, bytesRead, sofByte, *rpcBuff, rpcBuffIdx;    
-  static uint8_t retryAttempts = 0;
-
-  //read first byte and check it is a SOF
-  read(serialPortFd, &sofByte, 1);
-  if ( sofByte == MT_RPC_SOF )
-  { 
-    retryAttempts = 0;     
-        
-    //read len
-    bytesRead = read(serialPortFd, &rpcLen, 1);
-
-    if( bytesRead == 1)
-    {    
-      //allocating RPC payload (+ cmd0, cmd1 and fcs)
-      rpcLen += 3;
-
-      rpcBuff = malloc(rpcLen);
-
-      //non blocking read, so we need to wait for the rpc to be read
-      rpcBuffIdx = 0;
-      while(rpcLen > 0)
-      {
-        //read rpc
-        bytesRead = read(serialPortFd, &(rpcBuff[rpcBuffIdx]), rpcLen);  
-
-        //check for error
-        if( bytesRead > rpcLen)
-        {
-          //there was an error
-          printf("zllSocProcessRpc: read of %d bytes failed - %s\n", rpcLen, strerror(errno) );
-
-          if( retryAttempts++ < 5 )
-          {
-            //sleep for 10ms
-                 usleep(10000);
-            //try again
-            bytesRead = 0;
-          }
-          else
-          {
-            //something went wrong.
-            printf("zllSocProcessRpc: failed\n");
-            return;
-          }
-        }
-
-        rpcLen -= bytesRead;   
-        rpcBuffIdx += bytesRead;
-      }
-
-      //printf("zllSocProcessRpc: Processing CMD0:%x, CMD1:%x\n", rpcBuff[0], rpcBuff[1] );
-      //Read CMD0
-      switch (rpcBuff[0] & MT_RPC_SUBSYSTEM_MASK) 
-      {
-        case MT_RPC_SYS_DBG:
-        {
-          processRpcSysDbg(rpcBuff);        
-          break;       
-        }
-        case MT_RPC_SYS_APP:
-        {
-          processRpcSysApp(rpcBuff);        
-          break;       
-        }
-        default:
-        {
-          printf("zllSocProcessRpc: CMD0:%x, CMD1:%x, not handled\n", rpcBuff[0], rpcBuff[1] );
-          break;
-        }
-      }
-      
-      free(rpcBuff);
-    }
-    else
-    {
-      printf("zllSocProcessRpc: No valid Start Of Frame found\n");
-    }
-  }
-  
-  return; 
-}
-
diff --git a/server/Source/zllSocCmd.h b/server/Source/zllSocCmd.h
deleted file mode 100644 (file)
index e9e0b82..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * zllSocCmd.h
- *
- * This module contains the API for the zll SoC Host Interface.
- *
- * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ 
- * 
- * 
- *  Redistribution and use in source and binary forms, with or without 
- *  modification, are permitted provided that the following conditions 
- *  are met:
- *
- *    Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer.
- *
- *    Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the 
- *    documentation and/or other materials provided with the   
- *    distribution.
- *
- *    Neither the name of Texas Instruments Incorporated nor the names of
- *    its contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
- *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
- *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
- *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef ZLLSOCCMD_H
-#define ZLLSOCCMD_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <stdint.h>
-
-/********************************************************************/
-// ZLL Soc Types
-
-// Endpoint information record entry
-typedef struct
-{
-  uint8_t IEEEAddr[8];
-  uint16_t nwkAddr;   // Network address
-  uint8_t endpoint;   // Endpoint identifier
-  uint16_t profileID; // Profile identifier
-  uint16_t deviceID;  // Device identifier
-  uint8_t version;    // Version
-  char* deviceName;
-  uint8_t status;
-} epInfo_t;
-
-typedef uint8_t (*zllSocTlIndicationCb_t)(epInfo_t *epInfo);
-typedef uint8_t (*zllNewDevIndicationCb_t)(epInfo_t *epInfo);
-typedef uint8_t (*zllSocZclGetStateCb_t)(uint8_t state, uint16_t nwkAddr, uint8_t endpoint);
-typedef uint8_t (*zllSocZclGetLevelCb_t)(uint8_t level, uint16_t nwkAddr, uint8_t endpoint);
-typedef uint8_t (*zllSocZclGetHueCb_t)(uint8_t hue, uint16_t nwkAddr, uint8_t endpoint);
-typedef uint8_t (*zllSocZclGetSatCb_t)(uint8_t sat, uint16_t nwkAddr, uint8_t endpoint);
-
-typedef struct
-{
-  zllSocTlIndicationCb_t          pfnTlIndicationCb;      // TouchLink Indication callback
-  zllNewDevIndicationCb_t         pfnNewDevIndicationCb;  // New device Indication callback    
-  zllSocZclGetStateCb_t           pfnZclGetStateCb;       // ZCL response callback for get State
-  zllSocZclGetLevelCb_t           pfnZclGetLevelCb;     // ZCL response callback for get Level
-  zllSocZclGetHueCb_t             pfnZclGetHueCb;         // ZCL response callback for get Hue
-  zllSocZclGetSatCb_t             pfnZclGetSatCb;         // ZCL response callback for get Sat
-} zllSocCallbacks_t;
-
-#define Z_EXTADDR_LEN 8
-
-typedef enum
-{
-  afAddrNotPresent = 0,
-  afAddrGroup      = 1,
-  afAddr16Bit      = 2,
-  afAddr64Bit      = 3,  
-  afAddrBroadcast  = 15
-} afAddrMode_t;
-
-/********************************************************************/
-// ZLL Soc API
-
-//configuration API's
-int32_t zllSocOpen( char *devicePath );
-void zllSocRegisterCallbacks( zllSocCallbacks_t zllSocCallbacks);
-void zllSocClose( void );
-void zllSocProcessRpc (void);
-
-//ZLL API's
-void zllSocTouchLink(void);
-void zllSocResetToFn(void);
-void zllSocSendResetToFn(void);
-void zllSocOpenNwk(void);
-//ZCL Set API's
-void zllSocSetState(uint8_t state, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode);
-void zllSocSetLevel(uint8_t level, uint16_t time, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode);
-void zllSocSetHue(uint8_t hue, uint16_t time, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode);
-void zllSocSetSat(uint8_t sat, uint16_t time, uint16_t dstAddr, uint8_t  endpoint, uint8_t addrMode);
-void zllSocSetHueSat(uint8_t hue, uint8_t sat, uint16_t time, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode);
-void zllSocAddGroup(uint16_t groupId, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode);
-void zllSocStoreScene(uint16_t groupId, uint8_t sceneId, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode);
-void zllSocRecallScene(uint16_t groupId, uint8_t sceneId, uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode);
-void zllSocBind(uint16_t srcNwkAddr, uint8_t srcEndpoint, uint8_t srcIEEE[8], uint8_t dstEndpoint, uint8_t dstIEEE[8], uint16_t clusterID);
-//ZCL Get API's
-void zllSocGetState(uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode);
-void zllSocGetLevel(uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode);
-void zllSocGetHue(uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode);
-void zllSocGetSat(uint16_t dstAddr, uint8_t endpoint, uint8_t addrMode);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ZLLSOCCMD_H */
diff --git a/server/Source/zll_controller.c b/server/Source/zll_controller.c
deleted file mode 100644 (file)
index b2eef91..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/**************************************************************************************************
- * Filename:       zll_controller.c
- * Description:    This file contains the interface to the UART.
- *
- *
- * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ 
- * 
- * 
- *  Redistribution and use in source and binary forms, with or without 
- *  modification, are permitted provided that the following conditions 
- *  are met:
- *
- *    Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer.
- *
- *    Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the 
- *    documentation and/or other materials provided with the   
- *    distribution.
- *
- *    Neither the name of Texas Instruments Incorporated nor the names of
- *    its contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
- *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
- *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
- *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <poll.h>
-
-#include "zllSocCmd.h"
-#include "interface_devicelist.h"
-#include "interface_grouplist.h"
-#include "interface_scenelist.h"
-
-uint8_t pfnTlIndicationCb(epInfo_t *epInfo);
-uint8_t pfnNewDevIndicationCb(epInfo_t *epInfo);
-uint8_t zclGetStateCb(uint8_t state, uint16_t nwkAddr, uint8_t endpoint);
-uint8_t zclGetLevelCb(uint8_t level, uint16_t nwkAddr, uint8_t endpoint);
-uint8_t zclGetHueCb(uint8_t hue, uint16_t nwkAddr, uint8_t endpoint);
-uint8_t zclGetSatCb(uint8_t sat, uint16_t nwkAddr, uint8_t endpoint);
-
-static zllSocCallbacks_t zllSocCbs =
-{
-  pfnTlIndicationCb,      // pfnTlIndicationCb - TouchLink Indication callback  
-  pfnNewDevIndicationCb,  // pfnNewDevIndicationCb - New Device Indication callback
-  zclGetStateCb,          //pfnZclGetStateCb - ZCL response callback for get State
-  zclGetLevelCb,          //pfnZclGetLevelCb_t - ZCL response callback for get Level
-  zclGetHueCb,            // pfnZclGetHueCb - ZCL response callback for get Hue
-  zclGetSatCb,            //pfnZclGetSatCb - ZCL response callback for get Sat
-};
-
-#include "interface_srpcserver.h"
-#include "socket_server.h"
-
-void usage( char* exeName )
-{
-    printf("Usage: ./%s <port>\n", exeName);
-    printf("Eample: ./%s /dev/ttyACM0\n", exeName);
-}
-
-int main(int argc, char* argv[])
-{
-  int retval = 0;
-  int zllSoc_fd;    
-  printf("%s -- %s %s\n", argv[0], __DATE__, __TIME__ );
-  // accept only 1
-  if( argc != 2 )
-  {
-    usage(argv[0]);
-    printf("attempting to use /dev/ttyACM0\n");
-    zllSoc_fd = zllSocOpen( "/dev/ttyACM0" );        
-  }
-  else
-  {
-    zllSoc_fd = zllSocOpen( argv[1] );       
-  }
-  
-  if( zllSoc_fd == -1 )
-  {
-    exit(-1);
-  }
-
-  //printf("zllMain: restoring device, group and scene lists\n");
-  devListRestorDevices();
-  groupListRestorGroups();  
-  sceneListRestorScenes();
-  
-  zllSocRegisterCallbacks( zllSocCbs );    
-  SRPC_Init();
-  
-  while(1)
-  {          
-    int numClientFds = socketSeverGetNumClients(); 
-    
-         //poll on client socket fd's and the ZllSoC serial port for any activity
-               if(numClientFds)
-               {
-                 int pollFdIdx;                   
-                 int *client_fds = malloc(  numClientFds * sizeof( int ) );
-                 //socket client FD's + zllSoC serial port FD
-                 struct pollfd *pollFds = malloc(  ((numClientFds + 1) * sizeof( struct pollfd )) );
-                 
-                 if(client_fds && pollFds)     
-                 {
-                   //set the zllSoC serial port FD in the poll file descriptors
-                   pollFds[0].fd = zllSoc_fd;
-                       pollFds[0].events = POLLIN;
-                       
-                   //Set the socket file descriptors               
-                 socketSeverGetClientFds(client_fds, numClientFds);                                                     
-                       for(pollFdIdx=0; pollFdIdx < numClientFds; pollFdIdx++)
-               {
-                         pollFds[pollFdIdx+1].fd = client_fds[pollFdIdx];
-                         pollFds[pollFdIdx+1].events = POLLIN | POLLRDHUP;
-                         //printf("zllMain: adding fd %d to poll()\n", pollFds[pollFdIdx].fd);                                         
-                 }     
-
-        printf("zllMain: waiting for poll()\n");
-
-        poll(pollFds, (numClientFds+1), -1); 
-        
-        //printf("zllMain: got poll()\n");
-        
-        //did the poll unblock because of the zllSoC serial?
-        if(pollFds[0].revents)
-        {
-          printf("Message from ZLL SoC\n");
-          zllSocProcessRpc();
-        }
-        //did the poll unblock because of activity on the socket interface?
-        for(pollFdIdx=1; pollFdIdx < (numClientFds+1); pollFdIdx++)
-        {
-          if ( (pollFds[pollFdIdx].revents) )
-          {
-            printf("Message from Socket Sever\n");
-            socketSeverPoll(pollFds[pollFdIdx].fd, pollFds[pollFdIdx].revents);
-          }
-        }          
-                         
-                 free( client_fds );     
-                 free( pollFds );                      
-                 }
-               }                          
-  }    
-
-  return retval;
-}
-
-uint8_t pfnTlIndicationCb(epInfo_t *epInfo)
-{
-  devListAddDevice(epInfo);
-  RSPC_SendEpInfo(epInfo);
-  return 0;  
-}
-
-uint8_t pfnNewDevIndicationCb(epInfo_t *epInfo)
-{
-  devListAddDevice(epInfo);
-  RSPC_SendEpInfo(epInfo);
-  return 0;  
-}
-
-uint8_t zclGetStateCb(uint8_t state, uint16_t nwkAddr, uint8_t endpoint)
-{
-  RPCS_ZLL_CallBack_getStateRsp(state, nwkAddr, endpoint, 0);
-  return 0;  
-}
-
-uint8_t zclGetLevelCb(uint8_t level, uint16_t nwkAddr, uint8_t endpoint)
-{
-  RPCS_ZLL_CallBack_getLevelRsp(level, nwkAddr, endpoint, 0);
-  return 0;  
-}
-
-uint8_t zclGetHueCb(uint8_t hue, uint16_t nwkAddr, uint8_t endpoint)
-{
-  RPCS_ZLL_CallBack_getHueRsp(hue, nwkAddr, endpoint, 0);
-  return 0;  
-}
-
-uint8_t zclGetSatCb(uint8_t sat, uint16_t nwkAddr, uint8_t endpoint)
-{
-  RPCS_ZLL_CallBack_getSatRsp(sat, nwkAddr, endpoint, 0);
-  return 0;  
-}
-
old mode 100755 (executable)
new mode 100644 (file)
similarity index 100%
rename from server/i486-linux-gnu/Makefile
rename to server/linux-gnu/makefile