Fork for the GitHub

Committer:
DiegoOstuni
Date:
Thu Nov 14 10:34:11 2019 +0000
Revision:
0:de13951f30f6
Add files

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DiegoOstuni 0:de13951f30f6 1 /**
DiegoOstuni 0:de13951f30f6 2 ******************************************************************************
DiegoOstuni 0:de13951f30f6 3 * @file lib_NDEF_Bluetooth.h
DiegoOstuni 0:de13951f30f6 4 * @author MMY Application Team
DiegoOstuni 0:de13951f30f6 5 * @version $Revision: 2475 $
DiegoOstuni 0:de13951f30f6 6 * @date $Date: 2016-06-24 12:11:59 +0200 (Fri, 24 Jun 2016) $
DiegoOstuni 0:de13951f30f6 7 * @brief This file help to manage Bluetooth NDEF file.
DiegoOstuni 0:de13951f30f6 8 ******************************************************************************
DiegoOstuni 0:de13951f30f6 9 * @attention
DiegoOstuni 0:de13951f30f6 10 *
DiegoOstuni 0:de13951f30f6 11 * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
DiegoOstuni 0:de13951f30f6 12 *
DiegoOstuni 0:de13951f30f6 13 * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
DiegoOstuni 0:de13951f30f6 14 * You may not use this file except in compliance with the License.
DiegoOstuni 0:de13951f30f6 15 * You may obtain a copy of the License at:
DiegoOstuni 0:de13951f30f6 16 *
DiegoOstuni 0:de13951f30f6 17 * http://www.st.com/myliberty
DiegoOstuni 0:de13951f30f6 18 *
DiegoOstuni 0:de13951f30f6 19 * Unless required by applicable law or agreed to in writing, software
DiegoOstuni 0:de13951f30f6 20 * distributed under the License is distributed on an "AS IS" BASIS,
DiegoOstuni 0:de13951f30f6 21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
DiegoOstuni 0:de13951f30f6 22 * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
DiegoOstuni 0:de13951f30f6 23 * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
DiegoOstuni 0:de13951f30f6 24 * See the License for the specific language governing permissions and
DiegoOstuni 0:de13951f30f6 25 * limitations under the License.
DiegoOstuni 0:de13951f30f6 26 *
DiegoOstuni 0:de13951f30f6 27 ******************************************************************************
DiegoOstuni 0:de13951f30f6 28 */
DiegoOstuni 0:de13951f30f6 29
DiegoOstuni 0:de13951f30f6 30 /* Define to prevent recursive inclusion -------------------------------------*/
DiegoOstuni 0:de13951f30f6 31 #ifndef __LIB_NDEF_HANDOVER_H
DiegoOstuni 0:de13951f30f6 32 #define __LIB_NDEF_HANDOVER_H
DiegoOstuni 0:de13951f30f6 33
DiegoOstuni 0:de13951f30f6 34
DiegoOstuni 0:de13951f30f6 35 /* Includes ------------------------------------------------------------------*/
DiegoOstuni 0:de13951f30f6 36 #include "lib_NDEF.h"
DiegoOstuni 0:de13951f30f6 37
DiegoOstuni 0:de13951f30f6 38
DiegoOstuni 0:de13951f30f6 39 /** @addtogroup lib_NDEF_Handover NDEF Handover library
DiegoOstuni 0:de13951f30f6 40 * @{
DiegoOstuni 0:de13951f30f6 41 */
DiegoOstuni 0:de13951f30f6 42
DiegoOstuni 0:de13951f30f6 43 /** @brief SIze of the buffer used to store an Alternative Carrier (allocated on the stack).
DiegoOstuni 0:de13951f30f6 44 * @details 128 bytes should be enough, the specification recommends to use short URIs as AC identifiers.
DiegoOstuni 0:de13951f30f6 45 */
DiegoOstuni 0:de13951f30f6 46 #define NDEF_AC_BUFFER_SIZE (128)
DiegoOstuni 0:de13951f30f6 47
DiegoOstuni 0:de13951f30f6 48 /** @brief NFC Forum Well-Known Type name for a Handover Select record */
DiegoOstuni 0:de13951f30f6 49 #define NDEF_HANDOVER_SELECT_TYPE_STR "Hs"
DiegoOstuni 0:de13951f30f6 50 /** @brief NFC Forum Well-Known Type name for a Handover Request record */
DiegoOstuni 0:de13951f30f6 51 #define NDEF_HANDOVER_REQUEST_TYPE_STR "Hr"
DiegoOstuni 0:de13951f30f6 52 /** @brief NFC Forum Well-Known Type name for a Handover Select Select (ascii value) */
DiegoOstuni 0:de13951f30f6 53 #define NDEF_HANDOVER_SELECT_TYPE 0x4872
DiegoOstuni 0:de13951f30f6 54 /** @brief NFC Forum Well-Known Type name for a Handover Request record (ascii value) */
DiegoOstuni 0:de13951f30f6 55 #define NDEF_HANDOVER_REQUEST_TYPE 0x4873
DiegoOstuni 0:de13951f30f6 56 /** @brief NFC Forum Handover record implemented version */
DiegoOstuni 0:de13951f30f6 57 #define NDEF_HANDOVER_VERSION_1_2 0x12
DiegoOstuni 0:de13951f30f6 58
DiegoOstuni 0:de13951f30f6 59 /** @brief NFC Forum Well-Known Type name for a Colision Resolution record */
DiegoOstuni 0:de13951f30f6 60 #define NDEF_HANDOVER_COLLISION_RESOLUTION_TYPE_STR "cr"
DiegoOstuni 0:de13951f30f6 61 /** @brief NFC Forum Well-Known Type name for an Alternative Carrier record */
DiegoOstuni 0:de13951f30f6 62 #define NDEF_HANDOVER_ALTERNATIVE_CARRIER_TYPE_STR "ac"
DiegoOstuni 0:de13951f30f6 63
DiegoOstuni 0:de13951f30f6 64 /** @brief NFC Forum Power States values mask */
DiegoOstuni 0:de13951f30f6 65 #define NDEF_HANDOVER_AC_CPS_MASK (0x3)
DiegoOstuni 0:de13951f30f6 66 /** @brief Enumerates the NFC Forum Power States possible values */
DiegoOstuni 0:de13951f30f6 67 typedef enum {
DiegoOstuni 0:de13951f30f6 68 NDEF_HANDOVER_AC_CPS_INACTIVE = 0x0, /**< The HW for this Alternative Carrier has to be switch on before proceeding. */
DiegoOstuni 0:de13951f30f6 69 NDEF_HANDOVER_AC_CPS_ACTIVE = 0x1, /**< The HW for this Alternative Carrier is currently running. */
DiegoOstuni 0:de13951f30f6 70 NDEF_HANDOVER_AC_CPS_ACTIVATING = 0x2, /**< The HW for this Alternative Carrier is being activated. */
DiegoOstuni 0:de13951f30f6 71 NDEF_HANDOVER_AC_CPS_UNKNOWN = 0x3 /**< The HW for this Alternative Carrier is unknown. */
DiegoOstuni 0:de13951f30f6 72 } Ndef_Handover_ac_cps_t;
DiegoOstuni 0:de13951f30f6 73
DiegoOstuni 0:de13951f30f6 74
DiegoOstuni 0:de13951f30f6 75
DiegoOstuni 0:de13951f30f6 76 typedef struct {
DiegoOstuni 0:de13951f30f6 77 uint8_t cps; /**< Current Power State for this Alternative Carrier Hardware. */
DiegoOstuni 0:de13951f30f6 78 sRecordInfo_t ac_record; /**< The record structure used to store/build the Alternative Carrier record. */
DiegoOstuni 0:de13951f30f6 79 uint8_t aux_data_ref_count; /**< The number of Auxiliary Data Reference for this Alternative Carrier. */
DiegoOstuni 0:de13951f30f6 80 /* following fields are only used when reading NDEF */
DiegoOstuni 0:de13951f30f6 81 uint8_t* aux_data_ref_start; /**< Internal field, managed by the library, to keep track of the Auxiliary Data Reference start address in the AC record. */
DiegoOstuni 0:de13951f30f6 82 uint8_t* aux_data_ref_end; /**< Internal field, managed by the library, to keep track of the Auxiliary Data Reference end address in the AC record. */
DiegoOstuni 0:de13951f30f6 83 } Ndef_Handover_alternative_carrier_t;
DiegoOstuni 0:de13951f30f6 84
DiegoOstuni 0:de13951f30f6 85
DiegoOstuni 0:de13951f30f6 86 typedef struct {
DiegoOstuni 0:de13951f30f6 87 uint16_t type; /**< Handover type: could be Select or Request. */
DiegoOstuni 0:de13951f30f6 88 uint8_t version; /**< Version of the Handover record. */
DiegoOstuni 0:de13951f30f6 89 /* following fields are only used when reading NDEF */
DiegoOstuni 0:de13951f30f6 90 uint8_t has_cr; /**< Boolean, if true this Handover has a Collision Resolution nested record. */
DiegoOstuni 0:de13951f30f6 91 uint16_t cr_random_number; /**< Random number for the Collision Resolution. */
DiegoOstuni 0:de13951f30f6 92 uint8_t nb_alternative_carrier; /**< Number of Alternative Carrier nested records un this Handover. */
DiegoOstuni 0:de13951f30f6 93 uint8_t* ac_start; /**< Internal field, managed by the library, to keep track of the Alternative Carrier Reference Data start address in the Handover record. */
DiegoOstuni 0:de13951f30f6 94 uint8_t* ac_end; /**< Internal field, managed by the library, to keep track of the Alternative Carrier Reference Data end address in the Handover record. */
DiegoOstuni 0:de13951f30f6 95 } Ndef_Handover_t;
DiegoOstuni 0:de13951f30f6 96
DiegoOstuni 0:de13951f30f6 97
DiegoOstuni 0:de13951f30f6 98
DiegoOstuni 0:de13951f30f6 99 uint16_t NDEF_ReadHandover(sRecordInfo_t *pRecord , Ndef_Handover_t *pHandover );
DiegoOstuni 0:de13951f30f6 100 uint16_t NDEF_ReadAC( uint8_t ac_nb, Ndef_Handover_t *pHandover , Ndef_Handover_alternative_carrier_t *pAC );
DiegoOstuni 0:de13951f30f6 101 uint16_t NDEF_ReadAuxData( uint8_t aux_data_nb, Ndef_Handover_alternative_carrier_t *pAC, sRecordInfo_t *pRecord );
DiegoOstuni 0:de13951f30f6 102
DiegoOstuni 0:de13951f30f6 103 uint16_t NDEF_CreateHandover(Ndef_Handover_t *pHandover, sRecordInfo_t* pRecord );
DiegoOstuni 0:de13951f30f6 104 uint16_t NDEF_AddAlternativeCarrier(Ndef_Handover_alternative_carrier_t *pAC, char* CarrierDataRef, char **AuxDataRefID, sRecordInfo_t* pRecord );
DiegoOstuni 0:de13951f30f6 105 uint16_t NDEF_WriteHandover( sRecordInfo_t* pRecord , uint8_t* pNdef, I2C* mi2cChannel);
DiegoOstuni 0:de13951f30f6 106
DiegoOstuni 0:de13951f30f6 107 uint32_t NDEF_GetACDataLength(Ndef_Handover_alternative_carrier_t *pAC,char *CarrierDataRef, char **AuxDataRefID);
DiegoOstuni 0:de13951f30f6 108
DiegoOstuni 0:de13951f30f6 109
DiegoOstuni 0:de13951f30f6 110
DiegoOstuni 0:de13951f30f6 111 /** @}
DiegoOstuni 0:de13951f30f6 112 */
DiegoOstuni 0:de13951f30f6 113
DiegoOstuni 0:de13951f30f6 114 #endif /* __LIB_NDEF_HANDOVER_H */
DiegoOstuni 0:de13951f30f6 115
DiegoOstuni 0:de13951f30f6 116 /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/