Merge branch 'UNLEASHED' into 420

This commit is contained in:
RogueMaster
2022-10-24 15:33:18 -04:00
29 changed files with 880 additions and 89 deletions

View File

@@ -23,7 +23,7 @@ steps:
- ls -laS artifacts-default - ls -laS artifacts-default
- ls -laS artifacts-default/f7-update-${DRONE_TAG} - ls -laS artifacts-default/f7-update-${DRONE_TAG}
- sed -i 's/(version)/'${DRONE_TAG}'/g' CHANGELOG.md - sed -i 's/(version)/'${DRONE_TAG}'/g' CHANGELOG.md
- echo '# [Install via Web Updater](https://my.flipp.dev/?url=https://unleashedflip.com/builds/flipper-z-f7-update-'${DRONE_TAG}'.tgz&channel=dev-cfw&version='${DRONE_TAG}')' >> CHANGELOG.md - echo '# [Install via Web Updater](https://lab.flipper.net/?url=https://unleashedflip.com/builds/flipper-z-f7-update-'${DRONE_TAG}'.tgz&channel=dev-cfw&version='${DRONE_TAG}')' >> CHANGELOG.md
environment: environment:
FBT_TOOLS_CUSTOM_LINK: FBT_TOOLS_CUSTOM_LINK:
from_secret: fbt_link from_secret: fbt_link
@@ -88,7 +88,7 @@ steps:
[-How to install firmware-](https://github.com/DarkFlippers/unleashed-firmware/blob/dev/documentation/HowToInstall.md) [-How to install firmware-](https://github.com/DarkFlippers/unleashed-firmware/blob/dev/documentation/HowToInstall.md)
[-Install via Web Updater-](https://my.flipp.dev/?url=https://unleashedflip.com/builds/flipper-z-f7-update-${DRONE_TAG}.tgz&channel=dev-cfw&version=${DRONE_TAG})" [-Install via Web Updater-](https://lab.flipper.net/?url=https://unleashedflip.com/builds/flipper-z-f7-update-${DRONE_TAG}.tgz&channel=dev-cfw&version=${DRONE_TAG})"
document: document:
- artifacts-default/flipper-z-f7-update-${DRONE_TAG}.tgz - artifacts-default/flipper-z-f7-update-${DRONE_TAG}.tgz
@@ -108,7 +108,7 @@ steps:
[[Github]](https://github.com/DarkFlippers/unleashed-firmware/releases/tag/${DRONE_TAG}) [[Github]](https://github.com/DarkFlippers/unleashed-firmware/releases/tag/${DRONE_TAG})
[-Install via Web Updater-](https://my.flipp.dev/?url=https://unleashedflip.com/builds/flipper-z-f7-update-${DRONE_TAG}.tgz&channel=dev-cfw&version=${DRONE_TAG})" [-Install via Web Updater-](https://lab.flipper.net/?url=https://unleashedflip.com/builds/flipper-z-f7-update-${DRONE_TAG}.tgz&channel=dev-cfw&version=${DRONE_TAG})"
trigger: trigger:
event: event:

View File

@@ -109,13 +109,13 @@
"label": "[Debug] Build FAPs", "label": "[Debug] Build FAPs",
"group": "build", "group": "build",
"type": "shell", "type": "shell",
"command": "./fbt plugin_dist" "command": "./fbt fap_dist"
}, },
{ {
"label": "[Release] Build FAPs", "label": "[Release] Build FAPs",
"group": "build", "group": "build",
"type": "shell", "type": "shell",
"command": "./fbt COMPACT=1 DEBUG=0 plugin_dist" "command": "./fbt COMPACT=1 DEBUG=0 fap_dist"
}, },
{ {
"label": "[Debug] Launch App on Flipper", "label": "[Debug] Launch App on Flipper",

View File

@@ -1,7 +1,14 @@
### New changes ### New changes
* API version changed to 5.1 due to OFW updates, Extra apps pack update is coming, download it from link below tomorrow or get it from our discord * API version changed to 6.1 due to OFW updates, Extra apps pack update is already done! Download it from link below
* OFW: SubGHz: Move Oregon2 protocol to Weather Station plugin * Halloween theme + animation :) (by @Svaarich) (will be disabled on first days of November)
* OFW: Gui: update statusbar attention icon and better crash handling (breaking change, API version increased because of that) * Plugins: Add new plugin - HC-SR04 Distance sensor [(original by Sanqui)](https://github.com/Sanqui/flipperzero-firmware/tree/hc_sr04) - Ported and modified by @xMasterX - How to connect -> (5V -> VCC) / (GND -> GND) / (13|TX -> Trig) / (14|RX -> Echo)
* Plugins: Snake -> Allow food to spawn anywhere (by @TQMatvey | PR #130)
* Plugins: Use clear power in temp sensor plugin
* Plugins: WS -> add protocol Acurite 592TXR (OFW PR 1916 by Skorpionm)
* Plugins: WS -> fix oregon2 flags, and protocol type
* Fixed wrong fbt arguments in tasks.json in vscode example config -> plugin_dist -> fap_dist
* OFW PR: TikTok: reset cursor after enter and reconnect (OFW PR 1921 by gornekich)
* OFW: Furi: smaller crash routine (breaking change, API version increased because of that)
#### [🎲 Download extra apps pack](https://download-directory.github.io/?url=https://github.com/UberGuidoZ/Flipper/tree/main/Applications/Unleashed%20(and%20RogueMaster)) #### [🎲 Download extra apps pack](https://download-directory.github.io/?url=https://github.com/UberGuidoZ/Flipper/tree/main/Applications/Unleashed%20(and%20RogueMaster))

View File

@@ -17,6 +17,7 @@ typedef struct {
bool down_pressed; bool down_pressed;
bool ok_pressed; bool ok_pressed;
bool connected; bool connected;
bool is_cursor_set;
} BtHidTikTokModel; } BtHidTikTokModel;
static void bt_hid_tiktok_draw_callback(Canvas* canvas, void* context) { static void bt_hid_tiktok_draw_callback(Canvas* canvas, void* context) {
@@ -88,48 +89,48 @@ static void bt_hid_tiktok_draw_callback(Canvas* canvas, void* context) {
elements_multiline_text_aligned(canvas, 13, 62, AlignLeft, AlignBottom, "Hold to exit"); elements_multiline_text_aligned(canvas, 13, 62, AlignLeft, AlignBottom, "Hold to exit");
} }
static void bt_hid_tiktok_process_press(BtHidTikTok* bt_hid_tiktok, InputEvent* event) { static void bt_hid_tiktok_reset_cursor() {
with_view_model( // Set cursor to the phone's left up corner
bt_hid_tiktok->view, // Delays to guarantee one packet per connection interval
BtHidTikTokModel * model, for(size_t i = 0; i < 8; i++) {
{ furi_hal_bt_hid_mouse_move(-127, -127);
if(event->key == InputKeyUp) { furi_delay_ms(50);
model->up_pressed = true; }
} else if(event->key == InputKeyDown) { // Move cursor from the corner
model->down_pressed = true; furi_hal_bt_hid_mouse_move(20, 120);
} else if(event->key == InputKeyLeft) { furi_delay_ms(50);
model->left_pressed = true;
furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_VOLUME_DECREMENT);
} else if(event->key == InputKeyRight) {
model->right_pressed = true;
furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_VOLUME_INCREMENT);
} else if(event->key == InputKeyOk) {
model->ok_pressed = true;
}
},
true);
} }
static void bt_hid_tiktok_process_release(BtHidTikTok* bt_hid_tiktok, InputEvent* event) { static void bt_hid_tiktok_process_press(BtHidTikTokModel* model, InputEvent* event) {
with_view_model( if(event->key == InputKeyUp) {
bt_hid_tiktok->view, model->up_pressed = true;
BtHidTikTokModel * model, } else if(event->key == InputKeyDown) {
{ model->down_pressed = true;
if(event->key == InputKeyUp) { } else if(event->key == InputKeyLeft) {
model->up_pressed = false; model->left_pressed = true;
} else if(event->key == InputKeyDown) { furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_VOLUME_DECREMENT);
model->down_pressed = false; } else if(event->key == InputKeyRight) {
} else if(event->key == InputKeyLeft) { model->right_pressed = true;
model->left_pressed = false; furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_VOLUME_INCREMENT);
furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_VOLUME_DECREMENT); } else if(event->key == InputKeyOk) {
} else if(event->key == InputKeyRight) { model->ok_pressed = true;
model->right_pressed = false; }
furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_VOLUME_INCREMENT); }
} else if(event->key == InputKeyOk) {
model->ok_pressed = false; static void bt_hid_tiktok_process_release(BtHidTikTokModel* model, InputEvent* event) {
} if(event->key == InputKeyUp) {
}, model->up_pressed = false;
true); } else if(event->key == InputKeyDown) {
model->down_pressed = false;
} else if(event->key == InputKeyLeft) {
model->left_pressed = false;
furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_VOLUME_DECREMENT);
} else if(event->key == InputKeyRight) {
model->right_pressed = false;
furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_VOLUME_INCREMENT);
} else if(event->key == InputKeyOk) {
model->ok_pressed = false;
}
} }
static bool bt_hid_tiktok_input_callback(InputEvent* event, void* context) { static bool bt_hid_tiktok_input_callback(InputEvent* event, void* context) {
@@ -137,43 +138,59 @@ static bool bt_hid_tiktok_input_callback(InputEvent* event, void* context) {
BtHidTikTok* bt_hid_tiktok = context; BtHidTikTok* bt_hid_tiktok = context;
bool consumed = false; bool consumed = false;
if(event->type == InputTypePress) { with_view_model(
bt_hid_tiktok_process_press(bt_hid_tiktok, event); bt_hid_tiktok->view,
consumed = true; BtHidTikTokModel * model,
} else if(event->type == InputTypeRelease) { {
bt_hid_tiktok_process_release(bt_hid_tiktok, event); if(event->type == InputTypePress) {
consumed = true; bt_hid_tiktok_process_press(model, event);
} else if(event->type == InputTypeShort) { if(model->connected && !model->is_cursor_set) {
if(event->key == InputKeyOk) { bt_hid_tiktok_reset_cursor();
furi_hal_bt_hid_mouse_press(HID_MOUSE_BTN_LEFT); model->is_cursor_set = true;
furi_delay_ms(50); }
furi_hal_bt_hid_mouse_release(HID_MOUSE_BTN_LEFT); consumed = true;
furi_delay_ms(50); } else if(event->type == InputTypeRelease) {
furi_hal_bt_hid_mouse_press(HID_MOUSE_BTN_LEFT); bt_hid_tiktok_process_release(model, event);
furi_delay_ms(50); consumed = true;
furi_hal_bt_hid_mouse_release(HID_MOUSE_BTN_LEFT); } else if(event->type == InputTypeShort) {
consumed = true; if(event->key == InputKeyOk) {
} else if(event->key == InputKeyUp) { furi_hal_bt_hid_mouse_press(HID_MOUSE_BTN_LEFT);
// Emulate up swipe furi_delay_ms(50);
furi_hal_bt_hid_mouse_scroll(-6); furi_hal_bt_hid_mouse_release(HID_MOUSE_BTN_LEFT);
furi_hal_bt_hid_mouse_scroll(-12); furi_delay_ms(50);
furi_hal_bt_hid_mouse_scroll(-19); furi_hal_bt_hid_mouse_press(HID_MOUSE_BTN_LEFT);
furi_hal_bt_hid_mouse_scroll(-12); furi_delay_ms(50);
furi_hal_bt_hid_mouse_scroll(-6); furi_hal_bt_hid_mouse_release(HID_MOUSE_BTN_LEFT);
consumed = true; consumed = true;
} else if(event->key == InputKeyDown) { } else if(event->key == InputKeyUp) {
// Emulate down swipe // Emulate up swipe
furi_hal_bt_hid_mouse_scroll(6); furi_hal_bt_hid_mouse_scroll(-6);
furi_hal_bt_hid_mouse_scroll(12); furi_hal_bt_hid_mouse_scroll(-12);
furi_hal_bt_hid_mouse_scroll(19); furi_hal_bt_hid_mouse_scroll(-19);
furi_hal_bt_hid_mouse_scroll(12); furi_hal_bt_hid_mouse_scroll(-12);
furi_hal_bt_hid_mouse_scroll(6); furi_hal_bt_hid_mouse_scroll(-6);
consumed = true; consumed = true;
} else if(event->key == InputKeyBack) { } else if(event->key == InputKeyDown) {
furi_hal_bt_hid_consumer_key_release_all(); // Emulate down swipe
consumed = true; furi_hal_bt_hid_mouse_scroll(6);
} furi_hal_bt_hid_mouse_scroll(12);
} furi_hal_bt_hid_mouse_scroll(19);
furi_hal_bt_hid_mouse_scroll(12);
furi_hal_bt_hid_mouse_scroll(6);
consumed = true;
} else if(event->key == InputKeyBack) {
furi_hal_bt_hid_consumer_key_release_all();
consumed = true;
}
} else if(event->type == InputTypeLong) {
if(event->key == InputKeyBack) {
furi_hal_bt_hid_consumer_key_release_all();
model->is_cursor_set = false;
consumed = false;
}
}
},
true);
return consumed; return consumed;
} }
@@ -203,5 +220,11 @@ View* bt_hid_tiktok_get_view(BtHidTikTok* bt_hid_tiktok) {
void bt_hid_tiktok_set_connected_status(BtHidTikTok* bt_hid_tiktok, bool connected) { void bt_hid_tiktok_set_connected_status(BtHidTikTok* bt_hid_tiktok, bool connected) {
furi_assert(bt_hid_tiktok); furi_assert(bt_hid_tiktok);
with_view_model( with_view_model(
bt_hid_tiktok->view, BtHidTikTokModel * model, { model->connected = connected; }, true); bt_hid_tiktok->view,
BtHidTikTokModel * model,
{
model->connected = connected;
model->is_cursor_set = false;
},
true);
} }

View File

@@ -0,0 +1,14 @@
App(
appid="hc_sr04",
name="HC-SR04 Dist. Sensor",
apptype=FlipperAppType.EXTERNAL,
entry_point="hc_sr04_app",
cdefines=["APP_HC_SR04"],
requires=[
"gui",
],
stack_size=2 * 1024,
order=20,
fap_icon="dist_sensor10px.png",
fap_category="GPIO",
)

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

View File

@@ -0,0 +1,251 @@
// insired by
// https://github.com/esphome/esphome/blob/ac0d921413c3884752193fe568fa82853f0f99e9/esphome/components/ultrasonic/ultrasonic_sensor.cpp
// Ported and modified by @xMasterX
#include <furi.h>
#include <furi_hal_power.h>
#include <gui/gui.h>
#include <input/input.h>
#include <stdlib.h>
#include <gui/elements.h>
#include <notification/notification.h>
#include <notification/notification_messages.h>
typedef enum {
EventTypeTick,
EventTypeKey,
} EventType;
typedef struct {
EventType type;
InputEvent input;
} PluginEvent;
typedef struct {
NotificationApp* notification;
bool have_5v;
bool measurement_made;
uint32_t echo; // ms
float distance; // meters
} PluginState;
const NotificationSequence sequence_done = {
&message_display_backlight_on,
&message_green_255,
&message_note_c5,
&message_delay_50,
&message_sound_off,
NULL,
};
static void render_callback(Canvas* const canvas, void* ctx) {
const PluginState* plugin_state = acquire_mutex((ValueMutex*)ctx, 25);
if(plugin_state == NULL) {
return;
}
// border around the edge of the screen
// canvas_draw_frame(canvas, 0, 0, 128, 64);
canvas_set_font(canvas, FontPrimary);
elements_multiline_text_aligned(
canvas, 64, 2, AlignCenter, AlignTop, "HC-SR04 Ultrasonic\nDistance Sensor");
canvas_set_font(canvas, FontSecondary);
if(!plugin_state->have_5v) {
elements_multiline_text_aligned(
canvas,
4,
28,
AlignLeft,
AlignTop,
"5V on GPIO must be\nenabled, or USB must\nbe connected.");
} else {
if(!plugin_state->measurement_made) {
elements_multiline_text_aligned(
canvas, 64, 28, AlignCenter, AlignTop, "Press OK button to measure");
elements_multiline_text_aligned(
canvas, 64, 40, AlignCenter, AlignTop, "13/TX -> Trig\n14/RX -> Echo");
} else {
elements_multiline_text_aligned(canvas, 4, 28, AlignLeft, AlignTop, "Readout:");
FuriString* str_buf;
str_buf = furi_string_alloc();
furi_string_printf(str_buf, "Echo: %ld ms", plugin_state->echo);
canvas_draw_str_aligned(
canvas, 8, 38, AlignLeft, AlignTop, furi_string_get_cstr(str_buf));
furi_string_printf(str_buf, "Distance: %02f m", (double)plugin_state->distance);
canvas_draw_str_aligned(
canvas, 8, 48, AlignLeft, AlignTop, furi_string_get_cstr(str_buf));
furi_string_free(str_buf);
}
}
release_mutex((ValueMutex*)ctx, plugin_state);
}
static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) {
furi_assert(event_queue);
PluginEvent event = {.type = EventTypeKey, .input = *input_event};
furi_message_queue_put(event_queue, &event, FuriWaitForever);
}
static void hc_sr04_state_init(PluginState* const plugin_state) {
plugin_state->echo = -1;
plugin_state->distance = -1;
plugin_state->measurement_made = false;
furi_hal_power_suppress_charge_enter();
plugin_state->have_5v = false;
if(furi_hal_power_is_otg_enabled() || furi_hal_power_is_charging()) {
plugin_state->have_5v = true;
} else {
furi_hal_power_enable_otg();
plugin_state->have_5v = true;
}
}
float hc_sr04_ms_to_m(uint32_t ms) {
const float speed_sound_m_per_s = 343.0f;
const float time_s = ms / 1e3f;
const float total_dist = time_s * speed_sound_m_per_s;
return total_dist / 2.0f;
}
static void hc_sr04_measure(PluginState* const plugin_state) {
//plugin_state->echo = 1;
//return;
if(!plugin_state->have_5v) {
if(furi_hal_power_is_otg_enabled() || furi_hal_power_is_charging()) {
plugin_state->have_5v = true;
} else {
return;
}
}
//furi_hal_light_set(LightRed, 0xFF);
notification_message(plugin_state->notification, &sequence_blink_start_yellow);
const uint32_t timeout_ms = 2000;
// Pin 13 / TX -> Trig
furi_hal_gpio_write(&gpio_usart_tx, false);
furi_hal_gpio_init(&gpio_usart_tx, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
// Pin 14 / RX -> Echo
furi_hal_gpio_write(&gpio_usart_rx, false);
furi_hal_gpio_init(&gpio_usart_rx, GpioModeInput, GpioPullNo, GpioSpeedVeryHigh);
//FURI_CRITICAL_ENTER();
// 10 ms pulse on TX
furi_hal_gpio_write(&gpio_usart_tx, true);
furi_delay_ms(10);
furi_hal_gpio_write(&gpio_usart_tx, false);
// TODO change from furi_get_tick(), which returns ms,
// to DWT->CYCCNT, which is a more precise counter with
// us precision (see furi_hal_cortex_delay_us)
const uint32_t start = furi_get_tick();
while(furi_get_tick() - start < timeout_ms && furi_hal_gpio_read(&gpio_usart_rx))
;
while(furi_get_tick() - start < timeout_ms && !furi_hal_gpio_read(&gpio_usart_rx))
;
const uint32_t pulse_start = furi_get_tick();
while(furi_get_tick() - start < timeout_ms && furi_hal_gpio_read(&gpio_usart_rx))
;
const uint32_t pulse_end = furi_get_tick();
//FURI_CRITICAL_EXIT();
plugin_state->echo = pulse_end - pulse_start;
plugin_state->distance = hc_sr04_ms_to_m(pulse_end - pulse_start);
plugin_state->measurement_made = true;
//furi_hal_light_set(LightRed, 0x00);
notification_message(plugin_state->notification, &sequence_blink_stop);
notification_message(plugin_state->notification, &sequence_done);
}
int32_t hc_sr04_app() {
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
PluginState* plugin_state = malloc(sizeof(PluginState));
hc_sr04_state_init(plugin_state);
ValueMutex state_mutex;
if(!init_mutex(&state_mutex, plugin_state, sizeof(PluginState))) {
FURI_LOG_E("hc_sr04", "cannot create mutex\r\n");
if(furi_hal_power_is_otg_enabled()) {
furi_hal_power_disable_otg();
}
furi_hal_power_suppress_charge_exit();
furi_message_queue_free(event_queue);
free(plugin_state);
return 255;
}
plugin_state->notification = furi_record_open(RECORD_NOTIFICATION);
// Set system callbacks
ViewPort* view_port = view_port_alloc();
view_port_draw_callback_set(view_port, render_callback, &state_mutex);
view_port_input_callback_set(view_port, input_callback, event_queue);
// Open GUI and register view_port
Gui* gui = furi_record_open(RECORD_GUI);
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
PluginEvent event;
for(bool processing = true; processing;) {
FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);
PluginState* plugin_state = (PluginState*)acquire_mutex_block(&state_mutex);
if(event_status == FuriStatusOk) {
// press events
if(event.type == EventTypeKey) {
if(event.input.type == InputTypePress) {
switch(event.input.key) {
case InputKeyUp:
case InputKeyDown:
case InputKeyRight:
case InputKeyLeft:
break;
case InputKeyOk:
hc_sr04_measure(plugin_state);
break;
case InputKeyBack:
processing = false;
break;
}
}
}
}
view_port_update(view_port);
release_mutex(&state_mutex, plugin_state);
}
if(furi_hal_power_is_otg_enabled()) {
furi_hal_power_disable_otg();
}
furi_hal_power_suppress_charge_exit();
view_port_enabled_set(view_port, false);
gui_remove_view_port(gui, view_port);
furi_record_close(RECORD_GUI);
furi_record_close(RECORD_NOTIFICATION);
view_port_free(view_port);
furi_message_queue_free(event_queue);
delete_mutex(&state_mutex);
return 0;
}

View File

@@ -194,6 +194,7 @@ static void temperature_sensor_timer_callback(FuriMessageQueue* event_queue) {
int32_t temperature_sensor_app(void* p) { int32_t temperature_sensor_app(void* p) {
UNUSED(p); UNUSED(p);
furi_hal_power_suppress_charge_enter();
// Declare our variables // Declare our variables
TSEvent tsEvent; TSEvent tsEvent;
bool sensorFound = false; bool sensorFound = false;
@@ -264,6 +265,7 @@ int32_t temperature_sensor_app(void* p) {
furi_delay_tick(wait_ticks); furi_delay_tick(wait_ticks);
} }
furi_hal_power_suppress_charge_exit();
// Dobby is freee (free our variables, Flipper will crash if we don't do this!) // Dobby is freee (free our variables, Flipper will crash if we don't do this!)
furi_timer_free(timer); furi_timer_free(timer);
gui_remove_view_port(gui, view_port); gui_remove_view_port(gui, view_port);

View File

@@ -3,7 +3,7 @@
#include <furi.h> #include <furi.h>
#include <furi_hal.h> #include <furi_hal.h>
#define WS_VERSION_APP "0.2" #define WS_VERSION_APP "0.3"
#define WS_DEVELOPED "SkorP" #define WS_DEVELOPED "SkorP"
#define WS_GITHUB "https://github.com/flipperdevices/flipperzero-firmware" #define WS_GITHUB "https://github.com/flipperdevices/flipperzero-firmware"

View File

@@ -0,0 +1,307 @@
#include "acurite_592txr.h"
#define TAG "WSProtocolAcurite_592TXR"
/*
* Help
* https://github.com/merbanan/rtl_433/blob/5bef4e43133ac4c0e2d18d36f87c52b4f9458453/src/devices/acurite.c
*
* Acurite 592TXR Temperature Humidity sensor decoder
* Message Type 0x04, 7 bytes
* | Byte 0 | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 | Byte 6 |
* | --------- | --------- | --------- | --------- | --------- | --------- | --------- |
* | CCII IIII | IIII IIII | pB00 0100 | pHHH HHHH | p??T TTTT | pTTT TTTT | KKKK KKKK |
* - C: Channel 00: C, 10: B, 11: A, (01 is invalid)
* - I: Device ID (14 bits)
* - B: Battery, 1 is battery OK, 0 is battery low
* - M: Message type (6 bits), 0x04
* - T: Temperature Celsius (11 - 14 bits?), + 1000 * 10
* - H: Relative Humidity (%) (7 bits)
* - K: Checksum (8 bits)
* - p: Parity bit
* Notes:
* - Temperature
* - Encoded as Celsius + 1000 * 10
* - only 11 bits needed for specified range -40 C to 70 C (-40 F - 158 F)
* - However 14 bits available for temperature, giving possible range of -100 C to 1538.4 C
* - @todo - check if high 3 bits ever used for anything else
*
*/
static const SubGhzBlockConst ws_protocol_acurite_592txr_const = {
.te_short = 200,
.te_long = 400,
.te_delta = 90,
.min_count_bit_for_found = 56,
};
struct WSProtocolDecoderAcurite_592TXR {
SubGhzProtocolDecoderBase base;
SubGhzBlockDecoder decoder;
WSBlockGeneric generic;
uint16_t header_count;
};
struct WSProtocolEncoderAcurite_592TXR {
SubGhzProtocolEncoderBase base;
SubGhzProtocolBlockEncoder encoder;
WSBlockGeneric generic;
};
typedef enum {
Acurite_592TXRDecoderStepReset = 0,
Acurite_592TXRDecoderStepCheckPreambule,
Acurite_592TXRDecoderStepSaveDuration,
Acurite_592TXRDecoderStepCheckDuration,
} Acurite_592TXRDecoderStep;
const SubGhzProtocolDecoder ws_protocol_acurite_592txr_decoder = {
.alloc = ws_protocol_decoder_acurite_592txr_alloc,
.free = ws_protocol_decoder_acurite_592txr_free,
.feed = ws_protocol_decoder_acurite_592txr_feed,
.reset = ws_protocol_decoder_acurite_592txr_reset,
.get_hash_data = ws_protocol_decoder_acurite_592txr_get_hash_data,
.serialize = ws_protocol_decoder_acurite_592txr_serialize,
.deserialize = ws_protocol_decoder_acurite_592txr_deserialize,
.get_string = ws_protocol_decoder_acurite_592txr_get_string,
};
const SubGhzProtocolEncoder ws_protocol_acurite_592txr_encoder = {
.alloc = NULL,
.free = NULL,
.deserialize = NULL,
.stop = NULL,
.yield = NULL,
};
const SubGhzProtocol ws_protocol_acurite_592txr = {
.name = WS_PROTOCOL_ACURITE_592TXR_NAME,
.type = SubGhzProtocolWeatherStation,
.flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 |
SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable,
.decoder = &ws_protocol_acurite_592txr_decoder,
.encoder = &ws_protocol_acurite_592txr_encoder,
};
void* ws_protocol_decoder_acurite_592txr_alloc(SubGhzEnvironment* environment) {
UNUSED(environment);
WSProtocolDecoderAcurite_592TXR* instance = malloc(sizeof(WSProtocolDecoderAcurite_592TXR));
instance->base.protocol = &ws_protocol_acurite_592txr;
instance->generic.protocol_name = instance->base.protocol->name;
return instance;
}
void ws_protocol_decoder_acurite_592txr_free(void* context) {
furi_assert(context);
WSProtocolDecoderAcurite_592TXR* instance = context;
free(instance);
}
void ws_protocol_decoder_acurite_592txr_reset(void* context) {
furi_assert(context);
WSProtocolDecoderAcurite_592TXR* instance = context;
instance->decoder.parser_step = Acurite_592TXRDecoderStepReset;
}
static bool ws_protocol_acurite_592txr_check_crc(WSProtocolDecoderAcurite_592TXR* instance) {
uint8_t msg[] = {
instance->decoder.decode_data >> 48,
instance->decoder.decode_data >> 40,
instance->decoder.decode_data >> 32,
instance->decoder.decode_data >> 24,
instance->decoder.decode_data >> 16,
instance->decoder.decode_data >> 8};
if((subghz_protocol_blocks_add_bytes(msg, 6) ==
(uint8_t)(instance->decoder.decode_data & 0xFF)) &&
(!subghz_protocol_blocks_parity_bytes(&msg[2], 4))) {
return true;
} else {
return false;
}
}
/**
* Analysis of received data
* @param instance Pointer to a WSBlockGeneric* instance
*/
static void ws_protocol_acurite_592txr_remote_controller(WSBlockGeneric* instance) {
uint8_t channel[] = {3, 0, 2, 1};
uint8_t channel_raw = ((instance->data >> 54) & 0x03);
instance->channel = channel[channel_raw];
instance->id = (instance->data >> 40) & 0x3FFF;
instance->battery_low = !((instance->data >> 38) & 1);
instance->humidity = (instance->data >> 24) & 0x7F;
uint16_t temp_raw = ((instance->data >> 9) & 0xF80) | ((instance->data >> 8) & 0x7F);
instance->temp = ((float)(temp_raw)-1000) / 10.0f;
instance->btn = WS_NO_BTN;
}
void ws_protocol_decoder_acurite_592txr_feed(void* context, bool level, uint32_t duration) {
furi_assert(context);
WSProtocolDecoderAcurite_592TXR* instance = context;
switch(instance->decoder.parser_step) {
case Acurite_592TXRDecoderStepReset:
if((level) && (DURATION_DIFF(duration, ws_protocol_acurite_592txr_const.te_short * 3) <
ws_protocol_acurite_592txr_const.te_delta * 2)) {
instance->decoder.parser_step = Acurite_592TXRDecoderStepCheckPreambule;
instance->decoder.te_last = duration;
instance->header_count = 0;
}
break;
case Acurite_592TXRDecoderStepCheckPreambule:
if(level) {
instance->decoder.te_last = duration;
} else {
if((DURATION_DIFF(
instance->decoder.te_last, ws_protocol_acurite_592txr_const.te_short * 3) <
ws_protocol_acurite_592txr_const.te_delta * 2) &&
(DURATION_DIFF(duration, ws_protocol_acurite_592txr_const.te_short * 3) <
ws_protocol_acurite_592txr_const.te_delta * 2)) {
//Found preambule
instance->header_count++;
} else if((instance->header_count > 2) && (instance->header_count < 5)) {
if((DURATION_DIFF(
instance->decoder.te_last, ws_protocol_acurite_592txr_const.te_short) <
ws_protocol_acurite_592txr_const.te_delta) &&
(DURATION_DIFF(duration, ws_protocol_acurite_592txr_const.te_long) <
ws_protocol_acurite_592txr_const.te_delta)) {
instance->decoder.decode_data = 0;
instance->decoder.decode_count_bit = 0;
subghz_protocol_blocks_add_bit(&instance->decoder, 0);
instance->decoder.parser_step = Acurite_592TXRDecoderStepSaveDuration;
} else if(
(DURATION_DIFF(
instance->decoder.te_last, ws_protocol_acurite_592txr_const.te_long) <
ws_protocol_acurite_592txr_const.te_delta) &&
(DURATION_DIFF(duration, ws_protocol_acurite_592txr_const.te_short) <
ws_protocol_acurite_592txr_const.te_delta)) {
instance->decoder.decode_data = 0;
instance->decoder.decode_count_bit = 0;
subghz_protocol_blocks_add_bit(&instance->decoder, 1);
instance->decoder.parser_step = Acurite_592TXRDecoderStepSaveDuration;
} else {
instance->decoder.parser_step = Acurite_592TXRDecoderStepReset;
}
} else {
instance->decoder.parser_step = Acurite_592TXRDecoderStepReset;
}
}
break;
case Acurite_592TXRDecoderStepSaveDuration:
if(level) {
instance->decoder.te_last = duration;
instance->decoder.parser_step = Acurite_592TXRDecoderStepCheckDuration;
} else {
instance->decoder.parser_step = Acurite_592TXRDecoderStepReset;
}
break;
case Acurite_592TXRDecoderStepCheckDuration:
if(!level) {
if(duration >= ((uint32_t)ws_protocol_acurite_592txr_const.te_short * 5)) {
if((instance->decoder.decode_count_bit ==
ws_protocol_acurite_592txr_const.min_count_bit_for_found) &&
ws_protocol_acurite_592txr_check_crc(instance)) {
instance->generic.data = instance->decoder.decode_data;
instance->generic.data_count_bit = instance->decoder.decode_count_bit;
ws_protocol_acurite_592txr_remote_controller(&instance->generic);
if(instance->base.callback)
instance->base.callback(&instance->base, instance->base.context);
}
instance->decoder.decode_data = 0;
instance->decoder.decode_count_bit = 0;
instance->decoder.parser_step = Acurite_592TXRDecoderStepReset;
break;
} else if(
(DURATION_DIFF(
instance->decoder.te_last, ws_protocol_acurite_592txr_const.te_short) <
ws_protocol_acurite_592txr_const.te_delta) &&
(DURATION_DIFF(duration, ws_protocol_acurite_592txr_const.te_long) <
ws_protocol_acurite_592txr_const.te_delta)) {
subghz_protocol_blocks_add_bit(&instance->decoder, 0);
instance->decoder.parser_step = Acurite_592TXRDecoderStepSaveDuration;
} else if(
(DURATION_DIFF(
instance->decoder.te_last, ws_protocol_acurite_592txr_const.te_long) <
ws_protocol_acurite_592txr_const.te_delta) &&
(DURATION_DIFF(duration, ws_protocol_acurite_592txr_const.te_short) <
ws_protocol_acurite_592txr_const.te_delta)) {
subghz_protocol_blocks_add_bit(&instance->decoder, 1);
instance->decoder.parser_step = Acurite_592TXRDecoderStepSaveDuration;
} else {
instance->decoder.parser_step = Acurite_592TXRDecoderStepReset;
}
} else {
instance->decoder.parser_step = Acurite_592TXRDecoderStepReset;
}
break;
}
}
uint8_t ws_protocol_decoder_acurite_592txr_get_hash_data(void* context) {
furi_assert(context);
WSProtocolDecoderAcurite_592TXR* instance = context;
return subghz_protocol_blocks_get_hash_data(
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
}
bool ws_protocol_decoder_acurite_592txr_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset) {
furi_assert(context);
WSProtocolDecoderAcurite_592TXR* instance = context;
return ws_block_generic_serialize(&instance->generic, flipper_format, preset);
}
bool ws_protocol_decoder_acurite_592txr_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
WSProtocolDecoderAcurite_592TXR* instance = context;
bool ret = false;
do {
if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) {
break;
}
if(instance->generic.data_count_bit !=
ws_protocol_acurite_592txr_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
ret = true;
} while(false);
return ret;
}
void ws_protocol_decoder_acurite_592txr_get_string(void* context, FuriString* output) {
furi_assert(context);
WSProtocolDecoderAcurite_592TXR* instance = context;
furi_string_printf(
output,
"%s %dbit\r\n"
"Key:0x%lX%08lX\r\n"
"Sn:0x%lX Ch:%d Bat:%d\r\n"
"Temp:%d.%d C Hum:%d%%",
instance->generic.protocol_name,
instance->generic.data_count_bit,
(uint32_t)(instance->generic.data >> 32),
(uint32_t)(instance->generic.data),
instance->generic.id,
instance->generic.channel,
instance->generic.battery_low,
(int16_t)instance->generic.temp,
abs(((int16_t)(instance->generic.temp * 10) - (((int16_t)instance->generic.temp) * 10))),
instance->generic.humidity);
}

View File

@@ -0,0 +1,79 @@
#pragma once
#include <lib/subghz/protocols/base.h>
#include <lib/subghz/blocks/const.h>
#include <lib/subghz/blocks/decoder.h>
#include <lib/subghz/blocks/encoder.h>
#include "ws_generic.h"
#include <lib/subghz/blocks/math.h>
#define WS_PROTOCOL_ACURITE_592TXR_NAME "Acurite 592TXR"
typedef struct WSProtocolDecoderAcurite_592TXR WSProtocolDecoderAcurite_592TXR;
typedef struct WSProtocolEncoderAcurite_592TXR WSProtocolEncoderAcurite_592TXR;
extern const SubGhzProtocolDecoder ws_protocol_acurite_592txr_decoder;
extern const SubGhzProtocolEncoder ws_protocol_acurite_592txr_encoder;
extern const SubGhzProtocol ws_protocol_acurite_592txr;
/**
* Allocate WSProtocolDecoderAcurite_592TXR.
* @param environment Pointer to a SubGhzEnvironment instance
* @return WSProtocolDecoderAcurite_592TXR* pointer to a WSProtocolDecoderAcurite_592TXR instance
*/
void* ws_protocol_decoder_acurite_592txr_alloc(SubGhzEnvironment* environment);
/**
* Free WSProtocolDecoderAcurite_592TXR.
* @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance
*/
void ws_protocol_decoder_acurite_592txr_free(void* context);
/**
* Reset decoder WSProtocolDecoderAcurite_592TXR.
* @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance
*/
void ws_protocol_decoder_acurite_592txr_reset(void* context);
/**
* Parse a raw sequence of levels and durations received from the air.
* @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance
* @param level Signal level true-high false-low
* @param duration Duration of this level in, us
*/
void ws_protocol_decoder_acurite_592txr_feed(void* context, bool level, uint32_t duration);
/**
* Getting the hash sum of the last randomly received parcel.
* @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance
* @return hash Hash sum
*/
uint8_t ws_protocol_decoder_acurite_592txr_get_hash_data(void* context);
/**
* Serialize data WSProtocolDecoderAcurite_592TXR.
* @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance
* @param flipper_format Pointer to a FlipperFormat instance
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
* @return true On success
*/
bool ws_protocol_decoder_acurite_592txr_serialize(
void* context,
FlipperFormat* flipper_format,
SubGhzRadioPreset* preset);
/**
* Deserialize data WSProtocolDecoderAcurite_592TXR.
* @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance
* @param flipper_format Pointer to a FlipperFormat instance
* @return true On success
*/
bool ws_protocol_decoder_acurite_592txr_deserialize(void* context, FlipperFormat* flipper_format);
/**
* Getting a textual representation of the received data.
* @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance
* @param output Resulting text
*/
void ws_protocol_decoder_acurite_592txr_get_string(void* context, FuriString* output);

View File

@@ -8,6 +8,7 @@ const SubGhzProtocol* weather_station_protocol_registry_items[] = {
&ws_protocol_acurite_606tx, &ws_protocol_acurite_606tx,
&ws_protocol_lacrosse_tx141thbv2, &ws_protocol_lacrosse_tx141thbv2,
&ws_protocol_oregon2, &ws_protocol_oregon2,
&ws_protocol_acurite_592txr,
}; };
const SubGhzProtocolRegistry weather_station_protocol_registry = { const SubGhzProtocolRegistry weather_station_protocol_registry = {

View File

@@ -8,5 +8,6 @@
#include "acurite_606tx.h" #include "acurite_606tx.h"
#include "lacrosse_tx141thbv2.h" #include "lacrosse_tx141thbv2.h"
#include "oregon2.h" #include "oregon2.h"
#include "acurite_592txr.h"
extern const SubGhzProtocolRegistry weather_station_protocol_registry; extern const SubGhzProtocolRegistry weather_station_protocol_registry;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,14 @@
Filetype: Flipper Animation
Version: 1
Width: 128
Height: 64
Passive frames: 4
Active frames: 0
Frames order: 0 1 2 3
Active cycles: 0
Frame rate: 3
Duration: 3600
Active cooldown: 0
Bubble slots: 0

View File

@@ -1,6 +1,13 @@
Filetype: Flipper Animation Manifest Filetype: Flipper Animation Manifest
Version: 1 Version: 1
Name: L1_Halloween_128x64
Min butthurt: 0
Max butthurt: 13
Min level: 1
Max level: 30
Weight: 3
Name: L1_Waves_128x50 Name: L1_Waves_128x50
Min butthurt: 0 Min butthurt: 0
Max butthurt: 5 Max butthurt: 5

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

After

Width:  |  Height:  |  Size: 447 B

View File

@@ -0,0 +1,14 @@
Filetype: Flipper Animation
Version: 1
Width: 128
Height: 64
Passive frames: 4
Active frames: 0
Frames order: 0 1 2 3
Active cycles: 0
Frame rate: 3
Duration: 3600
Active cooldown: 0
Bubble slots: 0

View File

@@ -455,3 +455,10 @@ Max butthurt: 14
Min level: 1 Min level: 1
Max level: 30 Max level: 30
Weight: 3 Weight: 3
Name: L1_Halloween_128x64
Min butthurt: 0
Max butthurt: 13
Min level: 1
Max level: 3
Weight: 8

View File

@@ -1,5 +1,5 @@
entry,status,name,type,params entry,status,name,type,params
Version,+,5.1,, Version,+,6.1,,
Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/cli/cli.h,, Header,+,applications/services/cli/cli.h,,
Header,+,applications/services/cli/cli_vcp.h,, Header,+,applications/services/cli/cli_vcp.h,,
@@ -2331,6 +2331,7 @@ Function,-,subghz_keystore_raw_encrypted_save,_Bool,"const char*, const char*, u
Function,-,subghz_keystore_raw_get_data,_Bool,"const char*, size_t, uint8_t*, size_t" Function,-,subghz_keystore_raw_get_data,_Bool,"const char*, size_t, uint8_t*, size_t"
Function,-,subghz_keystore_save,_Bool,"SubGhzKeystore*, const char*, uint8_t*" Function,-,subghz_keystore_save,_Bool,"SubGhzKeystore*, const char*, uint8_t*"
Function,+,subghz_protocol_blocks_add_bit,void,"SubGhzBlockDecoder*, uint8_t" Function,+,subghz_protocol_blocks_add_bit,void,"SubGhzBlockDecoder*, uint8_t"
Function,+,subghz_protocol_blocks_add_bytes,uint8_t,"const uint8_t[], unsigned"
Function,+,subghz_protocol_blocks_crc16,uint16_t,"const uint8_t[], unsigned, uint16_t, uint16_t" Function,+,subghz_protocol_blocks_crc16,uint16_t,"const uint8_t[], unsigned, uint16_t, uint16_t"
Function,+,subghz_protocol_blocks_crc16lsb,uint16_t,"const uint8_t[], unsigned, uint16_t, uint16_t" Function,+,subghz_protocol_blocks_crc16lsb,uint16_t,"const uint8_t[], unsigned, uint16_t, uint16_t"
Function,+,subghz_protocol_blocks_crc4,uint8_t,"const uint8_t[], unsigned, uint8_t, uint8_t" Function,+,subghz_protocol_blocks_crc4,uint8_t,"const uint8_t[], unsigned, uint8_t, uint8_t"
@@ -2344,8 +2345,11 @@ Function,+,subghz_protocol_blocks_get_upload,size_t,"uint8_t[], size_t, LevelDur
Function,+,subghz_protocol_blocks_lfsr_digest16,uint16_t,"const uint8_t[], unsigned, uint16_t, uint16_t" Function,+,subghz_protocol_blocks_lfsr_digest16,uint16_t,"const uint8_t[], unsigned, uint16_t, uint16_t"
Function,+,subghz_protocol_blocks_lfsr_digest8,uint8_t,"const uint8_t[], unsigned, uint8_t, uint8_t" Function,+,subghz_protocol_blocks_lfsr_digest8,uint8_t,"const uint8_t[], unsigned, uint8_t, uint8_t"
Function,+,subghz_protocol_blocks_lfsr_digest8_reflect,uint8_t,"const uint8_t[], int, uint8_t, uint8_t" Function,+,subghz_protocol_blocks_lfsr_digest8_reflect,uint8_t,"const uint8_t[], int, uint8_t, uint8_t"
Function,+,subghz_protocol_blocks_parity8,int,uint8_t
Function,+,subghz_protocol_blocks_parity_bytes,int,"const uint8_t[], unsigned"
Function,+,subghz_protocol_blocks_reverse_key,uint64_t,"uint64_t, uint8_t" Function,+,subghz_protocol_blocks_reverse_key,uint64_t,"uint64_t, uint8_t"
Function,+,subghz_protocol_blocks_set_bit_array,void,"_Bool, uint8_t[], size_t, size_t" Function,+,subghz_protocol_blocks_set_bit_array,void,"_Bool, uint8_t[], size_t, size_t"
Function,+,subghz_protocol_blocks_xor_bytes,uint8_t,"const uint8_t[], unsigned"
Function,+,subghz_protocol_decoder_base_deserialize,_Bool,"SubGhzProtocolDecoderBase*, FlipperFormat*" Function,+,subghz_protocol_decoder_base_deserialize,_Bool,"SubGhzProtocolDecoderBase*, FlipperFormat*"
Function,+,subghz_protocol_decoder_base_get_hash_data,uint8_t,SubGhzProtocolDecoderBase* Function,+,subghz_protocol_decoder_base_get_hash_data,uint8_t,SubGhzProtocolDecoderBase*
Function,+,subghz_protocol_decoder_base_get_string,_Bool,"SubGhzProtocolDecoderBase*, FuriString*" Function,+,subghz_protocol_decoder_base_get_string,_Bool,"SubGhzProtocolDecoderBase*, FuriString*"
@@ -4742,7 +4746,6 @@ Variable,-,subghz_protocol_nice_flo_encoder,const SubGhzProtocolEncoder,
Variable,-,subghz_protocol_nice_flor_s,const SubGhzProtocol, Variable,-,subghz_protocol_nice_flor_s,const SubGhzProtocol,
Variable,-,subghz_protocol_nice_flor_s_decoder,const SubGhzProtocolDecoder, Variable,-,subghz_protocol_nice_flor_s_decoder,const SubGhzProtocolDecoder,
Variable,-,subghz_protocol_nice_flor_s_encoder,const SubGhzProtocolEncoder, Variable,-,subghz_protocol_nice_flor_s_encoder,const SubGhzProtocolEncoder,
Variable,-,subghz_protocol_oregon2,const SubGhzProtocol,
Variable,-,subghz_protocol_phoenix_v2,const SubGhzProtocol, Variable,-,subghz_protocol_phoenix_v2,const SubGhzProtocol,
Variable,-,subghz_protocol_phoenix_v2_decoder,const SubGhzProtocolDecoder, Variable,-,subghz_protocol_phoenix_v2_decoder,const SubGhzProtocolDecoder,
Variable,-,subghz_protocol_phoenix_v2_encoder,const SubGhzProtocolEncoder, Variable,-,subghz_protocol_phoenix_v2_encoder,const SubGhzProtocolEncoder,
1 entry status name type params
2 Version + 5.1 6.1
3 Header + applications/services/bt/bt_service/bt.h
4 Header + applications/services/cli/cli.h
5 Header + applications/services/cli/cli_vcp.h
2331 Function - subghz_keystore_raw_get_data _Bool const char*, size_t, uint8_t*, size_t
2332 Function - subghz_keystore_save _Bool SubGhzKeystore*, const char*, uint8_t*
2333 Function + subghz_protocol_blocks_add_bit void SubGhzBlockDecoder*, uint8_t
2334 Function + subghz_protocol_blocks_add_bytes uint8_t const uint8_t[], unsigned
2335 Function + subghz_protocol_blocks_crc16 uint16_t const uint8_t[], unsigned, uint16_t, uint16_t
2336 Function + subghz_protocol_blocks_crc16lsb uint16_t const uint8_t[], unsigned, uint16_t, uint16_t
2337 Function + subghz_protocol_blocks_crc4 uint8_t const uint8_t[], unsigned, uint8_t, uint8_t
2345 Function + subghz_protocol_blocks_lfsr_digest16 uint16_t const uint8_t[], unsigned, uint16_t, uint16_t
2346 Function + subghz_protocol_blocks_lfsr_digest8 uint8_t const uint8_t[], unsigned, uint8_t, uint8_t
2347 Function + subghz_protocol_blocks_lfsr_digest8_reflect uint8_t const uint8_t[], int, uint8_t, uint8_t
2348 Function + subghz_protocol_blocks_parity8 int uint8_t
2349 Function + subghz_protocol_blocks_parity_bytes int const uint8_t[], unsigned
2350 Function + subghz_protocol_blocks_reverse_key uint64_t uint64_t, uint8_t
2351 Function + subghz_protocol_blocks_set_bit_array void _Bool, uint8_t[], size_t, size_t
2352 Function + subghz_protocol_blocks_xor_bytes uint8_t const uint8_t[], unsigned
2353 Function + subghz_protocol_decoder_base_deserialize _Bool SubGhzProtocolDecoderBase*, FlipperFormat*
2354 Function + subghz_protocol_decoder_base_get_hash_data uint8_t SubGhzProtocolDecoderBase*
2355 Function + subghz_protocol_decoder_base_get_string _Bool SubGhzProtocolDecoderBase*, FuriString*
4746 Variable - subghz_protocol_nice_flor_s const SubGhzProtocol
4747 Variable - subghz_protocol_nice_flor_s_decoder const SubGhzProtocolDecoder
4748 Variable - subghz_protocol_nice_flor_s_encoder const SubGhzProtocolEncoder
Variable - subghz_protocol_oregon2 const SubGhzProtocol
4749 Variable - subghz_protocol_phoenix_v2 const SubGhzProtocol
4750 Variable - subghz_protocol_phoenix_v2_decoder const SubGhzProtocolDecoder
4751 Variable - subghz_protocol_phoenix_v2_encoder const SubGhzProtocolEncoder

View File

@@ -216,4 +216,34 @@ uint16_t subghz_protocol_blocks_lfsr_digest16(
} }
} }
return sum; return sum;
}
uint8_t subghz_protocol_blocks_add_bytes(uint8_t const message[], unsigned num_bytes) {
int result = 0;
for(unsigned i = 0; i < num_bytes; ++i) {
result += message[i];
}
return (uint8_t)result;
}
int subghz_protocol_blocks_parity8(uint8_t byte) {
byte ^= byte >> 4;
byte &= 0xf;
return (0x6996 >> byte) & 1;
}
int subghz_protocol_blocks_parity_bytes(uint8_t const message[], unsigned num_bytes) {
int result = 0;
for(unsigned i = 0; i < num_bytes; ++i) {
result ^= subghz_protocol_blocks_parity8(message[i]);
}
return result;
}
uint8_t subghz_protocol_blocks_xor_bytes(uint8_t const message[], unsigned num_bytes) {
uint8_t result = 0;
for(unsigned i = 0; i < num_bytes; ++i) {
result ^= message[i];
}
return result;
} }

View File

@@ -161,6 +161,37 @@ uint16_t subghz_protocol_blocks_lfsr_digest16(
uint16_t gen, uint16_t gen,
uint16_t key); uint16_t key);
/**
* Compute Addition of a number of bytes.
* @param message bytes of message data
* @param num_bytes number of bytes to sum
* @return summation value
**/
uint8_t subghz_protocol_blocks_add_bytes(uint8_t const message[], unsigned num_bytes);
/**
* Compute bit parity of a single byte (8 bits).
* @param byte single byte to check
* @return 1 odd parity, 0 even parity
**/
int subghz_protocol_blocks_parity8(uint8_t byte);
/**
* Compute bit parity of a number of bytes.
* @param message bytes of message data
* @param num_bytes number of bytes to sum
* @return 1 odd parity, 0 even parity
**/
int subghz_protocol_blocks_parity_bytes(uint8_t const message[], unsigned num_bytes);
/**
* Compute XOR (byte-wide parity) of a number of bytes.
* @param message bytes of message data
* @param num_bytes number of bytes to sum
* @return summation value, per bit-position 1 odd parity, 0 even parity
**/
uint8_t subghz_protocol_blocks_xor_bytes(uint8_t const message[], unsigned num_bytes);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif