STM32WB15CC - 超低功耗双核Arm Cortex-M4 MCU 64 MHz,Cortex-M0 32 MHz,具有320 KB Flash存储器、蓝牙LE 5.2、AES-256 - 意法半导体STMicroelectronics
AN5491 STM32WB STM32WB ZCLZigbee® Exegin ZSDKZigbee ZCL Exegin ZSDK Zigbee®[R1]Exegin ZSDK [R3] Exegin ZCL [R5] 1. © 2019-2020 Exegin Technologies Limited. AN5491 - 1 - 2020 7 www.st.com 1 ARM® STM32WB Arm Arm Limited/ AN5491 AN5491 - 1 215 AN5491 2 1. [R1] Zigbee PRO 22 www.zigbeealliance.org/(1) 05-2374-22 [R2] Zigbee 7 www.zigbeealliance.org/(1) 07-5123-07 [R3] ZSDK API STM32WB ZigBee®(2) AN5500 [R4] Zigbee 1.4 www.zigbeealliance.org/(1) 07-5356-21 [R5] STM32WB ZigBee®(2) AN5498 1. URL URL 2. www.st.com AN5491 - 1 315 AN5491 ZCL 3 ZCL ZCL ZCL Zigbee ZCL """/"/ N M 1 9 OO/ "/" N 1 M 9 1. ZCL APS APS NWK [R3]ZSDK ZCL ZCL [R5] ZSDK ZCL 2. ZCL ZCL ZCL [R2] ZSE [R4] 2. ZCL N 1 M 9 AN5491 - 1 415 AN5491 4 ZCL ZbZclReadReq() static void read_onoff_callback(const ZbZclReadRspT *rsp, void *arg) { struct application *app = (application *)arg; if(rsp->status == ZCL_STATUS_SUCCESS) { if(rsp->attr[0].status == ZCL_STATUS_SUCCESS) { app->remote_onoff_state = pletoh16(rsp->attr[0].value[0]); } else { /* handle error */ ... } else { /* handle error */ ... } . . . enum ZclStatusCodeT status; ZbZclReadReqT req; memset(&req, 0, sizeof(req)); req.dst = ZbApsAddrBinding; req.attr[0] = ZCL_ONOFF_ATTR_ON_TIME; req.count = 1; status = ZbZclReadReq(app->client_cluster, &req, read_onoff_callback, &application) ZbZclReadReq() ZCL N OnOff 1 M 9 ZCL UNSUPPORTED_ATTRIBUTE (0x86) ZCL ZbZclAttrAppendList() ZCL struct ZbZclAttrT ZbZclAttrAppendList() static const struct ZbZclAttrT attr_list[] = { ... { ZCL_ONOFF_ATTR_ON_TIME, ZCL_DATATYPE_UNSIGNED_16BIT, ZCL_ATTR_FLAG_NONE, 0, NULL, {0, 0}, {0, 0} }, ... ZbZclAttrAppendList(cluster, attr_list, ZCL_ATTR_LIST_LEN(attr_list)) AN5491 - 1 515 AN5491 NULLZCL ZCL ZbZclAttrIntegerWrite() /* hardware register, little endian, two bytes*/ extern volatile uint8_t *on_time; enum ZclStatusCodeT on_time_cb(struct ZbZclClusterT *clusterPtr, struct ZbZclAttrCbInfoT *info) { uint8_t *data = info->attr_data; switch(info->type) { case ZCL_ATTR_CB_TYPE_READ: /* read from hardware */ data[0] = on_time[0]; data[1] = on_time[1] break; case ZCL_ATTR_CB_TYPE_WRITE: /* write to hardware */ on_time[0] = data[0]; on_time[1] = data[1]; break; case ZCL_ATTR_CB_TYPE_NOTIFY: on_time[0] = data[0]; on_time[1] = data[1]; break; } return ZCL_STATUS_SUCCESS; } static const struct ZbZclAttrT attr_list[] = { ... { ZCL_ONOFF_ATTR_ON_TIME, ZCL_DATATYPE_UNSIGNED_16BIT, ZCL_ATTR_FLAG_NONE, 0, on_time_cb, {0, 0}, {0, 0} }, ... ZCL_ATTR_FLAG_CB_READ ZCL_ATTR_FLAG_CB_WRITE NULL read_onoff_callback AN5491 - 1 615 AN5491 5 4 "" ZCL ZCL 2 3 4 GetCalendar PublishCalendar [R4] 5.1 D.9.2.4.1.1 [R4] GetCalendar 4 4 1 1 4 2. GetCalendar UTC 32 8 8 32 M IDM M M IDM D.9.2.3.1.1 [R4] PublishCalendar 4 4 4 4 1 1 1..13 1 1 1 3. PublishCalendar - 32 32 32 UTC 8 IDM IDM IDM M M 4. PublishCalendar - 8 8 8 8 M M M M M AN5491 - 1 715 AN5491 Get Calendar static void get_cal_cb (struct ZbZclCommandRspT *rsp, void *arg) { struct application app = (struct application *)arg; } ... enum ZclStatusCodeT status; struct ZbZclCalClientGetCalendarT req; memset(&req, 0, sizeof(req)); req.earliestStartTime = app->calendar_start; req.minIssuerEventId = ZCL_INVALID_UNSIGNED_32BIT; /* all ids */ req.numCalendars = 1; req.calendarType = 0x02; /* delivered and received */ req.providerId = app->provider_id; status = ZbZclCalClientCommandGetCalReq(cluster, ZbApsAddrBinding, &req, get_cal_cb, app); ZbZclCalClientCommandGetCalReq() ZB_STATUS_SUCCESS GetCalendar 2. GetCalendar ZB_STATUS_SUCCESS ZCL GetCalendar PublishCalendar ZCL ZCL ZCL · · · · · · AN5491 - 1 815 AN5491 ZbZclCalClientCommandGetCalReq() 1. ZCL rsp.status ZCL_STATUS_SUCCESS a. "cluster" rsp.hdr.frameCtrl.frameType & ZCL_FRAMECTRL_TYPE == ZCL_FRAMETYPE_CLUSTER b. ZCL ID ID Publish Calendarrsp.hdr.cmdId == ZCL_CAL_SVR_PUBLISH_CALENDAR c. Publish Calendar rsp->payload rsp->length ZbZclCalClientParsePublishCalendar() ZCL 2. ZCL "" rsp.status ZCL_STATUS_SUCCESS a. ZCL_FRAMETYPE_PROFILE b. ID ZCL_COMMAND_DEFAULT_RESPONSE c. ZbZclParseDefaultResponse() d. ZCL_STATUS_SUCCESS ZCL "" 1 ZCL " " 0 ZCL 3. rsp.status ZCL_STATUS_FAILURE rsp.aps_status APS NWK a. aps_status ZB_APS_STATUS_NO_ACK APS / APS ZB_APS_STATUS_NO_ACK aps_status b. aps_status ZB_WPAN_STATUS_NO_ACK aps_status AN5491 - 1 915 AN5491 5.2 GetCalendar 3 M NWK APS ZCL static enum ZclStatusCodeT get_calendar(struct ZbZclClusterT *clusterPtr, void *arg, struct ZbZclCalClientGetCalendarT *req, struct ZbZclAddrInfoT *srcInfo) { struct ZbZclCalServerPublishCalendarT rsp; memset(&rsp, 0, sizeof(rsp)); /* fill in response */ ZbZclCalServerSendPublishCalendar(clusterPtr, srcInfo, &rsp); return ZCL_STATUS_SUCCESS_NO_DEFAULT_RESPONSE; } ... callbacks.get_calendar = get_calendar; ... cluster = ZbZclCalServerAlloc(zb, endpoint, &callbacks, arg) ... struct ZbZclClusterT * ZbZclCalServerAlloc(struct ZigBeeT *zb, uint8_t endpoint, struct ZbZclCalServerCallbacksT *callbacks, void *arg) { ... clusterPtr->cluster.command = zcl_calendar_server_command; ... ZbZclCalServerConfigCallbacks(&clusterPtr->cluster, callbacks); ZCL zcl_calendar_server_command() ZCL_STATUS_UNSUPP_MFR_CLUSTER_COMMAND ZCL [R2] ZCL_STATUS_UNSUPP_CLUSTER_COMMAND ZCL ZCL struct ZbZclCalClientGetCalendarT get_calendar() GetCalendar get_calendar() ZbZclCalClientGetCalendarT *req ZbZclCalServerSendPublishCalendar() ZCL PublishCalendar ZCL_STATUS_SUCCESS_NO_DEFAULT_RESPONSE ZCL ZCL PublishCalendar"" "ZCL " ZCL_STATUS_SUCCESS "" ZCL_STATUS ZCL AN5491 - 1 1015 2020 7 17 5. 1 AN5491 AN5491 - 1 1115 AN5491 1 ...............................................................................................................................2 2 ........................................................................................................................3 3 ZCL ................................................................................................................4 4 ......................................................................................................5 5 .............................................................................................................7 5.1 ............................................................................................................. 7 5.2 ............................................................................................ 10 ............................................................................................................................11 ...................................................................................................................................12 ............................................................................................................................13 ............................................................................................................................14 AN5491 - 1 1215 AN5491 1. 2. 3. 4. 5. .............................................................................................................................................................. 3 GetCalendar ................................................................................................................................................ 7 PublishCalendar - ........................................................................................................................ 7 PublishCalendar - ........................................................................................................................ 7 ..................................................................................................................................................... 11 AN5491 - 1 1315 AN5491 1. 2. ................................................................................................................................................... 4 ZCL ...................................................................................................................................................... 4 AN5491 - 1 1415 AN5491 - "" ST / ST ST www.st.com/trademarks © 2023 STMicroelectronics - AN5491 - 1 1515C2 v20.4.0000 build 240 - c2 rendition config : Techlit Active Microsoft Word 2021; modified using iText 2.1.7 by 1T3XT