Commit e5cd9e56 authored by 尹佳钦's avatar 尹佳钦

2020 0930

parent e5950adc
......@@ -156,6 +156,9 @@ void emberAfPluginDeviceTableDeviceLeftCallback(EmberEUI64 nodeEui64)
rpc_printfJSON("left",nodeJson);
kk_msg_report_dev_leave(deviceTable[deviceTableIndex].eui64);
kk_device_table_delete(deviceTable[deviceTableIndex].eui64);
kk_device_db_delete(deviceTable[deviceTableIndex].eui64);
}
......
......@@ -266,7 +266,7 @@ int _init_param(struct jrpc_server *server) {
//kk_zlog_init("paltform");
printf("getenv\r\n");
char * debug_level_env = getenv("HOME");
char * debug_level_env = getenv("JRPC_DEBUG");
printf("getenv(JRPC_DEBUG):%s\n", server->debug_level);
if (debug_level_env == NULL)
server->debug_level = 0;
......
......@@ -47,13 +47,13 @@ void halReboot(void)
uint8_t halGetResetInfo(void)
{
return RESET_SOFTWARE;
return RESET_SOFTWARE;
}
PGM_P halGetResetString(void)
{
static PGM_P resetString = "SOFTWARE";
return (resetString);
static PGM_P resetString = "SOFTWARE";
return (resetString);
}
// Ideally this should not be necessary, but the serial code references
......
......@@ -31,31 +31,31 @@ void ashPrintCounters(AshCount *counters, bool clear);
void ashClearCounters(AshCount *counters);
static const char usage[] =
" {ncp type} {options}\n"
" ncp type:\n"
" -n 0,1 0=EM2xx/EM3xx @ 115200 bps, RTS/CTS\n"
" 1=EM2xx/EM3xx @ 57600 bps, XON/XOFF\n"
" (if present must be the first option)\n"
" options:\n"
" -b <baud rate> 9600, 19200, 38400, 57600, 115200, etc.\n"
" -f r,x flow control: r=RST/CTS, x=XON/XOFF\n"
" -h display usage information\n"
" -i 0,1 enable/disable input buffering\n"
" -o 0,1 enable/disable output buffering\n"
" -p <port> serial port name or number (eg, COM1, ttyS0, or 1)\n"
" -r d,r,c ncp reset method: d=DTR, r=RST frame, c=custom\n"
" -s 1,2 stop bits\n"
" -t <trace flags> trace B0=frames, B1=verbose frames, B2=events, B3=EZSP\n"
" -v[base-port] enables virtual ISA support. The [base-port] argument\n"
" is optional. Both serial ports are available via telnet\n"
" instead of local console. RAW serial port is available\n"
" on the first port (offset 0 from base port), and CLI is\n"
" available on the second port (offset 1 from base port).\n"
" By default, 4900 is the base-port, therefore RAW access\n"
" is available from port 4900, and CLI access is available\n"
" on port 4901.\n"
" NOTE: No space is allowed between '-v' and [base-port].\n"
" -x 0,1 enable/disable data randomization\n";
" {ncp type} {options}\n"
" ncp type:\n"
" -n 0,1 0=EM2xx/EM3xx @ 115200 bps, RTS/CTS\n"
" 1=EM2xx/EM3xx @ 57600 bps, XON/XOFF\n"
" (if present must be the first option)\n"
" options:\n"
" -b <baud rate> 9600, 19200, 38400, 57600, 115200, etc.\n"
" -f r,x flow control: r=RST/CTS, x=XON/XOFF\n"
" -h display usage information\n"
" -i 0,1 enable/disable input buffering\n"
" -o 0,1 enable/disable output buffering\n"
" -p <port> serial port name or number (eg, COM1, ttyS0, or 1)\n"
" -r d,r,c ncp reset method: d=DTR, r=RST frame, c=custom\n"
" -s 1,2 stop bits\n"
" -t <trace flags> trace B0=frames, B1=verbose frames, B2=events, B3=EZSP\n"
" -v[base-port] enables virtual ISA support. The [base-port] argument\n"
" is optional. Both serial ports are available via telnet\n"
" instead of local console. RAW serial port is available\n"
" on the first port (offset 0 from base port), and CLI is\n"
" available on the second port (offset 1 from base port).\n"
" By default, 4900 is the base-port, therefore RAW access\n"
" is available from port 4900, and CLI access is available\n"
" on port 4901.\n"
" NOTE: No space is allowed between '-v' and [base-port].\n"
" -x 0,1 enable/disable data randomization\n";
static const AshCount zeroAshCount = { 0 };
......
......@@ -559,6 +559,7 @@ bool ezspSerialPortRegisterCallback(EzspSerialPortCallbackFunction callback)
void ezspSerialWriteByte(uint8_t byte)
{
BUMP_HOST_COUNTER(txBytes);
#ifdef IO_LOG
{
......
......@@ -66,10 +66,10 @@
void ezspPrintUsage(char *name)
{
char *shortName = strrchr(name, '/');
shortName = shortName ? shortName + 1 : name;
fprintf(stderr, "Usage: %s", shortName);
fprintf(stderr, usage);
char *shortName = strrchr(name, '/');
shortName = shortName ? shortName + 1 : name;
fprintf(stderr, "Usage: %s", shortName);
fprintf(stderr, usage);
}
#ifdef __CYGWIN__
......@@ -103,16 +103,16 @@ bool checkSerialPort(const char* portString, bool silent)
bool ezspProcessCommandOptions(int argc, char *argv[])
{
char errStr[ERR_LEN] = "";
if (!ezspInternalProcessCommandOptions(argc, argv, errStr)) {
return false;
}
if (*errStr != '\0') {
fprintf(stderr, "%s", errStr);
ezspPrintUsage(argv[0]);
}
return (*errStr == '\0');
char errStr[ERR_LEN] = "";
if (!ezspInternalProcessCommandOptions(argc, argv, errStr)) {
return false;
}
if (*errStr != '\0') {
fprintf(stderr, "%s", errStr);
ezspPrintUsage(argv[0]);
}
return (*errStr == '\0');
}
//------------------------------------------------------------------------------
......
......@@ -1122,26 +1122,26 @@ typedef struct {
* an upgrade file.
*/
typedef struct {
uint16_t manufacturerId;
uint16_t imageTypeId;
uint32_t firmwareVersion;
uint16_t manufacturerId;
uint16_t imageTypeId;
uint32_t firmwareVersion;
/**
* This is only used for device specific files.
* It will be set to all 0's when the image does not
* have an upgrade destination field in it.
* Little endian format.
*/
uint8_t deviceSpecificFileEui64[EUI64_SIZE];
/**
* This is only used for device specific files.
* It will be set to all 0's when the image does not
* have an upgrade destination field in it.
* Little endian format.
*/
uint8_t deviceSpecificFileEui64[EUI64_SIZE];
} EmberAfOtaImageId;
/**
* @brief The list of options possible for the image block request/response.
*/
enum {
EMBER_AF_IMAGE_BLOCK_REQUEST_OPTIONS_NONE = 0,
EMBER_AF_IMAGE_BLOCK_REQUEST_MIN_BLOCK_REQUEST_SUPPORTED_BY_CLIENT = 1,
EMBER_AF_IMAGE_BLOCK_REQUEST_MIN_BLOCK_REQUEST_SUPPORTED_BY_SERVER = 2,
EMBER_AF_IMAGE_BLOCK_REQUEST_OPTIONS_NONE = 0,
EMBER_AF_IMAGE_BLOCK_REQUEST_MIN_BLOCK_REQUEST_SUPPORTED_BY_CLIENT = 1,
EMBER_AF_IMAGE_BLOCK_REQUEST_MIN_BLOCK_REQUEST_SUPPORTED_BY_SERVER = 2,
};
typedef uint8_t EmberAfImageBlockRequestOptions;
......@@ -1150,18 +1150,18 @@ typedef uint8_t EmberAfImageBlockRequestOptions;
* emberAfImageBlockRequestCallback() to let the application decide what to do.
*/
typedef struct {
const EmberAfOtaImageId* id;
uint32_t offset;
const EmberAfOtaImageId* id;
uint32_t offset;
uint32_t waitTimeSecondsResponse;
EmberNodeId source;
EmberEUI64 sourceEui; // optionally present in messages
// The minBlockRequestPeriod can be treated as milliseconds or seconds on the
// client. The OTA server plugin has optional support to probe clients and
// treat this field with appropriate units (ms or sec)
uint16_t minBlockRequestPeriod; // optionally present in messages
uint8_t maxDataSize;
uint8_t clientEndpoint;
EmberAfImageBlockRequestOptions bitmask;
EmberNodeId source;
EmberEUI64 sourceEui; // optionally present in messages
// The minBlockRequestPeriod can be treated as milliseconds or seconds on the
// client. The OTA server plugin has optional support to probe clients and
// treat this field with appropriate units (ms or sec)
uint16_t minBlockRequestPeriod; // optionally present in messages
uint8_t maxDataSize;
uint8_t clientEndpoint;
EmberAfImageBlockRequestOptions bitmask;
} EmberAfImageBlockRequestCallbackStruct;
/**
......@@ -1169,11 +1169,11 @@ typedef struct {
* device operation.
*/
typedef enum {
EMBER_AF_OTA_STORAGE_SUCCESS = 0,
EMBER_AF_OTA_STORAGE_ERROR = 1,
EMBER_AF_OTA_STORAGE_RETURN_DATA_TOO_LONG = 2,
EMBER_AF_OTA_STORAGE_PARTIAL_FILE_FOUND = 3,
EMBER_AF_OTA_STORAGE_OPERATION_IN_PROGRESS = 4,
EMBER_AF_OTA_STORAGE_SUCCESS = 0,
EMBER_AF_OTA_STORAGE_ERROR = 1,
EMBER_AF_OTA_STORAGE_RETURN_DATA_TOO_LONG = 2,
EMBER_AF_OTA_STORAGE_PARTIAL_FILE_FOUND = 3,
EMBER_AF_OTA_STORAGE_OPERATION_IN_PROGRESS = 4,
} EmberAfOtaStorageStatus;
/**
......@@ -1203,41 +1203,41 @@ typedef uint8_t EmberAfOtaDownloadResult;
* It is not a byte-for-byte copy.
*/
typedef struct {
// Magic Number omitted since it is always the same.
uint16_t headerVersion;
uint16_t headerLength;
uint16_t fieldControl;
uint16_t manufacturerId;
uint16_t imageTypeId; // a.k.a. Device ID
uint32_t firmwareVersion;
uint16_t zigbeeStackVersion;
// Magic Number omitted since it is always the same.
uint16_t headerVersion;
uint16_t headerLength;
uint16_t fieldControl;
uint16_t manufacturerId;
uint16_t imageTypeId; // a.k.a. Device ID
uint32_t firmwareVersion;
uint16_t zigbeeStackVersion;
/**
* @brief The spec. does NOT require that the string be NULL terminated in the
* header stored on disk. Therefore we make sure we can support a
* 32-character string without a NULL terminator by adding +1 in the data
* structure.
*/
uint8_t headerString[EMBER_AF_OTA_MAX_HEADER_STRING_LENGTH + 1];
/**
* @brief The spec. does NOT require that the string be NULL terminated in the
* header stored on disk. Therefore we make sure we can support a
* 32-character string without a NULL terminator by adding +1 in the data
* structure.
*/
uint8_t headerString[EMBER_AF_OTA_MAX_HEADER_STRING_LENGTH + 1];
/**
* @brief When reading the header this will be the complete length of
* the file. When writing the header, this must be set to
* the length of the MFG image data portion including all tags.
*/
uint32_t imageSize;
/**
* @brief When reading the header this will be the complete length of
* the file. When writing the header, this must be set to
* the length of the MFG image data portion including all tags.
*/
uint32_t imageSize;
/**
* @brief The remaining four fields are optional. The field control should be checked
* to determine if their values are valid.
*/
uint8_t securityCredentials;
union {
uint8_t EUI64[EUI64_SIZE];
uint8_t UID[UID_SIZE];
} upgradeFileDestination;
uint16_t minimumHardwareVersion;
uint16_t maximumHardwareVersion;
/**
* @brief The remaining four fields are optional. The field control should be checked
* to determine if their values are valid.
*/
uint8_t securityCredentials;
union {
uint8_t EUI64[EUI64_SIZE];
uint8_t UID[UID_SIZE];
} upgradeFileDestination;
uint16_t minimumHardwareVersion;
uint16_t maximumHardwareVersion;
} EmberAfOtaHeader;
/**
......
......@@ -89,94 +89,94 @@ static int myVprintf(int fd, const char* formatString, va_list ap);
EmberStatus backchannelStartServer(uint8_t port)
{
struct sockaddr_in serverAddress;
int flags;
if (!backchannelEnable) {
return EMBER_INVALID_CALL;
}
if (port > 1) {
return EMBER_SERIAL_INVALID_PORT;
}
if (socketFd[port] != -1) {
return EMBER_INVALID_CALL;
}
socketFd[port] = socket(AF_INET, SOCK_STREAM, 0);
if (socketFd[port] < 0) {
unixError("Error: Could not open socket");
return EMBER_ERR_FATAL;
}
flags = 1; // Enable SO_REUSEADDR to reduce bind() complaints
struct sockaddr_in serverAddress;
int flags;
if (!backchannelEnable) {
return EMBER_INVALID_CALL;
}
if (port > 1) {
return EMBER_SERIAL_INVALID_PORT;
}
if (socketFd[port] != -1) {
return EMBER_INVALID_CALL;
}
socketFd[port] = socket(AF_INET, SOCK_STREAM, 0);
if (socketFd[port] < 0) {
unixError("Error: Could not open socket");
return EMBER_ERR_FATAL;
}
flags = 1; // Enable SO_REUSEADDR to reduce bind() complaints
(void) setsockopt(socketFd[port], SOL_SOCKET, SO_REUSEADDR, &flags,
sizeof(flags));
bzero(&(clientConnections[port]), sizeof(struct sockaddr_in));
bzero((char *) &serverAddress, sizeof(serverAddress));
serverAddress.sin_family = AF_INET;
serverAddress.sin_addr.s_addr = INADDR_ANY;
serverAddress.sin_port = htons(SERVER_PORT_OFFSET + port);
if (bind(socketFd[port],
(struct sockaddr *) &serverAddress,
sizeof(serverAddress)) < 0) {
unixError("Error: Could not bind socket to %u", SERVER_PORT_OFFSET + port);
return EMBER_ERR_FATAL;
}
if (0 > listen(socketFd[port], 0)) {
unixError("Error: Could not mark socket as listening");
return EMBER_ERR_FATAL;
}
infoPrint("Listening for connections on port %u", SERVER_PORT_OFFSET + port);
return EMBER_SUCCESS;
bzero(&(clientConnections[port]), sizeof(struct sockaddr_in));
bzero((char *) &serverAddress, sizeof(serverAddress));
serverAddress.sin_family = AF_INET;
serverAddress.sin_addr.s_addr = INADDR_ANY;
serverAddress.sin_port = htons(SERVER_PORT_OFFSET + port);
if (bind(socketFd[port],
(struct sockaddr *) &serverAddress,
sizeof(serverAddress)) < 0) {
unixError("Error: Could not bind socket to %u", SERVER_PORT_OFFSET + port);
return EMBER_ERR_FATAL;
}
if (0 > listen(socketFd[port], 0)) {
unixError("Error: Could not mark socket as listening");
return EMBER_ERR_FATAL;
}
infoPrint("Listening for connections on port %u", SERVER_PORT_OFFSET + port);
return EMBER_SUCCESS;
}
EmberStatus backchannelClientConnectionCleanup(uint8_t port)
{
if (!backchannelEnable) {
return EMBER_INVALID_CALL;
}
if (port > 1) {
return EMBER_SERIAL_INVALID_PORT;
}
if (clientFd[port] != INVALID_FD) {
myPrintf(REMOTE_STDOUT,
"Server closing client connection from %s:%u on port %u\n",
inet_ntoa(clientConnections[port].sin_addr),
ntohs(clientConnections[port].sin_port),
SERVER_PORT_OFFSET + port);
infoPrint("Server closing client connection from %s:%u on port %u\n",
inet_ntoa(clientConnections[port].sin_addr),
ntohs(clientConnections[port].sin_port),
SERVER_PORT_OFFSET + port);
close(clientFd[port]);
clientFd[port] = INVALID_FD;
bzero(&(clientConnections[port]), sizeof(struct sockaddr_in));
}
return EMBER_SUCCESS;
if (!backchannelEnable) {
return EMBER_INVALID_CALL;
}
if (port > 1) {
return EMBER_SERIAL_INVALID_PORT;
}
if (clientFd[port] != INVALID_FD) {
myPrintf(REMOTE_STDOUT,
"Server closing client connection from %s:%u on port %u\n",
inet_ntoa(clientConnections[port].sin_addr),
ntohs(clientConnections[port].sin_port),
SERVER_PORT_OFFSET + port);
infoPrint("Server closing client connection from %s:%u on port %u\n",
inet_ntoa(clientConnections[port].sin_addr),
ntohs(clientConnections[port].sin_port),
SERVER_PORT_OFFSET + port);
close(clientFd[port]);
clientFd[port] = INVALID_FD;
bzero(&(clientConnections[port]), sizeof(struct sockaddr_in));
}
return EMBER_SUCCESS;
}
EmberStatus backchannelStopServer(uint8_t port)
{
if (!backchannelEnable) {
return EMBER_INVALID_CALL;
}
if (port > 1) {
return EMBER_SERIAL_INVALID_PORT;
}
backchannelClientConnectionCleanup(port);
if (socketFd[port] != INVALID_FD) {
myPrintf(LOCAL_STDOUT, "Server closing socket connection %u\n",
SERVER_PORT_OFFSET + port);
close(socketFd[port]);
socketFd[port] = INVALID_FD;
}
return EMBER_SUCCESS;
if (!backchannelEnable) {
return EMBER_INVALID_CALL;
}
if (port > 1) {
return EMBER_SERIAL_INVALID_PORT;
}
backchannelClientConnectionCleanup(port);
if (socketFd[port] != INVALID_FD) {
myPrintf(LOCAL_STDOUT, "Server closing socket connection %u\n",
SERVER_PORT_OFFSET + port);
close(socketFd[port]);
socketFd[port] = INVALID_FD;
}
return EMBER_SUCCESS;
}
// Retrieves a single byte from the client connection. Returns the number
......@@ -226,23 +226,23 @@ EmberStatus backchannelSend(uint8_t port, uint8_t * data, uint8_t length)
// If one doesn't exist, it can wait for a new connection and return
// the result.
BackchannelState backchannelCheckConnection(uint8_t port,
bool waitForConnection)
bool waitForConnection)
{
if (!backchannelEnable) {
return CONNECTION_ERROR;
} else if (clientFd[port] >= 0) {
return CONNECTION_EXISTS;
}
bool getConnection = false;
if (waitForConnection) {
infoPrint("Waiting for client connection on port %u",
port + SERVER_PORT_OFFSET);
getConnection = true;
} else if (!willServerConnectionBlock(port)) {
getConnection = true;
}
if (!backchannelEnable) {
return CONNECTION_ERROR;
} else if (clientFd[port] >= 0) {
return CONNECTION_EXISTS;
}
bool getConnection = false;
if (waitForConnection) {
infoPrint("Waiting for client connection on port %u",
port + SERVER_PORT_OFFSET);
getConnection = true;
} else if (!willServerConnectionBlock(port)) {
getConnection = true;
}
if (getConnection) {
return (getNewConnection(port)
......@@ -450,32 +450,32 @@ static bool getNewConnection(uint8_t port)
// Print an error message plus the associated 'errno' string
static void unixError(const char* format, ...)
{
va_list ap = { 0 };
va_start(ap, format);
myVprintf(LOCAL_STDERR, format, ap);
va_end(ap);
myPrintf(LOCAL_STDERR, ": %s\n", strerror(errno));
va_list ap = { 0 };
va_start(ap, format);
myVprintf(LOCAL_STDERR, format, ap);
va_end(ap);
myPrintf(LOCAL_STDERR, ": %s\n", strerror(errno));
}
static void debugPrint(const char* formatString, ...)
{
if (debugOn) {
va_list ap = { 0 };
myPrintf(LOCAL_STDERR, "[%s] ", debugString);
va_start(ap, formatString);
myVprintf(LOCAL_STDERR, formatString, ap);
va_end(ap);
myPrintf(LOCAL_STDERR, "\n");
}
if (debugOn) {
va_list ap = { 0 };
myPrintf(LOCAL_STDERR, "[%s] ", debugString);
va_start(ap, formatString);
myVprintf(LOCAL_STDERR, formatString, ap);
va_end(ap);
myPrintf(LOCAL_STDERR, "\n");
}
}
static void infoPrint(const char* formatString, ...)
{
va_list ap = { 0 };
va_start(ap, formatString);
myVprintf(LOCAL_STDOUT, formatString, ap);
va_end(ap);
myPrintf(LOCAL_STDOUT, "\n");
va_list ap = { 0 };
va_start(ap, formatString);
myVprintf(LOCAL_STDOUT, formatString, ap);
va_end(ap);
myPrintf(LOCAL_STDOUT, "\n");
}
// Because we mess around with FDs, we need our own printing routine
......@@ -483,20 +483,20 @@ static void infoPrint(const char* formatString, ...)
static int myPrintf(int fd, const char* formatString, ...)
{
va_list ap = { 0 };
int returnCode;
va_start(ap, formatString);
returnCode = myVprintf(fd, formatString, ap);
va_end(ap);
return returnCode;
va_list ap = { 0 };
int returnCode;
va_start(ap, formatString);
returnCode = myVprintf(fd, formatString, ap);
va_end(ap);
return returnCode;
}
// Returns 0 on success, 1 on error
static int myVprintf(int fd, const char* formatString, va_list ap)
{
int length;
char string[MAX_STRING_LENGTH];
length = vsnprintf(string, MAX_STRING_LENGTH - 1, formatString, ap);
string[length] = '\0';
return (length != write(fd, string, length));
int length;
char string[MAX_STRING_LENGTH];
length = vsnprintf(string, MAX_STRING_LENGTH - 1, formatString, ap);
string[length] = '\0';
return (length != write(fd, string, length));
}
......@@ -65,28 +65,28 @@ static void ezspSerialPortCallback(EzspSerialPortEvent event, int fileDescriptor
static EmberStatus gatewayBackchannelStart(void)
{
if (backchannelEnable) {
if (EMBER_SUCCESS != backchannelStartServer(SERIAL_PORT_CLI)) {
fprintf(stderr,
"Fatal: Failed to start backchannel services for CLI.\n");
return EMBER_ERR_FATAL;
}
if (EMBER_SUCCESS != backchannelStartServer(SERIAL_PORT_RAW)) {
fprintf(stderr,
"Fatal: Failed to start backchannel services for RAW data.\n");
return EMBER_ERR_FATAL;
}
}
return EMBER_SUCCESS;
if (backchannelEnable) {
if (EMBER_SUCCESS != backchannelStartServer(SERIAL_PORT_CLI)) {
fprintf(stderr,
"Fatal: Failed to start backchannel services for CLI.\n");
return EMBER_ERR_FATAL;
}
if (EMBER_SUCCESS != backchannelStartServer(SERIAL_PORT_RAW)) {
fprintf(stderr,
"Fatal: Failed to start backchannel services for RAW data.\n");
return EMBER_ERR_FATAL;
}
}
return EMBER_SUCCESS;
}
void gatewayBackchannelStop(void)
{
if (backchannelEnable) {
backchannelStopServer(SERIAL_PORT_CLI);
backchannelStopServer(SERIAL_PORT_RAW);
}
if (backchannelEnable) {
backchannelStopServer(SERIAL_PORT_CLI);
backchannelStopServer(SERIAL_PORT_RAW);
}
}
bool emberAfMainStartCallback(int* returnCode,
......@@ -95,21 +95,21 @@ bool emberAfMainStartCallback(int* returnCode,
{
debugPrint("gatewaitInit()");
// This will process EZSP command-line options as well as determine
// whether the backchannel should be turned on.
if (!ezspProcessCommandOptions(argc, argv)) {
*returnCode = EMBER_ERR_FATAL;
return true;
}
// This will process EZSP command-line options as well as determine
// whether the backchannel should be turned on.
if (!ezspProcessCommandOptions(argc, argv)) {
*returnCode = EMBER_ERR_FATAL;
return true;
}
*returnCode = gatewayBackchannelStart();
if (*returnCode != EMBER_SUCCESS) {
return true;
}
*returnCode = gatewayBackchannelStart();
if (*returnCode != EMBER_SUCCESS) {
return true;
}
emberSerialSetPrompt(cliPrompt);
emberSerialSetPrompt(cliPrompt);
emberSerialCommandCompletionInit(emberCommandTable);
emberSerialCommandCompletionInit(emberCommandTable);
return false;
}
......
......@@ -3,10 +3,10 @@ void gatewayBackchannelStop(void);
typedef uint8_t BackchannelState;
enum {
NO_CONNECTION = 0,
CONNECTION_EXISTS = 1,
NEW_CONNECTION = 2,
CONNECTION_ERROR = 3,
NO_CONNECTION = 0,
CONNECTION_EXISTS = 1,
NEW_CONNECTION = 2,
CONNECTION_ERROR = 3,
};
extern const bool backchannelSupported;
......
......@@ -38,7 +38,7 @@ void emAfOtaImageDelete(void);
// Server CLI interface
#if !defined (EMBER_AF_PLUGIN_OTA_SERVER)
#define OTA_SERVER_COMMANDS
#define OTA_SERVER_COMMANDS
#endif
void otaImageNotifyCommand(void);
......@@ -21,9 +21,9 @@
// This relates all OTA command IDs in app/framework/gen/command-id.h
// to minimum message lengths (does not include EMBER_AF_ZCL_OVERHEAD)
PGM uint8_t emAfOtaMinMessageLengths[] = {
2, // Image Notify
2, // Image Notify
8, // Query Next Image Request
1, // Query Next Image Response
1, // Query Next Image Response
13, // Image Block Request
13, // Image Page Request
1, // Image Block Response (abort is shortest)
......@@ -48,14 +48,14 @@ EmberAfOtaImageId emAfOtaCreateEmberAfOtaImageIdStruct(uint16_t manufacturerId,
// This assumes the message has already been validated for its length
uint8_t emAfOtaParseImageIdFromMessage(EmberAfOtaImageId* returnId,
const uint8_t* buffer,
uint8_t length)
const uint8_t* buffer,
uint8_t length)
{
returnId->manufacturerId = emberAfGetInt16u(buffer, 0, length);
returnId->imageTypeId = emberAfGetInt16u(buffer, 2, length);
returnId->firmwareVersion = emberAfGetInt32u(buffer, 4, length);
MEMSET(returnId->deviceSpecificFileEui64, 0, EUI64_SIZE);
return 8;
returnId->manufacturerId = emberAfGetInt16u(buffer, 0, length);
returnId->imageTypeId = emberAfGetInt16u(buffer, 2, length);
returnId->firmwareVersion = emberAfGetInt32u(buffer, 4, length);
MEMSET(returnId->deviceSpecificFileEui64, 0, EUI64_SIZE);
return 8;
}
#if defined(EMBER_AF_PRINT_CORE)
......
......@@ -149,9 +149,9 @@ static PGM_P notifyArguments[] = {
emberCommandEntryTerminator(),
EmberCommandEntry emberAfPluginOtaServerCommands[] = {
OTA_SERVER_COMMANDS
OTA_SERVER_COMMANDS
emberCommandEntryTerminator(),
emberCommandEntryTerminator(),
};
#endif // EMBER_AF_GENERATE_CLI
......
......@@ -79,13 +79,13 @@ uint8_t getIndexForDownloadingNodeId(EmberNodeId nodeId)
void emAfOtaServerDynamicBlockPeriodInit()
{
// Initialize array to have no current OTA downloads
uint8_t nodeIndex;
for (nodeIndex = 0; nodeIndex < MAX_DOWNLOADS; nodeIndex++) {
downloadingNodes[nodeIndex].nodeId = EMBER_NULL_NODE_ID;
downloadingNodes[nodeIndex].unitDiscoveryState = STATE_NONE;
downloadingNodes[nodeIndex].msTickWhenLastSeen = 0;
}
// Initialize array to have no current OTA downloads
uint8_t nodeIndex;
for (nodeIndex = 0; nodeIndex < MAX_DOWNLOADS; nodeIndex++) {
downloadingNodes[nodeIndex].nodeId = EMBER_NULL_NODE_ID;
downloadingNodes[nodeIndex].unitDiscoveryState = STATE_NONE;
downloadingNodes[nodeIndex].msTickWhenLastSeen = 0;
}
}
void emAfOtaServerDynamicBlockPeriodTick()
......
......@@ -111,11 +111,11 @@ uint8_t emAfOtaPageRequestHandler(uint8_t clientEndpoint,
void emAfOtaPageRequestTick(uint8_t endpoint)
{
if (requesterNodeId == EMBER_NULL_NODE_ID) {
return;
}
if (requesterNodeId == EMBER_NULL_NODE_ID) {
return;
}
sendBlockRequest();
sendBlockRequest();
emberAfScheduleServerTickExtended(endpoint,
ZCL_OTA_BOOTLOAD_CLUSTER_ID,
requesterResponseSpacing,
......
......@@ -142,10 +142,10 @@ void emAfOtaImageDelete(void)
void emAfOtaReloadStorageDevice(void)
{
#if defined (EMBER_AF_PLUGIN_OTA_STORAGE_POSIX_FILESYSTEM)
emAfOtaStorageClose();
emAfOtaStorageClose();
#endif
emberAfOtaStorageInitCallback();
emberAfOtaStorageInitCallback();
}
#define PRINT_BLOCK_LENGTH 64
......
......@@ -39,18 +39,18 @@
EmberAfOtaImageId emAfOtaStorageGetImageIdFromHeader(const EmberAfOtaHeader* header)
{
EmberAfOtaImageId id = INVALID_OTA_IMAGE_ID;
id.manufacturerId = header->manufacturerId;
id.imageTypeId = header->imageTypeId;
id.firmwareVersion = header->firmwareVersion;
if (headerHasUpgradeFileDest(header)) {
MEMCOPY(id.deviceSpecificFileEui64,
&header->upgradeFileDestination,
EUI64_SIZE);
}
return id;
EmberAfOtaImageId id = INVALID_OTA_IMAGE_ID;
id.manufacturerId = header->manufacturerId;
id.imageTypeId = header->imageTypeId;
id.firmwareVersion = header->firmwareVersion;
if (headerHasUpgradeFileDest(header)) {
MEMCOPY(id.deviceSpecificFileEui64,
&header->upgradeFileDestination,
EUI64_SIZE);
}
return id;
}
uint16_t emGetUpgradeFileDestinationLength(uint16_t headerVersion)
......@@ -249,7 +249,7 @@ EmberAfOtaStorageStatus emAfOtaStorageReadAllTagInfo(const EmberAfOtaImageId* id
bool emberAfIsOtaImageIdValid(const EmberAfOtaImageId* idToCompare)
{
return (0 != MEMPGMCOMPARE(idToCompare,
&emberAfInvalidImageId,
sizeof(EmberAfOtaImageId)));
return (0 != MEMPGMCOMPARE(idToCompare,
&emberAfInvalidImageId,
sizeof(EmberAfOtaImageId)));
}
......@@ -40,18 +40,18 @@
#define TAG_OVERHEAD (2 + 4) // 2 bytes for the tag ID, 4 bytes for the length
#define isValidHeaderVersion(headerVersion) \
((headerVersion == OTA_HEADER_VERSION_ZIGBEE) || (headerVersion == OTA_HEADER_VERSION_THREAD))
((headerVersion == OTA_HEADER_VERSION_ZIGBEE) || (headerVersion == OTA_HEADER_VERSION_THREAD))
#define SECURITY_CREDENTIAL_VERSION_FIELD_PRESENT_MASK 0x0001
#define DEVICE_SPECIFIC_FILE_PRESENT_MASK 0x0002
#define HARDWARE_VERSIONS_PRESENT_MASK 0x0004
#define headerHasSecurityCredentials(header) \
((header)->fieldControl & SECURITY_CREDENTIAL_VERSION_FIELD_PRESENT_MASK)
((header)->fieldControl & SECURITY_CREDENTIAL_VERSION_FIELD_PRESENT_MASK)
#define headerHasUpgradeFileDest(header) \
((header)->fieldControl & DEVICE_SPECIFIC_FILE_PRESENT_MASK)
((header)->fieldControl & DEVICE_SPECIFIC_FILE_PRESENT_MASK)
#define headerHasHardwareVersions(header) \
((header)->fieldControl & HARDWARE_VERSIONS_PRESENT_MASK)
((header)->fieldControl & HARDWARE_VERSIONS_PRESENT_MASK)
// This size does NOT include the tag overhead.
#define SIGNATURE_TAG_DATA_SIZE (EUI64_SIZE + EMBER_SIGNATURE_SIZE)
......@@ -63,11 +63,11 @@
#define INVALID_EUI64 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
#define INVALID_OTA_IMAGE_ID \
{ INVALID_MANUFACTURER_ID, \
INVALID_DEVICE_ID, \
INVALID_FIRMWARE_VERSION, \
INVALID_EUI64, \
}
{ INVALID_MANUFACTURER_ID, \
INVALID_DEVICE_ID, \
INVALID_FIRMWARE_VERSION, \
INVALID_EUI64, \
}
#define INVALID_SLOT (uint32_t)-1
......
......@@ -3,12 +3,12 @@
typedef void (EmAfOtaStorageFileAddedHandler)(const EmberAfOtaHeader*);
typedef struct {
bool memoryDebug;
bool fileDebug;
bool fieldDebug;
bool ignoreFilesWithUnderscorePrefix;
bool printFileDiscoveryOrRemoval;
EmAfOtaStorageFileAddedHandler* fileAddedHandler;
bool memoryDebug;
bool fileDebug;
bool fieldDebug;
bool ignoreFilesWithUnderscorePrefix;
bool printFileDiscoveryOrRemoval;
EmAfOtaStorageFileAddedHandler* fileAddedHandler;
} EmAfOtaStorageLinuxConfig;
void emAfOtaStorageGetConfig(EmAfOtaStorageLinuxConfig* currentConfig);
......
......@@ -77,6 +77,6 @@ bool emberAfIsCurrentSecurityProfileSmartEnergy(void)
|| (emAfCurrentZigbeeProNetwork->securityProfile
== EMBER_AF_SECURITY_PROFILE_SE_FULL)));
#else
return false;
return false;
#endif
}
......@@ -545,16 +545,12 @@ int emberAfMain(MAIN_FUNCTION_PARAMETERS)
halInit();
INTERRUPTS_ON(); // Safe to enable interrupts at this point
{
int returnCode;
if (emberAfMainStartCallback(&returnCode,
APP_FRAMEWORK_MAIN_ARGUMENTS)) { //get serial port info
int returnCode;
if (emberAfMainStartCallback(&returnCode,
APP_FRAMEWORK_MAIN_ARGUMENTS)) { //get serial port info
return returnCode;
}
}
kk_print("*******************123****************\r\n");
kk_print_info("\r\n-----hello world![%s:%s]-----\r\n",__DATE__,__TIME__);
kk_print_version();
}
emberSerialInit(APP_SERIAL, BAUD_RATE, PARITY_NONE, 1); //fock child process
......
......@@ -379,6 +379,6 @@ EmberApsFrame *emberAfGetCommandApsFrame(void)
void emberAfSetCommandEndpoints(uint8_t sourceEndpoint, uint8_t destinationEndpoint)
{
emAfCommandApsFrame->sourceEndpoint = sourceEndpoint;
emAfCommandApsFrame->destinationEndpoint = destinationEndpoint;
emAfCommandApsFrame->sourceEndpoint = sourceEndpoint;
emAfCommandApsFrame->destinationEndpoint = destinationEndpoint;
}
......@@ -688,7 +688,7 @@ EmberStatus emberAfSendResponseWithCallback(EmberAfMessageSentFunction callback)
EmberStatus emberAfSendResponse(void)
{
return emberAfSendResponseWithCallback(NULL);
return emberAfSendResponseWithCallback(NULL);
}
EmberStatus emberAfSendImmediateDefaultResponseWithCallback(EmberAfStatus status,
......
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