mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Merge branch 'RfidResearchGroup:main' into t55write
This commit is contained in:
@@ -141,7 +141,7 @@ static data_frame_tx_t *cmd_processor_reset_settings(uint16_t cmd, uint16_t stat
|
||||
}
|
||||
|
||||
static data_frame_tx_t *cmd_processor_get_device_settings(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
|
||||
uint8_t settings[7 + BLE_PAIRING_KEY_LEN] = {};
|
||||
uint8_t settings[8 + BLE_PAIRING_KEY_LEN] = {};
|
||||
settings[0] = SETTINGS_CURRENT_VERSION; // current version
|
||||
settings[1] = settings_get_animation_config(); // animation mode
|
||||
settings[2] = settings_get_button_press_config('A'); // short A button press mode
|
||||
@@ -150,7 +150,8 @@ static data_frame_tx_t *cmd_processor_get_device_settings(uint16_t cmd, uint16_t
|
||||
settings[5] = settings_get_long_button_press_config('B'); // long B button press mode
|
||||
settings[6] = settings_get_ble_pairing_enable(); // is device require pairing
|
||||
memcpy(settings + 7, settings_get_ble_connect_key(), BLE_PAIRING_KEY_LEN);
|
||||
return data_frame_make(cmd, STATUS_SUCCESS, 7 + BLE_PAIRING_KEY_LEN, settings);
|
||||
settings[7 + BLE_PAIRING_KEY_LEN] = settings_get_sleep_timeout() / 1000U; // wake timeout in seconds
|
||||
return data_frame_make(cmd, STATUS_SUCCESS, 8 + BLE_PAIRING_KEY_LEN, settings);
|
||||
}
|
||||
|
||||
static data_frame_tx_t *cmd_processor_set_animation_mode(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
|
||||
@@ -208,6 +209,19 @@ static data_frame_tx_t *cmd_processor_set_long_button_press_config(uint16_t cmd,
|
||||
return data_frame_make(cmd, STATUS_SUCCESS, 0, NULL);
|
||||
}
|
||||
|
||||
static data_frame_tx_t *cmd_processor_get_sleep_timeout(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
|
||||
uint8_t seconds = settings_get_sleep_timeout() / 1000U;
|
||||
return data_frame_make(cmd, STATUS_SUCCESS, 1, &seconds);
|
||||
}
|
||||
|
||||
static data_frame_tx_t *cmd_processor_set_sleep_timeout(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
|
||||
if (length != 1 || data[0] < SETTINGS_SLEEP_TIMEOUT_MIN_S || data[0] > SETTINGS_SLEEP_TIMEOUT_MAX_S) {
|
||||
return data_frame_make(cmd, STATUS_PAR_ERR, 0, NULL);
|
||||
}
|
||||
settings_set_sleep_timeout(data[0]);
|
||||
return data_frame_make(cmd, STATUS_SUCCESS, 0, NULL);
|
||||
}
|
||||
|
||||
static data_frame_tx_t *cmd_processor_get_ble_pairing_enable(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
|
||||
uint8_t is_enable = settings_get_ble_pairing_enable();
|
||||
return data_frame_make(cmd, STATUS_SUCCESS, 1, &is_enable);
|
||||
@@ -2613,6 +2627,8 @@ static cmd_data_map_t m_data_cmd_map[] = {
|
||||
{ DATA_CMD_GET_DEVICE_CAPABILITIES, NULL, cmd_processor_get_device_capabilities, NULL },
|
||||
{ DATA_CMD_GET_BLE_PAIRING_ENABLE, NULL, cmd_processor_get_ble_pairing_enable, NULL },
|
||||
{ DATA_CMD_SET_BLE_PAIRING_ENABLE, NULL, cmd_processor_set_ble_pairing_enable, NULL },
|
||||
{ DATA_CMD_GET_SLEEP_TIMEOUT, NULL, cmd_processor_get_sleep_timeout, NULL },
|
||||
{ DATA_CMD_SET_SLEEP_TIMEOUT, NULL, cmd_processor_set_sleep_timeout, NULL },
|
||||
{ DATA_CMD_GET_ALL_SLOT_NICKS, NULL, cmd_processor_get_all_slot_nicks, NULL },
|
||||
|
||||
#if defined(PROJECT_CHAMELEON_ULTRA)
|
||||
|
||||
@@ -479,7 +479,7 @@ static void check_wakeup_src(void) {
|
||||
light_up_by_slot();
|
||||
|
||||
// If no operation follows, wait for the timeout and then deep hibernate
|
||||
sleep_timer_start(SLEEP_DELAY_MS_BUTTON_WAKEUP);
|
||||
sleep_timer_start(settings_get_sleep_timeout());
|
||||
} else if ((m_reset_source & (NRF_POWER_RESETREAS_NFC_MASK | NRF_POWER_RESETREAS_LPCOMP_MASK)) ||
|
||||
(m_gpregret_val & RESET_ON_LF_FIELD_EXISTS_Msk)) {
|
||||
NRF_LOG_INFO("WakeUp from rfid field");
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
#define DATA_CMD_GET_BLE_PAIRING_ENABLE (1036)
|
||||
#define DATA_CMD_SET_BLE_PAIRING_ENABLE (1037)
|
||||
#define DATA_CMD_GET_ALL_SLOT_NICKS (1038)
|
||||
#define DATA_CMD_GET_SLEEP_TIMEOUT (1039)
|
||||
#define DATA_CMD_SET_SLEEP_TIMEOUT (1040)
|
||||
|
||||
//
|
||||
// ******************************************************************
|
||||
|
||||
@@ -53,6 +53,11 @@ void settings_init_ble_pairing_enable_config(void) {
|
||||
config.ble_pairing_enable = false;
|
||||
}
|
||||
|
||||
// add on version6
|
||||
void settings_init_sleep_timeout_config(void) {
|
||||
config.sleep_timeout = SETTINGS_SLEEP_TIMEOUT_DEFAULT_S;
|
||||
}
|
||||
|
||||
void settings_init_config(void) {
|
||||
settings_update_version_for_config();
|
||||
config.animation_config = SettingsAnimationModeFull; // add on version1
|
||||
@@ -60,6 +65,7 @@ void settings_init_config(void) {
|
||||
settings_init_button_long_press_config();
|
||||
settings_init_ble_connect_key_config();
|
||||
settings_init_ble_pairing_enable_config();
|
||||
settings_init_sleep_timeout_config();
|
||||
}
|
||||
|
||||
void settings_migrate(void) {
|
||||
@@ -80,6 +86,9 @@ void settings_migrate(void) {
|
||||
case 4:
|
||||
settings_init_ble_pairing_enable_config();
|
||||
|
||||
case 5:
|
||||
settings_init_sleep_timeout_config();
|
||||
|
||||
/*
|
||||
* Add new migration steps ABOVE THIS COMMENT
|
||||
* `settings_update_version_for_config()` and `break` statements should only be used on the last migration step, all the previous steps must fall
|
||||
@@ -291,3 +300,11 @@ bool settings_get_ble_pairing_enable(void) {
|
||||
bool settings_get_ble_pairing_enable_first_load(void) {
|
||||
return m_ble_pairing_enable_first_load_value;
|
||||
}
|
||||
|
||||
uint32_t settings_get_sleep_timeout(void) {
|
||||
return config.sleep_timeout * 1000U;
|
||||
}
|
||||
|
||||
void settings_set_sleep_timeout(uint8_t seconds) {
|
||||
config.sleep_timeout = seconds;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define SETTINGS_CURRENT_VERSION 5
|
||||
#define SETTINGS_CURRENT_VERSION 6
|
||||
#define SETTINGS_SLEEP_TIMEOUT_DEFAULT_S 8 // default wake timeout in seconds (matches SLEEP_DELAY_MS_BUTTON_WAKEUP)
|
||||
#define SETTINGS_SLEEP_TIMEOUT_MIN_S 5
|
||||
#define SETTINGS_SLEEP_TIMEOUT_MAX_S 60
|
||||
#define BLE_PAIRING_KEY_LEN 6
|
||||
#define DEFAULT_BLE_PAIRING_KEY "123456" // length must == 6
|
||||
|
||||
@@ -51,8 +54,8 @@ typedef struct ALIGN_U32 {
|
||||
// 6 byte
|
||||
uint8_t ble_connect_key[6];
|
||||
|
||||
// 1 byte
|
||||
uint8_t reserved1; // see bottom.
|
||||
// 1 byte (add on version6)
|
||||
uint8_t sleep_timeout; // wake timeout in seconds after button wakeup
|
||||
|
||||
/*
|
||||
* Warning !!!!!!!!!!!!!!!!!!!!!! <-------------
|
||||
@@ -78,4 +81,7 @@ void settings_set_ble_connect_key(uint8_t *key);
|
||||
void settings_set_ble_pairing_enable(bool enable);
|
||||
bool settings_get_ble_pairing_enable(void);
|
||||
bool settings_get_ble_pairing_enable_first_load(void);
|
||||
uint32_t settings_get_sleep_timeout(void);
|
||||
void settings_set_sleep_timeout(uint8_t seconds);
|
||||
void settings_init_sleep_timeout_config(void);
|
||||
#endif
|
||||
Reference in New Issue
Block a user