Skip to content

Commit

Permalink
telink: b92: optimize code format
Browse files Browse the repository at this point in the history
- Optimize code format to access CI .

Signed-off-by: Fengtai Xie <[email protected]>
  • Loading branch information
fengtai-telink committed Dec 18, 2024
1 parent 0f94666 commit e13cd8f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions examples/lighting-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ CHIP_ERROR AppTask::Init(void)
InitCommonParts();

#if CONFIG_DUAL_MODE_SWTICH
if(sBoot_zb)
if (sBoot_zb)
{
/* Switch from the touch link, need to restore previous values */
/* Switch from the touch link, need to restore previous values */
sfixture_on = user_para.onoff;
sBrightness = user_para.lightness;
sAppTask.UpdateClusterState();
Expand Down
15 changes: 8 additions & 7 deletions examples/platform/telink/common/include/AppTaskCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,22 @@
#include <zephyr/storage/flash_map.h>
#include <zephyr/sys/reboot.h>

#define USER_INIT_VAL 0xff
#define USER_ZB_SW_VAL 0xaa
#define USER_MATTER_PAIR_VAL 0x55
#define USER_PARA_MAC_OFFSET 0x100
#define USER_INIT_VAL 0xff
#define USER_ZB_SW_VAL 0xaa
#define USER_MATTER_PAIR_VAL 0x55
#define USER_PARA_MAC_OFFSET 0x100
#define USER_PARTITION user_para_partition
#define USER_PARTITION_DEVICE FIXED_PARTITION_DEVICE(USER_PARTITION)
#define USER_PARTITION_OFFSET FIXED_PARTITION_OFFSET(USER_PARTITION)
#define USER_PARTITION_SIZE FIXED_PARTITION_SIZE(USER_PARTITION)

typedef struct{
uint8_t val ;
typedef struct
{
uint8_t val;
uint8_t rfu;
uint8_t onoff;
uint8_t lightness;
}user_para_t;
} user_para_t;

extern user_para_t user_para;
extern uint8_t para_lightness;
Expand Down
21 changes: 10 additions & 11 deletions examples/platform/telink/common/src/AppTaskCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ constexpr uint32_t kIdentifyBreatheRateMs = 1000;

#if CONFIG_DUAL_MODE_SWTICH
const struct device * flash_para_dev = USER_PARTITION_DEVICE;
constexpr int kDnssTimeout = 60000;
constexpr int kDnssTimeout = 60000;
k_timer sDnssTimer;
#endif

Expand Down Expand Up @@ -248,25 +248,25 @@ CHIP_ERROR AppTaskCommon::StartApp(void)
{

#if CONFIG_DUAL_MODE_SWTICH
/* Proc ota boot flag , and erase flag */
/* Proc ota boot flag , and erase flag */
flash_read(flash_para_dev, USER_PARTITION_OFFSET, &user_para, sizeof(user_para));
/* Boot from Zigbee , need to clean the user parameters sector first and set a flag */
if (user_para.val == USER_ZB_SW_VAL)
{
sBoot_zb = 1;
/* Ensure lightness is at least 2 to avoid display error on HomePod Mini */
if(user_para.lightness < 2)
if (user_para.lightness < 2)
{
user_para.lightness = 2;
}
/* Pass the value to the init part to avoid gaps in pwm_pool init */
if(user_para.onoff)
if (user_para.onoff)
{
para_lightness = user_para.lightness;
}
k_timer_init(&sDnssTimer, &AppTask::DnssTimerTimeoutCallback, nullptr);
k_timer_start(&sDnssTimer, K_MSEC(kDnssTimeout), K_NO_WAIT);
printk("Matter: start timer to protect Dnss initialized %x \r\n",*(int *)(&user_para));
printk("Matter: start timer to protect Dnss initialized %x \r\n", *(int *) (&user_para));
}
#endif

Expand Down Expand Up @@ -812,16 +812,15 @@ void AppTaskCommon::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /*
#endif
break;
#if CONFIG_DUAL_MODE_SWTICH
case DeviceEventType::kCommissioningComplete:
{
case DeviceEventType::kCommissioningComplete: {
uint8_t val = USER_MATTER_PAIR_VAL;
flash_erase(flash_para_dev, USER_PARTITION_OFFSET, USER_PARTITION_SIZE);
flash_write(flash_para_dev, USER_PARTITION_OFFSET, &val, 1);
printk("Commissioning complete, set Matter commissionined flag");
}
break;
}
break;
case DeviceEventType::kFailSafeTimerExpired:
/* Reset to Zigbee mode if commissioning fails */
/* Reset to Zigbee mode if commissioning fails */
if (sBoot_zb)
{
printk("FailSafeTimer expired, Matter commissioning failed, rebooting to Zigbee mode.\r\n");
Expand Down Expand Up @@ -849,7 +848,7 @@ void AppTaskCommon::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /*
#endif

#if CONFIG_DUAL_MODE_SWTICH
if(sBoot_zb)
if (sBoot_zb)
{
k_timer_stop(&sDnssTimer);
printk("Dnss Timer stopped, Matter commissioning kDnssdInitialized.\r\n");
Expand Down

0 comments on commit e13cd8f

Please sign in to comment.