TI BLE5-Stack API Documentation  1.01.01.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 
446 #define OAD_EFL_MAX_META 4
447 
448 /*********************************************************************
449  * MACROS
450  */
451 
455 #define EXT_CTRL_OP_CODE(pData)(pData[0])
456 
457 /*********************************************************************
458  * TYPEDEFS
459  */
460 
464 PACKED_TYPEDEF_STRUCT
465 {
466  uint8_t imgID[8];
467  uint8_t bimVer;
468  uint8_t metaVer;
469  uint8_t imgCpStat;
470  uint8_t crcStat;
471  uint8_t imgType;
472  uint8_t imgNo;
473  uint32_t len;
474  uint8_t softVer[4];
476 
480 PACKED_TYPEDEF_STRUCT
481 {
482  uint8_t cmdID;
483  uint8_t prevBlkStat;
484  uint32_t requestedBlk;
486 
491 PACKED_TYPEDEF_STRUCT
492 {
493  uint8_t imgCpStat;
494  uint8_t crcStat;
495  uint8_t imgType;
496  uint8_t imgNo;
497 } imageInfo_t;
498 
502 typedef enum
503 {
509 }oadEvent_e;
510 
514 typedef struct
515 {
516  Queue_Elem _elem;
517  oadEvent_e event;
518  uint16_t connHandle;
519  uint16_t len;
520  uint16_t offset;
521  uint8_t *pData;
523 
527 typedef enum
528 {
535 }oadState_e;
536 
537 
538 /*********************************************************************
539  * Ext Control Command Payloads
540  */
541 
546 PACKED_TYPEDEF_STRUCT
547 {
548  uint8_t cmdID;
549  uint8_t status;
551 
555 PACKED_TYPEDEF_STRUCT
556 {
557  uint8_t cmdID;
558  uint8_t profVer;
560 
564 PACKED_TYPEDEF_STRUCT
565 {
566  uint8_t cmdID;
567  uint16_t oadBlkSz;
569 
573 PACKED_TYPEDEF_STRUCT
574 {
575  uint8_t cmdID;
576  uint8_t swVer[OAD_SW_VER_LEN];
578 
585 PACKED_TYPEDEF_STRUCT
586 {
587  uint8_t cmdID;
588  uint8_t chipType;
589  uint8_t chipFamily;
590  uint8_t hardwareRev;
591  uint8_t rsvd;
593 
597 PACKED_TYPEDEF_STRUCT
598 {
599  uint8_t cmdID;
600  uint8_t numImages;
601  uint8_t imgCpStat;
602  uint8_t crcStat;
603  uint8_t imgType;
604  uint8_t imgNo;
606 
612 PACKED_TYPEDEF_STRUCT
613 {
614  uint8_t cmdID;
615  uint8_t imgType;
616  uint8_t imgNo;
617  uint16_t techType;
619 
620 /*********************************************************************
621  * EXTERNAL VARIABLES
622  */
623 
624 /*********************************************************************
625  * Profile Callbacks
626  */
627 
638 typedef void (*oadWriteCB_t)(uint8_t event, uint16_t arg);
639 
643 typedef struct
644 {
647 
648 /*********************************************************************
649  * FUNCTIONS
650  */
651 
662 extern uint8_t OAD_open(uint32_t oadTimeout);
663 
667 extern void OAD_cancel(void);
668 
669 
673 extern void OAD_close(void);
674 
680 extern bool OAD_isUsrAppValid(void);
681 
688 extern void OAD_register(oadTargetCBs_t *pfnOadCBs);
689 
699 extern bool OAD_getSWVersion(uint8_t *swVer, uint8_t len);
700 
706 extern uint16_t OAD_getBlockSize(void);
707 
715 extern uint8_t OAD_setBlockSize(uint16_t mtuSize);
716 
722 extern uint8_t OAD_processQueue(void);
723 
729 extern uint16_t OAD_getactiveCxnHandle();
730 
737 extern uint8_t oadCreateFactoryImageBackup(void);
738 
739 /*********************************************************************
740 *********************************************************************/
741 
744 #ifdef __cplusplus
745 }
746 #endif
747 
748 #endif /* OAD_H */
uint8_t imgCpStat
Image copy status bytes.
Definition: oad.h:469
uint8_t oadCreateFactoryImageBackup(void)
uint8_t crcStat
Image CRC status flag.
Definition: oad.h:494
uint8_t cmdID
External control op-code.
Definition: oad.h:482
External Control Command received.
Definition: oad.h:507
Definition: oad.h:480
uint8_t imgCpStat
Image copy flag.
Definition: oad.h:493
uint8_t imgType
Image Type.
Definition: oad.h:603
OAD peer timed out.
Definition: oad.h:508
uint16_t len
Length of data received.
Definition: oad.h:519
uint8_t imgCpStat
Image copy status.
Definition: oad.h:601
uint32_t requestedBlk
Requested block number.
Definition: oad.h:484
uint8_t profVer
OAD profile version.
Definition: oad.h:558
oadEvent_e event
Event that occurred.
Definition: oad.h:517
uint8_t hardwareRev
Hardware revision Field from ChipInfo module.
Definition: oad.h:590
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:557
uint8_t crcStat
CRC status.
Definition: oad.h:470
Definition: oad.h:643
Definition: oad.h:555
uint8_t bimVer
BIM version.
Definition: oad.h:467
uint8_t imgNo
Image number flag.
Definition: oad.h:496
uint8_t imgType
Image Type.
Definition: oad.h:471
uint16_t OAD_getBlockSize(void)
bool OAD_getSWVersion(uint8_t *swVer, uint8_t len)
Definition: oad.h:612
uint8_t imgType
Image type flag.
Definition: oad.h:495
uint8_t OAD_processQueue(void)
uint8_t OAD_open(uint32_t oadTimeout)
uint8_t imgNo
Image Number.
Definition: oad.h:616
uint8_t chipType
Chip Type Field from ChipInfo module.
Definition: oad.h:588
Image block request/response event.
Definition: oad.h:505
uint32_t len
Image length in octets.
Definition: oad.h:473
uint16_t techType
Wireless technology type.
Definition: oad.h:617
oadState_e
Definition: oad.h:527
Definition: oad.h:514
uint8_t imgType
Image Type.
Definition: oad.h:615
Definition: oad.h:546
uint8_t prevBlkStat
Status of previous block write.
Definition: oad.h:483
OAD module is configuring for a download.
Definition: oad.h:531
void OAD_register(oadTargetCBs_t *pfnOadCBs)
uint8_t OAD_setBlockSize(uint16_t mtuSize)
OAD module is not performing any action.
Definition: oad.h:529
OAD module is validating an received image.
Definition: oad.h:533
uint16_t connHandle
Connection event was received on.
Definition: oad.h:518
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:566
oadWriteCB_t pfnOadWrite
The peer has written to the OAD service.
Definition: oad.h:645
void OAD_close(void)
uint8_t rsvd
RFU.
Definition: oad.h:591
uint8_t * pData
Pointer to data received.
Definition: oad.h:521
uint16_t oadBlkSz
OAD block size.
Definition: oad.h:567
uint8_t imgNo
Image number of &#39;image type&#39;.
Definition: oad.h:472
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:575
Definition: oad.h:464
Definition: oad.h:597
OAD module is receiving an image.
Definition: oad.h:532
void OAD_cancel(void)
Definition: oad.h:564
OAD module is checking an image.
Definition: oad.h:530
uint16_t offset
GATT offset into blob.
Definition: oad.h:520
uint8_t chipFamily
Chip Family Field from ChipInfo module.
Definition: oad.h:589
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:548
#define OAD_SW_VER_LEN
Definition: oad_image_header.h:400
uint8_t crcStat
Image CRC status.
Definition: oad.h:602
uint16_t OAD_getactiveCxnHandle()
void(* oadWriteCB_t)(uint8_t event, uint16_t arg)
Definition: oad.h:638
bool OAD_isUsrAppValid(void)
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:599
uint8_t status
Status of command.
Definition: oad.h:549
Image identify received.
Definition: oad.h:504
Definition: oad.h:585
uint8_t metaVer
Metadata version.
Definition: oad.h:468
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:614
oadEvent_e
Definition: oad.h:502
uint8_t numImages
Number of images.
Definition: oad.h:600
Definition: oad.h:491
Structure definition for image header and segments, these are prepended to the over the air images...
Definition: oad.h:573
OAD complete.
Definition: oad.h:506
uint8_t imgNo
Image Number.
Definition: oad.h:604
OAD module has completed a download.
Definition: oad.h:534
Queue_Elem _elem
New queue element to contain write evt info.
Definition: oad.h:516
uint8_t cmdID
Ext Ctrl Op-code.
Definition: oad.h:587
Copyright 2018, Texas Instruments Incorporated