Skip to content

Commit

Permalink
riscv: telink: clean code .
Browse files Browse the repository at this point in the history
- add log for attribute cb.
- clean code.

Signed-off-by: Haiwen Xia <haiwen.xia@telink-semi.com>
  • Loading branch information
haiwentelink committed Dec 25, 2024
1 parent e2b48b2 commit 1ac3915
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions config/telink/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ config BT_GATT_CACHING

config BT_RX_STACK_SIZE
default 1352 if BT_B9X
default 1010 if BT_TLX
default 1352 if BT_TLX
default 2048 if BT_W91

config BT_HCI_TX_STACK_SIZE
Expand Down Expand Up @@ -267,7 +267,7 @@ config COMPRESS_LZMA

config CUSTOMER_MODE
bool "Disable application code and add demo code"
default n if SOC_RISCV_TELINK_TL321X || SOC_RISCV_TELINK_B92
default y if SOC_RISCV_TELINK_TL321X || SOC_RISCV_TELINK_B92
default n

config DUAL_MODE_SWTICH
Expand Down
5 changes: 5 additions & 0 deletions examples/lighting-app/telink/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
uint8_t * value)
{
#if CONFIG_CUTOMER_MODE
/* user mode , add the customer code here for cb*/
ClusterId clusterId = attributePath.mClusterId;
AttributeId attributeId = attributePath.mAttributeId;
ChipLogProgress(Zcl, "========MatterPostAttributeChangeCallback:clusterId=0x%x,AttributeId=0x%x,value=0x%x", clusterId,
attributeId, *value);

#else
static HsvColor_t hsv;
Expand Down
16 changes: 9 additions & 7 deletions examples/platform/telink/common/src/AppTaskCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ constexpr uint32_t kIdentifyBreatheRateMs = 1000;

#if CONFIG_DUAL_MODE_SWTICH
const struct device * flash_para_dev = USER_PARTITION_DEVICE;
const struct device * zb_para_dev = ZB_NVS_PARTITION_DEVICE;
constexpr int kDnssTimeout = 60000;
k_timer sDnssTimer;
#endif
Expand Down Expand Up @@ -146,7 +147,7 @@ void FactoryResetExtHandler(void)
// Erase the user parameters partition to reset mode settings
flash_erase(flash_para_dev, USER_PARTITION_OFFSET, USER_PARTITION_SIZE);
// Need to erase zb nvs part in factory mode
flash_erase(flash_para_dev, ZB_NVS_START_ADR, ZB_NVS_SEC_SIZE);
flash_erase(zb_para_dev, ZB_NVS_START_ADR, ZB_NVS_SEC_SIZE);
}
#endif

Expand Down Expand Up @@ -240,7 +241,6 @@ void AppTaskCommon::PowerOnFactoryReset(void)
void SwitchBackToZigbee()
{
uint8_t switch_flag = USER_MATTER_BACK_ZB;
// flash_erase(flash_para_dev, USER_PARTITION_OFFSET, USER_PARTITION_SIZE);
flash_write(flash_para_dev, USER_PARTITION_OFFSET, &switch_flag, 1);
sys_reboot(0);
}
Expand Down Expand Up @@ -760,9 +760,9 @@ void AppTaskCommon::StartWiFiButtonEventHandler(void)
{
AppEvent event;

event.Type = AppEvent::kEventType_Button;
event.Type = AppEvent::kEventType_Button;
event.ButtonEvent.Action = kButtonPushEvent;
event.Handler = StartWiFiHandler;
event.Handler = StartWiFiHandler;
GetAppTask().PostEvent(&event);
}

Expand Down Expand Up @@ -833,7 +833,8 @@ 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;
#if CONFIG_CUSTOMER_MODE
/* need to add here to update the cluster information , only in the zb switch and touchlink is paired*/
Expand All @@ -852,6 +853,7 @@ void AppTaskCommon::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /*
}
}
#endif
sBoot_zb = 0;
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");
Expand Down Expand Up @@ -900,8 +902,8 @@ void AppTaskCommon::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /*
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
case DeviceEventType::kWiFiConnectivityChange:
sIsNetworkProvisioned = ConnectivityMgr().IsWiFiStationProvisioned();
sIsNetworkEnabled = ConnectivityMgr().IsWiFiStationEnabled();
sIsNetworkAttached = ConnectivityMgr().IsWiFiStationConnected();
sIsNetworkEnabled = ConnectivityMgr().IsWiFiStationEnabled();
sIsNetworkAttached = ConnectivityMgr().IsWiFiStationConnected();
#if CONFIG_CHIP_OTA_REQUESTOR
if (event->WiFiConnectivityChange.Result == kConnectivity_Established)
{
Expand Down

0 comments on commit 1ac3915

Please sign in to comment.