TI BLE-Stack for Bluetooth API Documentation  3.03.08.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 
134 #include "oad_image_header.h"
135 
136 /*********************************************************************
137  * CONSTANTS
138  */
139 
144 #ifdef OAD_BLE_SECURITY
145  #define OAD_WRITE_PERMIT GATT_PERMIT_AUTHEN_WRITE
146 #else
147  #define OAD_WRITE_PERMIT GATT_PERMIT_WRITE
148 #endif //OAD_SECURITY
149 
153 #define OAD_IMG_ID_RETRIES 3
154 
155 // Events the OAD process will post to the app
156 
166 #define OAD_QUEUE_EVT Event_Id_01
167 
173 #define OAD_DL_COMPLETE_EVT Event_Id_02
174 
179 #define OAD_OUT_OF_MEM_EVT Event_Id_03
180 
186 #define OAD_RESET_DEV_EVT Event_Id_04
187 
202 #define OAD_SERVICE_UUID 0xFFC0
203 
207 #define OAD_IMG_IDENTIFY_UUID 0xFFC1
208 
212 #define OAD_IMG_BLOCK_UUID 0xFFC2
213 
218 #define OAD_IMG_COUNT_UUID 0xFFC3
219 
225 #define OAD_IMG_STATUS_UUID 0xFFC4
226 
230 #define OAD_EXT_CTRL_UUID 0xFFC5
231 
242 #define OAD_IDX_IMG_IDENTIFY 0
243 
247 #define OAD_IDX_IMG_BLOCK 1
248 
252 #define OAD_IDX_EXT_CTRL 2
253 
260 #define OAD_ATT_OVERHEAD 3
261 
265 #define OAD_BLK_NUM_HDR_SZ 4
266 
272 #define OAD_DEFAULT_BLOCK_SIZE 20
273 
279 #define OAD_MAX_BLOCK_SIZE 244
280 
284 #define OAD_IMAGE_ID_RSP_LEN 0x01
285 
296 #define OAD_EXT_CTRL_GET_BLK_SZ 0x01
297 
303 #define OAD_EXT_CTRL_IMG_CNT 0x02
304 
310 #define OAD_EXT_CTRL_START_OAD 0x03
311 
317 #define OAD_EXT_CTRL_ENABLE_IMG 0x04
318 
323 #define OAD_EXT_CTRL_CANCEL_OAD 0x05
324 
329 #define OAD_EXT_CTRL_DISABLE_BLK_NOTIF 0x06
330 
335 #define OAD_EXT_CTRL_GET_SW_VER 0x07
336 
341 #define OAD_EXT_CTRL_GET_IMG_STAT 0x08
342 
347 #define OAD_EXT_CTRL_GET_PROF_VER 0x09
348 
353 #define OAD_EXT_CTRL_GET_DEV_TYPE 0x10
354 
360 #define OAD_EXT_CTRL_GET_IMG_INFO 0x11
361 
366 #define OAD_EXT_CTRL_BLK_RSP_NOTIF 0x12
367 
372 #define OAD_EXT_CTRL_ERASE_BONDS 0x13
373 
381 #define OAD_EXT_CTRL_CMD_NOT_SUPPORTED 0xFF
382 
389 #define OAD_IMG_INFO_ONCHIP 0x01
390 
397 #define OAD_DEFAULT_INACTIVITY_TIME 10000
398 
403 #define OAD_MIN_INACTIVITY_TIME 4000
404 
408 #define OAD_CHAR_CNT 3
409 
413 #define OAD_CCCD_CNT OAD_CHAR_CNT
414 
415 
420 #define OAD_SUCCESS 0
421 #define OAD_CRC_ERR 1
422 #define OAD_FLASH_ERR 2
423 #define OAD_BUFFER_OFL 3
424 #define OAD_ALREADY_STARTED 4
425 #define OAD_NOT_STARTED 5
426 #define OAD_DL_NOT_COMPLETE 6
427 #define OAD_NO_RESOURCES 7
428 #define OAD_IMAGE_TOO_BIG 8
429 #define OAD_INCOMPATIBLE_IMAGE 9
430 #define OAD_INVALID_FILE 10
431 #define OAD_INCOMPATIBLE_FILE 11
432 #define OAD_AUTH_FAIL 12
433 #define OAD_EXT_NOT_SUPPORTED 13
434 #define OAD_DL_COMPLETE 14
435 #define OAD_CCCD_NOT_ENABLED 15
436 #define OAD_IMG_ID_TIMEOUT 16
437 
438 
440 #define BIM_START 0x1F000
442 
447 #define OAD_IMG_PG_INVALID 0xFF
448 
450 #define OAD_SEC_ECDSA_P256 0x01
451 #define OAD_SEC_AES_128_CBC 0x02
453 
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 signerInfo[8];
514  uint8_t signature[64];
515 }signPld_ECDSA_P256_t;
516 
517 PACKED_TYPEDEF_STRUCT
518 {
519  uint8_t securityVersion;
520  uint32_t timeStamp;
521 }securityHdr_t;
522 
526 typedef enum
527 {
533 }oadEvent_e;
534 
535 
539 typedef enum
540 {
547 }oadState_e;
548 
549 
550 /*********************************************************************
551  * Ext Control Command Payloads
552  */
553 
558 PACKED_TYPEDEF_STRUCT
559 {
560  uint8_t cmdID;
561  uint8_t status;
563 
567 PACKED_TYPEDEF_STRUCT
568 {
569  uint8_t cmdID;
570  uint8_t profVer;
572 
576 PACKED_TYPEDEF_STRUCT
577 {
578  uint8_t cmdID;
579  uint16_t oadBlkSz;
581 
585 PACKED_TYPEDEF_STRUCT
586 {
587  uint8_t cmdID;
588  uint8_t swVer[OAD_SW_VER_LEN];
590 
597 PACKED_TYPEDEF_STRUCT
598 {
599  uint8_t cmdID;
600  uint8_t chipType;
601  uint8_t chipFamily;
602  uint8_t hardwareRev;
603  uint8_t rsvd;
605 
609 PACKED_TYPEDEF_STRUCT
610 {
611  uint8_t cmdID;
612  uint8_t numImages;
613  uint8_t imgCpStat;
614  uint8_t crcStat;
615  uint8_t imgType;
616  uint8_t imgNo;
618 
624 PACKED_TYPEDEF_STRUCT
625 {
626  uint8_t cmdID;
627  uint8_t imgType;
628  uint8_t imgNo;
629  uint16_t techType;
631 
632 /*********************************************************************
633  * EXTERNAL VARIABLES
634  */
635 
636 /*********************************************************************
637  * Profile Callbacks
638  */
639 
650 typedef void (*oadWriteCB_t)(uint8_t event, uint16_t arg);
651 
655 typedef struct
656 {
659 
660 /*********************************************************************
661  * FUNCTIONS
662  */
663 
674 extern uint8_t OAD_open(uint32_t oadTimeout);
675 
679 extern void OAD_cancel(void);
680 
681 
685 extern void OAD_close(void);
686 
692 extern bool OAD_isUsrAppValid(void);
693 
700 extern void OAD_register(oadTargetCBs_t *pfnOadCBs);
701 
711 extern bool OAD_getSWVersion(uint8_t *swVer, uint8_t len);
712 
718 extern uint16_t OAD_getBlockSize(void);
719 
727 extern uint8_t OAD_setBlockSize(uint16_t mtuSize);
728 
734 extern uint8_t OAD_processQueue(void);
735 
741 extern uint16_t OAD_getactiveCxnHandle();
742 
749 extern uint8_t oadCreateFactoryImageBackup(void);
750 
751 /*********************************************************************
752 *********************************************************************/
753 
755 #ifdef __cplusplus
756 }
757 #endif
758 
759 #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:531
Definition: oad.h:492
uint8_t imgCpStat
Image copy flag.
Definition: oad.h:505
uint8_t imgType
Image Type.
Definition: oad.h:615
OAD peer timed out.
Definition: oad.h:532
uint8_t imgCpStat
Image copy status.
Definition: oad.h:613
uint32_t requestedBlk
Requested block number.
Definition: oad.h:496
uint8_t profVer
OAD profile version.
Definition: oad.h:570
uint8_t hardwareRev
Hardware revision Field from ChipInfo module.
Definition: oad.h:602
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:569
uint8_t crcStat
CRC status.
Definition: oad.h:482
Definition: oad.h:655
Definition: oad.h:567
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:624
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:628
uint8_t chipType
Chip Type Field from ChipInfo module.
Definition: oad.h:600
Image block request/response event.
Definition: oad.h:529
uint32_t len
Image length in octets.
Definition: oad.h:485
uint16_t techType
Wireless technology type.
Definition: oad.h:629
oadState_e
Definition: oad.h:539
uint8_t imgType
Image Type.
Definition: oad.h:627
Definition: oad.h:558
uint8_t prevBlkStat
Status of previous block write.
Definition: oad.h:495
OAD module is configuring for a download.
Definition: oad.h:543
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:664
OAD module is not performing any action.
Definition: oad.h:541
OAD module is validating an received image.
Definition: oad.h:545
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:578
oadWriteCB_t pfnOadWrite
The peer has written to the OAD service.
Definition: oad.h:657
void OAD_close(void)
uint8_t rsvd
RFU.
Definition: oad.h:603
uint16_t oadBlkSz
OAD block size.
Definition: oad.h:579
uint8_t imgNo
Image number of 'image type'.
Definition: oad.h:484
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:587
Definition: oad.h:476
Definition: oad.h:609
OAD module is receiving an image.
Definition: oad.h:544
void OAD_cancel(void)
uint32_t len
Image length in bytes.
Definition: oad_image_header.h:662
Definition: oad.h:576
OAD module is checking an image.
Definition: oad.h:542
uint8_t chipFamily
Chip Family Field from ChipInfo module.
Definition: oad.h:601
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:560
#define OAD_SW_VER_LEN
Definition: oad_image_header.h:515
uint8_t crcStat
Image CRC status.
Definition: oad.h:614
uint16_t OAD_getactiveCxnHandle()
void(* oadWriteCB_t)(uint8_t event, uint16_t arg)
Definition: oad.h:650
bool OAD_isUsrAppValid(void)
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:611
uint8_t status
Status of command.
Definition: oad.h:561
Image identify received.
Definition: oad.h:528
Definition: oad.h:597
uint8_t metaVer
Metadata version.
Definition: oad.h:480
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:626
oadEvent_e
Definition: oad.h:526
uint8_t numImages
Number of images.
Definition: oad.h:612
Definition: oad.h:503
Structure definition for image header and segments, these are prepended to the over the air images...
Definition: oad.h:585
OAD complete.
Definition: oad.h:530
uint8_t imgNo
Image Number.
Definition: oad.h:616
OAD module has completed a download.
Definition: oad.h:546
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:599
© Copyright 1995-2021, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale