Skip to content

Commit d866416

Browse files
authored
Merge pull request #20 from leedave/feature/td174
Feature/td174
2 parents 01e8273 + e2e3c2e commit d866416

15 files changed

+152
-13
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ This app triggers restaurant pagers in a brute force manner, useful to test if d
77
## Supported Pagers
88
- Retekess T119
99
- Retekess TD157
10-
- Retekess TD165 (coming soon)
11-
- Retekess TD174 (coming soon)
10+
- Retekess TD165
11+
- Retekess TD174
1212

1313
### Features
1414
- Select range of stations (needs improving for full range)

application.fam

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ App(
77
fap_icon="icons/meal_pager_10px.png",
88
fap_icon_assets="icons",
99
fap_category="Sub-Ghz",
10-
fap_version="0.8",
10+
fap_version="1.0",
1111
fap_author="leedave",
1212
fap_weburl="https://github.com/leedave/flipper-zero-meal-pager",
1313
fap_description="This app triggers restaurant pagers in a brute force manner, useful to test if devices are still functional.",

docs/changelog.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v1.0
2+
- Added support for TD174
3+
4+
## v0.9
5+
- Added support for TD165
6+
17
## v0.8
28
- Added Repeats feature
39
- Repeats configuration in settings

helpers/meal_pager_storage.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static void meal_pager_close_config_file(FlipperFormat* file) {
1515
flipper_format_free(file);
1616
}
1717

18-
bool meal_pager_save_subghz_buffer_file_start(void* context, FlipperFormat* ff, Storage* storage) {
18+
bool meal_pager_save_subghz_buffer_file_start(void* context, FlipperFormat* ff, Storage* storage, char* frequency) {
1919
// SubGhz TXRX can only be loaded with files, makes sense as to save RAM
2020
Meal_Pager* app = context;
2121
UNUSED(app);
@@ -56,12 +56,10 @@ bool meal_pager_save_subghz_buffer_file_start(void* context, FlipperFormat* ff,
5656
success =
5757
flipper_format_write_header_cstr(
5858
ff, MEAL_PAGER_SUBGHZ_FILE_TYPE, MEAL_PAGER_SUBGHZ_FILE_VERSION) &&
59-
flipper_format_write_string_cstr(ff, "Frequency", MEAL_PAGER_SUBGHZ_FILE_FREQUENCY) &&
59+
flipper_format_write_string_cstr(ff, "Frequency", frequency) &&
6060
flipper_format_write_string_cstr(ff, "Preset", MEAL_PAGER_SUBGHZ_FILE_PRESET) &&
6161
flipper_format_write_string_cstr(ff, "Protocol", MEAL_PAGER_SUBGHZ_FILE_Protocol);
62-
//UNUSED(success);
6362
return success;
64-
//return ff;
6563
}
6664

6765
void meal_pager_save_subghz_buffer_stop(void* context, FlipperFormat* ff) {

helpers/meal_pager_storage.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
#define MEAL_PAGER_SUBGHZ_FILE_TYPE "Flipper SubGhz RAW File"
2626
#define MEAL_PAGER_SUBGHZ_FILE_VERSION 1
2727
#define MEAL_PAGER_SUBGHZ_FILE_FREQUENCY "433920000"
28+
#define MEAL_PAGER_SUBGHZ_FILE_ALT_FREQUENCY "433889000"
2829
#define MEAL_PAGER_SUBGHZ_FILE_PRESET "FuriHalSubGhzPresetOok650Async"
2930
#define MEAL_PAGER_SUBGHZ_FILE_Protocol "RAW"
3031

31-
bool meal_pager_save_subghz_buffer_file_start(void* context, FlipperFormat* ff, Storage* storage);
32+
bool meal_pager_save_subghz_buffer_file_start(void* context, FlipperFormat* ff, Storage* storage, char* frequency);
3233

3334
void meal_pager_save_subghz_buffer_stop(void* context, FlipperFormat* ff);
3435

helpers/retekess/meal_pager_retekess_t119.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ bool meal_pager_retekess_t119_generate_all(void* context) {
107107

108108
Storage* storage = furi_record_open(RECORD_STORAGE);
109109
FlipperFormat* ff = flipper_format_file_alloc(storage);
110-
bool success = meal_pager_save_subghz_buffer_file_start(app, ff, storage);
110+
bool success = meal_pager_save_subghz_buffer_file_start(app, ff, storage, MEAL_PAGER_SUBGHZ_FILE_FREQUENCY);
111111

112112
if(!success) {
113113
FURI_LOG_D(TAG, "failed to save to buffer");

helpers/retekess/meal_pager_retekess_t119.h

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33

44
#include "../../meal_pager_i.h"
55
#include "../meal_pager_calc.h"
6+
#include "../meal_pager_storage.h"
67

78
bool meal_pager_retekess_t119_generate_all(void* context);

helpers/retekess/meal_pager_retekess_td157.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ bool meal_pager_retekess_td157_generate_all(void* context) {
9393

9494
Storage* storage = furi_record_open(RECORD_STORAGE);
9595
FlipperFormat* ff = flipper_format_file_alloc(storage);
96-
bool success = meal_pager_save_subghz_buffer_file_start(app, ff, storage);
96+
bool success = meal_pager_save_subghz_buffer_file_start(app, ff, storage, MEAL_PAGER_SUBGHZ_FILE_FREQUENCY);
9797

9898
if(!success) {
9999
FURI_LOG_D(TAG, "failed to save to buffer");

helpers/retekess/meal_pager_retekess_td157.h

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33

44
#include "../../meal_pager_i.h"
55
#include "../meal_pager_calc.h"
6+
#include "../meal_pager_storage.h"
67

78
bool meal_pager_retekess_td157_generate_all(void* context);

helpers/retekess/meal_pager_retekess_td165.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ bool meal_pager_retekess_td165_generate_all(void* context) {
9595

9696
Storage* storage = furi_record_open(RECORD_STORAGE);
9797
FlipperFormat* ff = flipper_format_file_alloc(storage);
98-
bool success = meal_pager_save_subghz_buffer_file_start(app, ff, storage);
98+
bool success = meal_pager_save_subghz_buffer_file_start(app, ff, storage, MEAL_PAGER_SUBGHZ_FILE_FREQUENCY);
9999

100100
if(!success) {
101101
FURI_LOG_D(TAG, "failed to save to buffer");

helpers/retekess/meal_pager_retekess_td165.h

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33

44
#include "../../meal_pager_i.h"
55
#include "../meal_pager_calc.h"
6+
#include "../meal_pager_storage.h"
67

78
bool meal_pager_retekess_td165_generate_all(void* context);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
2+
#include "meal_pager_retekess_td174.h"
3+
4+
static char* genRawDataTd174(int zero, int one, const char* bits) {
5+
int bitsLen = strlen(bits);
6+
int lineLen = 256; // Adjust the line length as needed
7+
char* line = (char*)malloc(lineLen * sizeof(char));
8+
9+
// Initialize the line with the first part
10+
char* res = (char*)malloc(lineLen * sizeof(char));
11+
res[0] = '\0'; // Null-terminate the result string
12+
13+
customConcat(res, "-6000 300 -900"); // Always starts with 01
14+
15+
// Append bits and create the line
16+
for(int i = 0; i < bitsLen; i++) {
17+
char c = bits[i];
18+
int t = (c == '0') ? zero : one;
19+
20+
if(i % 2 == 0) {
21+
snprintf(line, lineLen, " %d", t);
22+
} else {
23+
snprintf(line, lineLen, " -%d", t);
24+
}
25+
26+
// Concatenate the line to the result string
27+
customConcat(res, line);
28+
}
29+
30+
// Append the closing part to the line
31+
customConcat(res, " 300 -6000");
32+
33+
free(line); // Free memory allocated for the line
34+
35+
return res;
36+
}
37+
38+
static void meal_pager_retekess_td174_generate_pager(
39+
void* context,
40+
char* stationId,
41+
uint32_t pager,
42+
FlipperFormat* ff) {
43+
Meal_Pager* app = context;
44+
char pagerId[11];
45+
char* fullId = (char*)malloc(25 * sizeof(char));
46+
uint32_t action = 0; // 0 = ring, 1 = mute
47+
char actionId[2];
48+
//FURI_LOG_D(TAG, "Generating TD174 Data for Pager %lu", pager);
49+
app->current_pager = pager;
50+
meal_pager_transmit_model_set_pager(app->meal_pager_transmit, app->current_pager);
51+
uint32ToBinaray(pager, pagerId, 8);
52+
uint32ToBinaray(action, actionId, 2);
53+
reverse(pagerId);
54+
reverse(actionId);
55+
//FURI_LOG_D(TAG, "Station Bin: %s", stationId);
56+
//FURI_LOG_D(TAG, "Pager Bin: %s", pagerId);
57+
//FURI_LOG_D(TAG, "Action Bin: %s", actionId);
58+
customConcat(fullId, stationId);
59+
customConcat(fullId, actionId);
60+
customConcat(fullId, pagerId);
61+
char* manchester = encManchester(fullId, 0);
62+
char* rawSignal = genRawDataTd174(300, 900, manchester);
63+
for(u_int32_t i = 1; app->repeats >= i; i++) {
64+
flipper_format_write_string_cstr(ff, "RAW_Data", rawSignal);
65+
}
66+
free(manchester);
67+
free(rawSignal);
68+
}
69+
70+
static void
71+
meal_pager_retekess_td174_generate_station(void* context, uint32_t station, FlipperFormat* ff) {
72+
Meal_Pager* app = context;
73+
FURI_LOG_D(
74+
TAG,
75+
"Generating TD174 Data for Station %lu. Pagers From %lu to %lu",
76+
station,
77+
app->first_pager,
78+
app->last_pager);
79+
app->current_station = station;
80+
app->current_pager = app->first_pager;
81+
char stationId[14];
82+
uint32ToBinaray(station, stationId, 13);
83+
reverse(stationId);
84+
meal_pager_transmit_model_set_station(app->meal_pager_transmit, app->current_station);
85+
for(u_int32_t i = app->current_pager; i <= app->last_pager; i++) {
86+
meal_pager_retekess_td174_generate_pager(app, stationId, i, ff);
87+
if(app->stop_transmit) {
88+
break;
89+
}
90+
}
91+
}
92+
93+
bool meal_pager_retekess_td174_generate_all(void* context) {
94+
Meal_Pager* app = context;
95+
96+
app->current_pager = 1;
97+
app->current_station = app->first_station;
98+
99+
Storage* storage = furi_record_open(RECORD_STORAGE);
100+
FlipperFormat* ff = flipper_format_file_alloc(storage);
101+
bool success = meal_pager_save_subghz_buffer_file_start(app, ff, storage, MEAL_PAGER_SUBGHZ_FILE_ALT_FREQUENCY);
102+
103+
if(!success) {
104+
FURI_LOG_D(TAG, "failed to save to buffer");
105+
meal_pager_save_subghz_buffer_stop(app, ff);
106+
furi_record_close(RECORD_STORAGE);
107+
return success;
108+
}
109+
110+
for(u_int32_t i = app->current_station; i <= app->last_station; i++) {
111+
meal_pager_retekess_td174_generate_station(app, i, ff);
112+
//furi_thread_flags_wait(0, FuriFlagWaitAny, 100);
113+
if(app->stop_transmit) {
114+
break;
115+
}
116+
}
117+
118+
meal_pager_save_subghz_buffer_stop(app, ff);
119+
furi_record_close(RECORD_STORAGE);
120+
return success;
121+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
#pragma once
3+
4+
#include "../../meal_pager_i.h"
5+
#include "../meal_pager_calc.h"
6+
7+
bool meal_pager_retekess_td174_generate_all(void* context);

scenes/meal_pager_scene_settings.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ void meal_pager_scene_settings_on_enter(void* context) {
153153
item = variable_item_list_add(
154154
app->variable_item_list,
155155
"Pager Type:",
156-
//4,
157-
3,
156+
4,
158157
meal_pager_scene_settings_set_pager_type,
159158
app);
160159
value_index = value_index_uint32(app->pager_type, pager_type_value, 4);

scenes/meal_pager_scene_transmit.c

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "../helpers/retekess/meal_pager_retekess_t119.h"
44
#include "../helpers/retekess/meal_pager_retekess_td157.h"
55
#include "../helpers/retekess/meal_pager_retekess_td165.h"
6+
#include "../helpers/retekess/meal_pager_retekess_td174.h"
67
#include "../views/meal_pager_transmit.h"
78
#include "../helpers/meal_pager_led.h"
89
#include "../helpers/subghz/subghz.h"
@@ -38,6 +39,9 @@ void meal_pager_scene_transmit_on_enter(void* context) {
3839
case Meal_PagerPagerTypeTD165:
3940
generated = meal_pager_retekess_td165_generate_all(app);
4041
break;
42+
case Meal_PagerPagerTypeTD174:
43+
generated = meal_pager_retekess_td174_generate_all(app);
44+
break;
4145
default:
4246
generated = false;
4347
break;

0 commit comments

Comments
 (0)