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

2020 0930

parent e5950adc
...@@ -156,6 +156,9 @@ void emberAfPluginDeviceTableDeviceLeftCallback(EmberEUI64 nodeEui64) ...@@ -156,6 +156,9 @@ void emberAfPluginDeviceTableDeviceLeftCallback(EmberEUI64 nodeEui64)
rpc_printfJSON("left",nodeJson); rpc_printfJSON("left",nodeJson);
kk_msg_report_dev_leave(deviceTable[deviceTableIndex].eui64); 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) { ...@@ -266,7 +266,7 @@ int _init_param(struct jrpc_server *server) {
//kk_zlog_init("paltform"); //kk_zlog_init("paltform");
printf("getenv\r\n"); 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); printf("getenv(JRPC_DEBUG):%s\n", server->debug_level);
if (debug_level_env == NULL) if (debug_level_env == NULL)
server->debug_level = 0; server->debug_level = 0;
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
static const char options[] = "b:f:hv::i:n:o:p:r:s:t:x:"; static const char options[] = "b:f:hv::i:n:o:p:r:s:t:x:";
bool checkSerialPort(const char* portString); bool checkSerialPort(const char* portString);
bool ezspInternalProcessCommandOptions(int argc, char *argv[], char *errStr) bool ezspInternalProcessCommandOptions(int argc, char *argv[], char *errStr)
{ {
int c; int c;
...@@ -137,7 +138,7 @@ bool ezspInternalProcessCommandOptions(int argc, char *argv[], char *errStr) ...@@ -137,7 +138,7 @@ bool ezspInternalProcessCommandOptions(int argc, char *argv[], char *errStr)
devport[5] = '\0'; devport[5] = '\0';
if ( strncmp(devport, port, 5) == 0) { if ( strncmp(devport, port, 5) == 0) {
strncat(devport, port + 5, ASH_PORT_LEN - 5 - 1); strncat(devport, port + 5, ASH_PORT_LEN - 5 - 1);
#ifdef __CYGWIN__ #ifdef __CYGWIN__
} else if ( ((strncmp("COM", port, 3) == 0) } else if ( ((strncmp("COM", port, 3) == 0)
|| (strncmp("com", port, 3) == 0) ) || (strncmp("com", port, 3) == 0) )
&& (sscanf(port + 3, "%hhu", &portnum) == 1) && (sscanf(port + 3, "%hhu", &portnum) == 1)
...@@ -145,10 +146,10 @@ bool ezspInternalProcessCommandOptions(int argc, char *argv[], char *errStr) ...@@ -145,10 +146,10 @@ bool ezspInternalProcessCommandOptions(int argc, char *argv[], char *errStr)
snprintf(devport, ASH_PORT_LEN, "/dev/ttyS%hhu", portnum - 1); snprintf(devport, ASH_PORT_LEN, "/dev/ttyS%hhu", portnum - 1);
} else if ( (sscanf(port, "%hhu", &portnum) == 1) && portnum ) { } else if ( (sscanf(port, "%hhu", &portnum) == 1) && portnum ) {
snprintf(devport, ASH_PORT_LEN, "/dev/ttyS%hhu", portnum - 1); snprintf(devport, ASH_PORT_LEN, "/dev/ttyS%hhu", portnum - 1);
#else #else
} else if (sscanf(port, "%hhu", &portnum) == 1) { } else if (sscanf(port, "%hhu", &portnum) == 1) {
snprintf(devport, ASH_PORT_LEN, "/dev/ttyS%hhu", portnum); snprintf(devport, ASH_PORT_LEN, "/dev/ttyS%hhu", portnum);
#endif #endif
} else { } else {
strncat(devport, port, ASH_PORT_LEN - 1); strncat(devport, port, ASH_PORT_LEN - 1);
} }
......
...@@ -559,6 +559,7 @@ bool ezspSerialPortRegisterCallback(EzspSerialPortCallbackFunction callback) ...@@ -559,6 +559,7 @@ bool ezspSerialPortRegisterCallback(EzspSerialPortCallbackFunction callback)
void ezspSerialWriteByte(uint8_t byte) void ezspSerialWriteByte(uint8_t byte)
{ {
BUMP_HOST_COUNTER(txBytes); BUMP_HOST_COUNTER(txBytes);
#ifdef IO_LOG #ifdef IO_LOG
{ {
......
...@@ -226,11 +226,13 @@ uint8_t emberAfOtaServerQueryCallback(const EmberAfOtaImageId* currentImageId, ...@@ -226,11 +226,13 @@ uint8_t emberAfOtaServerQueryCallback(const EmberAfOtaImageId* currentImageId,
// We only perform a check if both the query and the // We only perform a check if both the query and the
// file have hardware version(s). If one or the other doesn't // file have hardware version(s). If one or the other doesn't
// have them, we assume a match is still possible. // have them, we assume a match is still possible.
otaPrintln("[OTA]2222,hardwareVersion=%d",hardwareVersion);
if (hardwareVersion) { if (hardwareVersion) {
EmberAfOtaHeader header; EmberAfOtaHeader header;
emberAfOtaStorageGetFullHeaderCallback(nextUpgradeImageId, emberAfOtaStorageGetFullHeaderCallback(nextUpgradeImageId,
&header); &header);
if (header.fieldControl & HARDWARE_VERSIONS_PRESENT_MASK) { if (header.fieldControl & HARDWARE_VERSIONS_PRESENT_MASK) {
otaPrintln("[OTA]3333");
if (*hardwareVersion < header.minimumHardwareVersion if (*hardwareVersion < header.minimumHardwareVersion
|| header.maximumHardwareVersion < *hardwareVersion) { || header.maximumHardwareVersion < *hardwareVersion) {
otaPrintln("Hardware version 0x%02X does not fall within the min (0x%02X) and max (0x%02X) hardware versions in the file.", otaPrintln("Hardware version 0x%02X does not fall within the min (0x%02X) and max (0x%02X) hardware versions in the file.",
...@@ -246,16 +248,19 @@ uint8_t emberAfOtaServerQueryCallback(const EmberAfOtaImageId* currentImageId, ...@@ -246,16 +248,19 @@ uint8_t emberAfOtaServerQueryCallback(const EmberAfOtaImageId* currentImageId,
// as a potential upgrade candidate because the hardware is out // as a potential upgrade candidate because the hardware is out
// of range. // of range.
if (!hardwareVersionMismatch) { if (!hardwareVersionMismatch) {
otaPrintln("[OTA]4444,%x,%x",nextUpgradeImageId->firmwareVersion,currentImageId->firmwareVersion);
status = (determineNextSoftwareVersion(nextUpgradeImageId->firmwareVersion, status = (determineNextSoftwareVersion(nextUpgradeImageId->firmwareVersion,
currentImageId->firmwareVersion) currentImageId->firmwareVersion)
? EMBER_ZCL_STATUS_SUCCESS ? EMBER_ZCL_STATUS_SUCCESS
: EMBER_ZCL_STATUS_NO_IMAGE_AVAILABLE); : EMBER_ZCL_STATUS_NO_IMAGE_AVAILABLE);
otaPrintln("[OTA]555,status=%x",status);
if (status == EMBER_ZCL_STATUS_SUCCESS) { if (status == EMBER_ZCL_STATUS_SUCCESS) {
otaPrintln("Next fw version is: 0x%4X", otaPrintln("Next fw version is: 0x%4X",
nextUpgradeImageId->firmwareVersion); nextUpgradeImageId->firmwareVersion);
} }
} }
} }
otaPrintln("[OTA]11111");
return status; return status;
} }
......
...@@ -571,6 +571,54 @@ void emberAfOtaServerSendUpgradeCommandCallback(EmberNodeId dest, ...@@ -571,6 +571,54 @@ void emberAfOtaServerSendUpgradeCommandCallback(EmberNodeId dest,
} }
} }
void kk_ota_test123123123()
{
EmberAfOtaImageId id;
id.manufacturerId = 0x1268;
id.imageTypeId = 0x2904;
id.firmwareVersion = 15;
emberAfOtaServerSendImageNotifyCallback(0xffff,
1,
0x03,
0,
&id);
}
void kk_ota_test111()
{
/*zclBufferSetup(ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT|ZCL_DISABLE_DEFAULT_RESPONSE_MASK, \
(ZCL_OTA_BOOTLOAD_CLUSTER_ID), \
(ZCL_IMAGE_NOTIFY_COMMAND_ID));
zclBufferAddByte(0x03);
zclBufferAddByte(0x00);
zclBufferAddWord(0x1234);
zclBufferAddWord(0x5678);
zclBufferAddInt32(0x11223344);
rpcSendCommand(0xffff,1,1,false);
emberAfCorePrintln("[kk_ota_test111] \r\n");*/
emberAfCorePrintln("[kk_ota_test111] \r\n");
static int cnt;
EmberAfOtaImageId id = emberAfOtaStorageIteratorFirstCallback();
cnt = 0;
do {
emberAfCorePrintln("**********%d********\r\n",++cnt);
emberAfCorePrintln("manufacturerId=0x%4X \r\n",id.manufacturerId);
emberAfCorePrintln("imageTypeId=0x%4X \r\n",id.imageTypeId);
emberAfCorePrintln("firmwareVersion=0x%8X \r\n",id.firmwareVersion);
id = emberAfOtaStorageIteratorNextCallback();
} while (emberAfIsOtaImageIdValid(&id));
}
static int s_ota_server_init = 0; static int s_ota_server_init = 0;
EmberAfOtaImageId kk_get_imageId(char* filename){ EmberAfOtaImageId kk_get_imageId(char* filename){
...@@ -589,7 +637,6 @@ EmberAfOtaImageId kk_get_imageId(char* filename){ ...@@ -589,7 +637,6 @@ EmberAfOtaImageId kk_get_imageId(char* filename){
return emberAfInvalidImageId; return emberAfInvalidImageId;
} }
void kk_ota_notify(char* filepath){ void kk_ota_notify(char* filepath){
if (s_ota_server_init == 0){ if (s_ota_server_init == 0){
s_ota_server_init = 1; s_ota_server_init = 1;
......
...@@ -63,11 +63,11 @@ ...@@ -63,11 +63,11 @@
#define INVALID_EUI64 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } #define INVALID_EUI64 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
#define INVALID_OTA_IMAGE_ID \ #define INVALID_OTA_IMAGE_ID \
{ INVALID_MANUFACTURER_ID, \ { INVALID_MANUFACTURER_ID, \
INVALID_DEVICE_ID, \ INVALID_DEVICE_ID, \
INVALID_FIRMWARE_VERSION, \ INVALID_FIRMWARE_VERSION, \
INVALID_EUI64, \ INVALID_EUI64, \
} }
#define INVALID_SLOT (uint32_t)-1 #define INVALID_SLOT (uint32_t)-1
......
...@@ -170,9 +170,9 @@ static OtaImage* iterator = NULL; ...@@ -170,9 +170,9 @@ static OtaImage* iterator = NULL;
#endif #endif
static EmAfOtaStorageLinuxConfig config = { static EmAfOtaStorageLinuxConfig config = {
false, // memoryDebug true, // memoryDebug
false, // fileDebug true, // fileDebug
false, // fieldDebug true, // fieldDebug
true, // ignoreFilesWithUnderscorePrefix true, // ignoreFilesWithUnderscorePrefix
true, // printFileDiscoveryOrRemoval true, // printFileDiscoveryOrRemoval
NULL, // fileAddedHandler NULL, // fileAddedHandler
...@@ -863,13 +863,6 @@ static void printHeaderInfo(const EmberAfOtaHeader* header) ...@@ -863,13 +863,6 @@ static void printHeaderInfo(const EmberAfOtaHeader* header)
if (!config.printFileDiscoveryOrRemoval) { if (!config.printFileDiscoveryOrRemoval) {
return; return;
} }
// printf(" Header Version: 0x%04X\n",
// header->headerVersion);
// printf(" Header Length: 0x%04X\n",
// header->headerLength);
// printf(" Field Control: 0x%04X\n",
// header->fieldControl);
note(" Manufacturer ID: 0x%04X\n", note(" Manufacturer ID: 0x%04X\n",
header->manufacturerId); header->manufacturerId);
note(" Image Type ID: 0x%04X\n", note(" Image Type ID: 0x%04X\n",
...@@ -878,7 +871,6 @@ static void printHeaderInfo(const EmberAfOtaHeader* header) ...@@ -878,7 +871,6 @@ static void printHeaderInfo(const EmberAfOtaHeader* header)
header->firmwareVersion); header->firmwareVersion);
note(" Header String: %s\n", note(" Header String: %s\n",
header->headerString); header->headerString);
// printf("\n");
} }
static OtaImage* addImageFileToList(const char* filename, static OtaImage* addImageFileToList(const char* filename,
......
...@@ -545,16 +545,12 @@ int emberAfMain(MAIN_FUNCTION_PARAMETERS) ...@@ -545,16 +545,12 @@ int emberAfMain(MAIN_FUNCTION_PARAMETERS)
halInit(); halInit();
INTERRUPTS_ON(); // Safe to enable interrupts at this point INTERRUPTS_ON(); // Safe to enable interrupts at this point
{
int returnCode; int returnCode;
if (emberAfMainStartCallback(&returnCode, if (emberAfMainStartCallback(&returnCode,
APP_FRAMEWORK_MAIN_ARGUMENTS)) { //get serial port info APP_FRAMEWORK_MAIN_ARGUMENTS)) { //get serial port info
return returnCode; 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 emberSerialInit(APP_SERIAL, BAUD_RATE, PARITY_NONE, 1); //fock child process
......
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