Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FL-2904, FL-2900, FL-2890] WS: add app WeatherStation #1833

Merged
merged 35 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
84cac29
WeatherStation: start
Skorpionm Oct 5, 2022
bd7798f
SubGhz: rename protocol magellen -> magellan
Skorpionm Oct 6, 2022
b2e150d
WeatherStation: err Unresolved symbols: {'subghz_protocol_decoder_bas…
Skorpionm Oct 6, 2022
94be1bf
WeatherStation: fix Unresolved symbols: {'subghz_protocol_decoder_bas…
Skorpionm Oct 6, 2022
d8e4f02
Subghz: add set protocol_items
Skorpionm Oct 6, 2022
f8a7409
WeatherStation: adding your protocols
Skorpionm Oct 6, 2022
1df29b7
WS: add Infactory protocol
Skorpionm Oct 9, 2022
9d5b817
WS: add history
Skorpionm Oct 10, 2022
046f8ef
WS: add setting
Skorpionm Oct 11, 2022
53ac3b6
WS: add lock
Skorpionm Oct 11, 2022
d5e988b
WS: add hopper frequency
Skorpionm Oct 11, 2022
7c96bbb
WS: fix history
Skorpionm Oct 11, 2022
bd6a2fc
Merge remote-tracking branch 'origin/dev' into skorp/weather_station
Skorpionm Oct 11, 2022
01c1b10
WS fix string_t -> FuriString*
Skorpionm Oct 11, 2022
2dd45ba
WS: add images
Skorpionm Oct 11, 2022
f66f1db
WS: history record update when receiving data from the sensor again
Skorpionm Oct 11, 2022
3fb25d2
WS: fix syntax
Skorpionm Oct 11, 2022
a87d4c8
WS: fix syntax
Skorpionm Oct 11, 2022
fcd5432
WS: add receiver info, delete extra code
Skorpionm Oct 12, 2022
fa3a55a
WS: add protocol ThermoPRO_TX4
Skorpionm Oct 13, 2022
2578041
[FL-2900] SubGhz: Move icons in Sub-GHz
Skorpionm Oct 13, 2022
c6293b2
WS: add Notification
Skorpionm Oct 13, 2022
68e80a6
[FL-2890] SubGhz: Rename *_user files in resources to _user.example
Skorpionm Oct 13, 2022
d374a53
WS: add about scene
Skorpionm Oct 15, 2022
8d74b7b
WS: removing redundant code
Skorpionm Oct 15, 2022
1fbc924
WS: fix syntax
Skorpionm Oct 15, 2022
e02a0af
WS: add protocol Nexus-TH
Skorpionm Oct 16, 2022
7fa0a36
WS: add protocol GT_WT03
Skorpionm Oct 18, 2022
f8c88e8
WS: fix notification and rename "Weather Station" -> "Read Weather St…
Skorpionm Oct 18, 2022
1623ac1
Merge remote-tracking branch 'origin/dev' into skorp/weather_station
skotopes Oct 18, 2022
f146207
SubGhz: partial unit tests fix
skotopes Oct 18, 2022
35bd9de
SubGhz: fix unit_test
Skorpionm Oct 18, 2022
313aa93
Merge remote-tracking branch 'origin/dev' into skorp/weather_station
skotopes Oct 19, 2022
a693a28
SubGhz: remove dead code
skotopes Oct 19, 2022
f695e30
SubGhz: rename SubGhzPresetDefinition into SubGhzRadioPreset, cleanup…
skotopes Oct 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions applications/debug/unit_tests/subghz/subghz_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <lib/subghz/transmitter.h>
#include <lib/subghz/subghz_keystore.h>
#include <lib/subghz/subghz_file_encoder_worker.h>
#include <lib/subghz/protocols/registry.h>
#include <lib/subghz/protocols/protocol_items.h>
#include <flipper_format/flipper_format_i.h>

#define TAG "SubGhz TEST"
Expand Down Expand Up @@ -43,6 +43,8 @@ static void subghz_test_init(void) {
environment_handler, CAME_ATOMO_DIR_NAME);
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
environment_handler, NICE_FLOR_S_DIR_NAME);
subghz_environment_set_protocol_registry(
environment_handler, (void*)&subghz_protocol_registry);

receiver_handler = subghz_receiver_alloc_init(environment_handler);
subghz_receiver_set_filter(receiver_handler, SubGhzProtocolFlag_Decodable);
Expand Down Expand Up @@ -413,11 +415,11 @@ MU_TEST(subghz_decoder_honeywell_wdb_test) {
"Test decoder " SUBGHZ_PROTOCOL_HONEYWELL_WDB_NAME " error\r\n");
}

