Commit 20d7df7c authored by whmaizmy's avatar whmaizmy Committed by 黄振令

【修改内容】platform 临时增加通信接口库 (后期编译在改造)

【提交人】黄振令
parent fc5ec9a9

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

...@@ -5,80 +5,83 @@ ...@@ -5,80 +5,83 @@
#define PLAT2MID "ipc:///tmp/plat2mid.ipc" #define PLAT2MID "ipc:///tmp/plat2mid.ipc"
typedef struct { typedef struct {
int n; //nanomsg socket int n;//nanomsg socket
int s; //nanomsg recieve fd int s;//nanomsg recieve fd
}nanomsg_info_t; }nanomsg_info_t;
typedef struct { typedef struct {
nanomsg_info_t ba; nanomsg_info_t ba;
struct ev_io watcher;
ipc_cb* cb;
ipc_type type;
}Bloop_ctrl_t; }Bloop_ctrl_t;
Bloop_ctrl_t Bloop_ctrl; Bloop_ctrl_t Bloop_ctrl;
static struct ev_io g_watcher; Bloop_ctrl_t Mloop_ctrl;
struct ev_loop* gloop;
struct ev_loop* gloop = NULL;
pthread_t g_pTh = NULL;
ipc_cb* g_cb = NULL;
static void watcher_cb (struct ev_loop *loop ,struct ev_io *w, int revents) static void watcher_cb (struct ev_loop *loop ,struct ev_io *w, int revents)
{ {
void *user_data = ev_userdata(loop); printf("watcher_cb !! \r\n\r\n");
Bloop_ctrl_t *Bloop_ctrl = (Bloop_ctrl_t *)user_data; void *user_data = ev_userdata(loop);
Bloop_ctrl_t *loop_ctrl = (Bloop_ctrl_t *)w->data;
uint8_t *dat = NULL; uint8_t *dat = NULL;
uint32_t bytes = nn_recv(Bloop_ctrl->ba.n, &dat, NN_MSG, NN_DONTWAIT); uint32_t bytes = nn_recv(loop_ctrl->ba.n, &dat, NN_MSG, NN_DONTWAIT);
if (bytes <= 0) { if (bytes <= 0) {
return; return;
} }
printf("watcher_cb:%s recived\r\n\r\n", (char *)dat); printf("watcher_cb:%s recived\r\n\r\n", (char *)dat);
if (g_cb != NULL){ if (loop_ctrl->cb != NULL){
g_cb((void *)dat); loop_ctrl->cb((void *)dat, bytes);
} }
nn_freemsg(dat); nn_freemsg(dat);
} }
struct ev_loop* __loop_init(Bloop_ctrl_t *loop_ctrl) void __loop_init(Bloop_ctrl_t *loop_ctrl, struct ev_loop* loop)
{ {
struct ev_loop *loop = ev_loop_new(EVBACKEND_EPOLL); loop_ctrl->watcher.data = loop_ctrl;
if (NULL == loop) { ev_io_init (&(loop_ctrl->watcher), watcher_cb, loop_ctrl->ba.s, EV_READ);
printf("create loop failed\r\n"); ev_io_start (loop, &(loop_ctrl->watcher));
return NULL;
}
ev_io_init (&g_watcher, watcher_cb, loop_ctrl->ba.s, EV_READ);
ev_io_start (loop, &g_watcher);
return loop;
} }
int __nanomsg_init(Bloop_ctrl_t *Bloop_ctrl, ipc_type type) int __nanomsg_init(Bloop_ctrl_t *loop_ctrl, ipc_type type)
{ {
Bloop_ctrl->ba.n = nn_socket(AF_SP, NN_PAIR); loop_ctrl->ba.n = nn_socket(AF_SP, NN_PAIR);
printf("__nanomsg_initBloop_ctrl->ba.n=%d \r\n",Bloop_ctrl->ba.n); printf("__nanomsg_init loop_ctrl->ba.n=%d \r\n",loop_ctrl->ba.n);
if (Bloop_ctrl->ba.n < 0) { if (loop_ctrl->ba.n < 0) {
return -1; return -1;
} }
switch (type) { switch (type) {
case IPC_APP2MID:{ case IPC_APP2MID:{
if (nn_connect(Bloop_ctrl->ba.n, APP2MID) < 0) { if (nn_connect(loop_ctrl->ba.n, APP2MID) < 0) {
return -1; return -1;
} }
} }
break; break;
case IPC_PLAT2MID: { case IPC_PLAT2MID: {
if (nn_connect(Bloop_ctrl->ba.n, PLAT2MID) < 0) { if (nn_connect(loop_ctrl->ba.n, PLAT2MID) < 0) {
return -1; return -1;
} }
} }
break; break;
case IPC_MID2APP: { case IPC_MID2APP: {
if (nn_bind(Bloop_ctrl->ba.n, APP2MID) < 0) { if (nn_bind(loop_ctrl->ba.n, APP2MID) < 0) {
return -1; return -1;
} }
} }
break; break;
case IPC_MID2PLAT: { case IPC_MID2PLAT: {
if (nn_bind(Bloop_ctrl->ba.n, PLAT2MID) < 0) { if (nn_bind(loop_ctrl->ba.n, PLAT2MID) < 0) {
return -1; return -1;
} }
} }
...@@ -89,77 +92,111 @@ int __nanomsg_init(Bloop_ctrl_t *Bloop_ctrl, ipc_type type) ...@@ -89,77 +92,111 @@ int __nanomsg_init(Bloop_ctrl_t *Bloop_ctrl, ipc_type type)
} }
size_t size = sizeof(size_t); size_t size = sizeof(size_t);
if (nn_getsockopt(Bloop_ctrl->ba.n, NN_SOL_SOCKET, NN_RCVFD, (char *)&Bloop_ctrl->ba.s, &size) < 0) { if (nn_getsockopt(loop_ctrl->ba.n, NN_SOL_SOCKET, NN_RCVFD, (char *)&loop_ctrl->ba.s, &size) < 0) {
return -1; return -1;
} }
return 0; return 0;
} }
/*================================= /*=================================
* TODO: only one methd pair * TODO: only one methd pair
* *
* *
==================================*/ ==================================*/
void loop_thread(void *arg){ void loop_thread(void *arg){
gloop = __loop_init(&Bloop_ctrl); printf("loop_thread start!\r\n");
if (NULL == gloop) {
printf("gloop init failed\r\n");
return ;
}
ev_set_userdata(gloop, &Bloop_ctrl);
ev_run (gloop, 0); ev_run (gloop, 0);
} }
int kk_ipc_init(ipc_type type, ipc_cb cb) int kk_ipc_init(ipc_type type, ipc_cb cb)
{ {
pthread_t pb;
if (g_cb != NULL){
printf("ipc has been inited!\r\n"); Bloop_ctrl_t* loop_ctrl;
if (IPC_MID2PLAT == type){
loop_ctrl = &Mloop_ctrl;
}else {
loop_ctrl = &Bloop_ctrl;
}
if(loop_ctrl->cb != NULL){
printf("middleware to platform ipc has been inited!\r\n");
return -1; return -1;
}
}
if (__nanomsg_init(&Bloop_ctrl, type) < 0) {
if (__nanomsg_init(loop_ctrl, type) < 0) {
printf("nanomsg init failed\r\n"); printf("nanomsg init failed\r\n");
return -1; return -1;
} }
if (0 != pthread_create(&pb, NULL, loop_thread, NULL)) {
printf("create pthread B failed\r\n"); if (gloop == NULL){
gloop = ev_loop_new(EVBACKEND_EPOLL);
if (NULL == gloop) {
printf("create loop failed\r\n");
return -1;
}
}
__loop_init(loop_ctrl, gloop);
if (g_pTh ==NULL && 0 != pthread_create(&g_pTh, NULL, loop_thread, NULL)) {
printf("create pthread failed\r\n");
return -1; return -1;
} }
g_cb = cb;
loop_ctrl->cb = cb;
loop_ctrl->type = type;
return 0; return 0;
} }
int kk_ipc_dinit() int kk_ipc_dinit(ipc_type type)
{ {
if (Bloop_ctrl.ba.n > -1){ Bloop_ctrl_t* loop_ctrl;
nn_shutdown(Bloop_ctrl.ba.n, 0); if (Bloop_ctrl.type == type){
loop_ctrl = &Bloop_ctrl;
}else if (Mloop_ctrl.type == type){
loop_ctrl = &Mloop_ctrl;
}else{
printf("kk_ipc_dinit failed, no ipc need destroy!\r\n");
return -1;
}
if (loop_ctrl->ba.n > -1){
nn_shutdown(loop_ctrl->ba.n, 0);
} }
ev_io_stop(gloop, &g_watcher); ev_io_stop(gloop, &loop_ctrl->watcher);
loop_ctrl->cb = NULL;
ev_break(gloop,EVBREAK_ALL); loop_ctrl->type = IPC_UNDEF;
g_cb = NULL;
if (Bloop_ctrl.cb ==NULL && Mloop_ctrl.cb ==NULL){
ev_break(gloop,EVBREAK_ALL);
pthread_exit(g_pTh);
ev_loop_destroy(gloop);
gloop = NULL;
g_pTh = NULL;
}
return 0; return 0;
} }
int kk_ipc_send(void* data) int kk_ipc_send(ipc_type type, void* data, int len)
{ {
//printf("kk_ipc_send 11111111\r\n");
if (data != NULL){ if (data != NULL){
printf("kk_ipc_send data= %s\r\n", data);
char* buf = nn_allocmsg(strlen(data)+1, 0); void* buf = nn_allocmsg(len, 0);
memcpy(buf, data,strlen(data)+1); memcpy(buf, data, len);
nn_send(Bloop_ctrl.ba.n, &buf, NN_MSG, NN_DONTWAIT); if (type == IPC_MID2PLAT){
//printf("kk_ipc_send: RECEIVED \"%s\"\n", data); nn_send(Mloop_ctrl.ba.n, &buf, NN_MSG, NN_DONTWAIT);
}else{
nn_send(Bloop_ctrl.ba.n, &buf, NN_MSG, NN_DONTWAIT);
}
} }
return 0; return 0;
......
...@@ -23,13 +23,14 @@ typedef enum { ...@@ -23,13 +23,14 @@ typedef enum {
IPC_APP2MID = 0, IPC_APP2MID = 0,
IPC_MID2APP, IPC_MID2APP,
IPC_MID2PLAT, IPC_MID2PLAT,
IPC_PLAT2MID IPC_PLAT2MID,
IPC_UNDEF
} ipc_type; } ipc_type;
typedef void ipc_cb(void* data); typedef void ipc_cb(void* data, int len);
int kk_ipc_init(ipc_type type, ipc_cb cb); int kk_ipc_init(ipc_type type, ipc_cb cb);
int kk_ipc_dinit(); int kk_ipc_dinit();
int kk_ipc_send(void* data); int kk_ipc_send(ipc_type type, void* data, int len);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
......
...@@ -18,6 +18,9 @@ SUBDIRS += common/api ...@@ -18,6 +18,9 @@ SUBDIRS += common/api
SUBDIRS += common/nanomsg SUBDIRS += common/nanomsg
SUBDIRS += common/ev SUBDIRS += common/ev
SUBDIRS += common/sqlite SUBDIRS += common/sqlite
SUBDIRS += platform/zigbee
#SUBDIRS += example/json
$(call Append_Conditional, SUBDIRS) $(call Append_Conditional, SUBDIRS)
include $(RULE_DIR)/rules.mk include $(RULE_DIR)/rules.mk
......
build/afv2-bookkeeping.d: afv2-bookkeeping.c \
../../../platform/base/hal/micro/unix/compiler/gcc.h \
../../../platform/base/hal/../hal/micro/generic/compiler/platform-common.h \
../../../protocol/zigbee/app/framework/util/config.h \
../../../app/builder/Z3GatewayHost/./Z3GatewayHost.h \
../../../app/builder/Z3GatewayHost/./Z3GatewayHost_endpoint_config.h \
../../../protocol/zigbee/app/framework/../../app/framework/security/security-config.h \
../../../protocol/zigbee/app/framework/include/af.h \
../../../protocol/zigbee/app/framework/../../stack/../../../platform/base/hal/micro/unix/compiler/gcc.h \
../../../protocol/zigbee/app/framework/../../stack/../../../protocol/zigbee/app/framework/util/config.h \
../../../protocol/zigbee/app/framework/../../stack/include/error.h \
../../../protocol/zigbee/app/framework/../../stack/include/error-def.h \
../../../protocol/zigbee/app/framework/../../stack/include/ember-types.h \
../../../protocol/zigbee/app/framework/../../stack/config/ember-configuration-defaults.h \
../../../protocol/zigbee/app/framework/../../stack/include/ember-static-struct.h \
../../../protocol/zigbee/app/framework/../../stack/include/zll-types.h \
../../../protocol/zigbee/app/framework/../../stack/include/gp-types.h \
../../../protocol/zigbee/app/framework/../../app/util/ezsp/ezsp-protocol.h \
../../../protocol/zigbee/app/framework/../../app/util/ezsp/ezsp-enum.h \
../../../protocol/zigbee/app/framework/../../app/util/ezsp/secure-ezsp-protocol.h \
../../../protocol/zigbee/app/framework/../../app/util/ezsp/secure-ezsp-types.h \
../../../protocol/zigbee/app/framework/../../app/util/ezsp/ezsp-enum.h \
../../../protocol/zigbee/app/framework/../../app/util/ezsp/ezsp.h \
../../../protocol/zigbee/app/framework/../../app/util/ezsp/rename-ezsp-functions.h \
../../../protocol/zigbee/app/framework/../../app/util/ezsp/command-prototypes.h \
../../../protocol/zigbee/app/framework/../../app/util/ezsp/ezsp-utils.h \
../../../protocol/zigbee/app/framework/../../app/util/ezsp/serial-interface.h \
../../../platform/base/hal/../hal/hal.h \
../../../platform/base/hal/../hal/micro/micro.h \
../../../platform/base/hal/../hal/micro/generic/em2xx-reset-defs.h \
../../../platform/base/hal/../hal/micro/micro-types.h \
../../../platform/base/hal/../hal/micro/micro-common.h \
../../../platform/base/hal/../hal/micro/unix/host/micro.h \
../../../app/builder/Z3GatewayHost/Z3GatewayHost_board.h \
../../../platform/base/hal/../hal/plugin/antenna/antenna.h \
../../../platform/base/hal/../hal/plugin/adc/adc.h \
../../../platform/base/hal/../hal/micro/button.h \
../../../platform/base/hal/../hal/plugin/buzzer/buzzer.h \
../../../platform/base/hal/../hal/micro/crc.h \
../../../platform/base/hal/../hal/micro/endian.h \
../../../platform/base/hal/../hal/micro/led.h \
../../../platform/base/hal/../hal/micro/random.h \
../../../platform/base/hal/../hal/micro/serial.h \
../../../platform/base/hal/../hal/micro/spi.h \
../../../platform/base/hal/../hal/micro/system-timer.h \
../../../platform/base/hal/../hal/micro/bootloader-eeprom.h \
../../../platform/base/hal/plugin/serial/serial.h \
../../../protocol/zigbee/app/framework/../../stack/include/event.h \
../../../protocol/zigbee/app/framework/include/af-types.h \
../../../app/builder/Z3GatewayHost/enums.h \
../../../protocol/zigbee/app/framework/../../app/framework/util/print.h \
../../../app/builder/Z3GatewayHost/debug-printing.h \
../../../app/builder/Z3GatewayHost/debug-util.h \
../../../protocol/zigbee/app/framework/../../app/framework/util/time-util.h \
../../../app/builder/Z3GatewayHost/af-structs.h \
../../../app/builder/Z3GatewayHost/attribute-id.h \
../../../app/builder/Z3GatewayHost/att-storage.h \
../../../app/builder/Z3GatewayHost/attribute-type.h \
../../../app/builder/Z3GatewayHost/call-command-handler.h \
../../../app/builder/Z3GatewayHost/callback.h \
../../../protocol/zigbee/app/framework/../../app/framework/include/af-types.h \
../../../protocol/zigbee/app/framework/../../app/framework/util/util.h \
../../../protocol/zigbee/app/framework/../../app/framework/util/../include/af.h \
../../../app/builder/Z3GatewayHost/../../../platform/base/hal/micro/unix/compiler/gcc.h \
../../../protocol/zigbee/app/framework/../../app/framework/plugin/ota-server-policy/ota-server-policy.h \
../../../app/builder/Z3GatewayHost/../../../protocol/zigbee/app/framework/util/config.h \
../../../util/plugin/plugin-common/transport-mqtt/transport-mqtt.h \
../../../app/builder/Z3GatewayHost/client-command-macro.h \
../../../app/builder/Z3GatewayHost/cluster-id.h \
../../../app/builder/Z3GatewayHost/command-id.h \
../../../app/builder/Z3GatewayHost/print-cluster.h \
../../../protocol/zigbee/app/framework/../../app/framework/util/client-api.h \
../../../protocol/zigbee/app/framework/../../app/util/serial/command-interpreter2.h \
../../../protocol/zigbee/app/framework/../../app/framework/cli/zcl-cli.h
../../../platform/base/hal/micro/unix/compiler/gcc.h:
../../../platform/base/hal/../hal/micro/generic/compiler/platform-common.h:
../../../protocol/zigbee/app/framework/util/config.h:
../../../app/builder/Z3GatewayHost/./Z3GatewayHost.h:
../../../app/builder/Z3GatewayHost/./Z3GatewayHost_endpoint_config.h:
../../../protocol/zigbee/app/framework/../../app/framework/security/security-config.h:
../../../protocol/zigbee/app/framework/include/af.h:
../../../protocol/zigbee/app/framework/../../stack/../../../platform/base/hal/micro/unix/compiler/gcc.h:
../../../protocol/zigbee/app/framework/../../stack/../../../protocol/zigbee/app/framework/util/config.h:
../../../protocol/zigbee/app/framework/../../stack/include/error.h:
../../../protocol/zigbee/app/framework/../../stack/include/error-def.h:
../../../protocol/zigbee/app/framework/../../stack/include/ember-types.h:
../../../protocol/zigbee/app/framework/../../stack/config/ember-configuration-defaults.h:
../../../protocol/zigbee/app/framework/../../stack/include/ember-static-struct.h:
../../../protocol/zigbee/app/framework/../../stack/include/zll-types.h:
../../../protocol/zigbee/app/framework/../../stack/include/gp-types.h:
../../../protocol/zigbee/app/framework/../../app/util/ezsp/ezsp-protocol.h:
../../../protocol/zigbee/app/framework/../../app/util/ezsp/ezsp-enum.h:
../../../protocol/zigbee/app/framework/../../app/util/ezsp/secure-ezsp-protocol.h:
../../../protocol/zigbee/app/framework/../../app/util/ezsp/secure-ezsp-types.h:
../../../protocol/zigbee/app/framework/../../app/util/ezsp/ezsp-enum.h:
../../../protocol/zigbee/app/framework/../../app/util/ezsp/ezsp.h:
../../../protocol/zigbee/app/framework/../../app/util/ezsp/rename-ezsp-functions.h:
../../../protocol/zigbee/app/framework/../../app/util/ezsp/command-prototypes.h:
../../../protocol/zigbee/app/framework/../../app/util/ezsp/ezsp-utils.h:
../../../protocol/zigbee/app/framework/../../app/util/ezsp/serial-interface.h:
../../../platform/base/hal/../hal/hal.h:
../../../platform/base/hal/../hal/micro/micro.h:
../../../platform/base/hal/../hal/micro/generic/em2xx-reset-defs.h:
../../../platform/base/hal/../hal/micro/micro-types.h:
../../../platform/base/hal/../hal/micro/micro-common.h:
../../../platform/base/hal/../hal/micro/unix/host/micro.h:
../../../app/builder/Z3GatewayHost/Z3GatewayHost_board.h:
../../../platform/base/hal/../hal/plugin/antenna/antenna.h:
../../../platform/base/hal/../hal/plugin/adc/adc.h:
../../../platform/base/hal/../hal/micro/button.h:
../../../platform/base/hal/../hal/plugin/buzzer/buzzer.h:
../../../platform/base/hal/../hal/micro/crc.h:
../../../platform/base/hal/../hal/micro/endian.h:
../../../platform/base/hal/../hal/micro/led.h:
../../../platform/base/hal/../hal/micro/random.h:
../../../platform/base/hal/../hal/micro/serial.h:
../../../platform/base/hal/../hal/micro/spi.h:
../../../platform/base/hal/../hal/micro/system-timer.h:
../../../platform/base/hal/../hal/micro/bootloader-eeprom.h:
../../../platform/base/hal/plugin/serial/serial.h:
../../../protocol/zigbee/app/framework/../../stack/include/event.h:
../../../protocol/zigbee/app/framework/include/af-types.h:
../../../app/builder/Z3GatewayHost/enums.h:
../../../protocol/zigbee/app/framework/../../app/framework/util/print.h:
../../../app/builder/Z3GatewayHost/debug-printing.h:
../../../app/builder/Z3GatewayHost/debug-util.h:
../../../protocol/zigbee/app/framework/../../app/framework/util/time-util.h:
../../../app/builder/Z3GatewayHost/af-structs.h:
../../../app/builder/Z3GatewayHost/attribute-id.h:
../../../app/builder/Z3GatewayHost/att-storage.h:
../../../app/builder/Z3GatewayHost/attribute-type.h:
../../../app/builder/Z3GatewayHost/call-command-handler.h:
../../../app/builder/Z3GatewayHost/callback.h:
../../../protocol/zigbee/app/framework/../../app/framework/include/af-types.h:
../../../protocol/zigbee/app/framework/../../app/framework/util/util.h:
../../../protocol/zigbee/app/framework/../../app/framework/util/../include/af.h:
../../../app/builder/Z3GatewayHost/../../../platform/base/hal/micro/unix/compiler/gcc.h:
../../../protocol/zigbee/app/framework/../../app/framework/plugin/ota-server-policy/ota-server-policy.h:
../../../app/builder/Z3GatewayHost/../../../protocol/zigbee/app/framework/util/config.h:
../../../util/plugin/plugin-common/transport-mqtt/transport-mqtt.h:
../../../app/builder/Z3GatewayHost/client-command-macro.h:
../../../app/builder/Z3GatewayHost/cluster-id.h:
../../../app/builder/Z3GatewayHost/command-id.h:
../../../app/builder/Z3GatewayHost/print-cluster.h:
../../../protocol/zigbee/app/framework/../../app/framework/util/client-api.h:
../../../protocol/zigbee/app/framework/../../app/util/serial/command-interpreter2.h:
../../../protocol/zigbee/app/framework/../../app/framework/cli/zcl-cli.h:
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
all:
@echo 'No Toolchain to build with.'
@echo ' Go to Project > Properties > C/C++ Build > Manage Configurations... > New'
@echo ' Then select a configuration from your preferred toolchain'
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/** @file host.h
* @brief Sample API functions.
*
* See also @ref board.
*
* <!-- Author(s): Lee Taylor, lee@ember.com -->
* <!-- Copyright 2005 by Ember Corporation. All rights reserved. *80*-->
*/
/** @addtogroup board
*
* See host.h for source code.
*@{
*/
#define halInternalInitBoard() \
do { \
/*halInternalInitLed(); not currently simulated */ \
} while (0)
#define halInternalPowerDownBoard() \
do { \
/*halInternalInitLed(); not currently simulated */ \
} while (0)
#define halInternalPowerUpBoard() \
do { \
} while (0)
enum HalBoardLedPins {
BOARDLED0 = 0,
BOARDLED1 = 1,
BOARDLED2 = 2,
BOARDLED3 = 3,
BOARDLED4 = 4,
BOARDLED5 = 5,
BOARD_ACTIVITY_LED = BOARDLED0,
BOARD_HEARTBEAT_LED = BOARDLED1
};
#define BUTTON0 0
#define BUTTON1 1
#define TEMP_SENSOR_ADC_CHANNEL 0
#define TEMP_SENSOR_SCALE_FACTOR 3
/** @} END addtogroup */
// Copyright 2016 Silicon Laboratories, Inc. *80*
// This callback file is created for your convenience. You may add application
// code to this file. If you regenerate this file over a previous version, the
// previous version will be overwritten and any code you have added will be
// lost.
#include "af.h"
#include "app/framework/util/af-main.h"
#include "app/framework/util/util.h"
#include "app/framework/plugin/concentrator/source-route-common.h"
#include "app/util/zigbee-framework/zigbee-device-common.h"
#include "stack/include/trust-center.h"
#include <stdlib.h>
// the number of tokens that can be written using ezspSetToken and read
// using ezspGetToken
#define MFGSAMP_NUM_EZSP_TOKENS 8
// the size of the tokens that can be written using ezspSetToken and
// read using ezspGetToken
#define MFGSAMP_EZSP_TOKEN_SIZE 8
// the number of manufacturing tokens
#define MFGSAMP_NUM_EZSP_MFG_TOKENS 11
// the size of the largest EZSP Mfg token, EZSP_MFG_CBKE_DATA
// please refer to app/util/ezsp/ezsp-enum.h
#define MFGSAMP_EZSP_TOKEN_MFG_MAXSIZE 92
EmberStatus emberAfTrustCenterStartNetworkKeyUpdate(void);
// Forward declarations of custom cli command functions
static void printSourceRouteTable(void);
static void mfgappTokenDump(void);
static void changeNwkKeyCommand(void);
static void printNextKeyCommand(void);
static void versionCommand(void);
static void setTxPowerCommand(void);
EmberCommandEntry emberAfCustomCommands[] = {
emberCommandEntryAction("print_srt", printSourceRouteTable, "", ""),
emberCommandEntryAction("tokdump", mfgappTokenDump, "", ""),
emberCommandEntryAction("changeNwkKey", changeNwkKeyCommand, "", ""),
emberCommandEntryAction("printNextKey", printNextKeyCommand, "", ""),
emberCommandEntryAction("version", versionCommand, "", ""),
emberCommandEntryAction("txPower", setTxPowerCommand, "s", ""),
emberCommandEntryTerminator()
};
//// ******* test of token dump code
// the manufacturing tokens are enumerated in app/util/ezsp/ezsp-protocol.h
// the names are enumerated here to make it easier for the user
PGM_NO_CONST PGM_P ezspMfgTokenNames[] =
{
"EZSP_MFG_CUSTOM_VERSION...",
"EZSP_MFG_STRING...........",
"EZSP_MFG_BOARD_NAME.......",
"EZSP_MFG_MANUF_ID.........",
"EZSP_MFG_PHY_CONFIG.......",
"EZSP_MFG_BOOTLOAD_AES_KEY.",
"EZSP_MFG_ASH_CONFIG.......",
"EZSP_MFG_EZSP_STORAGE.....",
"EZSP_STACK_CAL_DATA.......",
"EZSP_MFG_CBKE_DATA........",
"EZSP_MFG_INSTALLATION_CODE"
};
// IAS ACE Server side callbacks
bool emberAfIasAceClusterArmCallback(uint8_t armMode,
uint8_t* armDisarmCode,
uint8_t zoneId)
{
uint16_t armDisarmCodeLength = emberAfStringLength(armDisarmCode);
EmberNodeId sender = emberGetSender();
uint16_t i;
emberAfAppPrint("IAS ACE Arm Received %x", armMode);
// Start i at 1 to skip over leading character in the byte array as it is the
// length byte
for (i = 1; i < armDisarmCodeLength; i++) {
emberAfAppPrint("%c", armDisarmCode[i]);
}
emberAfAppPrintln(" %x", zoneId);
emberAfFillCommandIasAceClusterArmResponse(armMode);
emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, sender);
return true;
}
bool emberAfIasAceClusterBypassCallback(uint8_t numberOfZones,
uint8_t* zoneIds,
uint8_t* armDisarmCode)
{
EmberNodeId sender = emberGetSender();
uint8_t i;
emberAfAppPrint("IAS ACE Cluster Bypass for zones ");
for (i = 0; i < numberOfZones; i++) {
emberAfAppPrint("%d ", zoneIds[i]);
}
emberAfAppPrintln("");
emberAfFillCommandIasAceClusterBypassResponse(numberOfZones,
zoneIds,
numberOfZones);
emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, sender);
return true;
}
// code to print out the source route table
static void printSourceRouteTable(void)
{
uint8_t i;
for (i = 0; i < sourceRouteTableSize; i++) {
if (sourceRouteTable[i].destination != 0x0000) {
emberAfCorePrintln("[ind]%x[dest]%2x[closer]%x[older]%x",
i,
sourceRouteTable[i].destination,
sourceRouteTable[i].closerIndex,
sourceRouteTable[i].olderIndex);
}
emberSerialWaitSend(APP_SERIAL);
}
emberAfCorePrintln("<print srt>");
emberSerialWaitSend(APP_SERIAL);
}
// Called to dump all of the tokens. This dumps the indices, the names,
// and the values using ezspGetToken and ezspGetMfgToken. The indices
// are used for read and write functions below.
static void mfgappTokenDump(void)
{
EmberStatus status;
uint8_t tokenData[MFGSAMP_EZSP_TOKEN_MFG_MAXSIZE];
uint8_t index, i, tokenLength;
// first go through the tokens accessed using ezspGetToken
emberAfCorePrintln("(data shown little endian)");
emberAfCorePrintln("Tokens:");
emberAfCorePrintln("idx value:");
for (index = 0; index < MFGSAMP_NUM_EZSP_TOKENS; index++) {
// get the token data here
status = ezspGetToken(index, tokenData);
emberAfCorePrint("[%d]", index);
if (status == EMBER_SUCCESS) {
// Print out the token data
for (i = 0; i < MFGSAMP_EZSP_TOKEN_SIZE; i++) {
emberAfCorePrint(" %X", tokenData[i]);
}
emberSerialWaitSend(APP_SERIAL);
emberAfCorePrintln("");
} else {
// handle when ezspGetToken returns an error
emberAfCorePrintln(" ... error 0x%x ...",
status);
}
}
// now go through the tokens accessed using ezspGetMfgToken
// the manufacturing tokens are enumerated in app/util/ezsp/ezsp-protocol.h
// this file contains an array (ezspMfgTokenNames) representing the names.
emberAfCorePrintln("Manufacturing Tokens:");
emberAfCorePrintln("idx token name len value");
for (index = 0; index < MFGSAMP_NUM_EZSP_MFG_TOKENS; index++) {
// ezspGetMfgToken returns a length, be careful to only access
// valid token indices.
tokenLength = ezspGetMfgToken(index, tokenData);
emberAfCorePrintln("[%x] %p: 0x%x:", index,
ezspMfgTokenNames[index], tokenLength);
// Print out the token data
for (i = 0; i < tokenLength; i++) {
if ((i != 0) && ((i % 8) == 0)) {
emberAfCorePrintln("");
emberAfCorePrint(" :");
emberSerialWaitSend(APP_SERIAL);
}
emberAfCorePrint(" %X", tokenData[i]);
}
emberSerialWaitSend(APP_SERIAL);
emberAfCorePrintln("");
}
emberAfCorePrintln("");
}
static void changeNwkKeyCommand(void)
{
EmberStatus status = emberAfTrustCenterStartNetworkKeyUpdate();
if (status != EMBER_SUCCESS) {
emberAfCorePrintln("Change Key Error %x", status);
} else {
emberAfCorePrintln("Change Key Success");
}
}
static void dcPrintKey(uint8_t label, uint8_t *key)
{
uint8_t i;
emberAfCorePrintln("key %x: ", label);
for (i = 0; i < EMBER_ENCRYPTION_KEY_SIZE; i++) {
emberAfCorePrint("%x", key[i]);
}
emberAfCorePrintln("");
}
static void printNextKeyCommand(void)
{
EmberKeyStruct nextNwkKey;
EmberStatus status;
status = emberGetKey(EMBER_NEXT_NETWORK_KEY,
&nextNwkKey);
if (status != EMBER_SUCCESS) {
emberAfCorePrintln("Error getting key");
} else {
dcPrintKey(1, nextNwkKey.key.contents);
}
}
static void versionCommand(void)
{
emberAfCorePrintln("Version: 0.1 Alpha");
emberAfCorePrintln(" %s", __DATE__);
emberAfCorePrintln(" %s", __TIME__);
emberAfCorePrintln("");
}
static void setTxPowerCommand(void)
{
int8_t dBm = (int8_t)emberSignedCommandArgument(0);
if(emberSetRadioPower(dBm)==EMBER_SUCCESS){
emberAfCorePrintln("set tx power suc,%d dbm",dBm);
}else{
emberAfCorePrintln("out of range,%d dbm",dBm);
}
emberAfCorePrintln("");
}
This diff is collapsed.
// This file is generated by Simplicity Studio. Please do not edit manually.
//
//
#include PLATFORM_HEADER
#include CONFIGURATION_HEADER
#include "af.h"
// Init function declarations.
void emberAfInit(void);
void emberAfMainInitCallback(void);
void emberAfPluginGatewayInitCallback(void);
void emberAfPluginNetworkCreatorSecurityInitCallback(void);
void emAfInit(void)
{
emberAfInit(); //mqtt init is here
emberAfMainInitCallback();
emberAfPluginGatewayInitCallback();
emberAfPluginNetworkCreatorSecurityInitCallback();
}
// Tick function declarations.
void emberAfMainTickCallback(void);
void emberAfOtaServerTick(void);
void emberAfPluginGatewayTickCallback(void);
void emberAfPluginHeartbeatTickCallback(void);
void emberAfTick(void);
void emAfTick(void)
{
emberAfMainTickCallback();
emberAfOtaServerTick();
emberAfPluginGatewayTickCallback();
emberAfPluginHeartbeatTickCallback();
emberAfTick();
}
void emAfResetAttributes(uint8_t endpointId)
{
}
// PreCommandReceived function declarations.
bool emAfPluginCommandRelayPreCommandReceivedCallback(EmberAfClusterCommand* cmd);
bool emAfPluginDeviceTablePreCommandReceivedCallback(EmberAfClusterCommand* cmd);
bool emberAfPluginGatewayRelayMqttPreCommandReceivedCallback(EmberAfClusterCommand* cmd);
bool emberAfPreCommandReceivedCallback(EmberAfClusterCommand* cmd);
void rpc_PreCommandReceivedCallback(EmberAfClusterCommand* cmd);
bool emAfPreCommandReceived(EmberAfClusterCommand* cmd)
{
rpc_PreCommandReceivedCallback(cmd);
return (emAfPluginCommandRelayPreCommandReceivedCallback(cmd)
|| emAfPluginDeviceTablePreCommandReceivedCallback(cmd)
|| emberAfPluginGatewayRelayMqttPreCommandReceivedCallback(cmd)
|| emberAfPreCommandReceivedCallback(cmd));
}
// PreZDOMessageReceived function declarations.
bool emAfPluginDeviceTablePreZDOMessageReceived(EmberNodeId emberNodeId,EmberApsFrame* apsFrame,uint8_t* message,uint16_t length);
bool emberAfPluginGatewayRelayMqttPreZDOMessageReceivedCallback(EmberNodeId emberNodeId,EmberApsFrame* apsFrame,uint8_t* message,uint16_t length);
bool emberAfPreZDOMessageReceivedCallback(EmberNodeId emberNodeId,EmberApsFrame* apsFrame,uint8_t* message,uint16_t length);
bool emAfPreZDOMessageReceived(EmberNodeId emberNodeId,EmberApsFrame* apsFrame,uint8_t* message,uint16_t length)
{
return (emAfPluginDeviceTablePreZDOMessageReceived(emberNodeId, apsFrame, message, length)
|| emberAfPluginGatewayRelayMqttPreZDOMessageReceivedCallback(emberNodeId, apsFrame, message, length)
|| emberAfPreZDOMessageReceivedCallback(emberNodeId, apsFrame, message, length));
}
// RetrieveAttributeAndCraftResponse function declarations.
bool emAfPluginGreenPowerClientRetrieveAttributeAndCraftResponse(uint8_t endpoint, EmberAfClusterId clusterId, EmberAfAttributeId attrId, uint8_t mask, uint16_t maunfacturerCode, uint16_t readLength);
bool emAfRetrieveAttributeAndCraftResponse(uint8_t endpoint, EmberAfClusterId clusterId, EmberAfAttributeId attrId, uint8_t mask, uint16_t maunfacturerCode, uint16_t readLength)
{
return emAfPluginGreenPowerClientRetrieveAttributeAndCraftResponse(endpoint, clusterId, attrId, mask, maunfacturerCode, readLength);
}
// ZigbeeKeyEstablishment function declarations.
void emberAfPluginNetworkCreatorSecurityZigbeeKeyEstablishmentCallback(EmberEUI64 partner, EmberKeyStatus status);
void emberAfZigbeeKeyEstablishmentCallback(EmberEUI64 partner, EmberKeyStatus status);
void emAfZigbeeKeyEstablishment(EmberEUI64 partner, EmberKeyStatus status)
{
emberAfPluginNetworkCreatorSecurityZigbeeKeyEstablishmentCallback(partner, status);
emberAfZigbeeKeyEstablishmentCallback(partner, status);
}
// ReadAttributesResponse function declarations.
bool emberAfReadAttributesResponseCallback(EmberAfClusterId clusterId,uint8_t* buffer,uint16_t bufLen);
bool emAfReadAttributesResponse(EmberAfClusterId clusterId,uint8_t* buffer,uint16_t bufLen)
{
return emberAfReadAttributesResponseCallback(clusterId, buffer, bufLen);
}
// ReportAttributes function declarations.
bool emberAfReportAttributesCallback(EmberAfClusterId clusterId,uint8_t * buffer,uint16_t bufLen);
bool emAfReportAttributes(EmberAfClusterId clusterId,uint8_t * buffer,uint16_t bufLen)
{
return emberAfReportAttributesCallback(clusterId, buffer, bufLen);
}
// PluginDeviceTableDeviceLeft function declarations.
void emAfPluginCommandRelayRemoveDeviceByEui64(EmberEUI64 newNodeEui64);
void emberAfPluginDeviceTableDeviceLeftCallback(EmberEUI64 newNodeEui64);
void emAfPluginDeviceTableDeviceLeftCallback(EmberEUI64 newNodeEui64)
{
emAfPluginCommandRelayRemoveDeviceByEui64(newNodeEui64);
emberAfPluginDeviceTableDeviceLeftCallback(newNodeEui64);
}
// This file is generated by Simplicity Studio. Please do not edit manually.
//
//
// Enclosing macro to prevent multiple inclusion
#ifndef SILABS_AFV2_BOOKKEEPING_H
#define SILABS_AFV2_BOOKKEEPING_H
#include PLATFORM_HEADER
#include CONFIGURATION_HEADER
#include "af.h"
void emAfInit(void);
void emAfTick(void);
void emAfResetAttributes(uint8_t endpointId);
bool emAfPreCommandReceived(EmberAfClusterCommand* cmd);
bool emAfPreZDOMessageReceived(EmberNodeId emberNodeId,EmberApsFrame* apsFrame,uint8_t* message,uint16_t length);
bool emAfRetrieveAttributeAndCraftResponse(uint8_t endpoint, EmberAfClusterId clusterId, EmberAfAttributeId attrId, uint8_t mask, uint16_t maunfacturerCode, uint16_t readLength);
void emAfZigbeeKeyEstablishment(EmberEUI64 partner, EmberKeyStatus status);
bool emAfReadAttributesResponse(EmberAfClusterId clusterId,uint8_t* buffer,uint16_t bufLen);
bool emAfReportAttributes(EmberAfClusterId clusterId,uint8_t * buffer,uint16_t bufLen);
void emAfPluginDeviceTableDeviceLeftCallback(EmberEUI64 newNodeEui64);
#endif // SILABS_AFV2_BOOKKEEPING_H
// This file is generated by Simplicity Studio. Please do not edit manually.
//
//
// Enclosing macro to prevent multiple inclusion
#ifndef SILABS_ATTRIBUTE_STORAGE_GEN
#define SILABS_ATTRIBUTE_STORAGE_GEN
// Attribute masks modify how attributes are used by the framework
// Attribute that has this mask is NOT read-only
#define ATTRIBUTE_MASK_WRITABLE (0x01)
// Attribute that has this mask is saved to a token
#define ATTRIBUTE_MASK_TOKENIZE (0x02)
// Attribute that has this mask has a min/max values
#define ATTRIBUTE_MASK_MIN_MAX (0x04)
// Manufacturer specific attribute
#define ATTRIBUTE_MASK_MANUFACTURER_SPECIFIC (0x08)
// Attribute deferred to external storage
#define ATTRIBUTE_MASK_EXTERNAL_STORAGE (0x10)
// Attribute is singleton
#define ATTRIBUTE_MASK_SINGLETON (0x20)
// Attribute is a client attribute
#define ATTRIBUTE_MASK_CLIENT (0x40)
// Cluster masks modify how clusters are used by the framework
// Does this cluster have init function?
#define CLUSTER_MASK_INIT_FUNCTION (0x01)
// Does this cluster have attribute changed function?
#define CLUSTER_MASK_ATTRIBUTE_CHANGED_FUNCTION (0x02)
// Does this cluster have default response function?
#define CLUSTER_MASK_DEFAULT_RESPONSE_FUNCTION (0x04)
// Does this cluster have message sent function?
#define CLUSTER_MASK_MESSAGE_SENT_FUNCTION (0x08)
// Does this cluster have manufacturer specific attribute changed funciton?
#define CLUSTER_MASK_MANUFACTURER_SPECIFIC_ATTRIBUTE_CHANGED_FUNCTION (0x10)
// Does this cluster have pre-attribute changed function?
#define CLUSTER_MASK_PRE_ATTRIBUTE_CHANGED_FUNCTION (0x20)
// Cluster is a server
#define CLUSTER_MASK_SERVER (0x40)
// Cluster is a client
#define CLUSTER_MASK_CLIENT (0x80)
// Command masks modify meanings of commands
// Is sending of this client command supported
#define COMMAND_MASK_OUTGOING_CLIENT (0x01)
// Is sending of this server command supported
#define COMMAND_MASK_OUTGOING_SERVER (0x02)
// Is receiving of this client command supported
#define COMMAND_MASK_INCOMING_CLIENT (0x04)
// Is receiving of this server command supported
#define COMMAND_MASK_INCOMING_SERVER (0x08)
// Is this command manufacturer specific?
#define COMMAND_MASK_MANUFACTURER_SPECIFIC (0x10)
#endif // SILABS_ATTRIBUTE_STORAGE_GEN
This diff is collapsed.
// This file is generated by Simplicity Studio. Please do not edit manually.
//
//
// Enclosing macro to prevent multiple inclusion
#ifndef SILABS_ATTRIBUTE_SIZE
#define SILABS_ATTRIBUTE_SIZE
// Used ZCL attribute type sizes
ZCL_BITMAP16_ATTRIBUTE_TYPE, 2,
ZCL_BITMAP24_ATTRIBUTE_TYPE, 3,
ZCL_BITMAP32_ATTRIBUTE_TYPE, 4,
ZCL_BITMAP48_ATTRIBUTE_TYPE, 6,
ZCL_BITMAP64_ATTRIBUTE_TYPE, 8,
ZCL_BITMAP8_ATTRIBUTE_TYPE, 1,
ZCL_BOOLEAN_ATTRIBUTE_TYPE, 1,
ZCL_DATA8_ATTRIBUTE_TYPE, 1,
ZCL_ENUM16_ATTRIBUTE_TYPE, 2,
ZCL_ENUM8_ATTRIBUTE_TYPE, 1,
ZCL_FLOAT_SINGLE_ATTRIBUTE_TYPE, 4,
ZCL_IEEE_ADDRESS_ATTRIBUTE_TYPE, 8,
ZCL_INT16S_ATTRIBUTE_TYPE, 2,
ZCL_INT16U_ATTRIBUTE_TYPE, 2,
ZCL_INT24S_ATTRIBUTE_TYPE, 3,
ZCL_INT24U_ATTRIBUTE_TYPE, 3,
ZCL_INT32S_ATTRIBUTE_TYPE, 4,
ZCL_INT32U_ATTRIBUTE_TYPE, 4,
ZCL_INT48U_ATTRIBUTE_TYPE, 6,
ZCL_INT56U_ATTRIBUTE_TYPE, 7,
ZCL_INT8S_ATTRIBUTE_TYPE, 1,
ZCL_INT8U_ATTRIBUTE_TYPE, 1,
ZCL_SECURITY_KEY_ATTRIBUTE_TYPE, 16,
ZCL_UTC_TIME_ATTRIBUTE_TYPE, 4,
#endif // SILABS_ATTRIBUTE_SIZE
// This file is generated by Simplicity Studio. Please do not edit manually.
//
//
// Enclosing macro to prevent multiple inclusion
#ifndef SILABS_EMBER_AF_ATTRIBUTE_TYPES
#define SILABS_EMBER_AF_ATTRIBUTE_TYPES
// ZCL attribute types
enum {
ZCL_NO_DATA_ATTRIBUTE_TYPE = 0x00, // No data
ZCL_DATA8_ATTRIBUTE_TYPE = 0x08, // 8-bit data
ZCL_DATA16_ATTRIBUTE_TYPE = 0x09, // 16-bit data
ZCL_DATA24_ATTRIBUTE_TYPE = 0x0A, // 24-bit data
ZCL_DATA32_ATTRIBUTE_TYPE = 0x0B, // 32-bit data
ZCL_DATA40_ATTRIBUTE_TYPE = 0x0C, // 40-bit data
ZCL_DATA48_ATTRIBUTE_TYPE = 0x0D, // 48-bit data
ZCL_DATA56_ATTRIBUTE_TYPE = 0x0E, // 56-bit data
ZCL_DATA64_ATTRIBUTE_TYPE = 0x0F, // 64-bit data
ZCL_BOOLEAN_ATTRIBUTE_TYPE = 0x10, // Boolean
ZCL_BITMAP8_ATTRIBUTE_TYPE = 0x18, // 8-bit bitmap
ZCL_BITMAP16_ATTRIBUTE_TYPE = 0x19, // 16-bit bitmap
ZCL_BITMAP24_ATTRIBUTE_TYPE = 0x1A, // 24-bit bitmap
ZCL_BITMAP32_ATTRIBUTE_TYPE = 0x1B, // 32-bit bitmap
ZCL_BITMAP40_ATTRIBUTE_TYPE = 0x1C, // 40-bit bitmap
ZCL_BITMAP48_ATTRIBUTE_TYPE = 0x1D, // 48-bit bitmap
ZCL_BITMAP56_ATTRIBUTE_TYPE = 0x1E, // 56-bit bitmap
ZCL_BITMAP64_ATTRIBUTE_TYPE = 0x1F, // 64-bit bitmap
ZCL_INT8U_ATTRIBUTE_TYPE = 0x20, // Unsigned 8-bit integer
ZCL_INT16U_ATTRIBUTE_TYPE = 0x21, // Unsigned 16-bit integer
ZCL_INT24U_ATTRIBUTE_TYPE = 0x22, // Unsigned 24-bit integer
ZCL_INT32U_ATTRIBUTE_TYPE = 0x23, // Unsigned 32-bit integer
ZCL_INT40U_ATTRIBUTE_TYPE = 0x24, // Unsigned 40-bit integer
ZCL_INT48U_ATTRIBUTE_TYPE = 0x25, // Unsigned 48-bit integer
ZCL_INT56U_ATTRIBUTE_TYPE = 0x26, // Unsigned 56-bit integer
ZCL_INT64U_ATTRIBUTE_TYPE = 0x27, // Unsigned 64-bit integer
ZCL_INT8S_ATTRIBUTE_TYPE = 0x28, // Signed 8-bit integer
ZCL_INT16S_ATTRIBUTE_TYPE = 0x29, // Signed 16-bit integer
ZCL_INT24S_ATTRIBUTE_TYPE = 0x2A, // Signed 24-bit integer
ZCL_INT32S_ATTRIBUTE_TYPE = 0x2B, // Signed 32-bit integer
ZCL_INT40S_ATTRIBUTE_TYPE = 0x2C, // Signed 40-bit integer
ZCL_INT48S_ATTRIBUTE_TYPE = 0x2D, // Signed 48-bit integer
ZCL_INT56S_ATTRIBUTE_TYPE = 0x2E, // Signed 56-bit integer
ZCL_INT64S_ATTRIBUTE_TYPE = 0x2F, // Signed 64-bit integer
ZCL_ENUM8_ATTRIBUTE_TYPE = 0x30, // 8-bit enumeration
ZCL_ENUM16_ATTRIBUTE_TYPE = 0x31, // 16-bit enumeration
ZCL_FLOAT_SEMI_ATTRIBUTE_TYPE = 0x38, // Semi-precision
ZCL_FLOAT_SINGLE_ATTRIBUTE_TYPE = 0x39, // Single precision
ZCL_FLOAT_DOUBLE_ATTRIBUTE_TYPE = 0x3A, // Double precision
ZCL_OCTET_STRING_ATTRIBUTE_TYPE = 0x41, // Octet string
ZCL_CHAR_STRING_ATTRIBUTE_TYPE = 0x42, // Character string
ZCL_LONG_OCTET_STRING_ATTRIBUTE_TYPE = 0x43, // Long octet string
ZCL_LONG_CHAR_STRING_ATTRIBUTE_TYPE = 0x44, // Long character string
ZCL_ARRAY_ATTRIBUTE_TYPE = 0x48, // Array
ZCL_STRUCT_ATTRIBUTE_TYPE = 0x4C, // Structure
ZCL_SET_ATTRIBUTE_TYPE = 0x50, // Set
ZCL_BAG_ATTRIBUTE_TYPE = 0x51, // Bag
ZCL_TIME_OF_DAY_ATTRIBUTE_TYPE = 0xE0, // Time of day
ZCL_DATE_ATTRIBUTE_TYPE = 0xE1, // Date
ZCL_UTC_TIME_ATTRIBUTE_TYPE = 0xE2, // UTC Time
ZCL_CLUSTER_ID_ATTRIBUTE_TYPE = 0xE8, // Cluster ID
ZCL_ATTRIBUTE_ID_ATTRIBUTE_TYPE = 0xE9, // Attribute ID
ZCL_BACNET_OID_ATTRIBUTE_TYPE = 0xEA, // BACnet OID
ZCL_IEEE_ADDRESS_ATTRIBUTE_TYPE = 0xF0, // IEEE address
ZCL_SECURITY_KEY_ATTRIBUTE_TYPE = 0xF1, // 128-bit security key
ZCL_UNKNOWN_ATTRIBUTE_TYPE = 0xFF // Unknown
};
#endif // SILABS_EMBER_AF_ATTRIBUTE_TYPES
This diff is collapsed.
/*
Copyright (c) 2009 Dave Gamble
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef cJSON__h
#define cJSON__h
#ifdef __cplusplus
extern "C"
{
#endif
/* cJSON Types: */
#define cJSON_False 0
#define cJSON_True 1
#define cJSON_NULL 2
#define cJSON_Number 3
#define cJSON_String 4
#define cJSON_Array 5
#define cJSON_Object 6
#define cJSON_IsReference 256
/* The cJSON structure: */
typedef struct cJSON {
struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
int type; /* The type of the item, as above. */
char *valuestring; /* The item's string, if type==cJSON_String */
int valueint; /* The item's number, if type==cJSON_Number */
double valuedouble; /* The item's number, if type==cJSON_Number */
char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
} cJSON;
typedef struct cJSON_Hooks {
void *(*malloc_fn)(size_t sz);
void (*free_fn)(void *ptr);
} cJSON_Hooks;
/* Supply malloc, realloc and free functions to cJSON */
extern void cJSON_InitHooks(cJSON_Hooks* hooks);
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
extern cJSON *cJSON_Parse(const char *value);
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished.
* end_ptr will point to 1 past the end of the JSON object */
extern cJSON *cJSON_Parse_Stream(const char *value, char **end_ptr);
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
extern char *cJSON_Print(cJSON *item);
extern char *cJSON_Print_pure(cJSON *item);
/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
extern char *cJSON_PrintUnformatted(cJSON *item);
/* Delete a cJSON entity and all subentities. */
extern void cJSON_Delete(cJSON *c);
/* Returns the number of items in an array (or object). */
extern int cJSON_GetArraySize(cJSON *array);
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
/* Get item "string" from object. Case insensitive. */
extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
/* These calls create a cJSON item of the appropriate type. */
extern cJSON *cJSON_CreateNull();
extern cJSON *cJSON_CreateTrue();
extern cJSON *cJSON_CreateFalse();
extern cJSON *cJSON_CreateBool(int b);
extern cJSON *cJSON_CreateNumber(double num);
extern cJSON *cJSON_CreateString(const char *string);
extern cJSON *cJSON_CreateArray();
extern cJSON *cJSON_CreateObject();
/* These utilities create an Array of count items. */
extern cJSON *cJSON_CreateIntArray(int *numbers,int count);
extern cJSON *cJSON_CreateFloatArray(float *numbers,int count);
extern cJSON *cJSON_CreateDoubleArray(double *numbers,int count);
extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
/* Append item to the specified array/object. */
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
/* Remove/Detatch items from Arrays/Objects. */
extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
extern void cJSON_DeleteItemFromArray(cJSON *array,int which);
extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string);
/* Update array items. */
extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
#ifdef __cplusplus
}
#endif
#endif
This diff is collapsed.
// This file is generated by Simplicity Studio. Please do not edit manually.
//
//
// Enclosing macro to prevent multiple inclusion
#ifndef SILABS_EMBER_AF_COMMAND_PARSE_HEADER
#define SILABS_EMBER_AF_COMMAND_PARSE_HEADER
// This is a set of generated prototype for functions that parse the
// the incomming message, and call appropriate command handler.
// Cluster: Basic, server
EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand *cmd);
// Cluster: Identify, client
EmberAfStatus emberAfIdentifyClusterClientCommandParse(EmberAfClusterCommand *cmd);
// Cluster: Identify, server
EmberAfStatus emberAfIdentifyClusterServerCommandParse(EmberAfClusterCommand *cmd);
// Cluster: On/off, server
EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand *cmd);
// Cluster: Level Control, server
EmberAfStatus emberAfLevelControlClusterServerCommandParse(EmberAfClusterCommand *cmd);
// Cluster: Poll Control, client
EmberAfStatus emberAfPollControlClusterClientCommandParse(EmberAfClusterCommand *cmd);
// Cluster: Green Power, client
EmberAfStatus emberAfGreenPowerClusterClientCommandParse(EmberAfClusterCommand *cmd);
// Cluster: Color Control, server
EmberAfStatus emberAfColorControlClusterServerCommandParse(EmberAfClusterCommand *cmd);
// Cluster: IAS Zone, client
EmberAfStatus emberAfIasZoneClusterClientCommandParse(EmberAfClusterCommand *cmd);
// Cluster: Simple Metering, client
EmberAfStatus emberAfSimpleMeteringClusterClientCommandParse(EmberAfClusterCommand *cmd);
#endif // SILABS_EMBER_AF_COMMAND_PARSE_HEADER
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (C) 2020-2020 ikonke
*/
#ifndef _KK_COM_API_H_
#define _KK_COM_API_H_
#if defined(__cplusplus)
extern "C" {
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "ev.h"
#include "nn.h"
#include "pair.h"
//=====kk======================
typedef enum {
IPC_APP2MID = 0,
IPC_MID2APP,
IPC_MID2PLAT,
IPC_PLAT2MID,
IPC_UNDEF
} ipc_type;
typedef void ipc_cb(void* data, int len);
int kk_ipc_init(ipc_type type, ipc_cb cb);
int kk_ipc_dinit();
int kk_ipc_send(ipc_type type, void* data, int len);
#if defined(__cplusplus)
}
#endif
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// This file is generated by Simplicity Studio. Please do not edit manually.
//
//
// This c file provides stubs for all callbacks. These stubs
// will be used in the case where user defined implementations
// of the callbacks have not been provided.
#include "app/framework/include/af.h"
// Stubs required for implemented stack handlers.
#ifdef EZSP_HOST
#else // ! EZSP_HOST
#endif // EZSP_HOST
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment