ZigBee透传如何获取周数据,

Post Reply
cheng_JS
Posts: 117

使用ZigBee透传,由于产品有周定时功能,所以要获取周,时,分时间数据,但RTC时间获取函数好像没有周数据,无法确定是周几

Attachments
0097.PNG
huanghuan
Posts: 245

Re: ZigBee透传如何获取周数据,

你好,麻烦确认下使用的开发框架平台是哪个,具体的版本是哪个?使用ZigBee透传是用的MCU 通用对接么?

cheng_JS
Posts: 117

Re: ZigBee透传如何获取周数据,

对,通用对接的

cheng_JS
Posts: 117

Re: ZigBee透传如何获取周数据,

固件类型:
Zigbee固件
固件名称:
Telink zigbee 标准功耗通用固件
固件key:
keytq4v4
固件版本:
1.0.10

huanghuan
Posts: 245

Re: ZigBee透传如何获取周数据,

你好,我们提供了获取时间戳转换函数,void get_current_time_struct(device_time_struct_t *device_time)

cheng_JS
Posts: 117

Re: ZigBee透传如何获取周数据,

但我们这个是做的透传的,MCU SDK里没有这个函数

huanghuan
Posts: 245

Re: ZigBee透传如何获取周数据,

你好,获取到utc时间后可以通过下列函数得到周几

Code: Select all

#define SECONDS_IN_MINUTE 60
#define SECONDS_IN_HOUR 3600
#define SECONDS_IN_DAY   (SECONDS_IN_MINUTE * 60 * 24)
#define SECONDS_IN_WEEK  (SECONDS_IN_DAY * 7)

// Determine which day of the week it is, from a given utc timestamp.
// Return 0=MON, 1=TUES, etc.
uint8_t emberAfGetWeekdayFromUtc(uint32_t utcTime)
{
    uint8_t dayIndex;
    utcTime %= SECONDS_IN_WEEK;

for ( dayIndex = 0; dayIndex < 7; dayIndex++ ) {
  if ( utcTime < SECONDS_IN_DAY ) {
    break;
  }
  utcTime -= SECONDS_IN_DAY;
}
// Note:  Jan 1, 2000 is a SATURDAY.
// Do some translation work so 0=MONDAY, 5=SATURDAY, 6=SUNDAY
if ( dayIndex < 2 ) {
  dayIndex += 5;
} else {
  dayIndex -= 2;
}
return dayIndex;
}
Post Reply