Merge "soft version 2.34" into main
diff --git a/8271_ble_remote/makefile b/8271_ble_remote/makefile
index 97f2bc7..2862465 100644
--- a/8271_ble_remote/makefile
+++ b/8271_ble_remote/makefile
@@ -14,6 +14,7 @@
-include vendor/827x_ble_remote/pke_common/subdir.mk
-include vendor/827x_ble_remote/app_fmr/subdir.mk
-include vendor/827x_ble_remote/app_find_me/subdir.mk
+-include vendor/827x_ble_remote/app_common/subdir.mk
-include vendor/827x_ble_remote/app_backlight/subdir.mk
-include drivers/8278/subdir.mk
-include drivers/8278/flash/subdir.mk
diff --git a/8271_ble_remote/sources.mk b/8271_ble_remote/sources.mk
index cf8f6f3..a503c85 100644
--- a/8271_ble_remote/sources.mk
+++ b/8271_ble_remote/sources.mk
@@ -21,6 +21,7 @@
vendor/827x_ble_remote/pke_common \
vendor/827x_ble_remote/app_fmr \
vendor/827x_ble_remote/app_find_me \
+vendor/827x_ble_remote/app_common \
vendor/827x_ble_remote/app_backlight \
drivers/8278 \
drivers/8278/flash \
diff --git a/8271_ble_remote/vendor/827x_ble_remote/app_backlight/subdir.mk b/8271_ble_remote/vendor/827x_ble_remote/app_backlight/subdir.mk
index a8a5c38..507487d 100644
--- a/8271_ble_remote/vendor/827x_ble_remote/app_backlight/subdir.mk
+++ b/8271_ble_remote/vendor/827x_ble_remote/app_backlight/subdir.mk
@@ -4,10 +4,12 @@
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
-../vendor/827x_ble_remote/app_backlight/app_backlight.c
+../vendor/827x_ble_remote/app_backlight/app_backlight.c \
+../vendor/827x_ble_remote/app_backlight/app_backlight_gatt.c
OBJS += \
-./vendor/827x_ble_remote/app_backlight/app_backlight.o
+./vendor/827x_ble_remote/app_backlight/app_backlight.o \
+./vendor/827x_ble_remote/app_backlight/app_backlight_gatt.o
# Each subdirectory must supply rules for building sources it contributes
diff --git a/8271_ble_remote/vendor/827x_ble_remote/app_common/subdir.mk b/8271_ble_remote/vendor/827x_ble_remote/app_common/subdir.mk
new file mode 100644
index 0000000..fbbb5a4
--- /dev/null
+++ b/8271_ble_remote/vendor/827x_ble_remote/app_common/subdir.mk
@@ -0,0 +1,23 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables
+C_SRCS += \
+../vendor/827x_ble_remote/app_common/app_fifio.c \
+../vendor/827x_ble_remote/app_common/app_simple_fsm.c
+
+OBJS += \
+./vendor/827x_ble_remote/app_common/app_fifio.o \
+./vendor/827x_ble_remote/app_common/app_simple_fsm.o
+
+
+# Each subdirectory must supply rules for building sources it contributes
+vendor/827x_ble_remote/app_common/%.o: ../vendor/827x_ble_remote/app_common/%.c
+ @echo 'Building file: $<'
+ @echo 'Invoking: TC32 Compiler'
+ tc32-elf-gcc -ffunction-sections -fdata-sections -I../ -I../drivers/8278 -D__PROJECT_8278_BLE_REMOTE__=1 -DCHIP_TYPE=CHIP_TYPE_827x -Wall -O2 -fpack-struct -fshort-enums -finline-small-functions -std=gnu99 -fshort-wchar -fms-extensions -c -o"$@" "$<"
+ @echo 'Finished building: $<'
+ @echo ' '
+
+
diff --git a/vendor/827x_ble_remote/app.c b/vendor/827x_ble_remote/app.c
index 2b7bfa2..5644bbd 100644
--- a/vendor/827x_ble_remote/app.c
+++ b/vendor/827x_ble_remote/app.c
@@ -914,6 +914,8 @@
{
printf("connect\r\n");
app_mtu_size = 23;
+ app_slave_terminate = 0;
+
bls_l2cap_setMinimalUpdateReqSendingTime_after_connCreate(1000);
enterdeep_time = ADV_RECONN_ENTER_DEEP_COUNT;
@@ -1648,6 +1650,29 @@
app_adv_indirect();
}
+
+/**
+ * @brief This function is check If IRK(local IRK or peer IRK) valid
+ * @param[in] pIrk - pointer to IRK(local IRK or peer IRK)
+ * @return 1: IRK valid
+ * 0: IRK invalid
+ */
+bool blc_app_isIrkValid(u8* pIrk)
+{
+
+ u8 byte_all_0xFF[16] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
+ u8 byte_all_0x00[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+ /* IRK valid: not 16 0x00, not 16 0xFF */
+ if(memcmp(pIrk, byte_all_0xFF, 16) && memcmp(pIrk, byte_all_0x00, 16)){
+ return TRUE;
+ }
+ else{
+ return FALSE;
+ }
+}
+
+
void app_start_send_wakeup(rf_packet_adv_ind_module_t advdata)
{
// u8 tbl_scanRsp[30];
@@ -1663,6 +1688,19 @@
{
ll_whiteList_reset();
ll_whiteList_add(bondInfo.peer_addr_type,bondInfo.peer_addr);
+ }else{
+
+ printf("RPA ADDR. ADD RESOLUTION ADDRESS\n");
+ ll_whiteList_reset();
+
+ if(blc_app_isIrkValid(bondInfo.peer_irk)){
+ ll_resolvingList_reset();
+ ll_resolvingList_add(bondInfo.peer_id_adrType, bondInfo.peer_id_addr, bondInfo.peer_irk, NULL);
+ ll_resolvingList_setAddrResolutionEnable(1);
+ }
+
+ ll_whiteList_add(bondInfo.peer_addr_type,bondInfo.peer_addr);
+ ll_whiteList_add(bondInfo.peer_id_adrType,bondInfo.peer_id_addr);
}
}
@@ -1730,11 +1768,15 @@
app_backlight_task();
#if (BATT_CHECK_ENABLE)
- u32 my_battery_detect_interval = 300000;
+// u32 my_battery_detect_interval = 300000;
+ u32 my_battery_detect_interval = 2 *1000 *1000; // 2 sec
+
if(app_fmr_is_busy()){
my_battery_detect_interval = 150000;
}
- if(battery_get_detect_enable() && clock_time_exceed(lowBattDet_tick, my_battery_detect_interval) ){
+
+ // TODO check brx state
+ if( (FALSE == blc_ll_isBrxBusy()) && battery_get_detect_enable() && clock_time_exceed(lowBattDet_tick, my_battery_detect_interval) ){
lowBattDet_tick = clock_time();
#if(VBAT_LEAKAGE_PROTECT_EN)
diff --git a/vendor/827x_ble_remote/app_att.c b/vendor/827x_ble_remote/app_att.c
index 405aa00..66ede6d 100644
--- a/vendor/827x_ble_remote/app_att.c
+++ b/vendor/827x_ble_remote/app_att.c
@@ -790,10 +790,24 @@
static const attribute_t my_Attributes[] = {
- {ATT_END_H - 1 - 4 - 4, 0,0,0,0,0}, // total num of attribute
+ {ATT_END_H - 1 - 4, 0,0,0,0,0}, // total num of attribute
ATT_TABLE_COMMON
+ /********************************************************************************************
+ * empty service
+ ********************************************************************************************/
+ {4, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0},
+
+
+ /********************************************************************************************
+ * BACKLIGHT service
+ ********************************************************************************************/
+ APP_BACKLIGHT_GATT_SERVICE
+
};
static const attribute_t my_Attributes_FMR[] = {
@@ -802,7 +816,15 @@
ATT_TABLE_COMMON
+ /********************************************************************************************
+ * FMR service
+ ********************************************************************************************/
APP_FMR_SERVICE
+
+ /********************************************************************************************
+ * BACKLIGHT service
+ ********************************************************************************************/
+ APP_BACKLIGHT_GATT_SERVICE
};
#if (MP_TEST_MODE)
@@ -812,8 +834,17 @@
ATT_TABLE_COMMON
+ /********************************************************************************************
+ * FMR service
+ ********************************************************************************************/
APP_FMR_SERVICE
+ /********************************************************************************************
+ * BACKLIGHT service
+ ********************************************************************************************/
+ APP_BACKLIGHT_GATT_SERVICE
+
+
/////////////////////////////////// 9. TEST MODE ///////////////////////////////////////////////////
// 004E - 0051 (78-81)
{4, ATT_PERMISSIONS_READ, 2, 16, (u8*)(&my_primaryServiceUUID), (u8*)(&my_TestModeServiceUUID), 0},
diff --git a/vendor/827x_ble_remote/app_att.h b/vendor/827x_ble_remote/app_att.h
index 574bedd..2ccfd71 100644
--- a/vendor/827x_ble_remote/app_att.h
+++ b/vendor/827x_ble_remote/app_att.h
@@ -28,6 +28,7 @@
#include "app_config.h"
#include "app_fmr/app_fmr.h"
+#include "app_backlight/app_backlight_gatt.h"
///////////////////////////////////// ATT HANDLER define ///////////////////////////////////////
typedef enum
@@ -198,8 +199,15 @@
FMS_GOOGLE_DATA_CCC_H,
#endif
+ /********************************************************************************************
+ * GOOGLE FMR handle
+ ********************************************************************************************/
APP_FMR_HANDLE
+ /********************************************************************************************
+ * GOOGLE BACKLIGHT handle
+ ********************************************************************************************/
+ APP_BACKLIGHT_GATT_HANDLE
#if (MP_TEST_MODE)
//// Test Mode ////
diff --git a/vendor/827x_ble_remote/app_backlight/app_backlight.c b/vendor/827x_ble_remote/app_backlight/app_backlight.c
index fb99fd9..939efbc 100644
--- a/vendor/827x_ble_remote/app_backlight/app_backlight.c
+++ b/vendor/827x_ble_remote/app_backlight/app_backlight.c
@@ -9,6 +9,7 @@
#include "drivers.h"
#include "stack/ble/ble.h"
#include "app_backlight.h"
+#include "app_backlight_gatt.h"
#include "../app_ui.h"
typedef struct {
@@ -28,10 +29,19 @@
}app_backlight_ctr_t;
+#define EN_BACKLIGHT_DEBUG
+
+#ifdef EN_BACKLIGHT_DEBUG
+ #define BACKLIGHT_DEBUG printf
+ #define BACKLIGHT_DEBUG_ARRAY array_printf
+#else
+ #define BACKLIGHT_DEBUG(...)
+ #define BACKLIGHT_DEBUG_ARRAY(...)
+#endif
+
#define get_clock_time() (clock_time()|1)
-#define BOOST_IC_EN_GPIO (GPIO_PA0)
#define BACKLIGHT_REFRESH_INTERVAL (20) // ms
@@ -41,11 +51,17 @@
#define BACKLIGHT_PWM_FREQUENCY (600) // hz
#define BACKLIGHT_PWM_CYCLE_TICK (CLOCK_SYS_CLOCK_HZ/BACKLIGHT_PWM_FREQUENCY) // hz
#define BACKLIGHT_PWM_MIN_CMP_TICK_PERCENTAGE (0) // %
-#define BACKLIGHT_PWM_MAX_CMP_TICK_PERCENTAGE (50) // %
+#define BACKLIGHT_PWM_MAX_CMP_TICK_PERCENTAGE (40) // %
+
+/**
+ * Step 1. Getting brighter 0.5sec
+ * Step 2. Maximum brightness 2.0sec with duty 40%
+ * Step 3. Getting darker 2.5sec
+ * */
#define BACKLIGHT_TIME_RISE (500) // 500ms
-#define BACKLIGHT_TIME_MAINTAIN (1000) // 1000ms
-#define BACKLIGHT_TIME_DECLINE (1500) // 1500ms
+#define BACKLIGHT_TIME_MAINTAIN (2000) // 1000ms
+#define BACKLIGHT_TIME_DECLINE (2500) // 1500ms
#define BACKLIGHT_START_BRIGHTNESS (BACKLIGHT_PWM_CYCLE_TICK * BACKLIGHT_PWM_MIN_CMP_TICK_PERCENTAGE / 100)
#define BACKLIGHT_END_BRIGHTNESS (BACKLIGHT_PWM_CYCLE_TICK * BACKLIGHT_PWM_MAX_CMP_TICK_PERCENTAGE / 100)
@@ -145,7 +161,7 @@
break;
}
- printf("BACKLIGHT SETTINGS. EN[0x%02X] GPIO:[0x%04X]\n", s_en_backlight, s_boost_gpio);
+ BACKLIGHT_DEBUG("BACKLIGHT SETTINGS. EN[0x%02X] GPIO:[0x%04X]\n", s_en_backlight, s_boost_gpio);
}
u16 app_backlight_get_boost_pin(void){
@@ -201,7 +217,7 @@
}
void app_backlight_init(void){
- printf("%s\n", __FUNCTION__);
+ BACKLIGHT_DEBUG("%s\n", __FUNCTION__);
/* enable boost */
u16 my_boot_pin = app_backlight_get_boost_pin();
@@ -238,12 +254,16 @@
void app_backlight_start(void){
if(0 == s_en_backlight) return;
+ if(0 == app_backlight_gatt_is_allow_backlight()) return;
- printf("%s\n", __FUNCTION__);
+
+ BACKLIGHT_DEBUG("%s\n", __FUNCTION__);
if(s_backlight_task_tick){
+ // backlight already on
app_backlight_ctr.table_pos = 1;
}else{
+ // backlight fist on
app_backlight_ctr.table_pos = 0;
app_backlight_init();
/* When initialization fails, backlight disable may be set in app_backlight_init */
@@ -260,7 +280,7 @@
// TODO start PWM
pwm_set_cycle_and_duty(BACKLIGHT_PWM_ID, BACKLIGHT_PWM_CYCLE_TICK, app_backlight_ctr.brightness);
-// printf("song_note_index: %d cycle: %d counter: %d duty: %d\n",s_app_buzzer_ctrl.song_note_index, note ,counter, s_app_buzzer_ctrl.sound_level);
+// BACKLIGHT_DEBUG("song_note_index: %d cycle: %d counter: %d duty: %d\n",s_app_buzzer_ctrl.song_note_index, note ,counter, s_app_buzzer_ctrl.sound_level);
pwm_start(BACKLIGHT_PWM_ID);
bls_pm_setSuspendMask (SUSPEND_DISABLE);
@@ -305,7 +325,7 @@
s32 my_brightness = s_backlight_behavior[app_backlight_ctr.table_pos].start_value + (my_end_value- my_start_value)*sin_table[app_backlight_ctr.duration_cnt*100/my_duration]/U16_MAX;
- printf("duration_cnt:[%d]/[%d] table_pos:[%d] my_brightness:[%d] brightness:[%d]\n",
+ BACKLIGHT_DEBUG("duration_cnt:[%d]/[%d] table_pos:[%d] my_brightness:[%d] brightness:[%d]\n",
app_backlight_ctr.duration_cnt,
s_backlight_behavior[app_backlight_ctr.table_pos].duration,
app_backlight_ctr.table_pos,
@@ -322,7 +342,7 @@
}
-// printf("duration_cnt:[%d]/[%d] table_pos:[%d] my_brightness:[%d] brightness:[%d]\n", app_backlight_ctr.duration_cnt, app_backlight_ctr.table_pos, my_brightness, app_backlight_ctr.brightness);
+// BACKLIGHT_DEBUG("duration_cnt:[%d]/[%d] table_pos:[%d] my_brightness:[%d] brightness:[%d]\n", app_backlight_ctr.duration_cnt, app_backlight_ctr.table_pos, my_brightness, app_backlight_ctr.brightness);
/* Refresh only if they are not equal */
if(app_backlight_ctr.brightness != my_brightness){
@@ -342,8 +362,78 @@
+u32 s_priv_trigger_tick = 0;
+
+u32 s_y = 0;
+#define CONSTANT_A (0.955)
+#define CONSTANT_B (1-CONSTANT_A)
+
+#define CONSTANT_THRESHOLD (0.900)
+#define FIXED_A int /* data type for fixed point accumulator */
+#define FIXED_T short /* data type for fixed point constants */
+#define CHAR_BIT (8)
+#define F_PROTO8(x) (FIXED_A) ((x * 2) * ( (FIXED_A)1 << (sizeof(FIXED_T) * CHAR_BIT - 1)) + 0.5)
+
+
+#define CONSTANT_JUDGE_TIME (30000) //ms
+#define CONSTANT_JUDGE_COUNT (50)
+
+
+inline u16 formula_filter(u8 x){
+ u32 my_y = s_y*F_PROTO8(CONSTANT_A)/U16_MAX + x* F_PROTO8(CONSTANT_B);
+ printf("A:[%d] B:[%d] Y:[%05d] RES:[%s] \n", F_PROTO8(CONSTANT_A), F_PROTO8(CONSTANT_B), my_y, (my_y>=F_PROTO8(CONSTANT_THRESHOLD))?"Y":"N");
+ return my_y;
+}
+
+void app_backlight_record_trigger(void){
+
+ u32 my_spend_time_cnt = 0;
+ u32 my_spend_time_remainder = 1;
+
+ u32 my_spend_time_ms = 0;
+ if(s_priv_trigger_tick){
+ my_spend_time_ms = (clock_time() - s_priv_trigger_tick)/CLOCK_16M_SYS_TIMER_CLK_1MS;
+ my_spend_time_cnt = my_spend_time_ms/(CONSTANT_JUDGE_TIME/CONSTANT_JUDGE_COUNT);
+ my_spend_time_remainder = my_spend_time_ms%(CONSTANT_JUDGE_TIME/CONSTANT_JUDGE_COUNT);
+
+ }
+
+ s_priv_trigger_tick = clock_time()|1;
+// printf("MS:[%d] CNT:[%d] REM:[%d] ", my_spend_time_ms, my_spend_time_cnt, my_spend_time_remainder);
+ if(my_spend_time_cnt){
+ for(int i=0;i<my_spend_time_cnt;i++){
+ s_y = formula_filter(0);
+ }
+ }
+
+ if(my_spend_time_remainder){
+ s_y = formula_filter(1);
+ }
+}
+
+#ifdef DEBUG_BACKLIGHT
+void app_backlight_record_trigger_test(void){
+
+ s_priv_trigger_tick = 0;
+ s_y = 0;
+ for(int i=0;i<50;i++){
+ app_backlight_record_trigger();
+ WaitMs(100);
+ }
+
+ printf("########################################\n");
+ s_priv_trigger_tick = 0;
+ s_y = 0;
+
+ for(int i=0;i<100;i++){
+ app_backlight_record_trigger();
+ WaitMs(650);
+ }
+
+}
+#endif
diff --git a/vendor/827x_ble_remote/app_backlight/app_backlight.h b/vendor/827x_ble_remote/app_backlight/app_backlight.h
index a6d021a..4ff6e8d 100644
--- a/vendor/827x_ble_remote/app_backlight/app_backlight.h
+++ b/vendor/827x_ble_remote/app_backlight/app_backlight.h
@@ -8,6 +8,7 @@
#ifndef APP_BACKLIGHT_H_
#define APP_BACKLIGHT_H_
+#define BOOST_IC_EN_GPIO (GPIO_PA0)
void app_backlight_set_ability(unsigned char en, unsigned short boost_pin);
diff --git a/vendor/827x_ble_remote/app_backlight/app_backlight_gatt.c b/vendor/827x_ble_remote/app_backlight/app_backlight_gatt.c
new file mode 100644
index 0000000..d3a0846
--- /dev/null
+++ b/vendor/827x_ble_remote/app_backlight/app_backlight_gatt.c
@@ -0,0 +1,611 @@
+/*
+ * app_backlight_gatt.c
+ *
+ * Created on: 2024-5-8
+ * Author: name
+ */
+
+
+#include "tl_common.h"
+#include "drivers.h"
+#include "stack/ble/ble.h"
+#include "../app_common/app_simple_fsm.h"
+#include "../../common/blt_soft_timer.h"
+#include "../app_att.h"
+
+
+/**********************************************************************
+ * LOCAL DEFINE
+ */
+
+//#define BACKLIGHT_FSM_DEBUG
+
+#define BACKLIGHT_FIX_HANDLE
+
+
+//#define BACKLIGHT_DEBUG_LOG(...)
+
+//#define BACKLIGHT_DEBUG_LOG printf
+
+#define BACKLIGHT_HOUR_MAX (24)
+#define BACKLIGHT_MINUTE_MAX (60)
+
+
+#define BACKLIGHT_NIGHT_START_HOUR (18)
+#define BACKLIGHT_NIGHT_START_MINUTE (00)
+
+#define BACKLIGHT_NIGHT_END_HOUR (6)
+#define BACKLIGHT_NIGHT_END_MINUTE (00)
+
+#define BACKLIGHT_RTC_MINUTE (60) // unit:sec should be 60sec. 10sec just for test
+
+
+#define GOOGLE_BACKLIGHT_SERVICE_UUID 0x64,0xB6,0x17,0xF6,0x01,0xAF,0x7D,0xBC,0x05,0x4F,0x21,0x5A,0x69,0x8B,0xB3,0xA2
+#define GOOGL_BACKLIGHT_CHAR_UUID 0x64,0xB6,0x17,0xF6,0x01,0xAF,0x7D,0xBC,0x05,0x4F,0x21,0x5A,0x6A,0x8B,0xB3,0xA2
+
+
+
+#define MACROS_BACKLIGHT_STATE_TABLE \
+ TLK_BACKLIGHT_FSM_MACRO(BACKLIGHT_STATE_IDLE) \
+ TLK_BACKLIGHT_FSM_MACRO(BACKLIGHT_STATE_WAIT_TIME)
+
+
+#define MACROS_BACKLIGHT_EVENT_TABLE \
+ TLK_BACKLIGHT_FSM_MACRO(BACKLIGHT_EVENT_MODE_NAVER) \
+ TLK_BACKLIGHT_FSM_MACRO(BACKLIGHT_EVENT_MODE_ALWAYS) \
+ TLK_BACKLIGHT_FSM_MACRO(BACKLIGHT_EVENT_MODE_DAYTIME_NIGHTTIME) \
+ TLK_BACKLIGHT_FSM_MACRO(BACKLIGHT_EVENT_SET_TIME) \
+ TLK_BACKLIGHT_FSM_MACRO(BACKLIGHT_EVENT_WAIT_TIME_TIMEOUT) \
+ TLK_BACKLIGHT_FSM_MACRO(BACKLIGHT_EVENT_INVALID_DATA)
+
+
+/**********************************************************************
+ * LOCAL TYPES
+ */
+
+typedef enum{
+ BACKLIGHT_CMD_SET_BACKLIGHT_MODE = 0x00,
+ BACKLIGHT_CMD_SET_TIME = 0x01,
+
+ BACKLIGHT_CMD_INVALID_REQUEST = 0xFF,
+}BACKLIGHT_CMD_T;
+
+typedef enum{
+ BACKLIGHT_MODE_NAVER = 0x0000,
+ BACKLIGHT_MODE_ALWAYS = 0x0001,
+ BACKLIGHT_MODE_DAYTIME_NIGHTTIME = 0x0002,
+}BACKLIGHT_MODE_T;
+
+#define TLK_BACKLIGHT_FSM_MACRO(a) a,
+typedef enum{
+ MACROS_BACKLIGHT_STATE_TABLE
+}APP_BACKLIGHT_STATE_T;
+
+typedef enum{
+ MACROS_BACKLIGHT_EVENT_TABLE
+}APP_BACKLIGHT_EVNET_T;
+#undef TLK_BACKLIGHT_FSM_MACRO
+
+typedef struct {
+ unsigned char event;
+ unsigned char data_hi;
+ unsigned char data_lo;
+}backlight_event_format_t;
+
+typedef struct {
+ unsigned char event;
+ unsigned char hour;
+ unsigned char minute;
+}backlight_time_format_t;
+
+
+
+/**********************************************************************
+ * ATT SERVICE
+ */
+
+#define WRAPPING_BRACES(__DATAS__) { __DATAS__ }
+
+const u8 app_backlight_gatt_service_uuid[16] = WRAPPING_BRACES(GOOGLE_BACKLIGHT_SERVICE_UUID);
+const u8 app_backlight_gatt_char_uuid[16] = WRAPPING_BRACES(GOOGL_BACKLIGHT_CHAR_UUID);
+
+
+const u8 app_backlight_gatt_char_val[19] = {
+ CHAR_PROP_READ | CHAR_PROP_NOTIFY | CHAR_PROP_WRITE_WITHOUT_RSP,
+ U16_LO(APP_BACKLIGHT_GATT_CMD_DP_H), U16_HI(APP_BACKLIGHT_GATT_CMD_DP_H),
+ GOOGL_BACKLIGHT_CHAR_UUID,
+};
+
+//_attribute_data_retention_ volatile u8 app_backlight_gatt_data[3] = {0x00};
+_attribute_data_retention_ volatile u8 app_backlight_gatt_data[3] = {BACKLIGHT_CMD_SET_TIME, 0x00, 0x00};
+_attribute_data_retention_ u16 app_backlight_gatt_ccc = 0;
+
+/**********************************************************************
+ * LOCAL FUNCTIONS DEFINE
+ */
+
+static int backlight_event_cb_trygger_naver(app_fsm_evnet_t event);
+static int backlight_event_cb_trygger_always(app_fsm_evnet_t event);
+static int backlight_event_cb_wait_time(app_fsm_evnet_t event);
+static int backlight_event_cb_set_time(app_fsm_evnet_t event);
+static int backlight_event_cb_wait_time_timeout(app_fsm_evnet_t event);
+static int backlight_event_cb_invalid_data(app_fsm_evnet_t event);
+
+
+/**********************************************************************
+ * LOCAL VARIABLES
+ */
+
+const app_fsm_table_t backlight_fsm_table[] = {
+ //{current state, next state, EVENT, call back }
+ { BACKLIGHT_STATE_IDLE, BACKLIGHT_STATE_IDLE, BACKLIGHT_EVENT_MODE_NAVER, backlight_event_cb_trygger_naver},
+ { BACKLIGHT_STATE_IDLE, BACKLIGHT_STATE_IDLE, BACKLIGHT_EVENT_MODE_ALWAYS, backlight_event_cb_trygger_always},
+
+ { BACKLIGHT_STATE_IDLE, BACKLIGHT_STATE_WAIT_TIME, BACKLIGHT_EVENT_MODE_DAYTIME_NIGHTTIME, backlight_event_cb_wait_time},
+ { BACKLIGHT_STATE_WAIT_TIME, BACKLIGHT_STATE_IDLE, BACKLIGHT_EVENT_SET_TIME, backlight_event_cb_set_time},
+
+ /* The following are exceptions */
+ { BACKLIGHT_STATE_WAIT_TIME, BACKLIGHT_STATE_IDLE, BACKLIGHT_EVENT_WAIT_TIME_TIMEOUT, backlight_event_cb_wait_time_timeout},
+ { BACKLIGHT_STATE_WAIT_TIME, BACKLIGHT_STATE_IDLE, BACKLIGHT_EVENT_INVALID_DATA, backlight_event_cb_invalid_data},
+
+ { BACKLIGHT_STATE_WAIT_TIME, BACKLIGHT_STATE_IDLE, BACKLIGHT_EVENT_MODE_NAVER, backlight_event_cb_trygger_naver},
+ { BACKLIGHT_STATE_WAIT_TIME, BACKLIGHT_STATE_IDLE, BACKLIGHT_EVENT_MODE_ALWAYS, backlight_event_cb_trygger_always},
+
+ { BACKLIGHT_STATE_IDLE, BACKLIGHT_STATE_IDLE, BACKLIGHT_EVENT_INVALID_DATA, backlight_event_cb_invalid_data},
+
+ { BACKLIGHT_STATE_IDLE, BACKLIGHT_STATE_IDLE, BACKLIGHT_EVENT_SET_TIME, backlight_event_cb_invalid_data},
+};
+
+
+#ifdef BACKLIGHT_FSM_DEBUG
+ #define TLK_BACKLIGHT_FSM_MACRO(a) #a,
+ static const char* tlk_backlight_fms_state_str[] = {
+ MACROS_BACKLIGHT_STATE_TABLE
+ };
+
+ static const char* tlk_backlight_fms_event_str[] = {
+ MACROS_BACKLIGHT_EVENT_TABLE
+ };
+ #undef TLK_BACKLIGHT_FSM_MACRO
+#endif
+
+
+_attribute_data_retention_ app_fsm_t s_backlight_fms = {
+ .pFsmTable = (app_fsm_table_t *)backlight_fsm_table,
+ .fsmTabCnt = ARRAY_SIZE(backlight_fsm_table),
+ .curState = BACKLIGHT_STATE_IDLE,
+ .maxState = BACKLIGHT_STATE_WAIT_TIME,
+};
+
+#ifndef BACKLIGHT_FIX_HANDLE
+_attribute_data_retention_ u16 s_backlight_gatt_handle = 0;
+#endif
+/**********************************************************************
+ * LOCAL FUNCTIONS
+ */
+
+// TODO
+
+
+
+#ifndef BACKLIGHT_FSM_DEBUG
+
+#define app_backlight_gatt_trigger_event(eventID, p_buf, buf_len) app_fsm_triggerEvent(&s_backlight_fms, eventID, p_buf, buf_len);
+
+#else
+
+void app_backlight_gatt_trigger_event(u16 eventID, u8 *p_buf, u16 buf_len){
+
+ printf("Trigger EVENT[%d]:[%s] currState[%d]:[%s]",
+ eventID,
+ tlk_backlight_fms_event_str[eventID]+16,
+ s_backlight_fms.curState,
+ tlk_backlight_fms_state_str[s_backlight_fms.curState]+16);
+
+ app_fsm_triggerEvent(&s_backlight_fms, eventID, p_buf, buf_len);
+}
+
+#endif
+
+#define app_backlight_gatt_push_event(eventID, p_buf, buf_len) app_fsm_pushEvent(&s_backlight_fms, eventID, p_buf, buf_len);
+
+
+static short backlight_minute_sub(short minute0, short minute1){
+
+ if( (minute0>=BACKLIGHT_HOUR_MAX*BACKLIGHT_MINUTE_MAX) || (minute1>=BACKLIGHT_HOUR_MAX*BACKLIGHT_MINUTE_MAX)){
+ printf("[FATAL] This shouldn't happen !!!!\n");
+ return -1;
+ }
+
+ short my_sub = minute0 - minute1;
+
+ return my_sub>=0?my_sub:(my_sub+BACKLIGHT_HOUR_MAX*BACKLIGHT_MINUTE_MAX);
+}
+
+
+u8 backlight_day_night_mode_is_night(u8 hour, u8 minute){
+ short my_night_start = BACKLIGHT_NIGHT_START_HOUR*BACKLIGHT_MINUTE_MAX + BACKLIGHT_NIGHT_START_MINUTE;
+ short my_night_end = BACKLIGHT_NIGHT_END_HOUR*BACKLIGHT_MINUTE_MAX + BACKLIGHT_NIGHT_END_MINUTE;
+
+ short my_current_minute = hour*BACKLIGHT_MINUTE_MAX + minute;
+
+ short my_distance = backlight_minute_sub(my_current_minute, my_night_start) + backlight_minute_sub(my_night_end, my_current_minute);
+
+ u8 my_is_night = 0;
+
+ printf("DISTANCE:[%d] = [%d] + [%d]\n", my_distance, backlight_minute_sub(my_current_minute, my_night_start), backlight_minute_sub(my_night_end, my_current_minute));
+
+ if(my_distance<BACKLIGHT_HOUR_MAX*BACKLIGHT_MINUTE_MAX){
+ my_is_night = 1;
+ }
+
+ return my_is_night;
+}
+
+
+int backlight_rtc_timer(void){
+
+ backlight_time_format_t *p_my_time = (backlight_time_format_t *)app_backlight_gatt_data;
+
+ if(BACKLIGHT_CMD_SET_TIME == p_my_time->event){
+
+ }else{
+ printf("[ERROR] backlight_rtc_timer works in exception mode\n");
+ return -1;
+ }
+
+ p_my_time->minute++;
+ if(p_my_time->minute >= BACKLIGHT_MINUTE_MAX){
+ p_my_time->hour++;
+ p_my_time->minute = 0;
+ }
+
+ if(p_my_time->hour >= BACKLIGHT_HOUR_MAX){
+ p_my_time->hour = 0;
+ }
+
+ if( backlight_day_night_mode_is_night(p_my_time->hour, p_my_time->minute)){
+ printf("UPDATE BACKLIGHT NIGHT TIME:[%02d:%02d]\n", p_my_time->hour, p_my_time->minute);
+ }else{
+ printf("UPDATE BACKLIGHT TIME:[%02d:%02d]\n", p_my_time->hour, p_my_time->minute);
+ }
+
+ return 0;
+}
+
+int backlight_set_rtc_timeout_timer(void){
+ printf("%s\n", __FUNCTION__);
+
+ app_backlight_gatt_trigger_event(BACKLIGHT_EVENT_WAIT_TIME_TIMEOUT, NULL, 0);
+
+ return -1;
+}
+
+void bakclight_data_update(u8 *p_buf){
+ backlight_event_format_t *p_my_evnt = (backlight_event_format_t *)p_buf;
+ if(BACKLIGHT_CMD_SET_BACKLIGHT_MODE == p_my_evnt->event){
+ u16 my_event_mode = MAKE_U16(p_my_evnt->data_hi, p_my_evnt->data_lo);
+ if( (BACKLIGHT_MODE_NAVER == my_event_mode) || (BACKLIGHT_MODE_ALWAYS == my_event_mode) ){
+ blt_soft_timer_delete(backlight_rtc_timer);
+ }else{
+ printf("[BACLIGHT MODE] Incoming error message in mode setting. MODE:[0x%04X]\n", my_event_mode);
+ return;
+ }
+ }else if(BACKLIGHT_CMD_SET_TIME == p_my_evnt->event){
+ backlight_time_format_t *p_my_time = (backlight_time_format_t *)p_buf;
+
+ if( (p_my_time->hour < BACKLIGHT_HOUR_MAX) && (p_my_time->minute < BACKLIGHT_MINUTE_MAX) ){
+ /* Delete wait time timeout timer and start RTC timer */
+ blt_soft_timer_delete(backlight_set_rtc_timeout_timer);
+ blt_soft_timer_delete(backlight_rtc_timer);
+ blt_soft_timer_add(backlight_rtc_timer, BACKLIGHT_RTC_MINUTE*1000000);
+ }else{
+ printf("[BACLIGHT TIME] Incoming error message in time setting. HH:[0x%02X] MM:[0x%02X]\n", p_my_time->hour, p_my_time->minute);
+ return;
+ }
+ }else{
+ printf("[BACLIGHT EVENT] Passing in wrong event value. EVENT:[0x%02X]\n", p_my_evnt->event);
+ return;
+ }
+
+ app_backlight_gatt_data[0] = p_buf[0];
+ app_backlight_gatt_data[1] = p_buf[1];
+ app_backlight_gatt_data[2] = p_buf[2];
+#ifdef BACKLIGHT_FIX_HANDLE
+ ble_sts_t my_ret = bls_att_pushNotifyData(APP_BACKLIGHT_GATT_CMD_DP_H, (u8 *)app_backlight_gatt_data, sizeof(app_backlight_gatt_data));
+ printf("RET:[%d] NOTIFY BACKLIGHT UPDATE DATA:", my_ret);
+ array_printf((u8 *)app_backlight_gatt_data, sizeof(app_backlight_gatt_data));
+#else
+ if(s_backlight_gatt_handle){
+ ble_sts_t my_ret = bls_att_pushNotifyData(s_backlight_gatt_handle, (u8 *)app_backlight_gatt_data, sizeof(app_backlight_gatt_data));
+ printf("RET:[%d] NOTIFY BACKLIGHT UPDATE DATA:", my_ret);
+ array_printf((u8 *)app_backlight_gatt_data, sizeof(app_backlight_gatt_data));
+ }
+#endif
+}
+
+static int backlight_event_cb_trygger_naver(app_fsm_evnet_t event){
+ printf("%s\n", __FUNCTION__);
+
+ u8 my_update_data[3] = {BACKLIGHT_CMD_SET_BACKLIGHT_MODE, U16_HI(BACKLIGHT_MODE_NAVER), U16_LO(BACKLIGHT_MODE_NAVER)};
+ bakclight_data_update(my_update_data);
+
+ return 0;
+}
+
+static int backlight_event_cb_trygger_always(app_fsm_evnet_t event){
+ printf("%s\n", __FUNCTION__);
+
+ u8 my_update_data[3] = {BACKLIGHT_CMD_SET_BACKLIGHT_MODE, U16_HI(BACKLIGHT_MODE_ALWAYS), U16_LO(BACKLIGHT_MODE_ALWAYS)};
+ bakclight_data_update(my_update_data);
+
+ return 0;
+}
+
+static int backlight_event_cb_wait_time(app_fsm_evnet_t event){
+ printf("%s\n", __FUNCTION__);
+
+
+#ifdef BACKLIGHT_FIX_HANDLE
+ u8 my_wait_time_data[3] = {0x00, 0x00, 0x02};
+ bls_att_pushNotifyData(APP_BACKLIGHT_GATT_CMD_DP_H, my_wait_time_data, sizeof(my_wait_time_data));
+ printf("NOTIFY BACKLIGHT WAIT TIME DATA:");
+ array_printf(my_wait_time_data, sizeof(my_wait_time_data));
+#else
+ if(s_backlight_gatt_handle){
+ u8 my_wait_time_data[3] = {0x00, 0x00, 0x02};
+ bls_att_pushNotifyData(s_backlight_gatt_handle, my_wait_time_data, sizeof(my_wait_time_data));
+ printf("NOTIFY BACKLIGHT WAIT TIME DATA:");
+ array_printf(my_wait_time_data, sizeof(my_wait_time_data));
+ }
+#endif
+ blt_soft_timer_delete(backlight_set_rtc_timeout_timer);
+ blt_soft_timer_add(backlight_set_rtc_timeout_timer, 3*1000000);
+
+ return 0;
+}
+
+static int backlight_event_cb_set_time(app_fsm_evnet_t event){
+ printf("%s\n", __FUNCTION__);
+
+ array_printf(event.pBuf, event.bufLen);
+
+ backlight_time_format_t *p_my_time = (backlight_time_format_t *)event.pBuf;
+
+ if(p_my_time->hour < BACKLIGHT_HOUR_MAX){
+
+ }else{
+ blt_soft_timer_delete(backlight_set_rtc_timeout_timer);
+ app_backlight_gatt_push_event(BACKLIGHT_EVENT_INVALID_DATA, event.pBuf, event.bufLen);
+ return -1;
+ }
+
+ if(p_my_time->minute < BACKLIGHT_MINUTE_MAX){
+
+ }else{
+ blt_soft_timer_delete(backlight_set_rtc_timeout_timer);
+ app_backlight_gatt_push_event(BACKLIGHT_EVENT_INVALID_DATA, event.pBuf, event.bufLen);
+ return -1;
+
+ }
+
+ bakclight_data_update(event.pBuf);
+ return 0;
+}
+
+
+static int backlight_event_cb_wait_time_timeout(app_fsm_evnet_t event){
+ printf("%s\n", __FUNCTION__);
+
+#ifdef BACKLIGHT_FIX_HANDLE
+ u8 my_wait_time_data[4] = {0xff, 0x00, 0x00, 0x02};
+ bls_att_pushNotifyData(APP_BACKLIGHT_GATT_CMD_DP_H, my_wait_time_data, sizeof(my_wait_time_data));
+ printf("NOTIFY BACKLIGHT WAIT TIME TIMEOUT DATA:");
+ array_printf(my_wait_time_data, sizeof(my_wait_time_data));
+#else
+ if(s_backlight_gatt_handle){
+ u8 my_wait_time_data[4] = {0xff, 0x00, 0x00, 0x02};
+ bls_att_pushNotifyData(s_backlight_gatt_handle, my_wait_time_data, sizeof(my_wait_time_data));
+ printf("NOTIFY BACKLIGHT WAIT TIME TIMEOUT DATA:");
+ array_printf(my_wait_time_data, sizeof(my_wait_time_data));
+ }
+#endif
+ return 0;
+}
+
+//u8 my_invalid_notify[4] = {0};
+
+static int backlight_event_cb_invalid_data(app_fsm_evnet_t event){
+ printf("%s\n", __FUNCTION__);
+// array_printf(event.pBuf, event.bufLen);
+
+ blt_soft_timer_delete(backlight_set_rtc_timeout_timer);
+
+#ifdef BACKLIGHT_FIX_HANDLE
+ u8 my_invalid_notify[4] = {BACKLIGHT_CMD_INVALID_REQUEST, event.pBuf[0], event.pBuf[1], event.pBuf[2]};
+
+ ble_sts_t my_ret = bls_att_pushNotifyData(APP_BACKLIGHT_GATT_CMD_DP_H, my_invalid_notify, sizeof(my_invalid_notify));//
+ printf("RET:[%d] NOTIFY BACKLIGHT INVALID DATA:", my_ret);
+ array_printf(my_invalid_notify, sizeof(my_invalid_notify));
+#else
+ if(s_backlight_gatt_handle){
+ u8 my_invalid_notify[4] = {BACKLIGHT_CMD_INVALID_REQUEST, event.pBuf[0], event.pBuf[1], event.pBuf[2]};
+
+ ble_sts_t my_ret = bls_att_pushNotifyData(s_backlight_gatt_handle, my_invalid_notify, sizeof(my_invalid_notify));//
+ printf("RET:[%d] NOTIFY BACKLIGHT INVALID DATA:", my_ret);
+ array_printf(my_invalid_notify, sizeof(my_invalid_notify));
+
+ }
+#endif
+
+ return 0;
+}
+
+
+/**********************************************************************
+ * GLOBAL FUNCTIONS
+ */
+
+void app_backlight_gatt_init_state(void){
+
+ if(s_backlight_fms.curState != BACKLIGHT_STATE_IDLE){
+ printf("[warning]The initial value of s_atvv_fsm should be BACKLIGHT_STATE_IDLE");
+ }
+
+ app_fsm_init(&s_backlight_fms, (app_fsm_table_t *)backlight_fsm_table ,ARRAY_SIZE(backlight_fsm_table), BACKLIGHT_STATE_IDLE, BACKLIGHT_STATE_WAIT_TIME);
+}
+
+u8 app_backlight_gatt_fsm_get_state(void){
+ return s_backlight_fms.curState;
+}
+
+
+
+
+int app_backlight_gatt_write_cb(void *p){
+
+ rf_packet_att_data_t *req = (rf_packet_att_data_t*)p;
+ u16 my_data_len = req->l2cap - 3;
+
+ array_printf(req->dat, my_data_len);
+
+ if(my_data_len < 3){
+ printf("BACKLIGHT CMD LEN error\n");
+ return 0;
+ }
+#ifndef BACKLIGHT_FIX_HANDLE
+ if(0 == s_backlight_gatt_handle){
+ s_backlight_gatt_handle = req->handle;
+ }
+ printf("CMD HANDLE:[%d] NOTIFY HANDLE:[%d] SET:{%d}\n", req->handle, APP_BACKLIGHT_GATT_CMD_DP_H, s_backlight_gatt_handle);
+#endif
+
+ backlight_event_format_t *p_my_event = (backlight_event_format_t *)req->dat;
+
+ if(BACKLIGHT_CMD_SET_BACKLIGHT_MODE == p_my_event->event){
+
+ u16 my_backlight_mode = MAKE_U16(p_my_event->data_hi, p_my_event->data_lo);
+ switch (my_backlight_mode) {
+ case BACKLIGHT_MODE_NAVER:
+ app_backlight_gatt_trigger_event(BACKLIGHT_EVENT_MODE_NAVER, req->dat, my_data_len);
+ break;
+ case BACKLIGHT_MODE_ALWAYS:
+ app_backlight_gatt_trigger_event(BACKLIGHT_EVENT_MODE_ALWAYS, req->dat, my_data_len);
+ break;
+ case BACKLIGHT_MODE_DAYTIME_NIGHTTIME:
+ app_backlight_gatt_trigger_event(BACKLIGHT_EVENT_MODE_DAYTIME_NIGHTTIME, req->dat, my_data_len);
+ break;
+ default:
+ app_backlight_gatt_trigger_event(BACKLIGHT_EVENT_INVALID_DATA, req->dat, my_data_len);
+ break;
+ }
+ }else if(BACKLIGHT_CMD_SET_TIME == p_my_event->event){
+ app_backlight_gatt_trigger_event(BACKLIGHT_EVENT_SET_TIME, req->dat, my_data_len);
+ }else{
+ app_backlight_gatt_trigger_event(BACKLIGHT_EVENT_INVALID_DATA, req->dat, my_data_len);
+ }
+
+ return 0;
+}
+
+u8 app_backlight_gatt_is_allow_backlight(void){
+ u8 my_allow = 0;
+
+ backlight_event_format_t *p_my_event = (backlight_event_format_t *)app_backlight_gatt_data;
+
+ if(BACKLIGHT_CMD_SET_BACKLIGHT_MODE == p_my_event->event){
+ u16 my_backlight_mode = MAKE_U16(p_my_event->data_hi, p_my_event->data_lo);
+ switch (my_backlight_mode) {
+ case BACKLIGHT_MODE_NAVER:
+ break;
+ case BACKLIGHT_MODE_ALWAYS:
+ my_allow = 1;
+ break;
+ default:
+ printf("[ERROR] INVALID BACkLIGHT DATA");
+ array_printf((u8 *)app_backlight_gatt_data, sizeof(app_backlight_gatt_data));
+ break;
+ }
+
+ }else if(BACKLIGHT_CMD_SET_TIME == p_my_event->event){
+ u16 my_night_start_time = MAKE_U16(BACKLIGHT_NIGHT_START_HOUR, BACKLIGHT_NIGHT_START_MINUTE);
+ u16 my_night_end_time = MAKE_U16(BACKLIGHT_NIGHT_END_HOUR, BACKLIGHT_NIGHT_END_MINUTE);
+
+ backlight_time_format_t *p_my_time = (backlight_time_format_t *)app_backlight_gatt_data;
+ u16 my_current_time = MAKE_U16(p_my_time->hour, p_my_time->minute);
+
+ if( (my_current_time >= my_night_start_time) || (my_current_time <= my_night_end_time)){
+ my_allow = 1;
+ }
+ }else{
+ printf("[ERROR] INVALID BACkLIGHT DATA");
+ array_printf((u8 *)app_backlight_gatt_data, sizeof(app_backlight_gatt_data));
+ }
+
+
+ return my_allow;
+}
+
+//#define TEST_BACKLIGHT_GATT
+
+#ifdef TEST_BACKLIGHT_GATT
+
+void app_backlightr_gatt_test_write_to_cb(u8 *p_buf, u8 buf_size){
+
+ rf_packet_att_data_t my_test_pkt;
+
+ my_test_pkt.l2cap = 3+buf_size;
+ memcpy(my_test_pkt.dat, p_buf, buf_size);
+
+ app_backlight_gatt_write_cb(&my_test_pkt);
+}
+
+
+
+typedef struct {
+ unsigned char len;
+ unsigned char data[19];
+}test_cmd_t;
+
+void app_backlight_gatt_test_code(void){
+// int app_backlight_gatt_write_cb(void * p){
+
+ test_cmd_t my_test_cmd_table[] = {
+ {2, {0x01, 0x02} }, // LEN error
+ {3, {0x02, 0x02, 0x00} }, // EVENT ID error
+ {3, {0x00, 0x00, 0x03} }, // mode data error
+ {3, {0x00, 0x00, 0x00} }, // set mode to NAVER
+ {3, {0x00, 0x00, 0x01} }, // set mode to ALWAYS
+
+ {3, {0x01, 0x00, 0x03} }, // set time error0. Before setting the time, you need to set it to DAYTIME_NIGHTTIME mode
+
+ {3, {0x00, 0x00, 0x02} }, // DAYTIME_NIGHTTIME
+ {3, {0x01, 24, 0x03} }, // set time error1. hour out of range
+
+ {3, {0x01, 0x00, 0x01} }, // set time error2. Before setting the time, you need to set it to DAYTIME_NIGHTTIME mode
+
+ {3, {0x00, 0x00, 0x02} }, // DAYTIME_NIGHTTIME
+ {3, {0x01, 0x00, 60} }, // set time error3. minute out of range
+
+ {3, {0x00, 0x00, 0x02} }, // DAYTIME_NIGHTTIME
+ {3, {0x01, 0x01, 0x02} }, // set time
+
+ {3, {0x00, 0x00, 0x02} }, // DAYTIME_NIGHTTIME
+ };
+
+ printf("########################### TEST ##########################\n");
+
+ for(int i=0;i<ARRAY_SIZE(my_test_cmd_table);i++){
+ printf("\nCASE %d:\n", i);
+ app_backlightr_gatt_test_write_to_cb(my_test_cmd_table[i].data, my_test_cmd_table[i].len);
+ }
+
+ printf("########################### END ##########################\n");
+
+// extern void app_backlight_record_trigger_test(void);
+// app_backlight_record_trigger_test();
+
+
+}
+
+#endif
diff --git a/vendor/827x_ble_remote/app_backlight/app_backlight_gatt.h b/vendor/827x_ble_remote/app_backlight/app_backlight_gatt.h
new file mode 100644
index 0000000..c494ca7
--- /dev/null
+++ b/vendor/827x_ble_remote/app_backlight/app_backlight_gatt.h
@@ -0,0 +1,52 @@
+/*
+ * app_backlight_gatt.h
+ *
+ * Created on: 2024-5-14
+ * Author: name
+ */
+
+#ifndef APP_BACKLIGHT_GATT_H_
+#define APP_BACKLIGHT_GATT_H_
+
+/**********************************************************************
+ * GLOBAL DEFINES
+ */
+
+#define APP_BACKLIGHT_GATT_HANDLE \
+ APP_BACKLIGHT_GATT_PS_H, \
+ APP_BACKLIGHT_GATT_CMD_CD_H, \
+ APP_BACKLIGHT_GATT_CMD_DP_H, \
+ APP_BACKLIGHT_GATT_CMD_CCC_H,
+
+
+#define APP_BACKLIGHT_GATT_SERVICE \
+ {4,ATT_PERMISSIONS_READ, 2, 16, (u8*)(&my_primaryServiceUUID), (u8*)(&app_backlight_gatt_service_uuid), 0}, \
+ {0,ATT_PERMISSIONS_READ, 2, sizeof(app_backlight_gatt_char_val), (u8*)(&my_characterUUID), (u8*)(app_backlight_gatt_char_val), 0}, \
+ {0,ATT_PERMISSIONS_RDWR, 16,sizeof(app_backlight_gatt_data), (u8*)(&app_backlight_gatt_char_uuid), (u8*)(app_backlight_gatt_data), &app_backlight_gatt_write_cb, 0}, \
+ {0,ATT_PERMISSIONS_RDWR, 2, sizeof(app_backlight_gatt_ccc), (u8*)(&clientCharacterCfgUUID), (u8*)(&app_backlight_gatt_ccc), 0}, \
+
+
+/**********************************************************************
+ * ATT SERVICE VARIABLES
+ */
+
+extern const unsigned char app_backlight_gatt_service_uuid[16];
+extern const unsigned char app_backlight_gatt_char_uuid[16];
+
+
+extern const unsigned char app_backlight_gatt_char_val[19];
+
+extern volatile unsigned char app_backlight_gatt_data[3];
+extern unsigned short app_backlight_gatt_ccc;
+
+
+/**********************************************************************
+ * GLOBAL FUNCTIONS
+ */
+
+int app_backlight_gatt_write_cb(void *p);
+
+unsigned char app_backlight_gatt_is_allow_backlight(void);
+
+
+#endif /* APP_BACKLIGHT_GATT_H_ */
diff --git a/vendor/827x_ble_remote/app_common/app_fifio.c b/vendor/827x_ble_remote/app_common/app_fifio.c
new file mode 100644
index 0000000..1de4b10
--- /dev/null
+++ b/vendor/827x_ble_remote/app_common/app_fifio.c
@@ -0,0 +1,158 @@
+/********************************************************************************************************
+ * @file app_fifio.c
+ *
+ * @brief This is the source file for b85m
+ *
+ * @author ROW GROUP
+ * @date Nov,2022
+ *
+ * @par Copyright (c) 2022, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
+ * All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *******************************************************************************************************/
+
+#include "tl_common.h"
+#include "drivers.h"
+#include "app_fifo.h"
+
+/**********************************************************************
+ * GLOBAL FUNCTIONS
+ */
+
+void app_fifo_init(app_fifo_t *f, int s, u8 n, u8 *p)
+{
+ f->size = s;
+ f->num = n;
+ f->wptr = 0;
+ f->rptr = 0;
+ f->p = p;
+}
+
+u8* app_fifo_wptr(app_fifo_t *f)
+{
+ if( ((f->wptr - f->rptr) & 255) < f->num)
+ {
+#ifdef FIFO_QUICK_MODE
+ return f->p + (f->wptr & (f->num-1)) * f->size;
+#else
+ return f->p + (f->wptr % f->num) * f->size;
+#endif
+ }
+ return 0;
+}
+
+void app_fifo_next(app_fifo_t *f)
+{
+ f->wptr++;
+}
+
+int app_fifo_push(app_fifo_t *f, u8 *p, int n)
+{
+ if( ((f->wptr - f->rptr) & 255) >= f->num)
+ {
+ return -1;
+ }
+
+ if(n > f->size)
+ {
+ return -2;
+ }
+#ifdef FIFO_QUICK_MODE
+ u8 *pd = f->p + (f->wptr++ & (f->num-1)) * f->size;
+#else
+ u8 *pd = f->p + (f->wptr++ % f->num) * f->size;
+#endif
+ memcpy (pd, p, n);
+ return 0;
+}
+
+void app_fifo_pop(app_fifo_t *f)
+{
+ f->rptr++;
+}
+
+u8* app_fifo_get(app_fifo_t *f)
+{
+ if(f->rptr != f->wptr)
+ {
+#ifdef FIFO_QUICK_MODE
+ u8 *p = f->p + (f->rptr & (f->num-1)) * f->size;
+#else
+ u8 *p = f->p + (f->rptr % f->num) * f->size;
+#endif
+ return p;
+ }
+ return 0;
+}
+
+
+#ifdef FIFO_TEST_CODE_EN
+
+void app_fifo_test(void){
+
+#define FIFO_BUF_SIZE (8)
+#define FIFO_BUF_NUM (5)
+
+ u8 my_fifo_b[FIFO_BUF_SIZE * FIFO_BUF_NUM] = {0};
+ app_fifo_t my_fifo = {
+ .size = FIFO_BUF_SIZE,
+ .num = FIFO_BUF_NUM,
+ .wptr = 0,
+ .rptr = 0,
+ .p = my_fifo_b};
+
+ array_log_debug("my_fifo", (u8 *)&my_fifo, sizeof(app_fifo_t));
+
+ u8 my_test_buf[] = {0,1,2,3,4,5,6};
+
+ u8 i=0;
+ for(;i<=FIFO_BUF_NUM;i++){
+ my_test_buf[0] = i;
+ app_fifo_push(&my_fifo, my_test_buf, sizeof(my_test_buf));
+ array_log_debug("PUSH1", my_test_buf, sizeof(my_test_buf));
+
+ }
+
+ u8 *p_my_pop_buf = app_fifo_get(&my_fifo);
+
+ while(p_my_pop_buf){
+ array_log_debug("POP1", p_my_pop_buf, FIFO_BUF_SIZE);
+ app_fifo_pop(&my_fifo);
+
+ p_my_pop_buf = app_fifo_get(&my_fifo);
+ }
+
+
+ for(;i<=2*FIFO_BUF_NUM;i++){
+ my_test_buf[0] = i;
+ app_fifo_push(&my_fifo, my_test_buf, sizeof(my_test_buf));
+ array_log_debug("PUSH2", my_test_buf, sizeof(my_test_buf));
+ }
+
+ p_my_pop_buf = app_fifo_get(&my_fifo);
+
+ while(p_my_pop_buf){
+ array_log_debug("POP2", p_my_pop_buf, FIFO_BUF_SIZE);
+ app_fifo_pop(&my_fifo);
+
+ p_my_pop_buf = app_fifo_get(&my_fifo);
+ }
+}
+
+
+
+
+#endif
+
diff --git a/vendor/827x_ble_remote/app_common/app_fifo.h b/vendor/827x_ble_remote/app_common/app_fifo.h
new file mode 100644
index 0000000..3d273ea
--- /dev/null
+++ b/vendor/827x_ble_remote/app_common/app_fifo.h
@@ -0,0 +1,103 @@
+/********************************************************************************************************
+ * @file app_fifo.h
+ *
+ * @brief This is the header file for b85m
+ *
+ * @author ROW GROUP
+ * @date Nov,2022
+ *
+ * @par Copyright (c) 2022, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
+ * All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *******************************************************************************************************/
+
+#ifndef APP_FIFO_H_
+#define APP_FIFO_H_
+
+/**********************************************************************
+ * GLOBAL DEFINE
+ */
+
+/* The number of fifos in fast mode must be the factorial of 2 */
+//#define FIFO_QUICK_MODE
+
+/**********************************************************************
+ * GLOBAL TYPES
+ */
+
+typedef struct {
+ unsigned int size;
+ unsigned short num;
+ unsigned char wptr;
+ unsigned char rptr;
+ unsigned char *p;
+}app_fifo_t;
+
+
+/**********************************************************************
+ * GLOBAL FUNCTIONS
+ */
+
+/**
+ * @brief This function is used to initialize the structure
+ *
+ * @param f - FIFO structure pointer
+ * @param s - buffer size
+ * @param n - Number of buffers
+ * @param p - buffer pointer
+ */
+void app_fifo_init(app_fifo_t *f, int s, unsigned char n, unsigned char *p);
+
+/**
+ * @brief This function is used to obtain the pointer of the buffer that can be used
+ *
+ * @param f - FIFO structure pointer
+ * @return unsigned char* - NULL: There is no empty buffer other: Obtained buffer pointer
+ */
+unsigned char* app_fifo_wptr(app_fifo_t *f);
+
+/**
+ * @brief This function is used to increment the write pointer
+ *
+ * @param f - FIFO structure pointer
+ */
+void app_fifo_next(app_fifo_t *f);
+
+/**
+ * @brief This function is used to put data into fifo
+ *
+ * @param f - FIFO structure pointer
+ * @param p - Pointer to the passed data
+ * @param n - length of data
+ * @return int - 0:success other:Failure
+ */
+int app_fifo_push(app_fifo_t *f, unsigned char *p, int n);
+
+/**
+ * @brief This function is used to increment the read pointer
+ *
+ * @param f - FIFO structure pointer
+ */
+void app_fifo_pop(app_fifo_t *f);
+
+/**
+ * @brief This function is used to get the data pointer in fifo
+ *
+ * @param f - FIFO structure pointer
+ * @return unsigned char* - NULL: There is no data other: data pointer
+ */
+unsigned char* app_fifo_get(app_fifo_t *f);
+
+#endif /* APP_FIFO_H_ */
diff --git a/vendor/827x_ble_remote/app_common/app_simple_fsm.c b/vendor/827x_ble_remote/app_common/app_simple_fsm.c
new file mode 100644
index 0000000..7e69387
--- /dev/null
+++ b/vendor/827x_ble_remote/app_common/app_simple_fsm.c
@@ -0,0 +1,217 @@
+/********************************************************************************************************
+ * @file app_simple_fsm.c
+ *
+ * @brief This is the source file for b85m
+ *
+ * @author ROW GROUP
+ * @date Nov,2022
+ *
+ * @par Copyright (c) 2022, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
+ * All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *******************************************************************************************************/
+#include "tl_common.h"
+#include "app_simple_fsm.h"
+
+/**********************************************************************
+ * LOCAL DEFINE
+ */
+
+//#define APP_FSM_EN_LOG
+
+#ifdef APP_FSM_EN_LOG
+ #define APP_FSM_LOG_TRACE log_trace
+ #define APP_FSM_LOG_DEBUG log_debug
+ #define APP_FSM_LOG_WARN log_warn
+ #define APP_FSM_LOG_ERROR log_error
+ #define APP_FSM_ARRAY_LOG_TRACE array_log_trace
+ #define APP_FSM_ARRAY_LOG_DEBUG array_log_debug
+ #define APP_FSM_ARRAY_LOG_WARN array_log_warn
+#else
+ #define APP_FSM_LOG_TRACE(...)
+ #define APP_FSM_LOG_DEBUG(...)
+ #define APP_FSM_LOG_WARN(...)
+ #define APP_FSM_LOG_ERROR(...)
+ #define APP_FSM_ARRAY_LOG_TRACE(...)
+ #define APP_FSM_ARRAY_LOG_DEBUG(...)
+ #define APP_FSM_ARRAY_LOG_WARN(...)
+#endif
+
+
+#ifdef APP_FSM_EN_PUSH_TO_FIFO
+
+/* APP VOICE FSM FIFO settings */
+#define APP_FSM_BUF_SIZE (8)
+#define APP_FSM_BUF_NUM (2)
+
+#endif
+
+/**********************************************************************
+ * LOCAL TYPES
+ */
+
+typedef struct {
+ u16 eventID;
+ u16 paraLen;
+ u8 para[0];
+}fsm_event_cache_t;
+
+
+/**********************************************************************
+ * LOCAL VARIABLES
+ */
+
+#ifdef APP_FSM_EN_PUSH_TO_FIFO
+
+/* FMS FIFO */
+_attribute_data_no_init_ u8 s_fsm_fifo_b[APP_FSM_BUF_SIZE * APP_FSM_BUF_NUM] = {0};
+_attribute_data_no_init_ app_fifo_t s_fsm_fifo = {
+ .size = APP_FSM_BUF_SIZE,
+ .num = APP_FSM_BUF_NUM,
+ .wptr = 0,
+ .rptr = 0,
+ .p = s_fsm_fifo_b};
+#endif
+
+/**********************************************************************
+ * LOCAL FUNCTIONS
+ */
+
+inline void app_fsm_stateTrans(app_fsm_t *pFsm,u8 state ){
+ pFsm->curState = state;
+}
+
+static void trigger_event(app_fsm_t *pFsm, u16 eventID, u8 *pBuf, u16 bufLen){
+
+ app_fsm_table_t *p_my_table = pFsm->pFsmTable;
+
+ if(NULL == p_my_table) return;
+
+ u8 my_nextState;
+ u8 my_curState = pFsm->curState;
+ u8 my_fsmTabCnt = pFsm->fsmTabCnt;;
+ app_fsm_eventActFunc_t my_eventFunc = NULL;
+
+ u8 flag_hit = 0;
+ for(u16 i=0; i<my_fsmTabCnt; i++){
+ if((my_curState == p_my_table[i].curState) && (eventID == p_my_table[i].eventID)){
+ flag_hit = 1;
+ my_eventFunc = p_my_table[i].eventFunc;
+ my_nextState = p_my_table[i].nextState;
+ break;
+ }
+ }
+
+ if(flag_hit){
+
+ int ret_eventFunc = 0;
+ if(my_eventFunc){
+ app_fsm_evnet_t my_event = {eventID, bufLen, pBuf, my_curState, my_nextState};
+ ret_eventFunc = my_eventFunc(my_event);
+ }
+
+ if(0 == ret_eventFunc){
+ /* When the return value of the event function is 0, it is converted according to the FSM table. */
+ app_fsm_stateTrans(pFsm, my_nextState);
+ }else if(ret_eventFunc < 0){
+ /* When the return value of the event function is less than 0, the conversion state is refused and the original state is maintained */
+ }else{
+ /* When the return value of the event function is greater than 0, it is forced to be set to the state of the return value. */
+ if(ret_eventFunc <= pFsm->maxState){
+ app_fsm_stateTrans(pFsm, ret_eventFunc);
+ }
+ }
+ }
+}
+
+
+/**********************************************************************
+ * GLOBAL FUNCTIONS
+ */
+
+void app_fsm_init(app_fsm_t *pFsm, app_fsm_table_t *pFsmTable, u8 fmsTabCnt, u8 initState, u8 maxState){
+
+ if((NULL == pFsm) || (NULL == pFsmTable)) return;
+ pFsm->pFsmTable = pFsmTable;
+ pFsm->fsmTabCnt = fmsTabCnt;
+ pFsm->curState = initState;
+ pFsm->maxState = maxState;
+}
+
+void app_fsm_triggerEvent(app_fsm_t *pFsm, u16 eventID, u8 *pBuf, u16 bufLen){
+
+#ifndef APP_FSM_EN_PUSH_TO_FIFO
+
+ trigger_event(pFsm, eventID, pBuf, bufLen);
+
+#else
+ app_fifo_init(&s_fsm_fifo, APP_FSM_BUF_SIZE, APP_FSM_BUF_NUM, s_fsm_fifo_b);
+
+ trigger_event(pFsm, eventID, pBuf, bufLen);
+
+ /* Check whether FMS events is generated in the callback function */
+ fsm_event_cache_t *p_my_event_buf = (fsm_event_cache_t *)app_fifo_get(&s_fsm_fifo);
+
+ if(NULL == p_my_event_buf){
+ return;
+ }
+
+ /* Process the events generated in the FSM event callback function sequentially. */
+ for(u8 i=0; i<pFsm->maxState; i++){
+
+ trigger_event(pFsm, p_my_event_buf->eventID, p_my_event_buf->para, p_my_event_buf->paraLen);
+
+ app_fifo_pop(&s_fsm_fifo);
+
+ p_my_event_buf = (fsm_event_cache_t *)app_fifo_get(&s_fsm_fifo);
+
+ if(NULL == p_my_event_buf){
+ break;
+ }
+ }
+#endif
+}
+
+#ifdef APP_FSM_EN_PUSH_TO_FIFO
+
+void app_fsm_pushEvent(app_fsm_t *pFsm, unsigned short eventID, unsigned char *pBuf, unsigned short bufLen){
+
+ if(bufLen > (APP_FSM_BUF_SIZE-sizeof(fsm_event_cache_t))){
+ APP_FSM_LOG_WARN("bufLen of pBuf passed in is too long");
+ return;
+ }
+
+ fsm_event_cache_t *p_my_fmsEvent = (fsm_event_cache_t *)app_fifo_wptr(&s_fsm_fifo);
+
+ if(NULL == p_my_fmsEvent){
+ APP_FSM_LOG_WARN("FSM FIFO not enough !!!");
+ return;
+ }
+
+ p_my_fmsEvent->eventID = eventID;
+ p_my_fmsEvent->paraLen = 0;
+
+ if((NULL == pBuf) || (0 == bufLen)){
+
+ }else{
+ p_my_fmsEvent->paraLen = bufLen;
+ memcpy(p_my_fmsEvent->para, pBuf, bufLen);
+ }
+
+ app_fifo_next(&s_fsm_fifo);
+ APP_FSM_ARRAY_LOG_TRACE("FSM EVENT", (u8 *)p_my_fmsEvent, bufLen+sizeof(fsm_event_cache_t));
+}
+
+#endif
diff --git a/vendor/827x_ble_remote/app_common/app_simple_fsm.h b/vendor/827x_ble_remote/app_common/app_simple_fsm.h
new file mode 100644
index 0000000..d4631c3
--- /dev/null
+++ b/vendor/827x_ble_remote/app_common/app_simple_fsm.h
@@ -0,0 +1,105 @@
+/********************************************************************************************************
+ * @file app_simple_fsm.h
+ *
+ * @brief This is the header file for b85m
+ *
+ * @author ROW GROUP
+ * @date Nov,2022
+ *
+ * @par Copyright (c) 2022, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
+ * All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *******************************************************************************************************/
+
+#ifndef APP_SIMPLE_FSM_H_
+#define APP_SIMPLE_FSM_H_
+
+
+#define APP_FSM_EN_PUSH_TO_FIFO
+
+#ifdef APP_FSM_EN_PUSH_TO_FIFO
+#include "app_fifo.h"
+#endif
+/**********************************************************************
+ * GLOBAL TYPES
+ */
+
+typedef struct {
+ unsigned short eventID;
+ unsigned short bufLen;
+ unsigned char *pBuf;
+ unsigned char curState;
+ unsigned char nextState;
+}app_fsm_evnet_t;
+
+typedef int (*app_fsm_eventActFunc_t)(app_fsm_evnet_t event);
+
+typedef struct {
+ unsigned char curState; // current state
+ unsigned char nextState; // next state
+ unsigned short eventID; // event ID
+ app_fsm_eventActFunc_t eventFunc; // function pointer
+}app_fsm_table_t;
+
+typedef struct {
+ app_fsm_table_t *pFsmTable;
+ unsigned char fsmTabCnt;
+ unsigned char curState;
+ unsigned char maxState;
+}app_fsm_t;
+
+
+
+/**********************************************************************
+ * GLOBAL FUNCTIONS
+ */
+
+/**
+ * @brief This function is used to initialize FSM variables
+ *
+ * @param pFsm - FSM variable pointer.This function is to initialize this variable
+ * @param pFsmTable - FSM state migration table
+ * @param fmsTabCnt - Number of FSM state migration tables
+ * @param initState - Initial value of FSM variable
+ * @param maxState - Maximum value of FSM variable. Used to prevent status from going out of scope
+ * @return none
+ */
+void app_fsm_init(app_fsm_t *pFsm, app_fsm_table_t *pFsmTable, unsigned char fmsTabCnt, unsigned char initState, unsigned char maxState);
+
+/**
+ * @brief This function is used to trigger the EVENT of FMS
+ *
+ * @param pFsm - FSM variable pointer.
+ * @param eventID - Triggered EVNET ID
+ * @param pBuf - EVNET data pointer. If no data is required to be passed, set it to NULL
+ * @param bufLen - EVNET data length. If no data is required to be passed, set it to 0
+ * @return none
+ */
+void app_fsm_triggerEvent(app_fsm_t *pFsm, unsigned short eventID, unsigned char *pBuf, unsigned short bufLen);
+
+#ifdef APP_FSM_EN_PUSH_TO_FIFO
+/**
+ * @brief This function is used to trigger the EVENT of FMS. This function must be used in the callback function of FSM
+ *
+ * @param pFsm - FSM variable pointer.
+ * @param eventID - Triggered EVNET ID
+ * @param pBuf - EVNET data pointer. If no data is required to be passed, set it to NULL
+ * @param bufLen - EVNET data length. If no data is required to be passed, set it to 0
+ */
+void app_fsm_pushEvent(app_fsm_t *pFsm, unsigned short eventID, unsigned char *pBuf, unsigned short bufLen);
+
+#endif /* APP_FSM_EN_PUSH_TO_FIFO */
+
+#endif /* APP_SIMPLE_FSM_H_ */
diff --git a/vendor/827x_ble_remote/app_custom.c b/vendor/827x_ble_remote/app_custom.c
index ad87325..e90376d 100644
--- a/vendor/827x_ble_remote/app_custom.c
+++ b/vendor/827x_ble_remote/app_custom.c
@@ -806,8 +806,21 @@
flash_read_page(APP_EN_BACKLIGHT, sizeof(my_Backlight), &my_Backlight);
flash_read_page(APP_BOOST_PIN, sizeof(my_BoostGpio), (u8 *)&my_BoostGpio);
- /* disable backlight when the value is 0xff */
- app_backlight_set_ability(my_Backlight, my_BoostGpio);
+
+ if(REMOTE_G11 == _custom_data.device_type){
+ /* G11 enables backlight by default */
+ if(my_Backlight==0xff){
+ my_Backlight = 1;
+ }
+
+ /* The default boost pin setting for G11 is PA0 */
+ if(my_BoostGpio==0xffff){
+ my_BoostGpio = BOOST_IC_EN_GPIO;
+ }
+ }
+
+ /* disable backlight when the value is 0xff */
+ app_backlight_set_ability(my_Backlight, my_BoostGpio);
}
diff --git a/vendor/827x_ble_remote/battery_check.c b/vendor/827x_ble_remote/battery_check.c
index 69a38c9..91aadd7 100644
--- a/vendor/827x_ble_remote/battery_check.c
+++ b/vendor/827x_ble_remote/battery_check.c
@@ -246,7 +246,7 @@
//printf("bak_batpercent = %d\r\n",bak_batpercent);
if(batt_vol_mv <= 2000)
{
- my_batVal[0] = 0;
+ my_batVal[0] = 1;
}
else if(batt_vol_mv>3000)
my_batVal[0] = 100;
diff --git a/version.h b/version.h
index db0a2a8..fb0a76c 100644
--- a/version.h
+++ b/version.h
@@ -27,6 +27,6 @@
#ifndef VERSION_H_
#define VERSION_H_
-#define FW_VERSION 0x34210232//FW:v3.4.2 SW:v2.32
+#define FW_VERSION 0x34210234//FW:v3.4.2 SW:v2.34
#endif /* VERSION_H_ */