fix update config bug
This commit is contained in:
parent
4a7273cf43
commit
fa85d8ee46
@ -21,7 +21,6 @@ enum enumZigBeeTransmitStatus {
|
|||||||
//#define Q4G_MODULE
|
//#define Q4G_MODULE
|
||||||
//#define WIFI_MODULE
|
//#define WIFI_MODULE
|
||||||
//#define NR5G_MEIGE
|
//#define NR5G_MEIGE
|
||||||
//#define G2UL_GATEWAY
|
|
||||||
|
|
||||||
class GlobalConfig
|
class GlobalConfig
|
||||||
{
|
{
|
||||||
|
|||||||
@ -229,6 +229,20 @@ std::string JsonData::JsonCmd_Cgi_53(std::vector<Param_53> ¶m) {
|
|||||||
char whereCon[1024] = {0};
|
char whereCon[1024] = {0};
|
||||||
char updateSql[1024] = {0};
|
char updateSql[1024] = {0};
|
||||||
for (size_t i = 0; i < param.size(); i++) {
|
for (size_t i = 0; i < param.size(); i++) {
|
||||||
|
|
||||||
|
sprintf(whereCon, "dataNodeNo='%s'", param[i].mdataNodeNo.c_str());
|
||||||
|
std::string zigbeeShortAddr = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), " zigbeeShortAddr ", whereCon);
|
||||||
|
|
||||||
|
uint16_t short_addr;
|
||||||
|
char *end_ptr = NULL;
|
||||||
|
short_addr = strtol(zigbeeShortAddr.c_str(), &end_ptr, 16);
|
||||||
|
int res = scheduler::instance().UpdateSensorConfig(short_addr);
|
||||||
|
if (res != 0){
|
||||||
|
jsonVal["success"] = false;
|
||||||
|
jsonVal["message"] = "update config error";
|
||||||
|
return show_value_.write(jsonVal);
|
||||||
|
}
|
||||||
|
|
||||||
if (param[i].mUpdateKey2 == "") {
|
if (param[i].mUpdateKey2 == "") {
|
||||||
sprintf(updateSql, "%s='%s',UpdateFlag = 0", param[i].mUpdateKey.c_str(), param[i].mUpdateValue.c_str());
|
sprintf(updateSql, "%s='%s',UpdateFlag = 0", param[i].mUpdateKey.c_str(), param[i].mUpdateValue.c_str());
|
||||||
} else if (param[i].mUpdateKey3 == "" && param[i].mUpdateKey2 != "") {
|
} else if (param[i].mUpdateKey3 == "" && param[i].mUpdateKey2 != "") {
|
||||||
|
|||||||
7
main.cpp
7
main.cpp
@ -78,10 +78,6 @@ int main(int argc, char *argv[]) {
|
|||||||
boost::thread uartWaveReadTh(UartStartWave);
|
boost::thread uartWaveReadTh(UartStartWave);
|
||||||
uartWaveReadTh.detach();
|
uartWaveReadTh.detach();
|
||||||
|
|
||||||
//启动 RUN LED
|
|
||||||
boost::thread startRunLED(RunLED);
|
|
||||||
startRunLED.detach();
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef NR5G_MODULE
|
#ifdef NR5G_MODULE
|
||||||
print_info("NR5G_MODULE \n");
|
print_info("NR5G_MODULE \n");
|
||||||
@ -140,9 +136,6 @@ int main(int argc, char *argv[]) {
|
|||||||
//int fd = OpenWatchDog();
|
//int fd = OpenWatchDog();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (GlobalConfig::QuitFlag_G) {
|
while (GlobalConfig::QuitFlag_G) {
|
||||||
gpio_set(GlobalConfig::GPIO_G.hardWatchDog, 1);
|
|
||||||
usleep(20000);
|
|
||||||
gpio_set(GlobalConfig::GPIO_G.hardWatchDog, 0);
|
|
||||||
//WriteWatchDog(fd);
|
//WriteWatchDog(fd);
|
||||||
sleep(20);
|
sleep(20);
|
||||||
if (GlobalConfig::threadStatus == 0) {
|
if (GlobalConfig::threadStatus == 0) {
|
||||||
|
|||||||
@ -1034,7 +1034,14 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
|
|||||||
sprintf(whereCon, "zigbeeShortAddr='%s'",strShortAddr.c_str());
|
sprintf(whereCon, "zigbeeShortAddr='%s'",strShortAddr.c_str());
|
||||||
std::string strDataNodeNo = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), " dataNodeNo ", whereCon);
|
std::string strDataNodeNo = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), " dataNodeNo ", whereCon);
|
||||||
memset(whereCon, 0x00, sizeof(whereCon));
|
memset(whereCon, 0x00, sizeof(whereCon));
|
||||||
sprintf(error_msg,"Index error,command = %d",command);
|
if (command == WAVE_X){
|
||||||
|
sprintf(error_msg,"Index error,wave X");
|
||||||
|
}else if (command == WAVE_Y){
|
||||||
|
sprintf(error_msg,"Index error,wave Y");
|
||||||
|
}else if (command == WAVE_Z){
|
||||||
|
sprintf(error_msg,"Index error,wave Z");
|
||||||
|
}
|
||||||
|
|
||||||
sprintf(insertSql, "'%s','%s','%s',%d,'%d','%s' ", strDataNodeNo.c_str(),strShortAddr.c_str(),localtimestamp,bytesRead,0,error_msg);
|
sprintf(insertSql, "'%s','%s','%s',%d,'%d','%s' ", strDataNodeNo.c_str(),strShortAddr.c_str(),localtimestamp,bytesRead,0,error_msg);
|
||||||
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
|
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
|
||||||
|
|
||||||
@ -1065,7 +1072,13 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
|
|||||||
sprintf(whereCon, "zigbeeShortAddr='%s'",strShortAddr.c_str());
|
sprintf(whereCon, "zigbeeShortAddr='%s'",strShortAddr.c_str());
|
||||||
std::string strDataNodeNo = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), " dataNodeNo ", whereCon);
|
std::string strDataNodeNo = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), " dataNodeNo ", whereCon);
|
||||||
memset(whereCon, 0x00, sizeof(whereCon));
|
memset(whereCon, 0x00, sizeof(whereCon));
|
||||||
sprintf(error_msg,"Crc error,command = %d",command);
|
if (command == WAVE_X){
|
||||||
|
sprintf(error_msg,"Crc error,wave X");
|
||||||
|
}else if (command == WAVE_Y){
|
||||||
|
sprintf(error_msg,"Crc error,wave Y");
|
||||||
|
}else if (command == WAVE_Z){
|
||||||
|
sprintf(error_msg,"Crc error,wave Z");
|
||||||
|
}
|
||||||
sprintf(insertSql, "'%s','%s','%s',%d,'%d','%s' ", strDataNodeNo.c_str(),strShortAddr.c_str(),localtimestamp,bytesRead,0,error_msg);
|
sprintf(insertSql, "'%s','%s','%s',%d,'%d','%s' ", strDataNodeNo.c_str(),strShortAddr.c_str(),localtimestamp,bytesRead,0,error_msg);
|
||||||
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
|
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user