[FL-950] CC1101 Stage1, SPI Refactoring, Drivers layer (#386)
* API HAL SPI: refactoring, split into layers, prepare ST HAL separation. API HAL SubGhz: initialize on start. Drivers: add basic cc1101 driver. Update API usage. Debug: increase max debugger port speed. Remove subghz apps. * CC1101: chip status handling. ApiHalSpi: increase SubGhz bus speed to 8mhz. F4: backport subghz initialization. * Api Hal SubGhz: rx path and frequency. CC1101: frequency control. * SubGhz Application: basic tests * SubGhz app: tone and packet test. API HAL SUBGHZ: update configs, add missing bits and pieces.
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
#include "../subghz-event.h"
|
||||
|
||||
class SubghzApp;
|
||||
|
||||
class SubghzScene {
|
||||
public:
|
||||
virtual void on_enter(SubghzApp* app) = 0;
|
||||
virtual bool on_event(SubghzApp* app, SubghzEvent* event) = 0;
|
||||
virtual void on_exit(SubghzApp* app) = 0;
|
||||
|
||||
private:
|
||||
};
|
@@ -1,48 +0,0 @@
|
||||
#include "subghz-scene-spectrum-settings.h"
|
||||
#include "../subghz-app.h"
|
||||
#include "../subghz-view-manager.h"
|
||||
#include "../subghz-event.h"
|
||||
#include <callback-connector.h>
|
||||
|
||||
void SubghzSceneSpectrumSettings::on_enter(SubghzApp* app) {
|
||||
SubghzAppViewManager* view_manager = app->get_view_manager();
|
||||
SubghzViewSpectrumSettings* spectrum_settings = view_manager->get_spectrum_settings();
|
||||
|
||||
auto callback = cbc::obtain_connector(this, &SubghzSceneSpectrumSettings::ok_callback);
|
||||
spectrum_settings->set_ok_callback(callback, app);
|
||||
spectrum_settings->set_start_freq(433);
|
||||
|
||||
view_manager->switch_to(SubghzAppViewManager::ViewType::SpectrumSettings);
|
||||
}
|
||||
|
||||
bool SubghzSceneSpectrumSettings::on_event(SubghzApp* app, SubghzEvent* event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event->type == SubghzEvent::Type::NextScene) {
|
||||
// save data
|
||||
// uint32_t start_freq = app->get_view_manager()->get_spectrum_settings()->get_start_freq();
|
||||
// app->get_spectrum_analyzer()->set_start_freq(start_freq);
|
||||
|
||||
// switch to next scene
|
||||
// app->switch_to_next_scene(SubghzApp::Scene::SceneSpectrumAnalyze);
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void SubghzSceneSpectrumSettings::on_exit(SubghzApp* app) {
|
||||
SubghzAppViewManager* view_manager = app->get_view_manager();
|
||||
SubghzViewSpectrumSettings* spectrum_settings = view_manager->get_spectrum_settings();
|
||||
|
||||
spectrum_settings->set_ok_callback(nullptr, nullptr);
|
||||
spectrum_settings->set_start_freq(0);
|
||||
}
|
||||
|
||||
void SubghzSceneSpectrumSettings::ok_callback(void* context) {
|
||||
SubghzApp* app = static_cast<SubghzApp*>(context);
|
||||
SubghzEvent event;
|
||||
|
||||
event.type = SubghzEvent::Type::NextScene;
|
||||
app->get_view_manager()->send_event(&event);
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
#include "subghz-scene-generic.h"
|
||||
|
||||
class SubghzSceneSpectrumSettings : public SubghzScene {
|
||||
public:
|
||||
void on_enter(SubghzApp* app) final;
|
||||
bool on_event(SubghzApp* app, SubghzEvent* event) final;
|
||||
void on_exit(SubghzApp* app) final;
|
||||
|
||||
private:
|
||||
void ok_callback(void* context);
|
||||
};
|
@@ -1,67 +0,0 @@
|
||||
#include "subghz-scene-start.h"
|
||||
#include "../subghz-app.h"
|
||||
#include "../subghz-view-manager.h"
|
||||
#include "../subghz-event.h"
|
||||
#include <callback-connector.h>
|
||||
|
||||
typedef enum {
|
||||
SubmenuIndexSpectrumAnalyzer,
|
||||
SubmenuIndexFrequencyScanner,
|
||||
SubmenuIndexSignalAnalyzer,
|
||||
SubmenuIndexSignalTransmitter,
|
||||
SubmenuIndexApplications,
|
||||
} SubmenuIndex;
|
||||
|
||||
void SubghzSceneStart::on_enter(SubghzApp* app) {
|
||||
SubghzAppViewManager* view_manager = app->get_view_manager();
|
||||
Submenu* submenu = view_manager->get_submenu();
|
||||
auto callback = cbc::obtain_connector(this, &SubghzSceneStart::submenu_callback);
|
||||
|
||||
submenu_add_item(submenu, "Spectrum Analyzer", SubmenuIndexSpectrumAnalyzer, callback, app);
|
||||
submenu_add_item(submenu, "Frequency Scanner", SubmenuIndexFrequencyScanner, callback, app);
|
||||
submenu_add_item(submenu, "Signal Analyzer", SubmenuIndexSignalAnalyzer, callback, app);
|
||||
submenu_add_item(submenu, "Signal Transmitter", SubmenuIndexSignalTransmitter, callback, app);
|
||||
submenu_add_item(submenu, "Applications", SubmenuIndexApplications, callback, app);
|
||||
|
||||
view_manager->switch_to(SubghzAppViewManager::ViewType::Submenu);
|
||||
}
|
||||
|
||||
bool SubghzSceneStart::on_event(SubghzApp* app, SubghzEvent* event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event->type == SubghzEvent::Type::MenuSelected) {
|
||||
switch(event->payload.menu_index) {
|
||||
case SubmenuIndexSpectrumAnalyzer:
|
||||
app->switch_to_next_scene(SubghzApp::Scene::SceneSpectrumSettings);
|
||||
break;
|
||||
case SubmenuIndexFrequencyScanner:
|
||||
break;
|
||||
case SubmenuIndexSignalAnalyzer:
|
||||
break;
|
||||
case SubmenuIndexSignalTransmitter:
|
||||
break;
|
||||
case SubmenuIndexApplications:
|
||||
break;
|
||||
}
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void SubghzSceneStart::on_exit(SubghzApp* app) {
|
||||
SubghzAppViewManager* view_manager = app->get_view_manager();
|
||||
Submenu* submenu = view_manager->get_submenu();
|
||||
|
||||
submenu_clean(submenu);
|
||||
}
|
||||
|
||||
void SubghzSceneStart::submenu_callback(void* context, uint32_t index) {
|
||||
SubghzApp* app = static_cast<SubghzApp*>(context);
|
||||
SubghzEvent event;
|
||||
|
||||
event.type = SubghzEvent::Type::MenuSelected;
|
||||
event.payload.menu_index = index;
|
||||
|
||||
app->get_view_manager()->send_event(&event);
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
#include "subghz-scene-generic.h"
|
||||
|
||||
class SubghzSceneStart : public SubghzScene {
|
||||
public:
|
||||
void on_enter(SubghzApp* app) final;
|
||||
bool on_event(SubghzApp* app, SubghzEvent* event) final;
|
||||
void on_exit(SubghzApp* app) final;
|
||||
|
||||
private:
|
||||
void submenu_callback(void* context, uint32_t index);
|
||||
};
|
@@ -1,90 +0,0 @@
|
||||
#include "subghz-app.h"
|
||||
#include <api-hal-power.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void SubghzApp::run(void) {
|
||||
SubghzEvent event;
|
||||
bool consumed;
|
||||
bool exit = false;
|
||||
|
||||
scenes[current_scene]->on_enter(this);
|
||||
|
||||
while(!exit) {
|
||||
view.receive_event(&event);
|
||||
|
||||
consumed = scenes[current_scene]->on_event(this, &event);
|
||||
|
||||
if(!consumed) {
|
||||
if(event.type == SubghzEvent::Type::Back) {
|
||||
exit = switch_to_previous_scene();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
scenes[current_scene]->on_exit(this);
|
||||
}
|
||||
|
||||
SubghzApp::SubghzApp() {
|
||||
api_hal_power_insomnia_enter();
|
||||
}
|
||||
|
||||
SubghzApp::~SubghzApp() {
|
||||
api_hal_power_insomnia_exit();
|
||||
}
|
||||
|
||||
SubghzAppViewManager* SubghzApp::get_view_manager() {
|
||||
return &view;
|
||||
}
|
||||
|
||||
void SubghzApp::switch_to_next_scene(Scene next_scene) {
|
||||
previous_scenes_list.push_front(current_scene);
|
||||
|
||||
if(next_scene != Scene::SceneExit) {
|
||||
scenes[current_scene]->on_exit(this);
|
||||
current_scene = next_scene;
|
||||
scenes[current_scene]->on_enter(this);
|
||||
}
|
||||
}
|
||||
|
||||
void SubghzApp::search_and_switch_to_previous_scene(std::initializer_list<Scene> scenes_list) {
|
||||
Scene previous_scene = Scene::SceneStart;
|
||||
bool scene_found = false;
|
||||
|
||||
while(!scene_found) {
|
||||
previous_scene = get_previous_scene();
|
||||
for(Scene element : scenes_list) {
|
||||
if(previous_scene == element || previous_scene == Scene::SceneStart) {
|
||||
scene_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scenes[current_scene]->on_exit(this);
|
||||
current_scene = previous_scene;
|
||||
scenes[current_scene]->on_enter(this);
|
||||
}
|
||||
|
||||
bool SubghzApp::switch_to_previous_scene(uint8_t count) {
|
||||
Scene previous_scene = Scene::SceneStart;
|
||||
|
||||
for(uint8_t i = 0; i < count; i++) {
|
||||
previous_scene = get_previous_scene();
|
||||
if(previous_scene == Scene::SceneExit) break;
|
||||
}
|
||||
|
||||
if(previous_scene == Scene::SceneExit) {
|
||||
return true;
|
||||
} else {
|
||||
scenes[current_scene]->on_exit(this);
|
||||
current_scene = previous_scene;
|
||||
scenes[current_scene]->on_enter(this);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SubghzApp::Scene SubghzApp::get_previous_scene() {
|
||||
Scene scene = previous_scenes_list.front();
|
||||
previous_scenes_list.pop_front();
|
||||
return scene;
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include "subghz-view-manager.h"
|
||||
|
||||
#include "scene/subghz-scene-start.h"
|
||||
#include "scene/subghz-scene-spectrum-settings.h"
|
||||
|
||||
class SubghzApp {
|
||||
public:
|
||||
void run(void);
|
||||
|
||||
SubghzApp();
|
||||
~SubghzApp();
|
||||
|
||||
enum class Scene : uint8_t {
|
||||
SceneExit,
|
||||
SceneStart,
|
||||
SceneSpectrumSettings,
|
||||
};
|
||||
|
||||
SubghzAppViewManager* get_view_manager();
|
||||
void switch_to_next_scene(Scene index);
|
||||
void search_and_switch_to_previous_scene(std::initializer_list<Scene> scenes_list);
|
||||
bool switch_to_previous_scene(uint8_t count = 1);
|
||||
Scene get_previous_scene();
|
||||
|
||||
private:
|
||||
std::list<Scene> previous_scenes_list = {Scene::SceneExit};
|
||||
Scene current_scene = Scene::SceneStart;
|
||||
SubghzAppViewManager view;
|
||||
|
||||
std::map<Scene, SubghzScene*> scenes = {
|
||||
{Scene::SceneStart, new SubghzSceneStart()},
|
||||
{Scene::SceneSpectrumSettings, new SubghzSceneSpectrumSettings()},
|
||||
};
|
||||
};
|
@@ -1,21 +0,0 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
class SubghzEvent {
|
||||
public:
|
||||
// events enum
|
||||
enum class Type : uint8_t {
|
||||
Tick,
|
||||
Back,
|
||||
MenuSelected,
|
||||
NextScene,
|
||||
};
|
||||
|
||||
// payload
|
||||
union {
|
||||
uint32_t menu_index;
|
||||
} payload;
|
||||
|
||||
// event type
|
||||
Type type;
|
||||
};
|
@@ -1,81 +0,0 @@
|
||||
#include "subghz-view-manager.h"
|
||||
#include "subghz-event.h"
|
||||
#include <callback-connector.h>
|
||||
|
||||
SubghzAppViewManager::SubghzAppViewManager() {
|
||||
event_queue = osMessageQueueNew(10, sizeof(SubghzEvent), NULL);
|
||||
|
||||
view_dispatcher = view_dispatcher_alloc();
|
||||
auto callback = cbc::obtain_connector(this, &SubghzAppViewManager::previous_view_callback);
|
||||
|
||||
// allocate views
|
||||
submenu = submenu_alloc();
|
||||
view_dispatcher_add_view(
|
||||
view_dispatcher,
|
||||
static_cast<uint32_t>(SubghzAppViewManager::ViewType::Submenu),
|
||||
submenu_get_view(submenu));
|
||||
|
||||
spectrum_settings = new SubghzViewSpectrumSettings();
|
||||
view_dispatcher_add_view(
|
||||
view_dispatcher,
|
||||
static_cast<uint32_t>(SubghzAppViewManager::ViewType::SpectrumSettings),
|
||||
spectrum_settings->get_view());
|
||||
|
||||
gui = static_cast<Gui*>(furi_record_open("gui"));
|
||||
view_dispatcher_attach_to_gui(view_dispatcher, gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
// set previous view callback for all views
|
||||
view_set_previous_callback(submenu_get_view(submenu), callback);
|
||||
view_set_previous_callback(spectrum_settings->get_view(), callback);
|
||||
}
|
||||
|
||||
SubghzAppViewManager::~SubghzAppViewManager() {
|
||||
// remove views
|
||||
view_dispatcher_remove_view(
|
||||
view_dispatcher, static_cast<uint32_t>(SubghzAppViewManager::ViewType::Submenu));
|
||||
view_dispatcher_remove_view(
|
||||
view_dispatcher, static_cast<uint32_t>(SubghzAppViewManager::ViewType::SpectrumSettings));
|
||||
|
||||
// free view modules
|
||||
submenu_free(submenu);
|
||||
free(spectrum_settings);
|
||||
|
||||
// free dispatcher
|
||||
view_dispatcher_free(view_dispatcher);
|
||||
|
||||
// free event queue
|
||||
osMessageQueueDelete(event_queue);
|
||||
}
|
||||
|
||||
void SubghzAppViewManager::switch_to(ViewType type) {
|
||||
view_dispatcher_switch_to_view(view_dispatcher, static_cast<uint32_t>(type));
|
||||
}
|
||||
|
||||
Submenu* SubghzAppViewManager::get_submenu() {
|
||||
return submenu;
|
||||
}
|
||||
|
||||
SubghzViewSpectrumSettings* SubghzAppViewManager::get_spectrum_settings() {
|
||||
return spectrum_settings;
|
||||
}
|
||||
|
||||
void SubghzAppViewManager::receive_event(SubghzEvent* event) {
|
||||
if(osMessageQueueGet(event_queue, event, NULL, 100) != osOK) {
|
||||
event->type = SubghzEvent::Type::Tick;
|
||||
}
|
||||
}
|
||||
|
||||
void SubghzAppViewManager::send_event(SubghzEvent* event) {
|
||||
osStatus_t result = osMessageQueuePut(event_queue, event, 0, 0);
|
||||
furi_check(result == osOK);
|
||||
}
|
||||
|
||||
uint32_t SubghzAppViewManager::previous_view_callback(void* context) {
|
||||
if(event_queue != NULL) {
|
||||
SubghzEvent event;
|
||||
event.type = SubghzEvent::Type::Back;
|
||||
send_event(&event);
|
||||
}
|
||||
|
||||
return VIEW_IGNORE;
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
#include <furi.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include "subghz-event.h"
|
||||
#include "view/subghz-view-spectrum-settings.h"
|
||||
|
||||
class SubghzAppViewManager {
|
||||
public:
|
||||
enum class ViewType : uint8_t {
|
||||
Submenu,
|
||||
SpectrumSettings,
|
||||
};
|
||||
|
||||
osMessageQueueId_t event_queue;
|
||||
|
||||
SubghzAppViewManager();
|
||||
~SubghzAppViewManager();
|
||||
|
||||
void switch_to(ViewType type);
|
||||
|
||||
void receive_event(SubghzEvent* event);
|
||||
void send_event(SubghzEvent* event);
|
||||
|
||||
Submenu* get_submenu();
|
||||
SubghzViewSpectrumSettings* get_spectrum_settings();
|
||||
|
||||
private:
|
||||
ViewDispatcher* view_dispatcher;
|
||||
Gui* gui;
|
||||
|
||||
uint32_t previous_view_callback(void* context);
|
||||
|
||||
// view elements
|
||||
Submenu* submenu;
|
||||
SubghzViewSpectrumSettings* spectrum_settings;
|
||||
};
|
98
applications/subghz/subghz.c
Normal file
98
applications/subghz/subghz.c
Normal file
@@ -0,0 +1,98 @@
|
||||
#include "subghz_i.h"
|
||||
|
||||
osThreadId subghz_thread_id = NULL;
|
||||
|
||||
void subghz_menu_callback(void* context, uint32_t index) {
|
||||
furi_assert(context);
|
||||
|
||||
SubGhz* subghz = context;
|
||||
|
||||
if(index == 0) {
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewTestBasic);
|
||||
} else if(index == 1) {
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewTestPacket);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t subghz_exit(void* context) {
|
||||
osThreadResume(subghz_thread_id);
|
||||
return VIEW_NONE;
|
||||
}
|
||||
|
||||
SubGhz* subghz_alloc() {
|
||||
SubGhz* subghz = furi_alloc(sizeof(SubGhz));
|
||||
|
||||
// Thread id
|
||||
subghz_thread_id = osThreadGetId();
|
||||
|
||||
// GUI
|
||||
subghz->gui = furi_record_open("gui");
|
||||
|
||||
// View Dispatcher
|
||||
subghz->view_dispatcher = view_dispatcher_alloc();
|
||||
view_dispatcher_attach_to_gui(
|
||||
subghz->view_dispatcher, subghz->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
// Menu
|
||||
subghz->submenu = submenu_alloc();
|
||||
submenu_add_item(subghz->submenu, "Basic Test", 0, subghz_menu_callback, subghz);
|
||||
submenu_add_item(subghz->submenu, "Packet Test", 1, subghz_menu_callback, subghz);
|
||||
View* submenu_view = submenu_get_view(subghz->submenu);
|
||||
view_set_previous_callback(submenu_view, subghz_exit);
|
||||
view_dispatcher_add_view(subghz->view_dispatcher, SubGhzViewMenu, submenu_view);
|
||||
|
||||
// Basic Test Module
|
||||
subghz->subghz_test_basic = subghz_test_basic_alloc();
|
||||
view_dispatcher_add_view(
|
||||
subghz->view_dispatcher,
|
||||
SubGhzViewTestBasic,
|
||||
subghz_test_basic_get_view(subghz->subghz_test_basic));
|
||||
|
||||
// Packet Test
|
||||
subghz->subghz_test_packet = subghz_test_packet_alloc();
|
||||
view_dispatcher_add_view(
|
||||
subghz->view_dispatcher,
|
||||
SubGhzViewTestPacket,
|
||||
subghz_test_packet_get_view(subghz->subghz_test_packet));
|
||||
|
||||
// Switch to menu
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewMenu);
|
||||
|
||||
return subghz;
|
||||
}
|
||||
|
||||
void subghz_free(SubGhz* subghz) {
|
||||
furi_assert(subghz);
|
||||
|
||||
// Packet Test
|
||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewTestPacket);
|
||||
subghz_test_packet_free(subghz->subghz_test_packet);
|
||||
|
||||
// Basic Test
|
||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewTestBasic);
|
||||
subghz_test_basic_free(subghz->subghz_test_basic);
|
||||
|
||||
// Submenu
|
||||
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewMenu);
|
||||
submenu_free(subghz->submenu);
|
||||
|
||||
// View Dispatcher
|
||||
view_dispatcher_free(subghz->view_dispatcher);
|
||||
|
||||
// GUI
|
||||
furi_record_close("gui");
|
||||
subghz->gui = NULL;
|
||||
|
||||
// The rest
|
||||
free(subghz);
|
||||
}
|
||||
|
||||
int32_t subghz_app(void* context) {
|
||||
SubGhz* subghz = subghz_alloc();
|
||||
|
||||
osThreadSuspend(subghz_thread_id);
|
||||
|
||||
subghz_free(subghz);
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
#include "subghz-app.h"
|
||||
|
||||
// app enter function
|
||||
extern "C" int32_t app_subghz(void* p) {
|
||||
SubghzApp* app = new SubghzApp();
|
||||
app->run();
|
||||
delete app;
|
||||
|
||||
return 255;
|
||||
}
|
3
applications/subghz/subghz.h
Normal file
3
applications/subghz/subghz.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
typedef struct SubGhz SubGhz;
|
44
applications/subghz/subghz_i.h
Normal file
44
applications/subghz/subghz_i.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include "subghz.h"
|
||||
#include "subghz_test_basic.h"
|
||||
#include "subghz_test_packet.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
|
||||
static const uint32_t subghz_frequencies[] = {
|
||||
301000000,
|
||||
315000000,
|
||||
346000000,
|
||||
385000000,
|
||||
433920000,
|
||||
438900000,
|
||||
463000000,
|
||||
781000000,
|
||||
868000000,
|
||||
915000000,
|
||||
925000000,
|
||||
};
|
||||
|
||||
static const uint32_t subghz_frequencies_count = sizeof(subghz_frequencies) / sizeof(uint32_t);
|
||||
|
||||
struct SubGhz {
|
||||
Gui* gui;
|
||||
|
||||
ViewDispatcher* view_dispatcher;
|
||||
|
||||
Submenu* submenu;
|
||||
|
||||
SubghzTestBasic* subghz_test_basic;
|
||||
|
||||
SubghzTestPacket* subghz_test_packet;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
SubGhzViewMenu,
|
||||
SubGhzViewTestBasic,
|
||||
SubGhzViewTestPacket,
|
||||
} SubGhzView;
|
203
applications/subghz/subghz_test_basic.c
Normal file
203
applications/subghz/subghz_test_basic.c
Normal file
@@ -0,0 +1,203 @@
|
||||
#include "subghz_test_basic.h"
|
||||
#include "subghz_i.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
#include <input/input.h>
|
||||
|
||||
struct SubghzTestBasic {
|
||||
View* view;
|
||||
osTimerId timer;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
SubghzTestBasicModelStatusRx,
|
||||
SubghzTestBasicModelStatusTx,
|
||||
} SubghzTestBasicModelStatus;
|
||||
|
||||
typedef struct {
|
||||
uint8_t frequency;
|
||||
uint32_t real_frequency;
|
||||
ApiHalSubGhzPath path;
|
||||
float rssi;
|
||||
SubghzTestBasicModelStatus status;
|
||||
} SubghzTestBasicModel;
|
||||
|
||||
void subghz_test_basic_draw(Canvas* canvas, SubghzTestBasicModel* model) {
|
||||
char buffer[64];
|
||||
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str(canvas, 2, 12, "CC1101 Basic Test");
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
// Frequency
|
||||
snprintf(
|
||||
buffer,
|
||||
sizeof(buffer),
|
||||
"Freq: %03ld.%03ld.%03ld Hz",
|
||||
model->real_frequency / 1000000 % 1000,
|
||||
model->real_frequency / 1000 % 1000,
|
||||
model->real_frequency % 1000);
|
||||
canvas_draw_str(canvas, 2, 24, buffer);
|
||||
// Path
|
||||
char* path_name = "Unknown";
|
||||
if(model->path == ApiHalSubGhzPathIsolate) {
|
||||
path_name = "isolate";
|
||||
} else if(model->path == ApiHalSubGhzPath1) {
|
||||
path_name = "433MHz";
|
||||
} else if(model->path == ApiHalSubGhzPath2) {
|
||||
path_name = "315MHz";
|
||||
} else if(model->path == ApiHalSubGhzPath3) {
|
||||
path_name = "868MHz";
|
||||
}
|
||||
snprintf(buffer, sizeof(buffer), "Path: %d - %s", model->path, path_name);
|
||||
canvas_draw_str(canvas, 2, 36, buffer);
|
||||
if(model->status == SubghzTestBasicModelStatusRx) {
|
||||
snprintf(
|
||||
buffer,
|
||||
sizeof(buffer),
|
||||
"RSSI: %ld.%ld dBm",
|
||||
(int32_t)(model->rssi),
|
||||
(int32_t)fabs(model->rssi * 10) % 10);
|
||||
canvas_draw_str(canvas, 2, 48, buffer);
|
||||
} else {
|
||||
canvas_draw_str(canvas, 2, 48, "TX");
|
||||
}
|
||||
}
|
||||
|
||||
bool subghz_test_basic_input(InputEvent* event, void* context) {
|
||||
furi_assert(context);
|
||||
SubghzTestBasic* subghz_test_basic = context;
|
||||
|
||||
if(event->key == InputKeyBack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
with_view_model(
|
||||
subghz_test_basic->view, (SubghzTestBasicModel * model) {
|
||||
osTimerStop(subghz_test_basic->timer);
|
||||
api_hal_subghz_idle();
|
||||
|
||||
if(event->type == InputTypeShort) {
|
||||
if(event->key == InputKeyLeft) {
|
||||
if(model->frequency > 0) model->frequency--;
|
||||
} else if(event->key == InputKeyRight) {
|
||||
if(model->frequency < subghz_frequencies_count - 1) model->frequency++;
|
||||
} else if(event->key == InputKeyDown) {
|
||||
if(model->path > 0) model->path--;
|
||||
} else if(event->key == InputKeyUp) {
|
||||
if(model->path < ApiHalSubGhzPath3) model->path++;
|
||||
}
|
||||
|
||||
model->real_frequency =
|
||||
api_hal_subghz_set_frequency(subghz_frequencies[model->frequency]);
|
||||
api_hal_subghz_set_path(model->path);
|
||||
}
|
||||
|
||||
if(event->key == InputKeyOk) {
|
||||
if(event->type == InputTypePress) {
|
||||
model->status = SubghzTestBasicModelStatusTx;
|
||||
} else if(event->type == InputTypeRelease) {
|
||||
model->status = SubghzTestBasicModelStatusRx;
|
||||
}
|
||||
}
|
||||
|
||||
if(model->status == SubghzTestBasicModelStatusRx) {
|
||||
gpio_init(&cc1101_g0_gpio, GpioModeInput);
|
||||
api_hal_subghz_rx();
|
||||
osTimerStart(subghz_test_basic->timer, 1024 / 4);
|
||||
} else {
|
||||
gpio_init(&cc1101_g0_gpio, GpioModeOutputPushPull);
|
||||
gpio_write(&cc1101_g0_gpio, false);
|
||||
api_hal_subghz_tx();
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void subghz_test_basic_enter(void* context) {
|
||||
furi_assert(context);
|
||||
SubghzTestBasic* subghz_test_basic = context;
|
||||
|
||||
api_hal_subghz_reset();
|
||||
api_hal_subghz_load_preset(ApiHalSubGhzPresetOokAsync);
|
||||
|
||||
gpio_init(&cc1101_g0_gpio, GpioModeInput);
|
||||
|
||||
with_view_model(
|
||||
subghz_test_basic->view, (SubghzTestBasicModel * model) {
|
||||
model->frequency = 4; // 433
|
||||
model->real_frequency =
|
||||
api_hal_subghz_set_frequency(subghz_frequencies[model->frequency]);
|
||||
model->path = ApiHalSubGhzPathIsolate; // isolate
|
||||
model->rssi = 0.0f;
|
||||
model->status = SubghzTestBasicModelStatusRx;
|
||||
return true;
|
||||
});
|
||||
|
||||
api_hal_subghz_rx();
|
||||
|
||||
osTimerStart(subghz_test_basic->timer, 1024 / 4);
|
||||
}
|
||||
|
||||
void subghz_test_basic_exit(void* context) {
|
||||
furi_assert(context);
|
||||
SubghzTestBasic* subghz_test_basic = context;
|
||||
|
||||
osTimerStop(subghz_test_basic->timer);
|
||||
|
||||
// Reinitialize IC to default state
|
||||
api_hal_subghz_init();
|
||||
}
|
||||
|
||||
void subghz_test_basic_rssi_timer_callback(void* context) {
|
||||
furi_assert(context);
|
||||
SubghzTestBasic* subghz_test_basic = context;
|
||||
|
||||
with_view_model(
|
||||
subghz_test_basic->view, (SubghzTestBasicModel * model) {
|
||||
model->rssi = api_hal_subghz_get_rssi();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
uint32_t subghz_test_basic_back(void* context) {
|
||||
return SubGhzViewMenu;
|
||||
}
|
||||
|
||||
SubghzTestBasic* subghz_test_basic_alloc() {
|
||||
SubghzTestBasic* subghz_test_basic = furi_alloc(sizeof(SubghzTestBasic));
|
||||
|
||||
// View allocation and configuration
|
||||
subghz_test_basic->view = view_alloc();
|
||||
view_allocate_model(
|
||||
subghz_test_basic->view, ViewModelTypeLockFree, sizeof(SubghzTestBasicModel));
|
||||
view_set_context(subghz_test_basic->view, subghz_test_basic);
|
||||
view_set_draw_callback(subghz_test_basic->view, (ViewDrawCallback)subghz_test_basic_draw);
|
||||
view_set_input_callback(subghz_test_basic->view, subghz_test_basic_input);
|
||||
view_set_enter_callback(subghz_test_basic->view, subghz_test_basic_enter);
|
||||
view_set_exit_callback(subghz_test_basic->view, subghz_test_basic_exit);
|
||||
view_set_previous_callback(subghz_test_basic->view, subghz_test_basic_back);
|
||||
|
||||
subghz_test_basic->timer = osTimerNew(
|
||||
subghz_test_basic_rssi_timer_callback, osTimerPeriodic, subghz_test_basic, NULL);
|
||||
|
||||
return subghz_test_basic;
|
||||
}
|
||||
|
||||
void subghz_test_basic_free(SubghzTestBasic* subghz_test_basic) {
|
||||
furi_assert(subghz_test_basic);
|
||||
osTimerDelete(subghz_test_basic->timer);
|
||||
view_free(subghz_test_basic->view);
|
||||
free(subghz_test_basic);
|
||||
}
|
||||
|
||||
View* subghz_test_basic_get_view(SubghzTestBasic* subghz_test_basic) {
|
||||
furi_assert(subghz_test_basic);
|
||||
return subghz_test_basic->view;
|
||||
}
|
11
applications/subghz/subghz_test_basic.h
Normal file
11
applications/subghz/subghz_test_basic.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
typedef struct SubghzTestBasic SubghzTestBasic;
|
||||
|
||||
SubghzTestBasic* subghz_test_basic_alloc();
|
||||
|
||||
void subghz_test_basic_free(SubghzTestBasic* subghz_test_basic);
|
||||
|
||||
View* subghz_test_basic_get_view(SubghzTestBasic* subghz_test_basic);
|
210
applications/subghz/subghz_test_packet.c
Normal file
210
applications/subghz/subghz_test_packet.c
Normal file
@@ -0,0 +1,210 @@
|
||||
#include "subghz_test_packet.h"
|
||||
#include "subghz_i.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
#include <input/input.h>
|
||||
|
||||
static const uint8_t subghz_test_packet_data[] = {
|
||||
0x30, // 48bytes to transmit
|
||||
'F', 'L', 'I', 'P', 'P', 'E', 'R', ' ', 'T', 'E', 'S', 'T', ' ', 'P', 'A', 'C',
|
||||
'K', 'E', 'T', ' ', 'D', 'A', 'T', 'A', ' ', 'A', 'N', 'D', ' ', 'P', 'A', 'D',
|
||||
'F', 'L', 'I', 'P', 'P', 'E', 'R', ' ', 'T', 'E', 'S', 'T', ' ', 'P', 'A', 'C',
|
||||
|
||||
};
|
||||
|
||||
struct SubghzTestPacket {
|
||||
View* view;
|
||||
osTimerId timer;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
SubghzTestPacketModelStatusRx,
|
||||
SubghzTestPacketModelStatusTx,
|
||||
} SubghzTestPacketModelStatus;
|
||||
|
||||
typedef struct {
|
||||
uint8_t frequency;
|
||||
uint32_t real_frequency;
|
||||
ApiHalSubGhzPath path;
|
||||
float rssi;
|
||||
SubghzTestPacketModelStatus status;
|
||||
} SubghzTestPacketModel;
|
||||
|
||||
void subghz_test_packet_draw(Canvas* canvas, SubghzTestPacketModel* model) {
|
||||
char buffer[64];
|
||||
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str(canvas, 2, 12, "CC1101 Packet Test");
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
// Frequency
|
||||
snprintf(
|
||||
buffer,
|
||||
sizeof(buffer),
|
||||
"Freq: %03ld.%03ld.%03ld Hz",
|
||||
model->real_frequency / 1000000 % 1000,
|
||||
model->real_frequency / 1000 % 1000,
|
||||
model->real_frequency % 1000);
|
||||
canvas_draw_str(canvas, 2, 24, buffer);
|
||||
// Path
|
||||
char* path_name = "Unknown";
|
||||
if(model->path == ApiHalSubGhzPathIsolate) {
|
||||
path_name = "isolate";
|
||||
} else if(model->path == ApiHalSubGhzPath1) {
|
||||
path_name = "433MHz";
|
||||
} else if(model->path == ApiHalSubGhzPath2) {
|
||||
path_name = "315MHz";
|
||||
} else if(model->path == ApiHalSubGhzPath3) {
|
||||
path_name = "868MHz";
|
||||
}
|
||||
snprintf(buffer, sizeof(buffer), "Path: %d - %s", model->path, path_name);
|
||||
canvas_draw_str(canvas, 2, 36, buffer);
|
||||
if(model->status == SubghzTestPacketModelStatusRx) {
|
||||
snprintf(
|
||||
buffer,
|
||||
sizeof(buffer),
|
||||
"RSSI: %ld.%ld dBm",
|
||||
(int32_t)(model->rssi),
|
||||
(int32_t)fabs(model->rssi * 10) % 10);
|
||||
canvas_draw_str(canvas, 2, 48, buffer);
|
||||
} else {
|
||||
canvas_draw_str(canvas, 2, 48, "TX");
|
||||
}
|
||||
}
|
||||
|
||||
bool subghz_test_packet_input(InputEvent* event, void* context) {
|
||||
furi_assert(context);
|
||||
SubghzTestPacket* subghz_test_packet = context;
|
||||
|
||||
if(event->key == InputKeyBack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
with_view_model(
|
||||
subghz_test_packet->view, (SubghzTestPacketModel * model) {
|
||||
osTimerStop(subghz_test_packet->timer);
|
||||
api_hal_subghz_idle();
|
||||
|
||||
if(event->type == InputTypeShort) {
|
||||
if(event->key == InputKeyLeft) {
|
||||
if(model->frequency > 0) model->frequency--;
|
||||
} else if(event->key == InputKeyRight) {
|
||||
if(model->frequency < subghz_frequencies_count - 1) model->frequency++;
|
||||
} else if(event->key == InputKeyDown) {
|
||||
if(model->path > 0) model->path--;
|
||||
} else if(event->key == InputKeyUp) {
|
||||
if(model->path < ApiHalSubGhzPath3) model->path++;
|
||||
}
|
||||
|
||||
model->real_frequency =
|
||||
api_hal_subghz_set_frequency(subghz_frequencies[model->frequency]);
|
||||
api_hal_subghz_set_path(model->path);
|
||||
}
|
||||
|
||||
if(event->key == InputKeyOk) {
|
||||
if(event->type == InputTypePress) {
|
||||
model->status = SubghzTestPacketModelStatusTx;
|
||||
} else if(event->type == InputTypeRelease) {
|
||||
model->status = SubghzTestPacketModelStatusRx;
|
||||
}
|
||||
}
|
||||
|
||||
if(model->status == SubghzTestPacketModelStatusRx) {
|
||||
api_hal_subghz_rx();
|
||||
osTimerStart(subghz_test_packet->timer, 1024 / 4);
|
||||
} else {
|
||||
api_hal_subghz_write_packet(
|
||||
subghz_test_packet_data, sizeof(subghz_test_packet_data));
|
||||
api_hal_subghz_tx();
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void subghz_test_packet_enter(void* context) {
|
||||
furi_assert(context);
|
||||
SubghzTestPacket* subghz_test_packet = context;
|
||||
|
||||
api_hal_subghz_reset();
|
||||
api_hal_subghz_load_preset(ApiHalSubGhzPreset2FskPacket);
|
||||
|
||||
gpio_init(&cc1101_g0_gpio, GpioModeInput);
|
||||
|
||||
with_view_model(
|
||||
subghz_test_packet->view, (SubghzTestPacketModel * model) {
|
||||
model->frequency = 4; // 433
|
||||
model->real_frequency =
|
||||
api_hal_subghz_set_frequency(subghz_frequencies[model->frequency]);
|
||||
model->path = ApiHalSubGhzPathIsolate; // isolate
|
||||
model->rssi = 0.0f;
|
||||
model->status = SubghzTestPacketModelStatusRx;
|
||||
return true;
|
||||
});
|
||||
|
||||
api_hal_subghz_rx();
|
||||
|
||||
osTimerStart(subghz_test_packet->timer, 1024 / 4);
|
||||
}
|
||||
|
||||
void subghz_test_packet_exit(void* context) {
|
||||
furi_assert(context);
|
||||
SubghzTestPacket* subghz_test_packet = context;
|
||||
|
||||
osTimerStop(subghz_test_packet->timer);
|
||||
|
||||
// Reinitialize IC to default state
|
||||
api_hal_subghz_init();
|
||||
}
|
||||
|
||||
void subghz_test_packet_rssi_timer_callback(void* context) {
|
||||
furi_assert(context);
|
||||
SubghzTestPacket* subghz_test_packet = context;
|
||||
|
||||
with_view_model(
|
||||
subghz_test_packet->view, (SubghzTestPacketModel * model) {
|
||||
model->rssi = api_hal_subghz_get_rssi();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
uint32_t subghz_test_packet_back(void* context) {
|
||||
return SubGhzViewMenu;
|
||||
}
|
||||
|
||||
SubghzTestPacket* subghz_test_packet_alloc() {
|
||||
SubghzTestPacket* subghz_test_packet = furi_alloc(sizeof(SubghzTestPacket));
|
||||
|
||||
// View allocation and configuration
|
||||
subghz_test_packet->view = view_alloc();
|
||||
view_allocate_model(
|
||||
subghz_test_packet->view, ViewModelTypeLockFree, sizeof(SubghzTestPacketModel));
|
||||
view_set_context(subghz_test_packet->view, subghz_test_packet);
|
||||
view_set_draw_callback(subghz_test_packet->view, (ViewDrawCallback)subghz_test_packet_draw);
|
||||
view_set_input_callback(subghz_test_packet->view, subghz_test_packet_input);
|
||||
view_set_enter_callback(subghz_test_packet->view, subghz_test_packet_enter);
|
||||
view_set_exit_callback(subghz_test_packet->view, subghz_test_packet_exit);
|
||||
view_set_previous_callback(subghz_test_packet->view, subghz_test_packet_back);
|
||||
|
||||
subghz_test_packet->timer = osTimerNew(
|
||||
subghz_test_packet_rssi_timer_callback, osTimerPeriodic, subghz_test_packet, NULL);
|
||||
|
||||
return subghz_test_packet;
|
||||
}
|
||||
|
||||
void subghz_test_packet_free(SubghzTestPacket* subghz_test_packet) {
|
||||
furi_assert(subghz_test_packet);
|
||||
osTimerDelete(subghz_test_packet->timer);
|
||||
view_free(subghz_test_packet->view);
|
||||
free(subghz_test_packet);
|
||||
}
|
||||
|
||||
View* subghz_test_packet_get_view(SubghzTestPacket* subghz_test_packet) {
|
||||
furi_assert(subghz_test_packet);
|
||||
return subghz_test_packet->view;
|
||||
}
|
11
applications/subghz/subghz_test_packet.h
Normal file
11
applications/subghz/subghz_test_packet.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
typedef struct SubghzTestPacket SubghzTestPacket;
|
||||
|
||||
SubghzTestPacket* subghz_test_packet_alloc();
|
||||
|
||||
void subghz_test_packet_free(SubghzTestPacket* subghz_test_packet);
|
||||
|
||||
View* subghz_test_packet_get_view(SubghzTestPacket* subghz_test_packet);
|
@@ -1,95 +0,0 @@
|
||||
#include "subghz-view-spectrum-settings.h"
|
||||
#include <callback-connector.h>
|
||||
|
||||
struct SpectrumSettingsModel {
|
||||
uint32_t start_freq;
|
||||
};
|
||||
|
||||
/***************************************************************************************/
|
||||
|
||||
static void draw_callback(Canvas* canvas, void* _model) {
|
||||
SpectrumSettingsModel* model = static_cast<SpectrumSettingsModel*>(_model);
|
||||
const uint8_t str_size = 64;
|
||||
char str_buffer[str_size];
|
||||
|
||||
canvas_clear(canvas);
|
||||
snprintf(str_buffer, str_size, "Start freq < %ld > MHz", model->start_freq);
|
||||
canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignCenter, str_buffer);
|
||||
}
|
||||
|
||||
static bool input_callback(InputEvent* event, void* context) {
|
||||
SubghzViewSpectrumSettings* _this = static_cast<SubghzViewSpectrumSettings*>(context);
|
||||
|
||||
bool consumed = false;
|
||||
|
||||
// Process key presses only
|
||||
if(event->type == InputTypeShort) {
|
||||
if(event->key == InputKeyOk) {
|
||||
_this->call_ok_callback();
|
||||
consumed = true;
|
||||
} else if(event->key == InputKeyLeft) {
|
||||
with_view_model_cpp(_this->get_view(), SpectrumSettingsModel, model, {
|
||||
model->start_freq--;
|
||||
return true;
|
||||
});
|
||||
consumed = true;
|
||||
} else if(event->key == InputKeyRight) {
|
||||
with_view_model_cpp(_this->get_view(), SpectrumSettingsModel, model, {
|
||||
model->start_freq++;
|
||||
return true;
|
||||
});
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
/***************************************************************************************/
|
||||
|
||||
View* SubghzViewSpectrumSettings::get_view() {
|
||||
return view;
|
||||
}
|
||||
|
||||
void SubghzViewSpectrumSettings::set_ok_callback(OkCallback callback, void* context) {
|
||||
ok_callback = callback;
|
||||
ok_callback_context = context;
|
||||
}
|
||||
|
||||
void SubghzViewSpectrumSettings::call_ok_callback() {
|
||||
if(ok_callback != nullptr) {
|
||||
ok_callback(ok_callback_context);
|
||||
}
|
||||
}
|
||||
|
||||
void SubghzViewSpectrumSettings::set_start_freq(uint32_t start_freq) {
|
||||
with_view_model_cpp(view, SpectrumSettingsModel, model, {
|
||||
model->start_freq = start_freq;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
uint32_t SubghzViewSpectrumSettings::get_start_freq() {
|
||||
uint32_t result;
|
||||
|
||||
with_view_model_cpp(view, SpectrumSettingsModel, model, {
|
||||
result = model->start_freq;
|
||||
return false;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SubghzViewSpectrumSettings::SubghzViewSpectrumSettings() {
|
||||
view = view_alloc();
|
||||
view_set_context(view, this);
|
||||
view_allocate_model(view, ViewModelTypeLocking, sizeof(SpectrumSettingsModel));
|
||||
|
||||
view_set_draw_callback(view, draw_callback);
|
||||
|
||||
view_set_input_callback(view, input_callback);
|
||||
}
|
||||
|
||||
SubghzViewSpectrumSettings::~SubghzViewSpectrumSettings() {
|
||||
view_free(view);
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
#include <gui/view.h>
|
||||
|
||||
class SubghzViewSpectrumSettings {
|
||||
public:
|
||||
SubghzViewSpectrumSettings();
|
||||
~SubghzViewSpectrumSettings();
|
||||
|
||||
View* get_view();
|
||||
|
||||
// ok callback methods
|
||||
typedef void (*OkCallback)(void* context);
|
||||
void set_ok_callback(OkCallback callback, void* context);
|
||||
void call_ok_callback();
|
||||
|
||||
// model data getters/setters
|
||||
void set_start_freq(uint32_t start_freq);
|
||||
uint32_t get_start_freq();
|
||||
|
||||
private:
|
||||
View* view;
|
||||
|
||||
// ok callback data
|
||||
OkCallback ok_callback = nullptr;
|
||||
void* ok_callback_context = nullptr;
|
||||
};
|
Reference in New Issue
Block a user