MU_TEST(subghz_decoder_magellen_test) {
MU_TEST(subghz_decoder_magellan_test) {
mu_assert(
subghz_decoder_test(
EXT_PATH("unit_tests/subghz/magellen_raw.sub"), SUBGHZ_PROTOCOL_MAGELLEN_NAME),
"Test decoder " SUBGHZ_PROTOCOL_MAGELLEN_NAME " error\r\n");
EXT_PATH("unit_tests/subghz/magellan_raw.sub"), SUBGHZ_PROTOCOL_MAGELLAN_NAME),
"Test decoder " SUBGHZ_PROTOCOL_MAGELLAN_NAME " error\r\n");
}

MU_TEST(subghz_decoder_intertechno_v3_test) {
Expand Down Expand Up @@ -545,10 +547,10 @@ MU_TEST(subghz_encoder_honeywell_wdb_test) {
"Test encoder " SUBGHZ_PROTOCOL_HONEYWELL_WDB_NAME " error\r\n");
}

MU_TEST(subghz_encoder_magellen_test) {
MU_TEST(subghz_encoder_magellan_test) {
mu_assert(
subghz_encoder_test(EXT_PATH("unit_tests/subghz/magellen.sub")),
"Test encoder " SUBGHZ_PROTOCOL_MAGELLEN_NAME " error\r\n");
subghz_encoder_test(EXT_PATH("unit_tests/subghz/magellan.sub")),
"Test encoder " SUBGHZ_PROTOCOL_MAGELLAN_NAME " error\r\n");
}

