Update subghz_demo - latest firmware changes.
This commit is contained in:
parent
4d1d89a791
commit
a13cfb712b
@ -67,6 +67,7 @@ sudo hackrf_transfer -r flipper-chat.rf -f 433920000 -s 8000000 -x 47
|
|||||||
- Import the library:
|
- Import the library:
|
||||||
```
|
```
|
||||||
#include <lib/subghz/subghz_tx_rx_worker.h>
|
#include <lib/subghz/subghz_tx_rx_worker.h>
|
||||||
|
#include <lib/subghz/devices/cc1101_int/cc1101_int_interconnect.h>
|
||||||
```
|
```
|
||||||
|
|
||||||
- Define MESSAGE_MAX_LEN with the maximum size (in bytes) of a message. Messages are typically UTF-8 encoded, but it is up to the sending application to decide. I beleive the maximum for the CC1101 chip is in the low-60 bytes.
|
- Define MESSAGE_MAX_LEN with the maximum size (in bytes) of a message. Messages are typically UTF-8 encoded, but it is up to the sending application to decide. I beleive the maximum for the CC1101 chip is in the low-60 bytes.
|
||||||
@ -102,9 +103,20 @@ sudo hackrf_transfer -r flipper-chat.rf -f 433920000 -s 8000000 -x 47
|
|||||||
demo_context->subghz_txrx = subghz_tx_rx_worker_alloc();
|
demo_context->subghz_txrx = subghz_tx_rx_worker_alloc();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- Initialize the list of devices
|
||||||
|
```
|
||||||
|
subghz_devices_init();
|
||||||
|
```
|
||||||
|
|
||||||
|
- Get a device references to the internal CC1101 Sub-GHz radio.
|
||||||
|
```
|
||||||
|
const SubGhzDevice* device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_INT_NAME);
|
||||||
|
furi_assert(device);
|
||||||
|
```
|
||||||
|
|
||||||
- Start the worker.
|
- Start the worker.
|
||||||
```
|
```
|
||||||
bool worker_started = subghz_tx_rx_worker_start(demo_context->subghz_txrx, frequency);
|
bool worker_started = subghz_tx_rx_worker_start(demo_context->subghz_txrx, device, frequency);
|
||||||
```
|
```
|
||||||
|
|
||||||
- If the worker failed (worker_started == false) then free resources and exit.
|
- If the worker failed (worker_started == false) then free resources and exit.
|
||||||
@ -131,6 +143,7 @@ sudo hackrf_transfer -r flipper-chat.rf -f 433920000 -s 8000000 -x 47
|
|||||||
subghz_tx_rx_worker_stop(demo_context->subghz_txrx);
|
subghz_tx_rx_worker_stop(demo_context->subghz_txrx);
|
||||||
}
|
}
|
||||||
subghz_tx_rx_worker_free(demo_context->subghz_txrx);
|
subghz_tx_rx_worker_free(demo_context->subghz_txrx);
|
||||||
|
subghz_devices_deinit();
|
||||||
furi_hal_power_suppress_charge_exit();
|
furi_hal_power_suppress_charge_exit();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ Long press UP button on Flipper Zero to log and send 880Hz tone to another Flipp
|
|||||||
#include <locale/locale.h>
|
#include <locale/locale.h>
|
||||||
|
|
||||||
#include <lib/subghz/subghz_tx_rx_worker.h>
|
#include <lib/subghz/subghz_tx_rx_worker.h>
|
||||||
|
#include <lib/subghz/devices/cc1101_int/cc1101_int_interconnect.h>
|
||||||
|
|
||||||
// This is sent at the beginning of all RF messages.
|
// This is sent at the beginning of all RF messages.
|
||||||
// You should make the SUBGHZ_GAME_NAME short but unique.
|
// You should make the SUBGHZ_GAME_NAME short but unique.
|
||||||
@ -389,10 +390,14 @@ int32_t subghz_demo_app(void* p) {
|
|||||||
|
|
||||||
// Subghz worker.
|
// Subghz worker.
|
||||||
demo_context->subghz_txrx = subghz_tx_rx_worker_alloc();
|
demo_context->subghz_txrx = subghz_tx_rx_worker_alloc();
|
||||||
|
subghz_devices_init();
|
||||||
|
|
||||||
// Try to start the TX/RX on the frequency and configure our callback
|
// Try to start the TX/RX on the frequency and configure our callback
|
||||||
// whenever new data is received.
|
// whenever new data is received.
|
||||||
if(subghz_tx_rx_worker_start(demo_context->subghz_txrx, frequency)) {
|
const SubGhzDevice* device =
|
||||||
|
subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_INT_NAME); // Use internal CC1101 radio
|
||||||
|
furi_assert(device);
|
||||||
|
if(subghz_tx_rx_worker_start(demo_context->subghz_txrx, device, frequency)) {
|
||||||
subghz_tx_rx_worker_set_callback_have_read(
|
subghz_tx_rx_worker_set_callback_have_read(
|
||||||
demo_context->subghz_txrx, subghz_demo_worker_update_rx_event_callback, demo_context);
|
demo_context->subghz_txrx, subghz_demo_worker_update_rx_event_callback, demo_context);
|
||||||
} else {
|
} else {
|
||||||
@ -405,6 +410,7 @@ int32_t subghz_demo_app(void* p) {
|
|||||||
subghz_tx_rx_worker_stop(demo_context->subghz_txrx);
|
subghz_tx_rx_worker_stop(demo_context->subghz_txrx);
|
||||||
}
|
}
|
||||||
subghz_tx_rx_worker_free(demo_context->subghz_txrx);
|
subghz_tx_rx_worker_free(demo_context->subghz_txrx);
|
||||||
|
subghz_devices_deinit();
|
||||||
furi_message_queue_free(demo_context->queue);
|
furi_message_queue_free(demo_context->queue);
|
||||||
furi_mutex_free(demo_context->mutex);
|
furi_mutex_free(demo_context->mutex);
|
||||||
furi_string_free(demo_context->data->buffer);
|
furi_string_free(demo_context->data->buffer);
|
||||||
@ -519,6 +525,7 @@ int32_t subghz_demo_app(void* p) {
|
|||||||
subghz_tx_rx_worker_stop(demo_context->subghz_txrx);
|
subghz_tx_rx_worker_stop(demo_context->subghz_txrx);
|
||||||
}
|
}
|
||||||
subghz_tx_rx_worker_free(demo_context->subghz_txrx);
|
subghz_tx_rx_worker_free(demo_context->subghz_txrx);
|
||||||
|
subghz_devices_deinit();
|
||||||
view_port_enabled_set(view_port, false);
|
view_port_enabled_set(view_port, false);
|
||||||
gui_remove_view_port(gui, view_port);
|
gui_remove_view_port(gui, view_port);
|
||||||
view_port_free(view_port);
|
view_port_free(view_port);
|
||||||
|
Loading…
Reference in New Issue
Block a user