[已解决]GR5515开发门锁配件,使用离线密码开锁时,遇到时间戳不对的问题.
Posted: 2024年 Oct 17日 12:24
刚开始认为是传入的timestamp 参数问题,后面打印 得到的 T2 和T3 都不正确,显示时间为
TUYA_APP: T2->[2033-05-13 23:xx:xx]
TUYA_APP: T3->[2034-06-11 16:xx:xx]
TUYA_APP: NOW->[2024-10-17 04:xx:xx]
想知道这是 怎么回事?已经如何调试,有没有指导文档。
下面贴出 细节代码:
case UART_SIMULATE_OFFLINE_PWD: {
uint8_t pwd[128] = {0};
Code: Select all
if(len == OFFLINE_PWD_LEN) {
memcpy(pwd, data, OFFLINE_PWD_LEN);
}
else if(len <= 27+1) { //8λʮ����ת��Ϊ���������27λ
uint8_t notation = data[0];
int object_array_len = source_to_object(notation, &data[1], len-1, 10, pwd);
TUYA_APP_LOG_HEXDUMP_INFO("pwd", pwd, object_array_len);
}
uint8_t plain_pwd[OFFLINE_PWD_LEN+6] = {0};
uint8_t plain_pwd_len = 0;
uint8_t key[16];
memset(key, '0', sizeof(key));
memcpy(&key[10], tuya_ble_current_para.sys_settings.login_key, LOGIN_KEY_LEN);
uint32_t timestamp = app_port_get_timestamp();
int32_t ret = lock_offline_pwd_verify(key, sizeof(key),
&pwd[0], OFFLINE_PWD_LEN, timestamp,
plain_pwd+6, &plain_pwd_len);
for(uint32_t idx=0; idx<OFFLINE_PWD_LEN+6; idx++) {
plain_pwd[idx] += 0x30;
}
uint8_t encrypt_pwd[OFFLINE_PWD_LEN+6] = {0};
uint8_t iv[16] = {0x00};
app_port_aes128_cbc_encrypt(key, iv, plain_pwd, sizeof(plain_pwd), encrypt_pwd);
if(ret == OFFLINE_PWD_VERIFY_SUCCESS) {
lock_open_record_report_offline_pwd(OR_LOG_OFFLINE_PW_OPEN_WITH, encrypt_pwd);
TUYA_APP_LOG_INFO("lock_open_with_offline_pwd_success");
}
else if(ret == OFFLINE_PWD_CLEAR_SINGLE_SUCCESS) {
lock_open_record_report_offline_pwd(OR_LOG_OFFLINE_PW_CLEAR_SINGLE_ALARM, encrypt_pwd);
TUYA_APP_LOG_INFO("clear_single_with_offline_pwd_success");
}
else if(ret == OFFLINE_PWD_CLEAR_ALL_SUCCESS) {
lock_open_record_report_offline_pwd(OR_LOG_OFFLINE_PW_CLEAR_ALL_ALARM, encrypt_pwd);
TUYA_APP_LOG_INFO("clear_all_with_offline_pwd_success");
}
else {
TUYA_APP_LOG_INFO("lock_open_with_offline_pwd_fail");
}
} break;