2021-12-01 18:44:39 +03:00
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-01-05 19:10:18 +03:00
|
|
|
|
#include <furi_hal.h>
|
2021-12-01 18:44:39 +03:00
|
|
|
|
|
2022-09-14 19:11:38 +03:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-12-01 18:44:39 +03:00
|
|
|
|
typedef void (*SubGhzTxRxWorkerCallbackHaveRead)(void* context);
|
|
|
|
|
|
|
|
|
|
typedef struct SubGhzTxRxWorker SubGhzTxRxWorker;
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
SubGhzTxRxWorkerStatusIDLE,
|
|
|
|
|
SubGhzTxRxWorkerStatusTx,
|
|
|
|
|
SubGhzTxRxWorkerStatusRx,
|
|
|
|
|
} SubGhzTxRxWorkerStatus;
|
|
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
|
/**
|
|
|
|
|
* SubGhzTxRxWorker, add data to transfer
|
|
|
|
|
* @param instance Pointer to a SubGhzTxRxWorker instance
|
2021-12-01 18:44:39 +03:00
|
|
|
|
* @param data *data
|
|
|
|
|
* @param size data size
|
|
|
|
|
* @return bool true if ok
|
|
|
|
|
*/
|
|
|
|
|
bool subghz_tx_rx_worker_write(SubGhzTxRxWorker* instance, uint8_t* data, size_t size);
|
|
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
|
/**
|
|
|
|
|
* SubGhzTxRxWorker, get available data
|
|
|
|
|
* @param instance Pointer to a SubGhzTxRxWorker instance
|
2021-12-01 18:44:39 +03:00
|
|
|
|
* @return size_t data size
|
|
|
|
|
*/
|
|
|
|
|
size_t subghz_tx_rx_worker_available(SubGhzTxRxWorker* instance);
|
|
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
|
/**
|
|
|
|
|
* SubGhzTxRxWorker, read data
|
|
|
|
|
* @param instance Pointer to a SubGhzTxRxWorker instance
|
2021-12-01 18:44:39 +03:00
|
|
|
|
* @param data *data
|
|
|
|
|
* @param size max data size, which can be read
|
|
|
|
|
* @return size_t data size, how much is actually read
|
|
|
|
|
*/
|
|
|
|
|
size_t subghz_tx_rx_worker_read(SubGhzTxRxWorker* instance, uint8_t* data, size_t size);
|
|
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
|
/**
|
|
|
|
|
* Сallback SubGhzTxRxWorker when there is data to read in an empty buffer
|
|
|
|
|
* @param instance Pointer to a SubGhzTxRxWorker instance
|
2021-12-01 18:44:39 +03:00
|
|
|
|
* @param callback SubGhzTxRxWorkerCallbackHaveRead callback
|
|
|
|
|
* @param context
|
|
|
|
|
*/
|
|
|
|
|
void subghz_tx_rx_worker_set_callback_have_read(
|
|
|
|
|
SubGhzTxRxWorker* instance,
|
|
|
|
|
SubGhzTxRxWorkerCallbackHaveRead callback,
|
|
|
|
|
void* context);
|
|
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
|
/**
|
|
|
|
|
* Allocate SubGhzTxRxWorker
|
|
|
|
|
* @return SubGhzTxRxWorker* Pointer to a SubGhzTxRxWorker instance
|
2021-12-01 18:44:39 +03:00
|
|
|
|
*/
|
|
|
|
|
SubGhzTxRxWorker* subghz_tx_rx_worker_alloc();
|
|
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
|
/**
|
|
|
|
|
* Free SubGhzTxRxWorker
|
|
|
|
|
* @param instance Pointer to a SubGhzTxRxWorker instance
|
2021-12-01 18:44:39 +03:00
|
|
|
|
*/
|
|
|
|
|
void subghz_tx_rx_worker_free(SubGhzTxRxWorker* instance);
|
|
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
|
/**
|
|
|
|
|
* Start SubGhzTxRxWorker
|
|
|
|
|
* @param instance Pointer to a SubGhzTxRxWorker instance
|
2021-12-01 18:44:39 +03:00
|
|
|
|
* @return bool - true if ok
|
|
|
|
|
*/
|
|
|
|
|
bool subghz_tx_rx_worker_start(SubGhzTxRxWorker* instance, uint32_t frequency);
|
|
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
|
/**
|
|
|
|
|
* Stop SubGhzTxRxWorker
|
|
|
|
|
* @param instance Pointer to a SubGhzTxRxWorker instance
|
2021-12-01 18:44:39 +03:00
|
|
|
|
*/
|
|
|
|
|
void subghz_tx_rx_worker_stop(SubGhzTxRxWorker* instance);
|
|
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
|
/**
|
|
|
|
|
* Check if worker is running
|
|
|
|
|
* @param instance Pointer to a SubGhzTxRxWorker instance
|
2021-12-01 18:44:39 +03:00
|
|
|
|
* @return bool - true if running
|
|
|
|
|
*/
|
|
|
|
|
bool subghz_tx_rx_worker_is_running(SubGhzTxRxWorker* instance);
|
2022-09-14 19:11:38 +03:00
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|