MU_TEST(subghz_encoder_intertechno_v3_test) {
Expand Down Expand Up @@ -600,7 +602,7 @@ MU_TEST_SUITE(subghz) {
MU_RUN_TEST(subghz_decoder_doitrand_test);
MU_RUN_TEST(subghz_decoder_phoenix_v2_test);
MU_RUN_TEST(subghz_decoder_honeywell_wdb_test);
MU_RUN_TEST(subghz_decoder_magellen_test);
MU_RUN_TEST(subghz_decoder_magellan_test);
MU_RUN_TEST(subghz_decoder_intertechno_v3_test);
MU_RUN_TEST(subghz_decoder_clemsa_test);
MU_RUN_TEST(subghz_decoder_oregon2_test);
Expand All @@ -622,7 +624,7 @@ MU_TEST_SUITE(subghz) {
MU_RUN_TEST(subghz_encoder_doitrand_test);
MU_RUN_TEST(subghz_encoder_phoenix_v2_test);
MU_RUN_TEST(subghz_encoder_honeywell_wdb_test);
MU_RUN_TEST(subghz_encoder_magellen_test);
MU_RUN_TEST(subghz_encoder_magellan_test);
MU_RUN_TEST(subghz_encoder_intertechno_v3_test);
MU_RUN_TEST(subghz_encoder_clemsa_test);

Expand Down
2 changes: 1 addition & 1 deletion applications/main/lfrfid/scenes/lfrfid_scene_raw_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void lfrfid_scene_raw_info_on_enter(void* context) {
}

view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewWidget);
//string_clear(tmp_string);
//furi_string_free(tmp_string);
}

bool lfrfid_scene_raw_info_on_event(void* context, SceneManagerEvent event) {
Expand Down
9 changes: 0 additions & 9 deletions applications/main/subghz/helpers/subghz_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,3 @@ typedef enum {
SubGhzViewIdTestCarrier,
SubGhzViewIdTestPacket,
} SubGhzViewId;

struct SubGhzPresetDefinition {
FuriString* name;
uint32_t frequency;
uint8_t* data;
size_t data_size;
};

typedef struct SubGhzPresetDefinition SubGhzPresetDefinition;
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ static bool subghz_scene_receiver_info_update_parser(void* context) {
subghz->txrx->decoder_result,
subghz_history_get_raw_data(subghz->txrx->history, subghz->txrx->idx_menu_chosen));

SubGhzPresetDefinition* preset =
subghz_history_get_preset_def(subghz->txrx->history, subghz->txrx->idx_menu_chosen);
SubGhzRadioPreset* preset =
subghz_history_get_radio_preset(subghz->txrx->history, subghz->txrx->idx_menu_chosen);
subghz_preset_init(
subghz,
furi_string_get_cstr(preset->name),
Expand Down
2 changes: 1 addition & 1 deletion applications/main/subghz/scenes/subghz_scene_set_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <dolphin/dolphin.h>
#include <flipper_format/flipper_format_i.h>
#include <lib/toolbox/stream/stream.h>
#include <lib/subghz/protocols/registry.h>
#include <lib/subghz/protocols/protocol_items.h>

#define TAG "SubGhzSetType"

Expand Down
5 changes: 4 additions & 1 deletion applications/main/subghz/subghz.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "subghz/types.h"
#include "subghz_i.h"
#include <lib/toolbox/path.h>
#include <lib/subghz/protocols/protocol_items.h>

bool subghz_custom_event_callback(void* context, uint32_t event) {
furi_assert(context);
Expand Down Expand Up @@ -169,7 +170,7 @@ SubGhz* subghz_alloc() {
//init Worker & Protocol & History & KeyBoard
subghz->lock = SubGhzLockOff;
subghz->txrx = malloc(sizeof(SubGhzTxRx));
subghz->txrx->preset = malloc(sizeof(SubGhzPresetDefinition));
subghz->txrx->preset = malloc(sizeof(SubGhzRadioPreset));
subghz->txrx->preset->name = furi_string_alloc();
subghz_preset_init(
subghz, "AM650", subghz_setting_get_default_frequency(subghz->setting), NULL, 0);
Expand All @@ -186,6 +187,8 @@ SubGhz* subghz_alloc() {
subghz->txrx->environment, EXT_PATH("subghz/assets/came_atomo"));
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
subghz->txrx->environment, EXT_PATH("subghz/assets/nice_flor_s"));
subghz_environment_set_protocol_registry(
subghz->txrx->environment, (void*)&subghz_protocol_registry);
subghz->txrx->receiver = subghz_receiver_alloc_init(subghz->txrx->environment);
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);

Expand Down
4 changes: 4 additions & 0 deletions applications/main/subghz/subghz_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <lib/subghz/receiver.h>
#include <lib/subghz/transmitter.h>
#include <lib/subghz/subghz_file_encoder_worker.h>
#include <lib/subghz/protocols/protocol_items.h>

#include "helpers/subghz_chat.h"

Expand Down Expand Up @@ -164,6 +165,7 @@ void subghz_cli_command_tx(Cli* cli, FuriString* args, void* context) {
stream_write_cstring(stream, furi_string_get_cstr(flipper_format_string));

SubGhzEnvironment* environment = subghz_environment_alloc();
subghz_environment_set_protocol_registry(environment, (void*)&subghz_protocol_registry);

SubGhzTransmitter* transmitter = subghz_transmitter_alloc_init(environment, "Princeton");
subghz_transmitter_deserialize(transmitter, flipper_format);
Expand Down Expand Up @@ -257,6 +259,7 @@ void subghz_cli_command_rx(Cli* cli, FuriString* args, void* context) {
environment, EXT_PATH("subghz/assets/came_atomo"));
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
environment, EXT_PATH("subghz/assets/nice_flor_s"));
subghz_environment_set_protocol_registry(environment, (void*)&subghz_protocol_registry);

SubGhzReceiver* receiver = subghz_receiver_alloc_init(environment);
subghz_receiver_set_filter(receiver, SubGhzProtocolFlag_Decodable);
Expand Down Expand Up @@ -376,6 +379,7 @@ void subghz_cli_command_decode_raw(Cli* cli, FuriString* args, void* context) {
environment, EXT_PATH("subghz/assets/came_atomo"));
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
environment, EXT_PATH("subghz/assets/nice_flor_s"));
subghz_environment_set_protocol_registry(environment, (void*)&subghz_protocol_registry);

SubGhzReceiver* receiver = subghz_receiver_alloc_init(environment);
subghz_receiver_set_filter(receiver, SubGhzProtocolFlag_Decodable);
Expand Down
8 changes: 4 additions & 4 deletions applications/main/subghz/subghz_history.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ typedef struct {
FuriString* item_str;
FlipperFormat* flipper_string;
uint8_t type;
SubGhzPresetDefinition* preset;
SubGhzRadioPreset* preset;
} SubGhzHistoryItem;

ARRAY_DEF(SubGhzHistoryItemArray, SubGhzHistoryItem, M_POD_OPLIST)
Expand Down Expand Up @@ -60,7 +60,7 @@ uint32_t subghz_history_get_frequency(SubGhzHistory* instance, uint16_t idx) {
return item->preset->frequency;
}

SubGhzPresetDefinition* subghz_history_get_preset_def(SubGhzHistory* instance, uint16_t idx) {
SubGhzRadioPreset* subghz_history_get_radio_preset(SubGhzHistory* instance, uint16_t idx) {
furi_assert(instance);
SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx);
return item->preset;
Expand Down Expand Up @@ -138,7 +138,7 @@ void subghz_history_get_text_item_menu(SubGhzHistory* instance, FuriString* outp
bool subghz_history_add_to_history(
SubGhzHistory* instance,
void* context,
SubGhzPresetDefinition* preset) {
SubGhzRadioPreset* preset) {
furi_assert(instance);
furi_assert(context);

Expand All @@ -158,7 +158,7 @@ bool subghz_history_add_to_history(
FuriString* text;
text = furi_string_alloc();
SubGhzHistoryItem* item = SubGhzHistoryItemArray_push_raw(instance->history->data);
item->preset = malloc(sizeof(SubGhzPresetDefinition));
item->preset = malloc(sizeof(SubGhzRadioPreset));
item->type = decoder_base->protocol->type;
item->preset->frequency = preset->frequency;
item->preset->name = furi_string_alloc();
Expand Down
8 changes: 4 additions & 4 deletions applications/main/subghz/subghz_history.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <furi.h>
#include <furi_hal.h>
#include <lib/flipper_format/flipper_format.h>
#include "helpers/subghz_types.h"
#include <lib/subghz/types.h>

typedef struct SubGhzHistory SubGhzHistory;

Expand Down Expand Up @@ -35,7 +35,7 @@ void subghz_history_reset(SubGhzHistory* instance);
*/
uint32_t subghz_history_get_frequency(SubGhzHistory* instance, uint16_t idx);

SubGhzPresetDefinition* subghz_history_get_preset_def(SubGhzHistory* instance, uint16_t idx);
SubGhzRadioPreset* subghz_history_get_radio_preset(SubGhzHistory* instance, uint16_t idx);

/** Get preset to history[idx]
*
Expand Down Expand Up @@ -88,13 +88,13 @@ bool subghz_history_get_text_space_left(SubGhzHistory* instance, FuriString* out
*
* @param instance - SubGhzHistory instance
* @param context - SubGhzProtocolCommon context
* @param preset - SubGhzPresetDefinition preset
* @param preset - SubGhzRadioPreset preset
* @return bool;
*/
bool subghz_history_add_to_history(
SubGhzHistory* instance,
void* context,
SubGhzPresetDefinition* preset);
SubGhzRadioPreset* preset);

/** Get SubGhzProtocolCommonLoad to load into the protocol decoder bin data
*
Expand Down
9 changes: 3 additions & 6 deletions applications/main/subghz/subghz_i.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "helpers/subghz_types.h"
#include <lib/subghz/types.h>
#include "subghz.h"
#include "views/receiver.h"
#include "views/transmitter.h"
Expand All @@ -11,8 +12,6 @@
#include "views/subghz_test_carrier.h"
#include "views/subghz_test_packet.h"

// #include <furi.h>
// #include <furi_hal.h>
#include <gui/gui.h>
#include <dialogs/dialogs.h>
#include <gui/scene_manager.h>
Expand All @@ -24,14 +23,12 @@
#include <gui/modules/widget.h>

#include <subghz/scenes/subghz_scene.h>

#include <lib/subghz/subghz_worker.h>

#include <lib/subghz/subghz_setting.h>
#include <lib/subghz/receiver.h>
#include <lib/subghz/transmitter.h>

#include "subghz_history.h"
#include "subghz_setting.h"

#include <gui/modules/variable_item_list.h>
#include <lib/toolbox/path.h>
Expand All @@ -49,7 +46,7 @@ struct SubGhzTxRx {
SubGhzProtocolDecoderBase* decoder_result;
FlipperFormat* fff_data;

SubGhzPresetDefinition* preset;
SubGhzRadioPreset* preset;
SubGhzHistory* history;
uint16_t idx_menu_chosen;
SubGhzTxRxState txrx_state;
Expand Down
2 changes: 1 addition & 1 deletion applications/main/subghz/views/receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
} else {
canvas_set_color(canvas, ColorBlack);
}
canvas_draw_icon(canvas, 1, 2 + i * FRAME_HEIGHT, ReceiverItemIcons[item_menu->type]);
canvas_draw_icon(canvas, 4, 2 + i * FRAME_HEIGHT, ReceiverItemIcons[item_menu->type]);
canvas_draw_str(canvas, 15, 9 + i * FRAME_HEIGHT, furi_string_get_cstr(str_buff));
furi_string_reset(str_buff);
}
Expand Down
13 changes: 13 additions & 0 deletions applications/plugins/weather_station/application.fam
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
App(
appid="weather_station",
name="Weather Station",
apptype=FlipperAppType.PLUGIN,
entry_point="weather_station_app",
cdefines=["APP_WEATHER_STATION"],
requires=["gui"],
stack_size=4 * 1024,
order=50,
fap_icon="weather_station_10px.png",
fap_category="Tools",
fap_icon_assets="images",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

typedef enum {
//WSCustomEvent
WSCustomEventStartId = 100,

WSCustomEventSceneSettingLock,

WSCustomEventViewReceiverOK,
WSCustomEventViewReceiverConfig,
WSCustomEventViewReceiverBack,
WSCustomEventViewReceiverOffDisplay,
WSCustomEventViewReceiverUnlock,
} WSCustomEvent;
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#pragma once

#include <furi.h>
#include <furi_hal.h>

#define WS_VERSION_APP "0.1"
#define WS_DEVELOPED "SkorP"
#define WS_GITHUB "https://github.com/flipperdevices/flipperzero-firmware"

#define WS_KEY_FILE_VERSION 1
#define WS_KEY_FILE_TYPE "Flipper Weather Station Key File"

/** WSRxKeyState state */
typedef enum {
WSRxKeyStateIDLE,
WSRxKeyStateBack,
WSRxKeyStateStart,
WSRxKeyStateAddKey,
} WSRxKeyState;

/** WSHopperState state */
typedef enum {
WSHopperStateOFF,
WSHopperStateRunnig,
WSHopperStatePause,
WSHopperStateRSSITimeOut,
} WSHopperState;

/** WSLock */
typedef enum {
WSLockOff,
WSLockOn,
} WSLock;

typedef enum {
WeatherStationViewVariableItemList,
WeatherStationViewSubmenu,
WeatherStationViewReceiver,
WeatherStationViewReceiverInfo,
WeatherStationViewWidget,
} WeatherStationView;

/** WeatherStationTxRx state */
typedef enum {
WSTxRxStateIDLE,
WSTxRxStateRx,
WSTxRxStateTx,
WSTxRxStateSleep,
} WSTxRxState;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading