Skip to content

Commit 3705725

Browse files
committed
Merge branch 'dev' into 'main'
Dev See merge request flipper-zero/bc_scanner_e!1
2 parents e4be521 + 28dcc4b commit 3705725

18 files changed

+899
-90
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
.idea

README.md

Lines changed: 31 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,33 @@
1-
# BarCodeScannerEmulator
2-
3-
4-
5-
## Getting started
6-
7-
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
8-
9-
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
10-
11-
## Add your files
12-
13-
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
14-
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
15-
16-
```
17-
cd existing_repo
18-
git remote add origin https://gitlab.idcloud.space/flipper-zero/bc_scanner_e.git
19-
git branch -M main
20-
git push -uf origin main
21-
```
22-
23-
## Integrate with your tools
24-
25-
- [ ] [Set up project integrations](https://gitlab.idcloud.space/flipper-zero/bc_scanner_e/-/settings/integrations)
26-
27-
## Collaborate with your team
28-
29-
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
30-
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
31-
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
32-
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
33-
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
34-
35-
## Test and Deploy
36-
37-
Use the built-in continuous integration in GitLab.
38-
39-
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
40-
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
41-
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
42-
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
43-
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
44-
45-
***
46-
47-
# Editing this README
48-
49-
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
50-
51-
## Suggestions for a good README
52-
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
53-
54-
## Name
55-
Choose a self-explaining name for your project.
56-
57-
## Description
58-
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
59-
60-
## Badges
61-
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
62-
63-
## Visuals
64-
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
1+
# Bar code scanner emulator
2+
### Scanner work at COM-port emulation.
3+
### Characteristics
4+
* Speed: 19200 (Bit Rate)
5+
* VID: 1155 | PID: 22336
6+
* Name: Flipper {Your Flipper name}
7+
* Manufacturer Name: Flipper Devices Inc.
8+
* SerialNumber=flip_{Your Flipper name}
659

6610
## Installation
67-
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
68-
69-
## Usage
70-
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
71-
72-
## Support
73-
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
74-
75-
## Roadmap
76-
If you have ideas for releases in the future, it is a good idea to list them in the README.
77-
78-
## Contributing
79-
State if you are open to contributions and what your requirements are for accepting them.
80-
81-
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
82-
83-
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
84-
85-
## Authors and acknowledgment
86-
Show your appreciation to those who have contributed to the project.
87-
88-
## License
89-
For open source projects, say how it is licensed.
90-
91-
## Project status
92-
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
11+
1. Copy bc_scanner.fap file in Flipper SDCard (apps folder)
12+
2. Make "/bcscanner" folder in Flipper SDCard
13+
3. Add bar code files (.bc) in "bcscanner" folder
14+
15+
## GUI
16+
### App icon and name
17+
![Screenshot](https://gitlab.idcloud.space/flipper-zero/bc_scanner_e/-/wikis/uploads/4c4fabf431947ef31a6e4e8103154b0f/icon.png)
18+
### File Select
19+
After open app - select bar code to be emulated
20+
![Screenshot](https://gitlab.idcloud.space/flipper-zero/bc_scanner_e/-/wikis/uploads/a03a1fa3e8bea95510eca7e10af5b5cd/catalog.png)
21+
### Emulation
22+
1. Click "Run" Button \
23+
![Screenshot](https://gitlab.idcloud.space/flipper-zero/bc_scanner_e/-/wikis/uploads/2b6144eebd5e88caa8adc5e0c7514342/Runing.png) \
24+
When sending completed You will see 100% on the display:
25+
![Screenshot](https://gitlab.idcloud.space/flipper-zero/bc_scanner_e/-/wikis/uploads/676d868d7c377ef9d0f42706bcd83913/EndRun.png)
26+
2. If you need to resend, click "Run" again
27+
3. To exit - press the "Back" button on the flipper
28+
29+
## Create Bar Code File
30+
1. Open the .txt file in an editor that recognizes GS special characters, such as sublime text
31+
2. Add a barcode in any format, such as GS1 format
32+
3. Save file and change extension on .bc
33+
4. Copy file in Flipper SDCard, to "/bcscanner" folder

application.fam

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
App(
2+
appid="bc_scanner",
3+
name="BarCode ScannerE",
4+
apptype=FlipperAppType.EXTERNAL,
5+
entry_point="bc_scanner_app",
6+
cdefines=["APP_BC_SCANNER"],
7+
requires=[
8+
"gui",
9+
"dialogs",
10+
],
11+
stack_size=2 * 1024,
12+
fap_icon="logo_bc.png",
13+
fap_libs=["assets"],
14+
fap_description="Bar Code Emulator app for Evotor",
15+
fap_author="Igor Danilov",
16+
fap_version=(0, 5),
17+
order=70,
18+
fap_category="Tools",
19+
fap_icon_assets="icons"
20+
)
21+

bc_scanner_app.c

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#include "bc_scanner_app_i.h"
2+
#include <furi.h>
3+
#include <furi_hal.h>
4+
#include <storage/storage.h>
5+
#include <lib/toolbox/path.h>
6+
#define TAG "BarCodeScanner"
7+
#define WORKER_TAG TAG "App"
8+
9+
static bool bc_scanner_app_custom_event_callback(void* context, uint32_t event) {
10+
furi_assert(context);
11+
BarCodeApp* app = context;
12+
return scene_manager_handle_custom_event(app->scene_manager, event);
13+
}
14+
15+
static bool bc_scanner_app_back_event_callback(void* context) {
16+
furi_assert(context);
17+
BarCodeApp* app = context;
18+
return scene_manager_handle_back_event(app->scene_manager);
19+
}
20+
21+
static void bc_scanner_app_tick_event_callback(void* context) {
22+
furi_assert(context);
23+
BarCodeApp* app = context;
24+
scene_manager_handle_tick_event(app->scene_manager);
25+
}
26+
27+
BarCodeApp* bc_scanner_app_alloc(char* arg) {
28+
FURI_LOG_D(WORKER_TAG, "Start AppAlloc");
29+
BarCodeApp* app = malloc(sizeof(BarCodeApp));
30+
31+
app->file_path = furi_string_alloc();
32+
33+
if(arg && strlen(arg)) {
34+
furi_string_set(app->file_path, arg);
35+
FURI_LOG_D(WORKER_TAG, "File Path Setted");
36+
}
37+
38+
app->gui = furi_record_open(RECORD_GUI);
39+
app->notifications = furi_record_open(RECORD_NOTIFICATION);
40+
app->dialogs = furi_record_open(RECORD_DIALOGS);
41+
42+
app->view_dispatcher = view_dispatcher_alloc();
43+
view_dispatcher_enable_queue(app->view_dispatcher);
44+
45+
app->scene_manager = scene_manager_alloc(&bc_scanner_scene_handlers, app);
46+
47+
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
48+
view_dispatcher_set_tick_event_callback(
49+
app->view_dispatcher, bc_scanner_app_tick_event_callback, 500);
50+
view_dispatcher_set_custom_event_callback(
51+
app->view_dispatcher, bc_scanner_app_custom_event_callback);
52+
view_dispatcher_set_navigation_event_callback(
53+
app->view_dispatcher, bc_scanner_app_back_event_callback);
54+
55+
// Custom Widget
56+
app->widget = widget_alloc();
57+
view_dispatcher_add_view(
58+
app->view_dispatcher, BarCodeAppViewError, widget_get_view(app->widget));
59+
60+
app->bc_scanner_view = bc_scanner_alloc();
61+
view_dispatcher_add_view(
62+
app->view_dispatcher, BarCodeAppViewWork, bc_scanner_get_view(app->bc_scanner_view));
63+
64+
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
65+
66+
if(furi_hal_usb_is_locked()) {
67+
app->error = BarCodeAppErrorCloseRpc;
68+
scene_manager_next_scene(app->scene_manager, BarCodeSceneError);
69+
} else {
70+
if(!furi_string_empty(app->file_path)) {
71+
scene_manager_next_scene(app->scene_manager, BarCodeSceneWork);
72+
} else {
73+
furi_string_set(app->file_path, BC_SCANNER_APP_PATH_FOLDER);
74+
scene_manager_next_scene(app->scene_manager, BarCodeSceneFileSelect);
75+
}
76+
}
77+
FURI_LOG_D(WORKER_TAG, "End AppAlloc");
78+
return app;
79+
}
80+
81+
void bc_scanner_app_free(BarCodeApp* app) {
82+
furi_assert(app);
83+
84+
// Views
85+
view_dispatcher_remove_view(app->view_dispatcher, BarCodeAppViewWork);
86+
bc_scanner_free(app->bc_scanner_view);
87+
88+
// Custom Widget
89+
view_dispatcher_remove_view(app->view_dispatcher, BarCodeAppViewError);
90+
widget_free(app->widget);
91+
92+
// View dispatcher
93+
view_dispatcher_free(app->view_dispatcher);
94+
scene_manager_free(app->scene_manager);
95+
96+
// Close records
97+
furi_record_close(RECORD_GUI);
98+
furi_record_close(RECORD_NOTIFICATION);
99+
furi_record_close(RECORD_DIALOGS);
100+
101+
furi_string_free(app->file_path);
102+
103+
free(app);
104+
FURI_LOG_D(WORKER_TAG, "App Free");
105+
}
106+
107+
int32_t bc_scanner_app(void* p) {
108+
FURI_LOG_D(WORKER_TAG, "Start App");
109+
BarCodeApp* bar_code_app = bc_scanner_app_alloc((char*)p);
110+
111+
view_dispatcher_run(bar_code_app->view_dispatcher);
112+
113+
bc_scanner_app_free(bar_code_app);
114+
return 0;
115+
}

bc_scanner_app.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
typedef struct BarCodeApp BarCodeApp;
8+
9+
#ifdef __cplusplus
10+
}
11+
#endif

bc_scanner_app_i.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#pragma once
2+
3+
#include "bc_scanner_app.h"
4+
#include "scenes/bc_scanner_scene.h"
5+
6+
#include <gui/gui.h>
7+
#include <gui/icon_i.h>
8+
#include <bc_scanner_icons.h>
9+
#include <gui/view_dispatcher.h>
10+
#include <gui/scene_manager.h>
11+
#include <gui/modules/submenu.h>
12+
#include <dialogs/dialogs.h>
13+
#include <notification/notification_messages.h>
14+
#include <gui/modules/variable_item_list.h>
15+
#include <gui/modules/widget.h>
16+
#include "views/bc_scanner_view.h"
17+
18+
#define BC_SCANNER_APP_PATH_FOLDER ANY_PATH("bcscanner")
19+
#define BC_SCANNER_APP_EXTENSION ".bc"
20+
21+
typedef enum {
22+
BarCodeAppErrorNoFiles,
23+
BarCodeAppErrorCloseRpc,
24+
} BarCodeAppError;
25+
26+
struct BarCodeApp {
27+
Gui* gui;
28+
ViewDispatcher* view_dispatcher;
29+
SceneManager* scene_manager;
30+
NotificationApp* notifications;
31+
DialogsApp* dialogs;
32+
Widget* widget;
33+
34+
BarCodeAppError error;
35+
FuriString* file_path;
36+
BarCodeView* bc_scanner_view;
37+
BarCodeScript* bc_scanner_script;
38+
};
39+
40+
typedef enum {
41+
BarCodeAppViewError,
42+
BarCodeAppViewWork,
43+
} BarCodeAppView;

0 commit comments

Comments
 (0)