4
4
*
5
5
* @file chirp_connect.h
6
6
*
7
+ * @brief Chirp C SDK implementation header.
8
+ *
7
9
* All contents are strictly proprietary, and not for copying, resale,
8
10
* or use outside of the agreed license.
9
11
*
10
- * Copyright © 2011-2018 , Asio Ltd.
12
+ * Copyright © 2011-2019 , Asio Ltd.
11
13
* All rights reserved.
12
14
*
13
15
*----------------------------------------------------------------------------*/
14
16
15
- #ifndef __CHIRP_CONNECT_H__
16
- #define __CHIRP_CONNECT_H__
17
-
18
- #ifdef __cplusplus
19
- extern "C" {
20
- #endif
17
+ #ifndef CHIRP_CONNECT_H
18
+ #define CHIRP_CONNECT_H
21
19
22
20
#include <stdbool.h>
23
21
#include <stdint.h>
24
- #include <time.h>
22
+
23
+ /**
24
+ * Mark the function as public. Any attempt to call a function without this
25
+ * marker will fail.
26
+ */
27
+ #if defined(__WIN32 ) || defined(_WIN32 ) || defined(WIN32 )
28
+ #define PUBLIC_SYM __declspec(dllexport)
29
+ #else
30
+ #define PUBLIC_SYM __attribute__ ((visibility ("default")))
31
+ #endif
25
32
26
33
#include "chirp_connect_callbacks.h"
27
- #include "chirp_sdk_defines.h"
28
34
#include "chirp_connect_errors.h"
29
35
#include "chirp_connect_states.h"
36
+ #include "chirp_connect_version.h"
37
+
38
+ #ifdef __cplusplus
39
+ extern "C" {
40
+ #endif
30
41
31
42
/**
32
43
* Typedef exposing the SDK structure to the API.
@@ -46,8 +57,8 @@ typedef struct _chirp_connect_t chirp_connect_t;
46
57
PUBLIC_SYM chirp_connect_t * new_chirp_connect (const char * key , const char * secret );
47
58
48
59
/**
49
- * Free the memory of the SDK. This function should be the last one to be called
50
- * among all the API functions.
60
+ * Release the SDK. This function should be the last one to be called among all
61
+ * the API functions.
51
62
*
52
63
* During the program life time, this function should be called only one time.
53
64
*
@@ -59,6 +70,7 @@ PUBLIC_SYM chirp_connect_error_code_t del_chirp_connect(chirp_connect_t **connec
59
70
60
71
/**
61
72
* Free some memory previously allocated and returned by the SDK.
73
+ *
62
74
* @param ptr The pointer to the memory to be freed.
63
75
*/
64
76
PUBLIC_SYM void chirp_connect_free (void * ptr );
@@ -71,7 +83,7 @@ PUBLIC_SYM void chirp_connect_free(void *ptr);
71
83
*
72
84
* @param connect A pointer to the SDK structure which needs the config to be
73
85
* set.
74
- * @param config The config string which will be set.
86
+ * @param config The config string which will be set.
75
87
* @return An error code resulting from the call. CHIRP_CONNECT_OK will
76
88
* be returned if everything went well.
77
89
*/
@@ -111,21 +123,6 @@ PUBLIC_SYM chirp_connect_error_code_t chirp_connect_set_callbacks(chirp_connect_
111
123
*/
112
124
PUBLIC_SYM chirp_connect_error_code_t chirp_connect_start (chirp_connect_t * connect );
113
125
114
- /**
115
- * Pause the SDK and the audio processing. No more data can be sent or received.
116
- * If this is called when sending data, the rest of the audio will resume when
117
- * leaving the pause state. On the contrary of `chirp_connect_stop`, this function
118
- * doesn't free any internal memory.
119
- *
120
- * @param connect A pointer to the SDK structure.
121
- * @param pause A boolean indicating the SDK's `pause` status. If true, the
122
- * SDK will pause the audio processing. If false, the SDK will
123
- * resume the audio processing.
124
- * @return An error code resulting from the call. CHIRP_CONNECT_OK will
125
- * be returned if everything went well.
126
- */
127
- PUBLIC_SYM chirp_connect_error_code_t chirp_connect_pause (chirp_connect_t * connect , bool pause );
128
-
129
126
/**
130
127
* Stop the SDK and the audio processing. Once this function is called, some
131
128
* internal structures will be reset and any data being sent won't be
@@ -137,31 +134,26 @@ PUBLIC_SYM chirp_connect_error_code_t chirp_connect_pause(chirp_connect_t *conne
137
134
*/
138
135
PUBLIC_SYM chirp_connect_error_code_t chirp_connect_stop (chirp_connect_t * connect );
139
136
140
- /**
141
- * Allocate a new empty payload which will later be filled with the data to send.
142
- * To release the memory, call `chirp_connect_free` on the data pointer.
143
- *
144
- * @param connect A pointer to the SDK structure.
145
- * @param length The length, in bytes, of the new payload.
146
- * @return A pointer to the newly created data payload.
147
- */
148
- PUBLIC_SYM uint8_t * chirp_connect_new_payload (chirp_connect_t * connect , size_t length );
149
-
150
137
/**
151
138
* Get the maximum payload length allowed by the current config set for the SDK.
152
139
*
140
+ *
153
141
* @param connect A pointer to the SDK structure.
154
142
* @return The maximum payload length that can be sent. A length of 0 is
155
- * invalid.
143
+ * invalid. If the config hasn't been set yet when this function
144
+ * is called 0 is returned.
156
145
*/
157
146
PUBLIC_SYM size_t chirp_connect_get_max_payload_length (chirp_connect_t * connect );
158
147
159
148
/**
160
149
* Get the duration, in seconds, for a given payload length.
161
150
*
162
151
* @param connect A pointer to the SDK structure.
163
- * @param length The length, in bytes, of the payload we want to know the duration.
164
- * @return The duration, in second, of the given length.
152
+ * @param length The length, in bytes, of the payload we want to know the
153
+ * duration. You can get the maximum allowed length with
154
+ * `chirp_connect_get_max_payload_length`.
155
+ * @return The duration, in second, of the given length, -1 if the payload
156
+ * is too short or -2 if the payload is too long.
165
157
*/
166
158
PUBLIC_SYM float chirp_connect_get_duration_for_payload_length (chirp_connect_t * connect , size_t length );
167
159
@@ -184,7 +176,8 @@ PUBLIC_SYM chirp_connect_error_code_t chirp_connect_is_valid(chirp_connect_t *co
184
176
* @param length A pointer containing the length, in bytes, of the payload to be
185
177
* generated. If the length is 0, the SDK will randomise both the
186
178
* length of the payload and its content. The length pointer will
187
- * then be updated with the random length.
179
+ * then be updated with the random length. You can get the
180
+ * maximum allowed length with `chirp_connect_get_max_payload_length`.
188
181
* @return A pointer to the newly created random data payload.The user
189
182
* has to free this pointer once they doesn't need it anymore using
190
183
* `chirp_connect_free`.
@@ -193,10 +186,11 @@ PUBLIC_SYM uint8_t *chirp_connect_random_payload(chirp_connect_t *connect, size_
193
186
194
187
/**
195
188
* Convert the payload to an hexadecimal string representation to offer a quick
196
- * and easy human readable way to represent the data.
189
+ * and easy human readable way to represent the data. The result string is
190
+ * deprived of any "0x" marker thus converting the byte "B" would give "42".
197
191
*
198
192
* @param connect A pointer to the SDK structure.
199
- * @param bytes A pointer to the payload to be validated .
193
+ * @param bytes A pointer to the payload to be converted .
200
194
* @param length The length, in bytes, of the data payload.
201
195
* @return The string representation of the payload. The user has to free
202
196
* this pointer once they doesn't need it anymore using
@@ -205,7 +199,21 @@ PUBLIC_SYM uint8_t *chirp_connect_random_payload(chirp_connect_t *connect, size_
205
199
PUBLIC_SYM char * chirp_connect_as_string (chirp_connect_t * connect , uint8_t * bytes , size_t length );
206
200
207
201
/**
208
- * Send a payload.
202
+ * Convert an hexadecimal string to the payload it represents. The input must be
203
+ * an hexadecimal string without the "0x" prefix. Very few checks are done on
204
+ * the input and it is up to the user to ensure then input string is correct.
205
+ *
206
+ * @param connect A pointer to the SDK structure.
207
+ * @param hex_string A pointer to the hexadecimal string to be converted.
208
+ * @return The payload corresponding to the input string. The user has
209
+ * to free this pointer once they doesn't need it anymore using
210
+ * `chirp_connect_free`.
211
+ */
212
+ PUBLIC_SYM uint8_t * chirp_connect_from_string (chirp_connect_t * connect , char * hex_string );
213
+
214
+ /**
215
+ * Send a payload. A valid length is between 1 and the value returned by
216
+ * `chirp_connect_get_max_payload_length`.
209
217
*
210
218
* @param connect A pointer to the SDK structure.
211
219
* @param bytes A pointer to the payload that will be sent.
@@ -302,9 +310,10 @@ PUBLIC_SYM chirp_connect_state_t chirp_connect_get_state_for_channel(chirp_conne
302
310
* which the data is sent.
303
311
*
304
312
* @param connect A pointer to the SDK structure.
305
- * @return The channel on which the data is sent.
313
+ * @return The channel on which the data is sent (including 0) or -1 if
314
+ * the SDK hasn't been initialised.
306
315
*/
307
- PUBLIC_SYM uint8_t chirp_connect_get_transmission_channel (chirp_connect_t * connect );
316
+ PUBLIC_SYM int8_t chirp_connect_get_transmission_channel (chirp_connect_t * connect );
308
317
309
318
/**
310
319
* Set the channel on which the data will be sent. Allowed values are between 0
@@ -341,7 +350,7 @@ PUBLIC_SYM chirp_connect_state_t chirp_connect_get_state(chirp_connect_t *connec
341
350
* audio volume.
342
351
*
343
352
* @param connect A pointer to the SDK structure.
344
- * @return The volume of the output of SDK.
353
+ * @return The volume of the output of the SDK or -1 if an error happened .
345
354
*/
346
355
PUBLIC_SYM float chirp_connect_get_volume (chirp_connect_t * connect );
347
356
@@ -407,18 +416,18 @@ PUBLIC_SYM chirp_connect_error_code_t chirp_connect_set_output_sample_rate(chirp
407
416
* @return False: The SDK will attempt to decode the payloads it sends.
408
417
* True: The SDK will ignore the payloads it sends.
409
418
*/
410
- PUBLIC_SYM bool chirp_connect_get_auto_mute (chirp_connect_t * connect );
419
+ PUBLIC_SYM bool chirp_connect_get_listen_to_self (chirp_connect_t * connect );
411
420
412
421
/**
413
- * Set the auto mute status of the SDK.
422
+ * Set the listen to self status of the SDK.
414
423
*
415
- * @param connect A pointer to the SDK structure.
416
- * @param auto_mute False : The SDK will attempt to decode the payloads it sends.
417
- * True : The SDK will ignore the payloads it sends.
418
- * @return An error code resulting from the call. CHIRP_CONNECT_OK will
419
- * be returned if everything went well.
424
+ * @param connect A pointer to the SDK structure.
425
+ * @param listen_to_self True : The SDK will attempt to decode the payloads it sends.
426
+ * False : The SDK will ignore the payloads it sends.
427
+ * @return An error code resulting from the call. CHIRP_CONNECT_OK will
428
+ * be returned if everything went well.
420
429
*/
421
- PUBLIC_SYM chirp_connect_error_code_t chirp_connect_set_auto_mute (chirp_connect_t * connect , bool auto_mute );
430
+ PUBLIC_SYM chirp_connect_error_code_t chirp_connect_set_listen_to_self (chirp_connect_t * connect , bool listen_to_self );
422
431
423
432
/**
424
433
* Set the pointer which is accessible in the callbacks. This function doesn't
@@ -449,15 +458,15 @@ PUBLIC_SYM chirp_connect_error_code_t chirp_connect_set_callback_ptr(chirp_conne
449
458
PUBLIC_SYM chirp_connect_error_code_t chirp_connect_set_frequency_correction (chirp_connect_t * connect , float correction );
450
459
451
460
/**
452
- * Get the version number of the SDK. This function doesn't rely at all on the
453
- * SDK creation and can be called at any time.
461
+ * Return the current heap usage of the SDK, in bytes.
454
462
*
455
- * @return The version number of the SDK in the MAJOR.MINOR.PATCH string
456
- * representation .
463
+ * @param connect A pointer to the SDK structure.
464
+ * @return The heap usage in bytes of the SDK .
457
465
*/
458
- PUBLIC_SYM const char * chirp_connect_get_version ( void );
466
+ PUBLIC_SYM int32_t chirp_connect_get_heap_usage ( chirp_connect_t * connect );
459
467
460
468
#ifdef __cplusplus
461
469
}
462
470
#endif
463
- #endif // __CHIRP_CONNECT_H__
471
+
472
+ #endif /* !CHIRP_CONNECT_H */
0 commit comments