1 //========================================================================== 2 // Name: reliable_text.h 3 // 4 // Purpose: Handles reliable text (e.g. text with FEC). 5 // Created: August 15, 2021 6 // Authors: Mooneer Salem 7 // 8 // License: 9 // 10 // This program is free software; you can redistribute it and/or modify 11 // it under the terms of the GNU Lesser General Public License version 2.1, 12 // as published by the Free Software Foundation. This program is 13 // distributed in the hope that it will be useful, but WITHOUT ANY 14 // WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 16 // License for more details. 17 // 18 // You should have received a copy of the GNU Lesser General Public License 19 // along with this program; if not, see <http://www.gnu.org/licenses/>. 20 // 21 //========================================================================== 22 23 #ifndef RELIABLE_TEXT_H 24 #define RELIABLE_TEXT_H 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif // __cplusplus 29 30 /* Forward define struct freedv for use by the function prototypes below. */ 31 struct freedv; 32 33 /* Hide internals of reliable_text_t. */ 34 typedef void* reliable_text_t; 35 36 /* Function type for callback (when full reliable text has been received). */ 37 typedef void(*on_text_rx_t)(reliable_text_t rt, const char* txt_ptr, int length, void* state); 38 39 /* Allocate reliable_text object. */ 40 reliable_text_t reliable_text_create(); 41 42 /* Destroy reliable_text object. */ 43 void reliable_text_destroy(reliable_text_t ptr); 44 45 /* Reset reliable_text object for next sync. */ 46 void reliable_text_reset(reliable_text_t ptr); 47 48 /* Sets string that is sent on TX. */ 49 void reliable_text_set_string(reliable_text_t ptr, const char* str, int strlength); 50 51 /* Link FreeDV object to reliable_text object. */ 52 void reliable_text_use_with_freedv(reliable_text_t ptr, struct freedv* fdv, on_text_rx_t text_rx_fn, void* state); 53 54 /* Returns associated struct freedv object. */ 55 struct freedv* reliable_text_get_freedv_obj(reliable_text_t ptr); 56 57 /* Unlink FreeDV object from reliable_text object. */ 58 void reliable_text_unlink_from_freedv(reliable_text_t ptr); 59 60 #ifdef __cplusplus 61 } 62 #endif // __cplusplus 63 64 #endif // RELIABLE_TEXT_H 65