TI BLE5-Stack API Documentation  2.00.02.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 
191 #define OAD_SERVICE_UUID 0xFFC0
192 
196 #define OAD_IMG_IDENTIFY_UUID 0xFFC1
197 
201 #define OAD_IMG_BLOCK_UUID 0xFFC2
202 
207 #define OAD_IMG_COUNT_UUID 0xFFC3
208 
214 #define OAD_IMG_STATUS_UUID 0xFFC4
215 
219 #define OAD_EXT_CTRL_UUID 0xFFC5
220 
231 #define OAD_IDX_IMG_IDENTIFY 0
232 
236 #define OAD_IDX_IMG_BLOCK 1
237 
241 #define OAD_IDX_EXT_CTRL 2
242 
249 #define OAD_ATT_OVERHEAD 3
250 
254 #define OAD_BLK_NUM_HDR_SZ 4
255 
261 #define OAD_DEFAULT_BLOCK_SIZE 20
262 
268 #define OAD_MAX_BLOCK_SIZE 244
269 
273 #define OAD_IMAGE_ID_RSP_LEN 0x01
274 
285 #define OAD_EXT_CTRL_GET_BLK_SZ 0x01
286 
292 #define OAD_EXT_CTRL_IMG_CNT 0x02
293 
299 #define OAD_EXT_CTRL_START_OAD 0x03
300 
306 #define OAD_EXT_CTRL_ENABLE_IMG 0x04
307 
312 #define OAD_EXT_CTRL_CANCEL_OAD 0x05
313 
318 #define OAD_EXT_CTRL_DISABLE_BLK_NOTIF 0x06
319 
324 #define OAD_EXT_CTRL_GET_SW_VER 0x07
325 
330 #define OAD_EXT_CTRL_GET_IMG_STAT 0x08
331 
336 #define OAD_EXT_CTRL_GET_PROF_VER 0x09
337 
342 #define OAD_EXT_CTRL_GET_DEV_TYPE 0x10
343 
349 #define OAD_EXT_CTRL_GET_IMG_INFO 0x11
350 
355 #define OAD_EXT_CTRL_BLK_RSP_NOTIF 0x12
356 
361 #define OAD_EXT_CTRL_ERASE_BONDS 0x13
362 
370 #define OAD_EXT_CTRL_CMD_NOT_SUPPORTED 0xFF
371 
378 #define OAD_IMG_INFO_ONCHIP 0x01
379 
386 #define OAD_DEFAULT_INACTIVITY_TIME 10000
387 
392 #define OAD_MIN_INACTIVITY_TIME 4000
393 
397 #define OAD_CHAR_CNT 3
398 
402 #define OAD_CCCD_CNT OAD_CHAR_CNT
403 
404 
409 #define OAD_SUCCESS 0
410 #define OAD_CRC_ERR 1
411 #define OAD_FLASH_ERR 2
412 #define OAD_BUFFER_OFL 3
413 #define OAD_ALREADY_STARTED 4
414 #define OAD_NOT_STARTED 5
415 #define OAD_DL_NOT_COMPLETE 6
416 #define OAD_NO_RESOURCES 7
417 #define OAD_IMAGE_TOO_BIG 8
418 #define OAD_INCOMPATIBLE_IMAGE 9
419 #define OAD_INVALID_FILE 10
420 #define OAD_INCOMPATIBLE_FILE 11
421 #define OAD_AUTH_FAIL 12
422 #define OAD_EXT_NOT_SUPPORTED 13
423 #define OAD_DL_COMPLETE 14
424 #define OAD_CCCD_NOT_ENABLED 15
425 #define OAD_IMG_ID_TIMEOUT 16
426 
427 
429 #if defined(DeviceFamily_CC26X2) || defined(DeviceFamily_CC13X2)
431 #define BIM_START 0x56000
432 #else
433 #define BIM_START 0x1F000
434 #endif
435 
440 #define OAD_IMG_PG_INVALID 0xFF
441 
443 #define OAD_SEC_ECDSA_P256 0x01
444 #define OAD_SEC_AES_128_CBC 0x02
445 
450 #define OAD_EFL_MAX_META 4
451 
452 /*********************************************************************
453  * MACROS
454  */
455 
459 #define EXT_CTRL_OP_CODE(pData)(pData[0])
460 
461 /*********************************************************************
462  * TYPEDEFS
463  */
464 
468 PACKED_TYPEDEF_STRUCT
469 {
470  uint8_t imgID[8];
471  uint8_t bimVer;
472  uint8_t metaVer;
473  uint8_t imgCpStat;
474  uint8_t crcStat;
475  uint8_t imgType;
476  uint8_t imgNo;
477  uint32_t len;
478  uint8_t softVer[4];
480 
484 PACKED_TYPEDEF_STRUCT
485 {
486  uint8_t cmdID;
487  uint8_t prevBlkStat;
488  uint32_t requestedBlk;
490 
495 PACKED_TYPEDEF_STRUCT
496 {
497  uint8_t imgCpStat;
498  uint8_t crcStat;
499  uint8_t imgType;
500  uint8_t imgNo;
501 } imageInfo_t;
502 
503 PACKED_TYPEDEF_STRUCT
504 {
505  uint8_t securityVersion;
506  uint32_t timeStamp;
507 }securityHdr_t;
508 
512 typedef enum
513 {
519 }oadEvent_e;
520 
524 typedef struct
525 {
526  Queue_Elem _elem;
527  oadEvent_e event;
528  uint16_t connHandle;
529  uint16_t len;
530  uint16_t offset;
531  uint8_t *pData;
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 /*********************************************************************
631  * EXTERNAL VARIABLES
632  */
633 
634 /*********************************************************************
635  * Profile Callbacks
636  */
637 
648 typedef void (*oadWriteCB_t)(uint8_t event, uint16_t arg);
649 
653 typedef struct
654 {
657 
658 /*********************************************************************
659  * FUNCTIONS
660  */
661 
672 extern uint8_t OAD_open(uint32_t oadTimeout);
673 
677 extern void OAD_cancel(void);
678 
679 
683 extern void OAD_close(void);
684 
690 extern bool OAD_isUsrAppValid(void);
691 
698 extern void OAD_register(oadTargetCBs_t *pfnOadCBs);
699 
709 extern bool OAD_getSWVersion(uint8_t *swVer, uint8_t len);
710 
716 extern uint16_t OAD_getBlockSize(void);
717 
725 extern uint8_t OAD_setBlockSize(uint16_t mtuSize);
726 
732 extern uint8_t OAD_processQueue(void);
733 
739 extern uint16_t OAD_getactiveCxnHandle();
740 
747 extern uint8_t oadCreateFactoryImageBackup(void);
748 
749 /*********************************************************************
750 *********************************************************************/
751 
754 #ifdef __cplusplus
755 }
756 #endif
757 
758 #endif /* OAD_H */
uint8_t imgCpStat
Image copy status bytes.
Definition: oad.h:473
uint8_t oadCreateFactoryImageBackup(void)
uint8_t crcStat
Image CRC status flag.
Definition: oad.h:498
uint8_t cmdID
External control op-code.
Definition: oad.h:486
External Control Command received.
Definition: oad.h:517
Definition: oad.h:484
uint8_t imgCpStat
Image copy flag.
Definition: oad.h:497
uint8_t imgType
Image Type.
Definition: oad.h:613
OAD peer timed out.
Definition: oad.h:518
uint16_t len
Length of data received.
Definition: oad.h:529
uint8_t imgCpStat
Image copy status.
Definition: oad.h:611
uint32_t requestedBlk
Requested block number.
Definition: oad.h:488
uint8_t profVer
OAD profile version.
Definition: oad.h:568
oadEvent_e event
Event that occurred.
Definition: oad.h:527
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:474
Definition: oad.h:653
Definition: oad.h:565
uint8_t bimVer
BIM version.
Definition: oad.h:471
uint8_t imgNo
Image number flag.
Definition: oad.h:500
uint8_t imgType
Image Type.
Definition: oad.h:475
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:499
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:515
uint32_t len
Image length in octets.
Definition: oad.h:477
uint16_t techType
Wireless technology type.
Definition: oad.h:627
oadState_e
Definition: oad.h:537
Definition: oad.h:524
uint8_t imgType
Image Type.
Definition: oad.h:625
Definition: oad.h:556
uint8_t prevBlkStat
Status of previous block write.
Definition: oad.h:487
OAD module is configuring for a download.
Definition: oad.h:541
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:631
OAD module is not performing any action.
Definition: oad.h:539
OAD module is validating an received image.
Definition: oad.h:543
uint16_t connHandle
Connection event was received on.
Definition: oad.h:528
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:655
void OAD_close(void)
uint8_t rsvd
RFU.
Definition: oad.h:601
uint8_t * pData
Pointer to data received.
Definition: oad.h:531
uint16_t oadBlkSz
OAD block size.
Definition: oad.h:577
uint8_t imgNo
Image number of &#39;image type&#39;.
Definition: oad.h:476
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:585
Definition: oad.h:468
Definition: oad.h:607
OAD module is receiving an image.
Definition: oad.h:542
void OAD_cancel(void)
uint32_t len
Image length in bytes.
Definition: oad_image_header.h:629
Definition: oad.h:574
OAD module is checking an image.
Definition: oad.h:540
uint16_t offset
GATT offset into blob.
Definition: oad.h:530
uint8_t chipFamily
Chip Family Field from ChipInfo module.
Definition: oad.h:599
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:558
#define OAD_SW_VER_LEN
Definition: oad_image_header.h:480
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:648
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:514
Definition: oad.h:595
uint8_t metaVer
Metadata version.
Definition: oad.h:472
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:624
oadEvent_e
Definition: oad.h:512
uint8_t numImages
Number of images.
Definition: oad.h:610
Definition: oad.h:495
Structure definition for image header and segments, these are prepended to the over the air images...
Definition: oad.h:583
OAD complete.
Definition: oad.h:516
uint8_t imgNo
Image Number.
Definition: oad.h:614
OAD module has completed a download.
Definition: oad.h:544
Queue_Elem _elem
New queue element to contain write evt info.
Definition: oad.h:526
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:597
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale