TI BLE5-Stack API Documentation  2.02.08.01
oad.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  @file oad.h
4 
5  @brief This file contains OAD Profile header file.
6 
7  Group: WCS, BTS
8  $Target Device: DEVICES $
9 
10  ******************************************************************************
11  $License: BSD3 2017 $
12  ******************************************************************************
13  $Release Name: PACKAGE NAME $
14  $Release Date: PACKAGE RELEASE DATE $
15  *****************************************************************************/
122 #ifndef OAD_H
123 #define OAD_H
124 
125 #ifdef __cplusplus
126 extern "C"
127 {
128 #endif
129 
130 /*********************************************************************
131  * INCLUDES
132  */
133 #include "hal_types.h"
134 
135 #ifdef MCUBOOT_ENABLE
136 #define OAD_SW_VER_LEN 4 //taken from oad_image_header.h
137 #define OAD_IMG_TYPE_APP 1 //taken from oad_image_header.h
138 #else
139 #include <common/cc26xx/oad/oad_image_header.h>
140 #endif // MCUBOOT_ENABLE
141 
142 /*********************************************************************
143  * CONSTANTS
144  */
145 
150 #ifdef OAD_BLE_SECURITY
151  #define OAD_WRITE_PERMIT GATT_PERMIT_AUTHEN_WRITE
152 #else
153  #define OAD_WRITE_PERMIT GATT_PERMIT_WRITE
154 #endif //OAD_SECURITY
155 
159 #define OAD_IMG_ID_RETRIES 3
160 
161 // Events the OAD process will post to the app
162 
172 #define OAD_QUEUE_EVT (0x2)
173 
179 #define OAD_DL_COMPLETE_EVT (0x4)
180 
186 #define OAD_OUT_OF_MEM_EVT (0x8)
187 
201 #define OAD_SERVICE_UUID 0xFFC0
202 
206 #define OAD_IMG_IDENTIFY_UUID 0xFFC1
207 
211 #define OAD_IMG_BLOCK_UUID 0xFFC2
212 
217 #define OAD_IMG_COUNT_UUID 0xFFC3
218 
224 #define OAD_IMG_STATUS_UUID 0xFFC4
225 
229 #define OAD_EXT_CTRL_UUID 0xFFC5
230 
241 #define OAD_IDX_IMG_IDENTIFY 0
242 
246 #define OAD_IDX_IMG_BLOCK 1
247 
251 #define OAD_IDX_EXT_CTRL 2
252 
259 #define OAD_ATT_OVERHEAD 3
260 
264 #define OAD_BLK_NUM_HDR_SZ 4
265 
271 #define OAD_DEFAULT_BLOCK_SIZE 20
272 
278 #define OAD_MAX_BLOCK_SIZE 244
279 
283 #define OAD_IMAGE_ID_RSP_LEN 0x01
284 
295 #define OAD_EXT_CTRL_GET_BLK_SZ 0x01
296 
302 #define OAD_EXT_CTRL_IMG_CNT 0x02
303 
309 #define OAD_EXT_CTRL_START_OAD 0x03
310 
316 #define OAD_EXT_CTRL_ENABLE_IMG 0x04
317 
322 #define OAD_EXT_CTRL_CANCEL_OAD 0x05
323 
328 #define OAD_EXT_CTRL_DISABLE_BLK_NOTIF 0x06
329 
334 #define OAD_EXT_CTRL_GET_SW_VER 0x07
335 
340 #define OAD_EXT_CTRL_GET_IMG_STAT 0x08
341 
346 #define OAD_EXT_CTRL_GET_PROF_VER 0x09
347 
352 #define OAD_EXT_CTRL_GET_DEV_TYPE 0x10
353 
359 #define OAD_EXT_CTRL_GET_IMG_INFO 0x11
360 
365 #define OAD_EXT_CTRL_BLK_RSP_NOTIF 0x12
366 
371 #define OAD_EXT_CTRL_ERASE_BONDS 0x13
372 
380 #define OAD_EXT_CTRL_CMD_NOT_SUPPORTED 0xFF
381 
388 #define OAD_IMG_INFO_ONCHIP 0x01
389 
396 #define OAD_DEFAULT_INACTIVITY_TIME 10000
397 
402 #define OAD_MIN_INACTIVITY_TIME 4000
403 
407 #define OAD_CHAR_CNT 3
408 
412 #define OAD_CCCD_CNT OAD_CHAR_CNT
413 
414 
419 #define OAD_SUCCESS 0
420 #define OAD_CRC_ERR 1
421 #define OAD_FLASH_ERR 2
422 #define OAD_BUFFER_OFL 3
423 #define OAD_ALREADY_STARTED 4
424 #define OAD_NOT_STARTED 5
425 #define OAD_DL_NOT_COMPLETE 6
426 #define OAD_NO_RESOURCES 7
427 #define OAD_IMAGE_TOO_BIG 8
428 #define OAD_INCOMPATIBLE_IMAGE 9
429 #define OAD_INVALID_FILE 10
430 #define OAD_INCOMPATIBLE_FILE 11
431 #define OAD_AUTH_FAIL 12
432 #define OAD_EXT_NOT_SUPPORTED 13
433 #define OAD_DL_COMPLETE 14
434 #define OAD_CCCD_NOT_ENABLED 15
435 #define OAD_IMG_ID_TIMEOUT 16
436 
437 
439 #if defined(DeviceFamily_CC26X2) || defined(DeviceFamily_CC13X2) || defined(DeviceFamily_CC26X1)
441 #define BIM_START 0x56000
442 #elif defined(DeviceFamily_CC26X2X7) || defined(DeviceFamily_CC13X2X7)
443 #define BIM_START 0xAE000
444 #else
445 #define BIM_START 0x1F000
446 #endif
447 
452 #define OAD_IMG_PG_INVALID 0xFF
453 
455 #define OAD_SEC_ECDSA_P256 0x01
456 #define OAD_SEC_AES_128_CBC 0x02
457 
458 
462 #define OAD_EFL_MAX_META 4
463 
464 /*********************************************************************
465  * MACROS
466  */
467 
471 #define EXT_CTRL_OP_CODE(pData)(pData[0])
472 
473 /*********************************************************************
474  * TYPEDEFS
475  */
476 
480 PACKED_TYPEDEF_STRUCT
481 {
482  uint8_t imgID[8];
483  uint8_t bimVer;
484  uint8_t metaVer;
485  uint8_t imgCpStat;
486  uint8_t crcStat;
487  uint8_t imgType;
488  uint8_t imgNo;
489  uint32_t len;
490  uint8_t softVer[4];
492 
496 PACKED_TYPEDEF_STRUCT
497 {
498  uint8_t cmdID;
499  uint8_t prevBlkStat;
500  uint32_t requestedBlk;
502 
507 PACKED_TYPEDEF_STRUCT
508 {
509  uint8_t imgCpStat;
510  uint8_t crcStat;
511  uint8_t imgType;
512  uint8_t imgNo;
513 } imageInfo_t;
514 
515 PACKED_TYPEDEF_STRUCT
516 {
517  uint8_t securityVersion;
518  uint32_t timeStamp;
519 }securityHdr_t;
520 
524 typedef enum
525 {
531 }oadEvent_e;
532 
533 
537 typedef enum
538 {
545 }oadState_e;
546 
547 
548 /*********************************************************************
549  * Ext Control Command Payloads
550  */
551 
556 PACKED_TYPEDEF_STRUCT
557 {
558  uint8_t cmdID;
559  uint8_t status;
561 
565 PACKED_TYPEDEF_STRUCT
566 {
567  uint8_t cmdID;
568  uint8_t profVer;
570 
574 PACKED_TYPEDEF_STRUCT
575 {
576  uint8_t cmdID;
577  uint16_t oadBlkSz;
579 
583 PACKED_TYPEDEF_STRUCT
584 {
585  uint8_t cmdID;
586  uint8_t swVer[OAD_SW_VER_LEN];
588 
595 PACKED_TYPEDEF_STRUCT
596 {
597  uint8_t cmdID;
598  uint8_t chipType;
599  uint8_t chipFamily;
600  uint8_t hardwareRev;
601  uint8_t rsvd;
603 
607 PACKED_TYPEDEF_STRUCT
608 {
609  uint8_t cmdID;
610  uint8_t numImages;
611  uint8_t imgCpStat;
612  uint8_t crcStat;
613  uint8_t imgType;
614  uint8_t imgNo;
616 
622 PACKED_TYPEDEF_STRUCT
623 {
624  uint8_t cmdID;
625  uint8_t imgType;
626  uint8_t imgNo;
627  uint16_t techType;
629 
630 #ifdef DMM_OAD
631 typedef struct
632 {
633  uint32_t totBlocks;
634  uint32_t currBlock;
635 }imgProgressInfo_t;
636 #endif
637 
638 /*********************************************************************
639  * EXTERNAL VARIABLES
640  */
641 
642 /*********************************************************************
643  * Profile Callbacks
644  */
645 
656 typedef void (*oadWriteCB_t)(uint8_t event, uint16_t arg);
657 
661 typedef struct
662 {
665 
666 /*********************************************************************
667  * FUNCTIONS
668  */
669 
680 extern uint8_t OAD_open(uint32_t oadTimeout);
681 
685 extern void OAD_cancel(void);
686 
687 
691 extern void OAD_close(void);
692 
698 extern bool OAD_isUsrAppValid(void);
699 
706 extern void OAD_register(oadTargetCBs_t *pfnOadCBs);
707 
717 extern bool OAD_getSWVersion(uint8_t *swVer, uint8_t len);
718 
724 extern uint16_t OAD_getBlockSize(void);
725 
733 extern uint8_t OAD_setBlockSize(uint16_t mtuSize);
734 
740 extern uint8_t OAD_processQueue(void);
741 
747 extern uint16_t OAD_getactiveCxnHandle();
748 
755 extern uint8_t oadCreateFactoryImageBackup(void);
756 
764 extern bool OAD_evenBitCount(uint32_t value);
765 
766 #ifdef DMM_OAD
767 extern void OAD_getProgressInfo(imgProgressInfo_t* pImgInfo);
768 #endif
769 
770 /*********************************************************************
771 *********************************************************************/
772 
775 #ifdef __cplusplus
776 }
777 #endif
778 
779 #endif /* OAD_H */
uint8_t imgCpStat
Image copy status bytes.
Definition: oad.h:485
uint8_t oadCreateFactoryImageBackup(void)
uint8_t crcStat
Image CRC status flag.
Definition: oad.h:510
uint8_t cmdID
External control op-code.
Definition: oad.h:498
External Control Command received.
Definition: oad.h:529
Definition: oad.h:496
uint8_t imgCpStat
Image copy flag.
Definition: oad.h:509
uint8_t imgType
Image Type.
Definition: oad.h:613
OAD peer timed out.
Definition: oad.h:530
uint8_t imgCpStat
Image copy status.
Definition: oad.h:611
uint32_t requestedBlk
Requested block number.
Definition: oad.h:500
uint8_t profVer
OAD profile version.
Definition: oad.h:568
uint8_t hardwareRev
Hardware revision Field from ChipInfo module.
Definition: oad.h:600
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:567
uint8_t crcStat
CRC status.
Definition: oad.h:486
Definition: oad.h:661
Definition: oad.h:565
uint8_t bimVer
BIM version.
Definition: oad.h:483
uint8_t imgNo
Image number flag.
Definition: oad.h:512
uint8_t imgType
Image Type.
Definition: oad.h:487
uint16_t OAD_getBlockSize(void)
bool OAD_getSWVersion(uint8_t *swVer, uint8_t len)
Definition: oad.h:622
uint8_t imgType
Image type flag.
Definition: oad.h:511
uint8_t OAD_processQueue(void)
uint8_t OAD_open(uint32_t oadTimeout)
uint8_t imgNo
Image Number.
Definition: oad.h:626
uint8_t chipType
Chip Type Field from ChipInfo module.
Definition: oad.h:598
Image block request/response event.
Definition: oad.h:527
uint32_t len
Image length in octets.
Definition: oad.h:489
uint16_t techType
Wireless technology type.
Definition: oad.h:627
oadState_e
Definition: oad.h:537
uint8_t imgType
Image Type.
Definition: oad.h:625
Definition: oad.h:556
uint8_t prevBlkStat
Status of previous block write.
Definition: oad.h:499
OAD module is configuring for a download.
Definition: oad.h:541
void OAD_register(oadTargetCBs_t *pfnOadCBs)
uint8_t OAD_setBlockSize(uint16_t mtuSize)
OAD module is not performing any action.
Definition: oad.h:539
OAD module is validating an received image.
Definition: oad.h:543
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:576
oadWriteCB_t pfnOadWrite
The peer has written to the OAD service.
Definition: oad.h:663
void OAD_close(void)
uint8_t rsvd
RFU.
Definition: oad.h:601
uint16_t oadBlkSz
OAD block size.
Definition: oad.h:577
uint8_t imgNo
Image number of &#39;image type&#39;.
Definition: oad.h:488
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:585
Definition: oad.h:480
Definition: oad.h:607
OAD module is receiving an image.
Definition: oad.h:542
void OAD_cancel(void)
Definition: oad.h:574
OAD module is checking an image.
Definition: oad.h:540
uint8_t chipFamily
Chip Family Field from ChipInfo module.
Definition: oad.h:599
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:558
uint8_t crcStat
Image CRC status.
Definition: oad.h:612
uint16_t OAD_getactiveCxnHandle()
void(* oadWriteCB_t)(uint8_t event, uint16_t arg)
Definition: oad.h:656
bool OAD_isUsrAppValid(void)
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:609
uint8_t status
Status of command.
Definition: oad.h:559
Image identify received.
Definition: oad.h:526
Definition: oad.h:595
uint8_t metaVer
Metadata version.
Definition: oad.h:484
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:624
oadEvent_e
Definition: oad.h:524
uint8_t numImages
Number of images.
Definition: oad.h:610
Definition: oad.h:507
Definition: oad.h:583
OAD complete.
Definition: oad.h:528
uint8_t imgNo
Image Number.
Definition: oad.h:614
OAD module has completed a download.
Definition: oad.h:544
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:597
bool OAD_evenBitCount(uint32_t value)
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale