Exemplo n.º 1
0
void get_main_page(const char* message){
	 char pp[8];
	QlSysTimer loct;
    s32 simcard;
        s32 creg=0;
        s32 cgreg=0;
        u8 rssi=0;
        u8 ber=0;
        Ql_GetDeviceCurrentRunState(&simcard, &creg, &cgreg, &rssi, &ber);
	 Ql_GetLocalTime(&loct);
	 GetTextStateGpio(&pp[0]);
	Ql_sprintf(__data_buf,__main_page,
			   __str_loc_ip_addr,
                rssi,
			   &pp[0],
			   loct.day,loct.month,loct.year,loct.hour,loct.minute,loct.second,
               __settings.APN,
               __settings.IP[0],__settings.IP[1],__settings.IP[2],__settings.IP[3],
               __settings.TCP,
			   __settings.TSend,
			   __settings.Deboung,
			   __debug ? "<option selected>TRUE</option><option>FALSE</option>":"<option>TRUE</option><option selected>FALSE</option>",
			   __log ? "<option selected>TRUE</option><option>FALSE</option>":"<option>TRUE</option><option selected>FALSE</option>",
			    message,
			   __est_connection ? "Stop":"Start",
			   __est_connection ? "stop":"run"
               );
}
Exemplo n.º 2
0
u32 WD_SYSTEM performtest_getSystime(void)
{
    u32 seconds;
    ST_Time time;
    Ql_GetLocalTime(&time);
    seconds = Ql_Mktime(&time);
    return seconds * 1000000;
}
Exemplo n.º 3
0
static int wd_gettimeofday(struct timeval*tv, struct timezone *tz)
{
    u32 seconds;
    ST_Time time;
    Ql_GetLocalTime(&time);
    seconds = Ql_Mktime(&time);
    tv->tv_sec = seconds;
    tv->tv_usec = 0;

    return 0;
}
Exemplo n.º 4
0
void PrintSettings(){
    QlSysTimer loct;
    ReadSettings();
    Ql_GetLocalTime(&loct);
     s32 simcard;
     s32 creg;
     s32 cgreg;
     u8 rssi;
     u8 ber;
     char pp[8];
     Ql_GetDeviceCurrentRunState(&simcard, &creg, &cgreg, &rssi, &ber);
     GetTextStateGpio(&pp[0]);
     OUTER("\r\nAPN=%s IP=%d.%d.%d.%d TCP=%d USER=%s PASS=%s DEBUG=%s LOG=%s NUM=%d TSEND=%d DATE=%.2d.%.2d.%.2d TIME=%.2d:%.2d:%.2d DEBOUNCE=%d LocalIp=%s WUser=%s WPass=%s\r\n\r\n ***** SIM:%d GSM:%d GPRS:%d PINS=%s SIGNAL:%ddBm ******\r\n",
                      __settings.APN,__settings.IP[0],__settings.IP[1],__settings.IP[2],__settings.IP[3],
                      __settings.TCP,__settings.User,__settings.Pass,__settings.Debug,__settings.Log,__settings.Num,__settings.TSend,
                     loct.day,loct.month,loct.year,loct.hour,loct.minute,loct.second,__settings.Deboung,
                     __str_loc_ip_addr,__settings.WUser,__settings.WPass,simcard,creg,cgreg,&pp[0],rssi);
     
}
Exemplo n.º 5
0
s32 process_mcu_touchmemory_key_msg(u8 *pkt)
{
    OUT_DEBUG_2("process_mcu_touchmemory_key_msg()\r\n");

    u8 * const key = &pkt[MCUPKT_BEGIN_DATABLOCK + 1];
    const PinTypeCode io_pin = (PinTypeCode)pkt[MCUPKT_BEGIN_DATABLOCK];

    if (MSG_GetValue == pkt[MCUPKT_COMMAND_CODE])
    {
        if (Pin_Output != io_pin)
            return ERR_BAD_PINTYPE_FOR_COMMAND;

        // --
        u16 etr_uin = pkt[MCUPKT_PARENTDEV_UIN_H] << 8 | pkt[MCUPKT_PARENTDEV_UIN_L];

        ParentDevice *pParent = getParentDeviceByUIN(etr_uin, OBJ_ETR);
        if (!pParent) {
            OUT_DEBUG_1("getParentDeviceByUIN(<%s #%d>) = FALSE\r\n",
                        getUnitTypeByCode(OBJ_ETR), etr_uin);
            return ERR_DB_RECORD_NOT_FOUND;
        }

//        if (isTouchMemoryKeyAlreadyReceived(pParent, key)) {
//            OUT_DEBUG_3("Received KEY already handled\r\n");
//            return RETURN_NO_ERRORS;
//        }


        OUT_DEBUG_3("KEY RECEIVED: %#x %#x %#x %#x %#x %#x %#x %#x\r\n",
                        key[0], key[1], key[2], key[3], key[4], key[5], key[6], key[7]);

        // -- don't process the key, only send it to configurator
        if (pParent->d.etr.bBlocked) {
            finishETRWatingKey(pParent);
            return sendLastReceivedTouchMemoryCode(etr_uin, key);
        }


        TouchmemoryCode *pCode = getTouchmemoryCodeByValue(key);
        if (!pCode) {
            OUT_DEBUG_1("getTouchmemoryCodeByValue(%#x %#x %#x %#x %#x %#x %#x %#x): key not found\r\n",
                        key[0], key[1], key[2], key[3], key[4], key[5], key[6], key[7]);
            return ERR_DB_RECORD_NOT_FOUND; // unregistered key
        }

        OUT_DEBUG_3("ALIAS KEY RECEIVED: %s\r\n",
                        pCode->alias);


        if (ARMING_EVENT == pCode->action)
        {
            // -- check the group to ETR relation
            if (!isETRRelatedToGroup(pCode->group_id, &pParent->d.etr)) {
                OUT_DEBUG_3("The key is not valid for this ETR device\r\n");
                return RETURN_NO_ERRORS;
            }

            ArmingGroup *pGroup = getArmingGroupByID(pCode->group_id);
            if (!pGroup) {
                OUT_DEBUG_1("getArmingGroupByID(id=%d): group not found\r\n", pCode->group_id);
                return ERR_DB_RECORD_NOT_FOUND;
            }

            ArmingEvent ae;

            // -- key code info
            ae.key_info.key_type = OBJ_TOUCHMEMORY_CODE;
            ae.key_info.key = pCode;
            // --

            ae.emitter_type = (DbObjectCode)pkt[MCUPKT_SUBDEV_TYPE];
            ae.force = FALSE;   // won't be switched to arming if there are any error issures
            ae.p_group = pGroup;
            ae.p_etr=pParent;
            Ql_GetLocalTime(&ae.time);
            ae.p_current_arming_state = pGroup ? pGroup->p_group_state : NULL;

            // -- invoke Handler
            if (ae.p_current_arming_state) {
                s32 ret = ae.p_current_arming_state->handler_arming(&ae);
                if (ret < RETURN_NO_ERRORS) {
                    OUT_DEBUG_1("%s: handler_arming() = %d error.\r\n",
                                ae.p_current_arming_state->state_name, ret);
                    return ret;
                }
            }
        }
        else if (COMMON_KEY_EVENT == pCode->action)
        {
            ArmingGroup *pGroup = getArmingGroupByID(pCode->group_id);
            if (pGroup) {
                if (!isETRRelatedToGroup(pCode->group_id, &pParent->d.etr)) {
                    OUT_DEBUG_3("The key is not valid for this ETR device\r\n");
                    return RETURN_NO_ERRORS;
                }
            }

            CommonKeyEvent e;

            // -- key code info
            e.key_info.key_type = OBJ_TOUCHMEMORY_CODE;
            e.key_info.key = pCode;
            // --

            e.emitter_type = (DbObjectCode)pkt[MCUPKT_SUBDEV_TYPE];
            e.force = FALSE;   // won't be processed if there are any error issures

            Ql_GetLocalTime(&e.time);
            e.p_group = pGroup;

            e.p_current_arming_state = pGroup ? pGroup->p_group_state : NULL;

            // -- invoke group related Handler
            if (e.p_current_arming_state) {
                s32 ret = e.p_current_arming_state->handler_common_key(&e);
                if (ret < RETURN_NO_ERRORS) {
                    OUT_DEBUG_1("%s: handler_common_key() = %d error.\r\n",
                                e.p_current_arming_state->state_name, ret);
                    return ret;
                }
            }
            // -- else invoke common key Handler
            else {
                s32 ret = global_handler_common_key(&e);
                if (ret < RETURN_NO_ERRORS) {
                    OUT_DEBUG_1("global_handler_common_key() = %d error.\r\n", ret);
                    return ret;
                }
            }
        }
    }

    return RETURN_NO_ERRORS;
}
Exemplo n.º 6
0
void setCommand(char* command){
    char* cmd = NULL;
    char idx=0;
    char* pch=NULL;
	cmd = Ql_strstr(command, "DEBUG=");
	if (cmd){
		cmd += 6;
		if (Ql_strstr(cmd, "TRUE")){
            __debug=TRUE;
        }
        else{
            __debug=FALSE;
        }
        Ql_strcpy(&__settings.Debug[0],cmd);
	}
    cmd = Ql_strstr(command, "LOG=");
	if (cmd){
		cmd += 4;
		if (Ql_strstr(cmd, "TRUE")){
            __log=TRUE;
        }
        else{
            __log=FALSE;
        }
        Ql_strcpy(&__settings.Log[0],cmd);
	}
	cmd = Ql_strstr(command, "TCP=");
	if (cmd){
		cmd += 4;
        __settings.TCP=Ql_atoi(cmd);
	}
	cmd = Ql_strstr(command, "IP=");
	if (cmd){
		cmd += 3;
       
        pch = strtok(cmd, ".");
		while (pch != NULL)
		{
			__settings.IP[idx] = Ql_atoi(pch);   
			pch = strtok(NULL, ".");
			idx++;
		}
        //OUTD("Set IP:%d.%d.%d.%d\r\n",__settings.IP[0],__settings.IP[1],__settings.IP[2],__settings.IP[3]);
		
	}
	cmd = Ql_strstr(command, "APN=");
	if (cmd){
		cmd += 4;
		Ql_strcpy(&__settings.APN[0],cmd);
        
	}
	cmd = Ql_strstr(command, "PASS="******"NUM=");
	if (cmd){
		cmd += 4;
		__settings.Num=Ql_atoi(cmd);
	}
    /*cmd = Ql_strstr(command, "PWD=");
	if (cmd){
		cmd += 4;
		Ql_strcpy(&__settings.Pwd[0],cmd);
        
	}*/
     cmd = Ql_strstr(command, "USER="******"TIME=");
	if (cmd){
        char* last;
        QlSysTimer tm;
        Ql_GetLocalTime(&tm);
        cmd+=5;
        if (Ql_strlen(cmd)==8) {
        tm.hour = Ql_atoi(strtok_r(cmd, ":",&last));
		tm.minute = Ql_atoi(strtok_r(last, ":",&last));
        tm.second = Ql_atoi(strtok_r(last, ":",&last));
        Ql_SetLocalTime(&tm);
     }
	}
    cmd = Ql_strstr(command, "DATE=");
	if (cmd){
		char* last;
        QlSysTimer tm;
        Ql_GetLocalTime(&tm);
        cmd+=5;
        if (Ql_strlen(cmd)==8) {
        tm.day = Ql_atoi(strtok_r(cmd, ".",&last));
		tm.month = Ql_atoi(strtok_r(last, ".",&last));
        tm.year = Ql_atoi(strtok_r(last, ".",&last));
        Ql_SetLocalTime(&tm);
        }
	}
    cmd = Ql_strstr(command, "REBOOT");
	if (cmd){
        OUTD("!-----Get command to reboot..-----",NULL);
        Ql_Sleep(100);
		Ql_Reset(0);
	}

     cmd = Ql_strstr(command, "TSEND=");
	if (cmd){
        s32 tsend;
        cmd+=6;
        tsend=Ql_atoi(cmd);
        if (tsend>10 && tsend<60) {
            __settings.TSend = tsend;
        }
        
    }

    cmd = Ql_strstr(command, "DEBOUNCE=");
	if (cmd){
        s32 deboung;
        cmd+=9;
        deboung=Ql_atoi(cmd);
        //OUTD("set debounce ok:%d",deboung);
        if (deboung>=100 && deboung<=1000) {
            //OUTD("set debounce ok:%d",deboung);
            __settings.Deboung = deboung;
        }
        
    }
    cmd = Ql_strstr(command, "WUser="******"WPass="******"?");
	if (cmd){
        PrintSettings();
	}
}
Exemplo n.º 7
0
s32 process_mcu_zone_msg(u8 *pkt)
{
    OUT_DEBUG_2("process_mcu_zone_msg()\r\n");

    u16 parentDevUIN = pkt[MCUPKT_PARENTDEV_UIN_H] << 8 | pkt[MCUPKT_PARENTDEV_UIN_L];
    DbObjectCode parentDevType = (DbObjectCode)pkt[MCUPKT_PARENTDEV_TYPE];
    u8 zoneSUIN = pkt[MCUPKT_SUBDEV_UIN];
    u8 *datablock = &pkt[MCUPKT_BEGIN_DATABLOCK];

//    u16 parentDevId = 0xFFFF;
    // find Zone object
//    switch (parentDevType) {
//    case OBJ_MASTERBOARD:
//    {

//        break;
//    }
//    case OBJ_ZONE_EXPANDER:
//    {
//        break;
//    }
//    default:
//        // TODO: report to the pult "UNREGISTERED DEVICE"
//        return ERR_DB_RECORD_NOT_FOUND;
//    }

    // -- find Zone object in the table
    Zone *pZone = getZoneByParent(parentDevUIN, parentDevType, zoneSUIN);
    if (!pZone) {
        OUT_DEBUG_1("getZoneByParent(puin=%d, ptype=%d, suin=%d): zone not found\r\n",
                    parentDevUIN, parentDevType, zoneSUIN);
        return ERR_DB_RECORD_NOT_FOUND;
    }

    // -- check if the Zone is enabled
    if (!pZone->enabled) {
        OUT_DEBUG_3("Zone %d is disabled\r\n", pZone->humanized_id);
        return RETURN_NO_ERRORS;
    }

    PinTypeCode io_pin = (PinTypeCode)datablock[0];

    // -- WARNING: used direct conversion from HEX ASCII code to DEC
    ZoneEventType evt = (ZoneEventType)(datablock[3] - 0x30);
    pZone->last_event_type = evt;
    if (io_pin != Pin_Output)
        return ERR_BAD_PINTYPE_FOR_COMMAND;

OUT_DEBUG_8("Unit %s #%d, zone #%d, event: %d\r\n",
              getUnitTypeByCode(parentDevType), parentDevUIN, zoneSUIN, evt);

    ArmingGroup *pGroup = getArmingGroupByID(pZone->group_id);
    if (!pGroup) {
        OUT_DEBUG_1("getArmingGroupByID(id=%d): group not found\r\n", pZone->group_id);
        return ERR_DB_RECORD_NOT_FOUND;
    }

    GroupState *state = pGroup->p_group_state;

    // --  create Event
    ZoneEvent ze;
    ze.zone_event_type = evt;
    Ql_GetLocalTime(&ze.time);
    ze.p_zone = pZone;
    ze.p_group = pGroup;
    ze.p_current_arming_state = state;

    // -- invoke Handler
    s32 ret = state->handler_zone(&ze);
    if (ret < RETURN_NO_ERRORS) {
        OUT_DEBUG_1("%s: handler_zone() = %d error.\r\n", state->state_name, ret);
        return ret;
    }

    return RETURN_NO_ERRORS;
}