TI BLE5-Stack API Documentation  2.01.00.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 
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)
437 #define BIM_START 0x56000
438 #else
439 #define BIM_START 0x1F000
440 #endif
441 
446 #define OAD_IMG_PG_INVALID 0xFF
447 
449 #define OAD_SEC_ECDSA_P256 0x01
450 #define OAD_SEC_AES_128_CBC 0x02
451 
452 
456 #define OAD_EFL_MAX_META 4
457 
458 /*********************************************************************
459  * MACROS
460  */
461 
465 #define EXT_CTRL_OP_CODE(pData)(pData[0])
466 
467 /*********************************************************************
468  * TYPEDEFS
469  */
470 
474 PACKED_TYPEDEF_STRUCT
475 {
476  uint8_t imgID[8];
477  uint8_t bimVer;
478  uint8_t metaVer;
479  uint8_t imgCpStat;
480  uint8_t crcStat;
481  uint8_t imgType;
482  uint8_t imgNo;
483  uint32_t len;
484  uint8_t softVer[4];
486 
490 PACKED_TYPEDEF_STRUCT
491 {
492  uint8_t cmdID;
493  uint8_t prevBlkStat;
494  uint32_t requestedBlk;
496 
501 PACKED_TYPEDEF_STRUCT
502 {
503  uint8_t imgCpStat;
504  uint8_t crcStat;
505  uint8_t imgType;
506  uint8_t imgNo;
507 } imageInfo_t;
508 
509 PACKED_TYPEDEF_STRUCT
510 {
511  uint8_t securityVersion;
512  uint32_t timeStamp;
513 }securityHdr_t;
514 
518 typedef enum
519 {
525 }oadEvent_e;
526 
530 typedef struct
531 {
532  Queue_Elem _elem;
533  oadEvent_e event;
534  uint16_t connHandle;
535  uint16_t len;
536  uint16_t offset;
537  uint8_t *pData;
539 
543 typedef enum
544 {
551 }oadState_e;
552 
553 
554 /*********************************************************************
555  * Ext Control Command Payloads
556  */
557 
562 PACKED_TYPEDEF_STRUCT
563 {
564  uint8_t cmdID;
565  uint8_t status;
567 
571 PACKED_TYPEDEF_STRUCT
572 {
573  uint8_t cmdID;
574  uint8_t profVer;
576 
580 PACKED_TYPEDEF_STRUCT
581 {
582  uint8_t cmdID;
583  uint16_t oadBlkSz;
585 
589 PACKED_TYPEDEF_STRUCT
590 {
591  uint8_t cmdID;
592  uint8_t swVer[OAD_SW_VER_LEN];
594 
601 PACKED_TYPEDEF_STRUCT
602 {
603  uint8_t cmdID;
604  uint8_t chipType;
605  uint8_t chipFamily;
606  uint8_t hardwareRev;
607  uint8_t rsvd;
609 
613 PACKED_TYPEDEF_STRUCT
614 {
615  uint8_t cmdID;
616  uint8_t numImages;
617  uint8_t imgCpStat;
618  uint8_t crcStat;
619  uint8_t imgType;
620  uint8_t imgNo;
622 
628 PACKED_TYPEDEF_STRUCT
629 {
630  uint8_t cmdID;
631  uint8_t imgType;
632  uint8_t imgNo;
633  uint16_t techType;
635 
636 #ifdef DMM_OAD
637 typedef struct
638 {
639  uint32_t totBlocks;
640  uint32_t currBlock;
641 }imgProgressInfo_t;
642 #endif
643 
644 /*********************************************************************
645  * EXTERNAL VARIABLES
646  */
647 
648 /*********************************************************************
649  * Profile Callbacks
650  */
651 
662 typedef void (*oadWriteCB_t)(uint8_t event, uint16_t arg);
663 
667 typedef struct
668 {
671 
672 /*********************************************************************
673  * FUNCTIONS
674  */
675 
686 extern uint8_t OAD_open(uint32_t oadTimeout);
687 
691 extern void OAD_cancel(void);
692 
693 
697 extern void OAD_close(void);
698 
704 extern bool OAD_isUsrAppValid(void);
705 
712 extern void OAD_register(oadTargetCBs_t *pfnOadCBs);
713 
723 extern bool OAD_getSWVersion(uint8_t *swVer, uint8_t len);
724 
730 extern uint16_t OAD_getBlockSize(void);
731 
739 extern uint8_t OAD_setBlockSize(uint16_t mtuSize);
740 
746 extern uint8_t OAD_processQueue(void);
747 
753 extern uint16_t OAD_getactiveCxnHandle();
754 
761 extern uint8_t oadCreateFactoryImageBackup(void);
762 
770 extern bool OAD_evenBitCount(uint32_t value);
771 
772 #ifdef DMM_OAD
773 extern void OAD_getProgressInfo(imgProgressInfo_t* pImgInfo);
774 #endif
775 
776 /*********************************************************************
777 *********************************************************************/
778 
781 #ifdef __cplusplus
782 }
783 #endif
784 
785 #endif /* OAD_H */
uint8_t imgCpStat
Image copy status bytes.
Definition: oad.h:479
uint8_t oadCreateFactoryImageBackup(void)
uint8_t crcStat
Image CRC status flag.
Definition: oad.h:504
uint8_t cmdID
External control op-code.
Definition: oad.h:492
External Control Command received.
Definition: oad.h:523
Definition: oad.h:490
uint8_t imgCpStat
Image copy flag.
Definition: oad.h:503
uint8_t imgType
Image Type.
Definition: oad.h:619
OAD peer timed out.
Definition: oad.h:524
uint16_t len
Length of data received.
Definition: oad.h:535
uint8_t imgCpStat
Image copy status.
Definition: oad.h:617
uint32_t requestedBlk
Requested block number.
Definition: oad.h:494
uint8_t profVer
OAD profile version.
Definition: oad.h:574
oadEvent_e event
Event that occurred.
Definition: oad.h:533
uint8_t hardwareRev
Hardware revision Field from ChipInfo module.
Definition: oad.h:606
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:573
uint8_t crcStat
CRC status.
Definition: oad.h:480
Definition: oad.h:667
Definition: oad.h:571
uint8_t bimVer
BIM version.
Definition: oad.h:477
uint8_t imgNo
Image number flag.
Definition: oad.h:506
uint8_t imgType
Image Type.
Definition: oad.h:481
uint16_t OAD_getBlockSize(void)
bool OAD_getSWVersion(uint8_t *swVer, uint8_t len)
Definition: oad.h:628
uint8_t imgType
Image type flag.
Definition: oad.h:505
uint8_t OAD_processQueue(void)
uint8_t OAD_open(uint32_t oadTimeout)
uint8_t imgNo
Image Number.
Definition: oad.h:632
uint8_t chipType
Chip Type Field from ChipInfo module.
Definition: oad.h:604
Image block request/response event.
Definition: oad.h:521
uint32_t len
Image length in octets.
Definition: oad.h:483
uint16_t techType
Wireless technology type.
Definition: oad.h:633
oadState_e
Definition: oad.h:543
Definition: oad.h:530
uint8_t imgType
Image Type.
Definition: oad.h:631
Definition: oad.h:562
uint8_t prevBlkStat
Status of previous block write.
Definition: oad.h:493
OAD module is configuring for a download.
Definition: oad.h:547
void OAD_register(oadTargetCBs_t *pfnOadCBs)
uint8_t OAD_setBlockSize(uint16_t mtuSize)
uint8_t softVer[4]
Software version of the image.
Definition: oad_image_header.h:604
OAD module is not performing any action.
Definition: oad.h:545
OAD module is validating an received image.
Definition: oad.h:549
uint16_t connHandle
Connection event was received on.
Definition: oad.h:534
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:582
oadWriteCB_t pfnOadWrite
The peer has written to the OAD service.
Definition: oad.h:669
void OAD_close(void)
uint8_t rsvd
RFU.
Definition: oad.h:607
uint8_t * pData
Pointer to data received.
Definition: oad.h:537
uint16_t oadBlkSz
OAD block size.
Definition: oad.h:583
uint8_t imgNo
Image number of &#39;image type&#39;.
Definition: oad.h:482
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:591
Definition: oad.h:474
Definition: oad.h:613
OAD module is receiving an image.
Definition: oad.h:548
void OAD_cancel(void)
uint32_t len
Image length in bytes.
Definition: oad_image_header.h:602
Definition: oad.h:580
OAD module is checking an image.
Definition: oad.h:546
uint16_t offset
GATT offset into blob.
Definition: oad.h:536
uint8_t chipFamily
Chip Family Field from ChipInfo module.
Definition: oad.h:605
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:564
#define OAD_SW_VER_LEN
OAD software version length in bytes.
Definition: oad_image_header.h:455
uint8_t crcStat
Image CRC status.
Definition: oad.h:618
uint16_t OAD_getactiveCxnHandle()
void(* oadWriteCB_t)(uint8_t event, uint16_t arg)
Definition: oad.h:662
bool OAD_isUsrAppValid(void)
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:615
uint8_t status
Status of command.
Definition: oad.h:565
Image identify received.
Definition: oad.h:520
Definition: oad.h:601
uint8_t metaVer
Metadata version.
Definition: oad.h:478
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:630
oadEvent_e
Definition: oad.h:518
uint8_t numImages
Number of images.
Definition: oad.h:616
Definition: oad.h:501
Structure definition for image header and segments, these are prepended to the over the air images...
Definition: oad.h:589
OAD complete.
Definition: oad.h:522
uint8_t imgNo
Image Number.
Definition: oad.h:620
OAD module has completed a download.
Definition: oad.h:550
Queue_Elem _elem
New queue element to contain write evt info.
Definition: oad.h:532
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:603
bool OAD_evenBitCount(uint32_t value)
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale