FreeRTOS: BLE
BLE
Return to main page ↑
iot_ble_data_transfer.h
1 /*
2  * FreeRTOS BLE V2.2.0
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25 
32 #ifndef IOT_BLE_DATA_TRANSFER_H
33 #define IOT_BLE_DATA_TRANSFER_H
34 
35 #include <stdlib.h>
36 #include <string.h>
37 #include <stdbool.h>
38 
39 /*
40  * @brief Events related to a ble data transfer channel.
41  */
42 typedef enum IotBleDataTransferChannelEvent
43 {
44  IOT_BLE_DATA_TRANSFER_CHANNEL_OPENED = 0,
45  IOT_BLE_DATA_TRANSFER_CHANNEL_DATA_RECEIVED,
46  IOT_BLE_DATA_TRANSFER_CHANNEL_DATA_SENT,
47  IOT_BLE_DATA_TRANSFER_CHANNEL_CLOSED
48 } IotBleDataTransferChannelEvent_t;
49 
53 typedef struct IotBleDataTransferChannel IotBleDataTransferChannel_t;
54 
58 typedef void ( * IotBleDataTransferChannelCallback_t ) ( IotBleDataTransferChannelEvent_t event,
59  IotBleDataTransferChannel_t * pChannel,
60  void * pContext );
61 
69 bool IotBleDataTransfer_Init( void );
70 
78 IotBleDataTransferChannel_t * IotBleDataTransfer_Open( uint8_t channelIdentifier );
79 
89 bool IotBleDataTransfer_SetCallback( IotBleDataTransferChannel_t * pChannel,
90  const IotBleDataTransferChannelCallback_t callback,
91  void * pContext );
92 
102 size_t IotBleDataTransfer_Send( IotBleDataTransferChannel_t * pChannel,
103  const uint8_t * const pMessage,
104  size_t messageLength );
105 
116 size_t IotBleDataTransfer_Receive( IotBleDataTransferChannel_t * pChannel,
117  uint8_t * pBuffer,
118  size_t bytesRequested );
119 
129 void IotBleDataTransfer_PeekReceiveBuffer( IotBleDataTransferChannel_t * pChannel,
130  const uint8_t ** pBuffer,
131  size_t * pBufferLength );
132 
140 void IotBleDataTransfer_Close( IotBleDataTransferChannel_t * pChannel );
141 
142 
151 void IotBleDataTransfer_Reset( IotBleDataTransferChannel_t * pChannel );
152 
153 
159 bool IotBleDataTransfer_Cleanup( void );
160 
161 #endif /* IOT_BLE_DATA_TRANSFER_H */