summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c26bd9d)
raw | patch | inline | side by side (parent: c26bd9d)
author | TonyCave <t-cave@ti.com> | |
Wed, 4 Dec 2013 16:39:37 +0000 (16:39 +0000) | ||
committer | TonyCave <t-cave@ti.com> | |
Wed, 4 Dec 2013 16:39:37 +0000 (16:39 +0000) |
client/CClients/lightFlashCmdLine/linux-gnu/makefile | patch | blob | history | |
client/CClients/listDevsCmdLine/linux-gnu/makefile | patch | blob | history | |
client/CClients/openNetwork/Source/openNetwork.c | patch | blob | history | |
client/CClients/openNetwork/linux-gnu/makefile | patch | blob | history | |
zbFwStart/makefile | [new file with mode: 0644] | patch | blob |
zbFwStart/zbFwStart.c | [new file with mode: 0644] | patch | blob |
zbSocDriver/zbSocCmd.c | patch | blob | history | |
zbSocDriver/zbSocCmd.h | patch | blob | history |
diff --git a/client/CClients/lightFlashCmdLine/linux-gnu/makefile b/client/CClients/lightFlashCmdLine/linux-gnu/makefile
index 8d799d3b4568b6f702214b01c2e2bfb0dff9eb18..35ba87b1aacc4783fba2a88c67a2f196c920f8db 100644 (file)
#Relative project path
PROJ_DIR =
#Relative project path
PROJ_DIR =
-INCLUDE = -I$(PROJ_DIR)../../../../server/Source -I$(PROJ_DIR)../../Source -I$(PROJ_DIR)../Source
+INCLUDE = -I$(PROJ_DIR)../../../../zbSocDriver -I$(PROJ_DIR)../../../../server/Source -I$(PROJ_DIR)../../Source -I$(PROJ_DIR)../Source
LIBS = -lpthread
#CC= /data/opt/vendors/codesourcery/lite/arm-2009q1-203/bin/arm-none-linux-gnueabi-gcc
LIBS = -lpthread
#CC= /data/opt/vendors/codesourcery/lite/arm-2009q1-203/bin/arm-none-linux-gnueabi-gcc
diff --git a/client/CClients/listDevsCmdLine/linux-gnu/makefile b/client/CClients/listDevsCmdLine/linux-gnu/makefile
index 5d056870f5427bbe51c2dfce2ef5336af3b39612..c569de253b8e4f3a3f19f38e9ca69c93329a6d88 100644 (file)
#Relative project path
PROJ_DIR =
#Relative project path
PROJ_DIR =
-INCLUDE = -I$(PROJ_DIR)../../../../server/Source -I$(PROJ_DIR)../Source -I$(PROJ_DIR)../../Source
+INCLUDE = -I$(PROJ_DIR)../../../../zbSocDriver -I$(PROJ_DIR)../../../../server/Source -I$(PROJ_DIR)../Source -I$(PROJ_DIR)../../Source
LIBS = -lpthread
#CC= /data/opt/vendors/codesourcery/lite/arm-2009q1-203/bin/arm-none-linux-gnueabi-gcc
LIBS = -lpthread
#CC= /data/opt/vendors/codesourcery/lite/arm-2009q1-203/bin/arm-none-linux-gnueabi-gcc
diff --git a/client/CClients/openNetwork/Source/openNetwork.c b/client/CClients/openNetwork/Source/openNetwork.c
index 589493d76a414e0b0f98d85bbcd840609ceaf992..a2592b2c30b2b68258f60673f75895ff77f22324 100755 (executable)
printf("sendOpenNetwork++: duration=%d\n", duration);
printf("sendOpenNetwork++: duration=%d\n", duration);
- msg.cmdId = SRPC_OPEN_NETWORK;
- msg.len = 3;
+ msg.cmdId = SRPC_PERMIT_JOIN;
+ msg.len = 5;
//duration
*pRpcCmd++ = duration;
//duration
*pRpcCmd++ = duration;
+ *pRpcCmd++ = JOIN_AUTH_NUM & 0xFF;
+ *pRpcCmd++ = (JOIN_AUTH_NUM & 0xFF00) >> 8;
socketClientSendData(&msg);
}
socketClientSendData(&msg);
}
diff --git a/client/CClients/openNetwork/linux-gnu/makefile b/client/CClients/openNetwork/linux-gnu/makefile
index 1ea0e57ff3452e104855fd005fa3823ec6215455..8c2939b555e18a535e2f3c8aa6aef547c2531914 100644 (file)
#Relative project path
PROJ_DIR =
#Relative project path
PROJ_DIR =
-INCLUDE = -I$(PROJ_DIR)../../../../server/Source -I$(PROJ_DIR)../Source -I$(PROJ_DIR)../../Source
+INCLUDE = -I$(PROJ_DIR)../../../../zbSocDriver -I$(PROJ_DIR)../../../../server/Source -I$(PROJ_DIR)../Source -I$(PROJ_DIR)../../Source
LIBS = -lpthread
#CC= /data/opt/vendors/codesourcery/lite/arm-2009q1-203/bin/arm-none-linux-gnueabi-gcc
LIBS = -lpthread
#CC= /data/opt/vendors/codesourcery/lite/arm-2009q1-203/bin/arm-none-linux-gnueabi-gcc
diff --git a/zbFwStart/makefile b/zbFwStart/makefile
--- /dev/null
+++ b/zbFwStart/makefile
@@ -0,0 +1,26 @@
+\r
+SBU_REV= "0.1"\r
+\r
+\r
+GCC = gcc\r
+\r
+CFLAGS = -Wall -DVERSION_NUMBER=${SBU_REV}\r
+OBJECTS = zbFwStart.o ../zbSocDriver/zbSocCmd.o\r
+INCLUDE = -I../zbSocDriver/\r
+DEFS =\r
+\r
+APP_NAME=zbFwStart.bin\r
+\r
+.PHONY: all, clean\r
+\r
+${APP_NAME}: ${OBJECTS}\r
+ $(GCC) $(CFLAGS) $(OBJECTS) -o ${APP_NAME}\r
+\r
+%.o: %.c\r
+ ${GCC} ${CFLAGS} ${INCLUDE} ${DEFS} -c -o $@ $<\r
+\r
+all: ${APP_NAME}\r
+\r
+clean:\r
+ rm -rf *.o ${APP_NAME}\r
+ rm -rf ../zbSocDriver/*.o ${APP_NAME}\r
diff --git a/zbFwStart/zbFwStart.c b/zbFwStart/zbFwStart.c
--- /dev/null
+++ b/zbFwStart/zbFwStart.c
@@ -0,0 +1,182 @@
+/**************************************************************************************************\r
+ * Filename: zbFwStart.c\r
+ * Description: This starts the network (if needed) and gets the FW model.\r
+ *\r
+ *\r
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/\r
+ *\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ *\r
+ * Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ *\r
+ * Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the\r
+ * distribution.\r
+ *\r
+ * Neither the name of Texas Instruments Incorporated nor the names of\r
+ * its contributors may be used to endorse or promote products derived\r
+ * from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ */\r
+\r
+#include <string.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <poll.h>\r
+\r
+#include "zbSocCmd.h"\r
+\r
+uint8_t tlIndicationCb(epInfo_t *epInfo);\r
+uint8_t utilGetDevInfoRspCb(uint8_t status, uint16_t nwkAddr,\r
+ uint8_t ieeeAddr[8], uint8_t devType, uint8_t devState);\r
+uint8_t zclGetModelCb(uint8_t *ModelId);\r
+\r
+static zbSocCallbacks_t zbSocCbs =\r
+{ tlIndicationCb, // pfnTlIndicationCb - TouchLink Indication callback\r
+ NULL, // pfnNewDevIndicationCb - New Device Indication callback\r
+ NULL, //pfnZclGetStateCb - ZCL response callback for get State\r
+ NULL, //pfnZclGetLevelCb_t - ZCL response callback for get Level\r
+ NULL, // pfnZclGetHueCb - ZCL response callback for get Hue\r
+ NULL, //pfnZclGetSatCb - ZCL response callback for get Sat\r
+ NULL, //pfnzdoSimpleDescRspCb - ZDO simple desc rsp\r
+ NULL, // pfnZdoLeaveIndCb - ZDO Leave indication\r
+ utilGetDevInfoRspCb, //pfnUtilGetDevInfoRspCb\r
+ zclGetModelCb //pfnZclGetModelCb\r
+ };\r
+\r
+void usage(char* exeName)\r
+{\r
+ printf("Usage: ./%s <port>\n", exeName);\r
+ printf("Eample: ./%s /dev/ttyACM0\n", exeName);\r
+}\r
+\r
+int main(int argc, char* argv[])\r
+{ \r
+ int retval = 0;\r
+ int zbSoc_fd;\r
+\r
+ //printf("%s -- %s %s\n", argv[0], __DATE__, __TIME__);\r
+\r
+\r
+ // accept only 1\r
+ if (argc != 2)\r
+ {\r
+ usage(argv[0]);\r
+ //printf("attempting to use /dev/ttyACM0\n");\r
+ zbSoc_fd = zbSocOpen("/dev/ttyO4");\r
+ }\r
+ else\r
+ {\r
+ zbSoc_fd = zbSocOpen(argv[1]);\r
+ }\r
+\r
+ if (zbSoc_fd == -1)\r
+ {\r
+ exit(-1);\r
+ }\r
+\r
+ zbSocRegisterCallbacks(zbSocCbs);\r
+\r
+ //Attempt to start the network (assuming it is a control bridge\r
+ //that needs a command to start the network).\r
+ zbSocBridgeStartNwk();\r
+\r
+ zbSocGetInfo();\r
+\r
+ while (1)\r
+ {\r
+ struct pollfd pollFd;\r
+\r
+ //set the zllSoC serial port FD in the poll file descriptors\r
+ pollFd.fd = zbSoc_fd;\r
+ pollFd.events = POLLIN;\r
+\r
+ //printf("%s: waiting for poll()\n", argv[1]);\r
+\r
+ poll(&pollFd, 1, 500);\r
+\r
+ //printf("%s: got poll()\n", argv[1]);\r
+\r
+ //did the poll unblock because of the zllSoC serial?\r
+ if (pollFd.revents)\r
+ {\r
+ //printf("%s: Message from ZB SoC\n", argv[1]);\r
+ zbSocProcessRpc();\r
+ }\r
+ else\r
+ {\r
+ //printf("timeout\n");\r
+ static int timeoutCnt = 0;\r
+ timeoutCnt++;\r
+ if(timeoutCnt > 5)\r
+ {\r
+ printf("Unknown model\n");\r
+ zbSocClose();\r
+ exit(0);\r
+ }\r
+ else if(timeoutCnt > 3)\r
+ {\r
+ //maybe MT_UTIL is not define, assume coord (nwkAddr=0x0) and try to get model ID\r
+ zbSocGetModel(0x0000, 0xff, afAddr16Bit);\r
+ }\r
+ else\r
+ {\r
+ zbSocGetInfo();\r
+ }\r
+ }\r
+ }\r
+\r
+ return retval;\r
+}\r
+\r
+uint8_t tlIndicationCb(epInfo_t *epInfo)\r
+{\r
+\r
+return 0;\r
+}\r
+\r
+uint8_t utilGetDevInfoRspCb(uint8_t status, uint16_t nwkAddr,\r
+ uint8_t ieeeAddr[8], uint8_t devType, uint8_t devState)\r
+{\r
+ //printf("processRpcUtilGetDevInfoRsp: status:%x devState:%x, nwkAddr:%x ieeeIdx:%x:%x:%x:%x:%x:%x:%x:%x\n", status, devState, nwkAddr,\r
+//ieeeAddr[7], ieeeAddr[6], ieeeAddr[5], ieeeAddr[4], ieeeAddr[3], ieeeAddr[2], ieeeAddr[1], ieeeAddr[0]);\r
+\r
+ zbSocGetModel(nwkAddr, 0xff, afAddr16Bit);\r
+\r
+ return 0;\r
+}\r
+\r
+uint8_t zclGetModelCb(uint8_t *ModelId)\r
+{\r
+ uint8_t strIdx;\r
+ printf("Model ID:");\r
+\r
+ for(strIdx = 0; strIdx < ModelId[0]; strIdx++)\r
+ {\r
+ printf("%c", ModelId[strIdx+1]);\r
+ }\r
+ printf("\n");\r
+\r
+ zbSocClose();\r
+ exit(0);\r
+\r
+ return 0;\r
+}\r
+\r
diff --git a/zbSocDriver/zbSocCmd.c b/zbSocDriver/zbSocCmd.c
index e3e87aa33fb312a846d21d17123d7a711e26ec85..22d8fd1c05f5538bacc067265808c0d51b51154e 100755 (executable)
--- a/zbSocDriver/zbSocCmd.c
+++ b/zbSocDriver/zbSocCmd.c
#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 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 ZLL_MT_APP_RPC_CMD_START_DISTRIB_NWK 0x07
#define MT_APP_RSP 0x80
#define MT_APP_ZLL_TL_IND 0x81
#define MT_APP_RSP 0x80
#define MT_APP_ZLL_TL_IND 0x81
zbSocTransportWrite(cmd, sizeof(cmd));
}
zbSocTransportWrite(cmd, sizeof(cmd));
}
+/*********************************************************************
+ * @fn zbSocBridgeStartNwk
+ *
+ * @brief Send the start network command to the CC253x.
+ *
+ * @param none
+ *
+ * @return none
+ */
+void zbSocBridgeStartNwk(void)
+{
+ uint8_t cmd[] =
+ { APPCMDHEADER(13) 0x06, //Data Len
+ 0x02, //Address Mode
+ 0x00,//2dummy bytes
+ 0x00, ZLL_MT_APP_RPC_CMD_START_DISTRIB_NWK, 0x00, //
+ 0x00, //
+ 0x00 //FCS - fill in later
+ };
+
+ calcFcs(cmd, sizeof(cmd));
+ zbSocTransportWrite(cmd, sizeof(cmd));
+}
+
/*********************************************************************
* @fn zbSocResetToFn
*
/*********************************************************************
* @fn zbSocResetToFn
*
*/
void zbSocOpenNwk(uint8_t duration)
{
*/
void zbSocOpenNwk(uint8_t duration)
{
- uint8_t cmd[] =
+ uint16_t srcNwkAddr = 0xFFFD; //Everyone with RxOnWhenIdle == TRUE
+
+ uint8_t mgmtPermit[] =
+ { 0xFE, 5, /*RPC payload Len */
+ MT_RPC_CMD_SREQ | MT_RPC_SYS_ZDO,
+ 0x36, /*MT_ZDO_MGMT_PERMIT_JOIN_REQ*/
+ afAddrBroadcast, //addr mode
+ (srcNwkAddr & 0x00ff), /*Src Nwk Addr - To send the bind message to*/
+ (srcNwkAddr & 0xff00) >> 8, /*Src Nwk Addr - To send the bind message to*/
+ duration, /*Dst endpoint for the binding*/
+ 1, /*trust center significance set*/
+ 0x00 //FCS - fill in later
+ };
+
+ uint8_t localPermit[] =
{ APPCMDHEADER(13) 0x06, //Data Len
0x02, //Address Mode
0x00,//2dummy bytes
{ APPCMDHEADER(13) 0x06, //Data Len
0x02, //Address Mode
0x00,//2dummy bytes
- 0x00, ZLL_MT_APP_RPC_CMD_PERMIT_JOIN, 0x00, //
+ 0x00, ZLL_MT_APP_RPC_CMD_PERMIT_JOIN,
+ duration, //
0x00, //
0x00 //FCS - fill in later
};
0x00, //
0x00 //FCS - fill in later
};
- cmd[15] = duration;
-
printf("zbSocOpenNwk: duration %ds\n", duration);
printf("zbSocOpenNwk: duration %ds\n", duration);
- calcFcs(cmd, sizeof(cmd));
- zbSocTransportWrite(cmd, sizeof(cmd));
+ calcFcs(localPermit, sizeof(localPermit));
+ zbSocTransportWrite(localPermit, sizeof(localPermit));
+
+ //wait for message to be consumed
+ usleep(30);
+
+ calcFcs(mgmtPermit, sizeof(mgmtPermit));
+ zbSocTransportWrite(mgmtPermit, sizeof(mgmtPermit));
}
/*********************************************************************
}
/*********************************************************************
diff --git a/zbSocDriver/zbSocCmd.h b/zbSocDriver/zbSocCmd.h
index e622206d8b449c0f315a69b2fa1d4f01a4e879e4..8ae5f36647a48b9cd8564bf415b6a234098a8d9b 100755 (executable)
--- a/zbSocDriver/zbSocCmd.h
+++ b/zbSocDriver/zbSocCmd.h
void zbSocResetToFn(void);
void zbSocSendResetToFn(void);
void zbSocOpenNwk(uint8_t duration);
void zbSocResetToFn(void);
void zbSocSendResetToFn(void);
void zbSocOpenNwk(uint8_t duration);
+void zbSocBridgeStartNwk(void);
+
//ZCL Set API's
void zbSocSetState(uint8_t state, uint16_t dstAddr, uint8_t endpoint,
uint8_t addrMode);
//ZCL Set API's
void zbSocSetState(uint8_t state, uint16_t dstAddr, uint8_t endpoint,
uint8_t addrMode);