TI BLE5-Stack API Documentation  2.02.05.00
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 #include <ti/sysbios/knl/Queue.h>
135 
136 #include <common/cc26xx/oad/oad_image_header.h>
137 
138 /*********************************************************************
139  * CONSTANTS
140  */
141 
146 #ifdef OAD_BLE_SECURITY
147  #define OAD_WRITE_PERMIT GATT_PERMIT_AUTHEN_WRITE
148 #else
149  #define OAD_WRITE_PERMIT GATT_PERMIT_WRITE
150 #endif //OAD_SECURITY
151 
155 #define OAD_IMG_ID_RETRIES 3
156 
157 // Events the OAD process will post to the app
158 
168 #define OAD_QUEUE_EVT Event_Id_01
169 
175 #define OAD_DL_COMPLETE_EVT Event_Id_02
176 
182 #define OAD_OUT_OF_MEM_EVT Event_Id_03
183 
197 #define OAD_SERVICE_UUID 0xFFC0
198 
202 #define OAD_IMG_IDENTIFY_UUID 0xFFC1
203 
207 #define OAD_IMG_BLOCK_UUID 0xFFC2
208 
213 #define OAD_IMG_COUNT_UUID 0xFFC3
214 
220 #define OAD_IMG_STATUS_UUID 0xFFC4
221 
225 #define OAD_EXT_CTRL_UUID 0xFFC5
226 
237 #define OAD_IDX_IMG_IDENTIFY 0
238 
242 #define OAD_IDX_IMG_BLOCK 1
243 
247 #define OAD_IDX_EXT_CTRL 2
248 
255 #define OAD_ATT_OVERHEAD 3
256 
260 #define OAD_BLK_NUM_HDR_SZ 4
261 
267 #define OAD_DEFAULT_BLOCK_SIZE 20
268 
274 #define OAD_MAX_BLOCK_SIZE 244
275 
279 #define OAD_IMAGE_ID_RSP_LEN 0x01
280 
291 #define OAD_EXT_CTRL_GET_BLK_SZ 0x01
292 
298 #define OAD_EXT_CTRL_IMG_CNT 0x02
299 
305 #define OAD_EXT_CTRL_START_OAD 0x03
306 
312 #define OAD_EXT_CTRL_ENABLE_IMG 0x04
313 
318 #define OAD_EXT_CTRL_CANCEL_OAD 0x05
319 
324 #define OAD_EXT_CTRL_DISABLE_BLK_NOTIF 0x06
325 
330 #define OAD_EXT_CTRL_GET_SW_VER 0x07
331 
336 #define OAD_EXT_CTRL_GET_IMG_STAT 0x08
337 
342 #define OAD_EXT_CTRL_GET_PROF_VER 0x09
343 
348 #define OAD_EXT_CTRL_GET_DEV_TYPE 0x10
349 
355 #define OAD_EXT_CTRL_GET_IMG_INFO 0x11
356 
361 #define OAD_EXT_CTRL_BLK_RSP_NOTIF 0x12
362 
367 #define OAD_EXT_CTRL_ERASE_BONDS 0x13
368 
376 #define OAD_EXT_CTRL_CMD_NOT_SUPPORTED 0xFF
377 
384 #define OAD_IMG_INFO_ONCHIP 0x01
385 
392 #define OAD_DEFAULT_INACTIVITY_TIME 10000
393 
398 #define OAD_MIN_INACTIVITY_TIME 4000
399 
403 #define OAD_CHAR_CNT 3
404 
408 #define OAD_CCCD_CNT OAD_CHAR_CNT
409 
410 
415 #define OAD_SUCCESS 0
416 #define OAD_CRC_ERR 1
417 #define OAD_FLASH_ERR 2
418 #define OAD_BUFFER_OFL 3
419 #define OAD_ALREADY_STARTED 4
420 #define OAD_NOT_STARTED 5
421 #define OAD_DL_NOT_COMPLETE 6
422 #define OAD_NO_RESOURCES 7
423 #define OAD_IMAGE_TOO_BIG 8
424 #define OAD_INCOMPATIBLE_IMAGE 9
425 #define OAD_INVALID_FILE 10
426 #define OAD_INCOMPATIBLE_FILE 11
427 #define OAD_AUTH_FAIL 12
428 #define OAD_EXT_NOT_SUPPORTED 13
429 #define OAD_DL_COMPLETE 14
430 #define OAD_CCCD_NOT_ENABLED 15
431 #define OAD_IMG_ID_TIMEOUT 16
432 
433 
435 #if defined(DeviceFamily_CC26X2) || defined(DeviceFamily_CC13X2) || defined(DeviceFamily_CC26X1)
437 #define BIM_START 0x56000
438 #elif defined(DeviceFamily_CC26X2X7) || defined(DeviceFamily_CC13X2X7)
439 #define BIM_START 0xAE000
440 #else
441 #define BIM_START 0x1F000
442 #endif
443 
448 #define OAD_IMG_PG_INVALID 0xFF
449 
451 #define OAD_SEC_ECDSA_P256 0x01
452 #define OAD_SEC_AES_128_CBC 0x02
453 
454 
458 #define OAD_EFL_MAX_META 4
459 
460 /*********************************************************************
461  * MACROS
462  */
463 
467 #define EXT_CTRL_OP_CODE(pData)(pData[0])
468 
469 /*********************************************************************
470  * TYPEDEFS
471  */
472 
476 PACKED_TYPEDEF_STRUCT
477 {
478  uint8_t imgID[8];
479  uint8_t bimVer;
480  uint8_t metaVer;
481  uint8_t imgCpStat;
482  uint8_t crcStat;
483  uint8_t imgType;
484  uint8_t imgNo;
485  uint32_t len;
486  uint8_t softVer[4];
488 
492 PACKED_TYPEDEF_STRUCT
493 {
494  uint8_t cmdID;
495  uint8_t prevBlkStat;
496  uint32_t requestedBlk;
498 
503 PACKED_TYPEDEF_STRUCT
504 {
505  uint8_t imgCpStat;
506  uint8_t crcStat;
507  uint8_t imgType;
508  uint8_t imgNo;
509 } imageInfo_t;
510 
511 PACKED_TYPEDEF_STRUCT
512 {
513  uint8_t securityVersion;
514  uint32_t timeStamp;
515 }securityHdr_t;
516 
520 typedef enum
521 {
527 }oadEvent_e;
528 
532 typedef struct
533 {
534  Queue_Elem _elem;
535  oadEvent_e event;
536  uint16_t connHandle;
537  uint16_t len;
538  uint16_t offset;
539  uint8_t *pData;
541 
545 typedef enum
546 {
553 }oadState_e;
554 
555 
556 /*********************************************************************
557  * Ext Control Command Payloads
558  */
559 
564 PACKED_TYPEDEF_STRUCT
565 {
566  uint8_t cmdID;
567  uint8_t status;
569 
573 PACKED_TYPEDEF_STRUCT
574 {
575  uint8_t cmdID;
576  uint8_t profVer;
578 
582 PACKED_TYPEDEF_STRUCT
583 {
584  uint8_t cmdID;
585  uint16_t oadBlkSz;
587 
591 PACKED_TYPEDEF_STRUCT
592 {
593  uint8_t cmdID;
594  uint8_t swVer[OAD_SW_VER_LEN];
596 
603 PACKED_TYPEDEF_STRUCT
604 {
605  uint8_t cmdID;
606  uint8_t chipType;
607  uint8_t chipFamily;
608  uint8_t hardwareRev;
609  uint8_t rsvd;
611 
615 PACKED_TYPEDEF_STRUCT
616 {
617  uint8_t cmdID;
618  uint8_t numImages;
619  uint8_t imgCpStat;
620  uint8_t crcStat;
621  uint8_t imgType;
622  uint8_t imgNo;
624 
630 PACKED_TYPEDEF_STRUCT
631 {
632  uint8_t cmdID;
633  uint8_t imgType;
634  uint8_t imgNo;
635  uint16_t techType;
637 
638 #ifdef DMM_OAD
639 typedef struct
640 {
641  uint32_t totBlocks;
642  uint32_t currBlock;
643 }imgProgressInfo_t;
644 #endif
645 
646 /*********************************************************************
647  * EXTERNAL VARIABLES
648  */
649 
650 /*********************************************************************
651  * Profile Callbacks
652  */
653 
664 typedef void (*oadWriteCB_t)(uint8_t event, uint16_t arg);
665 
669 typedef struct
670 {
673 
674 /*********************************************************************
675  * FUNCTIONS
676  */
677 
688 extern uint8_t OAD_open(uint32_t oadTimeout);
689 
693 extern void OAD_cancel(void);
694 
695 
699 extern void OAD_close(void);
700 
706 extern bool OAD_isUsrAppValid(void);
707 
714 extern void OAD_register(oadTargetCBs_t *pfnOadCBs);
715 
725 extern bool OAD_getSWVersion(uint8_t *swVer, uint8_t len);
726 
732 extern uint16_t OAD_getBlockSize(void);
733 
741 extern uint8_t OAD_setBlockSize(uint16_t mtuSize);
742 
748 extern uint8_t OAD_processQueue(void);
749 
755 extern uint16_t OAD_getactiveCxnHandle();
756 
763 extern uint8_t oadCreateFactoryImageBackup(void);
764 
772 extern bool OAD_evenBitCount(uint32_t value);
773 
774 #ifdef DMM_OAD
775 extern void OAD_getProgressInfo(imgProgressInfo_t* pImgInfo);
776 #endif
777 
778 /*********************************************************************
779 *********************************************************************/
780 
783 #ifdef __cplusplus
784 }
785 #endif
786 
787 #endif /* OAD_H */
uint8_t imgCpStat
Image copy status bytes.
Definition: oad.h:481
uint8_t oadCreateFactoryImageBackup(void)
uint8_t crcStat
Image CRC status flag.
Definition: oad.h:506
uint8_t cmdID
External control op-code.
Definition: oad.h:494
External Control Command received.
Definition: oad.h:525
Definition: oad.h:492
uint8_t imgCpStat
Image copy flag.
Definition: oad.h:505
uint8_t imgType
Image Type.
Definition: oad.h:621
OAD peer timed out.
Definition: oad.h:526
uint16_t len
Length of data received.
Definition: oad.h:537
uint8_t imgCpStat
Image copy status.
Definition: oad.h:619
uint32_t requestedBlk
Requested block number.
Definition: oad.h:496
uint8_t profVer
OAD profile version.
Definition: oad.h:576
oadEvent_e event
Event that occurred.
Definition: oad.h:535
uint8_t hardwareRev
Hardware revision Field from ChipInfo module.
Definition: oad.h:608
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:575
uint8_t crcStat
CRC status.
Definition: oad.h:482
Definition: oad.h:669
Definition: oad.h:573
uint8_t bimVer
BIM version.
Definition: oad.h:479
uint8_t imgNo
Image number flag.
Definition: oad.h:508
uint8_t imgType
Image Type.
Definition: oad.h:483
uint16_t OAD_getBlockSize(void)
bool OAD_getSWVersion(uint8_t *swVer, uint8_t len)
Definition: oad.h:630
uint8_t imgType
Image type flag.
Definition: oad.h:507
uint8_t OAD_processQueue(void)
uint8_t OAD_open(uint32_t oadTimeout)
uint8_t imgNo
Image Number.
Definition: oad.h:634
uint8_t chipType
Chip Type Field from ChipInfo module.
Definition: oad.h:606
Image block request/response event.
Definition: oad.h:523
uint32_t len
Image length in octets.
Definition: oad.h:485
uint16_t techType
Wireless technology type.
Definition: oad.h:635
oadState_e
Definition: oad.h:545
Definition: oad.h:532
uint8_t imgType
Image Type.
Definition: oad.h:633
Definition: oad.h:564
uint8_t prevBlkStat
Status of previous block write.
Definition: oad.h:495
OAD module is configuring for a download.
Definition: oad.h:549
void OAD_register(oadTargetCBs_t *pfnOadCBs)
uint8_t OAD_setBlockSize(uint16_t mtuSize)
OAD module is not performing any action.
Definition: oad.h:547
OAD module is validating an received image.
Definition: oad.h:551
uint16_t connHandle
Connection event was received on.
Definition: oad.h:536
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:584
oadWriteCB_t pfnOadWrite
The peer has written to the OAD service.
Definition: oad.h:671
void OAD_close(void)
uint8_t rsvd
RFU.
Definition: oad.h:609
uint8_t * pData
Pointer to data received.
Definition: oad.h:539
uint16_t oadBlkSz
OAD block size.
Definition: oad.h:585
uint8_t imgNo
Image number of &#39;image type&#39;.
Definition: oad.h:484
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:593
Definition: oad.h:476
Definition: oad.h:615
OAD module is receiving an image.
Definition: oad.h:550
void OAD_cancel(void)
Definition: oad.h:582
OAD module is checking an image.
Definition: oad.h:548
uint16_t offset
GATT offset into blob.
Definition: oad.h:538
uint8_t chipFamily
Chip Family Field from ChipInfo module.
Definition: oad.h:607
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:566
uint8_t crcStat
Image CRC status.
Definition: oad.h:620
uint16_t OAD_getactiveCxnHandle()
void(* oadWriteCB_t)(uint8_t event, uint16_t arg)
Definition: oad.h:664
bool OAD_isUsrAppValid(void)
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:617
uint8_t status
Status of command.
Definition: oad.h:567
Image identify received.
Definition: oad.h:522
Definition: oad.h:603
uint8_t metaVer
Metadata version.
Definition: oad.h:480
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:632
oadEvent_e
Definition: oad.h:520
uint8_t numImages
Number of images.
Definition: oad.h:618
Definition: oad.h:503
Definition: oad.h:591
OAD complete.
Definition: oad.h:524
uint8_t imgNo
Image Number.
Definition: oad.h:622
OAD module has completed a download.
Definition: oad.h:552
Queue_Elem _elem
New queue element to contain write evt info.
Definition: oad.h:534
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:605
bool OAD_evenBitCount(uint32_t value)
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale