[FL-3168] Add one_wire lib to f18, separate ibutton (#2509)
* Separate ibutton to its own module, add one_wire to f18 * Move onewire cli to a separate app Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
parent
1d91a572cc
commit
0917494a80
@ -4,6 +4,7 @@ App(
|
||||
apptype=FlipperAppType.METAPACKAGE,
|
||||
provides=[
|
||||
"gpio",
|
||||
"onewire",
|
||||
"ibutton",
|
||||
"infrared",
|
||||
"lfrfid",
|
||||
|
@ -4,25 +4,20 @@
|
||||
#include <cli/cli.h>
|
||||
#include <toolbox/args.h>
|
||||
|
||||
#include <one_wire/one_wire_host.h>
|
||||
|
||||
#include <one_wire/ibutton/ibutton_key.h>
|
||||
#include <one_wire/ibutton/ibutton_worker.h>
|
||||
#include <one_wire/ibutton/ibutton_protocols.h>
|
||||
#include <ibutton/ibutton_key.h>
|
||||
#include <ibutton/ibutton_worker.h>
|
||||
#include <ibutton/ibutton_protocols.h>
|
||||
|
||||
static void ibutton_cli(Cli* cli, FuriString* args, void* context);
|
||||
static void onewire_cli(Cli* cli, FuriString* args, void* context);
|
||||
|
||||
// app cli function
|
||||
void ibutton_on_system_start() {
|
||||
#ifdef SRV_CLI
|
||||
Cli* cli = furi_record_open(RECORD_CLI);
|
||||
cli_add_command(cli, "ikey", CliCommandFlagDefault, ibutton_cli, cli);
|
||||
cli_add_command(cli, "onewire", CliCommandFlagDefault, onewire_cli, cli);
|
||||
furi_record_close(RECORD_CLI);
|
||||
#else
|
||||
UNUSED(ibutton_cli);
|
||||
UNUSED(onewire_cli);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -257,56 +252,3 @@ void ibutton_cli(Cli* cli, FuriString* args, void* context) {
|
||||
|
||||
furi_string_free(cmd);
|
||||
}
|
||||
|
||||
static void onewire_cli_print_usage() {
|
||||
printf("Usage:\r\n");
|
||||
printf("onewire search\r\n");
|
||||
};
|
||||
|
||||
static void onewire_cli_search(Cli* cli) {
|
||||
UNUSED(cli);
|
||||
OneWireHost* onewire = onewire_host_alloc(&ibutton_gpio);
|
||||
uint8_t address[8];
|
||||
bool done = false;
|
||||
|
||||
printf("Search started\r\n");
|
||||
|
||||
onewire_host_start(onewire);
|
||||
furi_hal_power_enable_otg();
|
||||
|
||||
while(!done) {
|
||||
if(onewire_host_search(onewire, address, OneWireHostSearchModeNormal) != 1) {
|
||||
printf("Search finished\r\n");
|
||||
onewire_host_reset_search(onewire);
|
||||
done = true;
|
||||
} else {
|
||||
printf("Found: ");
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
printf("%02X", address[i]);
|
||||
}
|
||||
printf("\r\n");
|
||||
}
|
||||
furi_delay_ms(100);
|
||||
}
|
||||
|
||||
furi_hal_power_disable_otg();
|
||||
onewire_host_free(onewire);
|
||||
}
|
||||
|
||||
void onewire_cli(Cli* cli, FuriString* args, void* context) {
|
||||
UNUSED(context);
|
||||
FuriString* cmd;
|
||||
cmd = furi_string_alloc();
|
||||
|
||||
if(!args_read_string_and_trim(args, cmd)) {
|
||||
furi_string_free(cmd);
|
||||
onewire_cli_print_usage();
|
||||
return;
|
||||
}
|
||||
|
||||
if(furi_string_cmp_str(cmd, "search") == 0) {
|
||||
onewire_cli_search(cli);
|
||||
}
|
||||
|
||||
furi_string_free(cmd);
|
||||
}
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include <gui/scene_manager.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
#include <one_wire/ibutton/ibutton_worker.h>
|
||||
#include <one_wire/ibutton/ibutton_protocols.h>
|
||||
#include <ibutton/ibutton_worker.h>
|
||||
#include <ibutton/ibutton_protocols.h>
|
||||
|
||||
#include <rpc/rpc_app.h>
|
||||
#include <storage/storage.h>
|
||||
|
14
applications/main/onewire/application.fam
Normal file
14
applications/main/onewire/application.fam
Normal file
@ -0,0 +1,14 @@
|
||||
App(
|
||||
appid="onewire",
|
||||
name="1-Wire",
|
||||
apptype=FlipperAppType.METAPACKAGE,
|
||||
provides=["onewire_start"],
|
||||
)
|
||||
|
||||
App(
|
||||
appid="onewire_start",
|
||||
apptype=FlipperAppType.STARTUP,
|
||||
entry_point="onewire_on_system_start",
|
||||
requires=["onewire"],
|
||||
order=60,
|
||||
)
|
72
applications/main/onewire/onewire_cli.c
Normal file
72
applications/main/onewire/onewire_cli.c
Normal file
@ -0,0 +1,72 @@
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
#include <cli/cli.h>
|
||||
#include <toolbox/args.h>
|
||||
|
||||
#include <one_wire/one_wire_host.h>
|
||||
|
||||
static void onewire_cli(Cli* cli, FuriString* args, void* context);
|
||||
|
||||
void onewire_on_system_start() {
|
||||
#ifdef SRV_CLI
|
||||
Cli* cli = furi_record_open(RECORD_CLI);
|
||||
cli_add_command(cli, "onewire", CliCommandFlagDefault, onewire_cli, cli);
|
||||
furi_record_close(RECORD_CLI);
|
||||
#else
|
||||
UNUSED(onewire_cli);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void onewire_cli_print_usage() {
|
||||
printf("Usage:\r\n");
|
||||
printf("onewire search\r\n");
|
||||
};
|
||||
|
||||
static void onewire_cli_search(Cli* cli) {
|
||||
UNUSED(cli);
|
||||
OneWireHost* onewire = onewire_host_alloc(&ibutton_gpio);
|
||||
uint8_t address[8];
|
||||
bool done = false;
|
||||
|
||||
printf("Search started\r\n");
|
||||
|
||||
onewire_host_start(onewire);
|
||||
furi_hal_power_enable_otg();
|
||||
|
||||
while(!done) {
|
||||
if(onewire_host_search(onewire, address, OneWireHostSearchModeNormal) != 1) {
|
||||
printf("Search finished\r\n");
|
||||
onewire_host_reset_search(onewire);
|
||||
done = true;
|
||||
} else {
|
||||
printf("Found: ");
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
printf("%02X", address[i]);
|
||||
}
|
||||
printf("\r\n");
|
||||
}
|
||||
furi_delay_ms(100);
|
||||
}
|
||||
|
||||
furi_hal_power_disable_otg();
|
||||
onewire_host_free(onewire);
|
||||
}
|
||||
|
||||
void onewire_cli(Cli* cli, FuriString* args, void* context) {
|
||||
UNUSED(context);
|
||||
FuriString* cmd;
|
||||
cmd = furi_string_alloc();
|
||||
|
||||
if(!args_read_string_and_trim(args, cmd)) {
|
||||
furi_string_free(cmd);
|
||||
onewire_cli_print_usage();
|
||||
return;
|
||||
}
|
||||
|
||||
if(furi_string_cmp_str(cmd, "search") == 0) {
|
||||
onewire_cli_search(cli);
|
||||
}
|
||||
|
||||
furi_string_free(cmd);
|
||||
}
|
@ -151,6 +151,10 @@ Header,+,lib/mlib/m-list.h,,
|
||||
Header,+,lib/mlib/m-rbtree.h,,
|
||||
Header,+,lib/mlib/m-tuple.h,,
|
||||
Header,+,lib/mlib/m-variant.h,,
|
||||
Header,+,lib/one_wire/maxim_crc.h,,
|
||||
Header,+,lib/one_wire/one_wire_host.h,,
|
||||
Header,+,lib/one_wire/one_wire_host_timing.h,,
|
||||
Header,+,lib/one_wire/one_wire_slave.h,,
|
||||
Header,+,lib/print/wrappers.h,,
|
||||
Header,+,lib/toolbox/args.h,,
|
||||
Header,+,lib/toolbox/crc32_calc.h,,
|
||||
@ -1394,6 +1398,7 @@ Function,+,manchester_advance,_Bool,"ManchesterState, ManchesterEvent, Mancheste
|
||||
Function,+,manchester_encoder_advance,_Bool,"ManchesterEncoderState*, const _Bool, ManchesterEncoderResult*"
|
||||
Function,+,manchester_encoder_finish,ManchesterEncoderResult,ManchesterEncoderState*
|
||||
Function,+,manchester_encoder_reset,void,ManchesterEncoderState*
|
||||
Function,+,maxim_crc8,uint8_t,"const uint8_t*, const uint8_t, const uint8_t"
|
||||
Function,-,mbedtls_des3_crypt_cbc,int,"mbedtls_des3_context*, int, size_t, unsigned char[8], const unsigned char*, unsigned char*"
|
||||
Function,-,mbedtls_des3_crypt_ecb,int,"mbedtls_des3_context*, const unsigned char[8], unsigned char[8]"
|
||||
Function,-,mbedtls_des3_free,void,mbedtls_des3_context*
|
||||
@ -1472,6 +1477,32 @@ Function,+,notification_message,void,"NotificationApp*, const NotificationSequen
|
||||
Function,+,notification_message_block,void,"NotificationApp*, const NotificationSequence*"
|
||||
Function,-,nrand48,long,unsigned short[3]
|
||||
Function,-,on_exit,int,"void (*)(int, void*), void*"
|
||||
Function,+,onewire_host_alloc,OneWireHost*,const GpioPin*
|
||||
Function,+,onewire_host_free,void,OneWireHost*
|
||||
Function,+,onewire_host_read,uint8_t,OneWireHost*
|
||||
Function,+,onewire_host_read_bit,_Bool,OneWireHost*
|
||||
Function,+,onewire_host_read_bytes,void,"OneWireHost*, uint8_t*, uint16_t"
|
||||
Function,+,onewire_host_reset,_Bool,OneWireHost*
|
||||
Function,+,onewire_host_reset_search,void,OneWireHost*
|
||||
Function,+,onewire_host_search,uint8_t,"OneWireHost*, uint8_t*, OneWireHostSearchMode"
|
||||
Function,+,onewire_host_skip,void,OneWireHost*
|
||||
Function,+,onewire_host_start,void,OneWireHost*
|
||||
Function,+,onewire_host_stop,void,OneWireHost*
|
||||
Function,+,onewire_host_target_search,void,"OneWireHost*, uint8_t"
|
||||
Function,+,onewire_host_write,void,"OneWireHost*, uint8_t"
|
||||
Function,+,onewire_host_write_bit,void,"OneWireHost*, _Bool"
|
||||
Function,+,onewire_host_write_bytes,void,"OneWireHost*, const uint8_t*, uint16_t"
|
||||
Function,+,onewire_slave_alloc,OneWireSlave*,const GpioPin*
|
||||
Function,+,onewire_slave_free,void,OneWireSlave*
|
||||
Function,+,onewire_slave_receive,_Bool,"OneWireSlave*, uint8_t*, size_t"
|
||||
Function,+,onewire_slave_receive_bit,_Bool,OneWireSlave*
|
||||
Function,+,onewire_slave_send,_Bool,"OneWireSlave*, const uint8_t*, size_t"
|
||||
Function,+,onewire_slave_send_bit,_Bool,"OneWireSlave*, _Bool"
|
||||
Function,+,onewire_slave_set_command_callback,void,"OneWireSlave*, OneWireSlaveCommandCallback, void*"
|
||||
Function,+,onewire_slave_set_reset_callback,void,"OneWireSlave*, OneWireSlaveResetCallback, void*"
|
||||
Function,+,onewire_slave_set_result_callback,void,"OneWireSlave*, OneWireSlaveResultCallback, void*"
|
||||
Function,+,onewire_slave_start,void,OneWireSlave*
|
||||
Function,+,onewire_slave_stop,void,OneWireSlave*
|
||||
Function,-,open_memstream,FILE*,"char**, size_t*"
|
||||
Function,+,path_append,void,"FuriString*, const char*"
|
||||
Function,+,path_concat,void,"const char*, const char*, FuriString*"
|
||||
|
|
@ -24,6 +24,7 @@
|
||||
"usb_stm32",
|
||||
"appframe",
|
||||
"assets",
|
||||
"one_wire",
|
||||
"misc",
|
||||
"flipper_application",
|
||||
"flipperformat",
|
||||
@ -45,10 +46,10 @@
|
||||
"furi_hal_subghz_configs.h"
|
||||
],
|
||||
"excluded_modules": [
|
||||
"one_wire",
|
||||
"nfc",
|
||||
"lfrfid",
|
||||
"subghz",
|
||||
"ibutton",
|
||||
"infrared",
|
||||
"st25rfal002"
|
||||
]
|
||||
|
@ -118,6 +118,9 @@ Header,+,lib/flipper_application/plugins/composite_resolver.h,,
|
||||
Header,+,lib/flipper_application/plugins/plugin_manager.h,,
|
||||
Header,+,lib/flipper_format/flipper_format.h,,
|
||||
Header,+,lib/flipper_format/flipper_format_i.h,,
|
||||
Header,+,lib/ibutton/ibutton_key.h,,
|
||||
Header,+,lib/ibutton/ibutton_protocols.h,,
|
||||
Header,+,lib/ibutton/ibutton_worker.h,,
|
||||
Header,+,lib/infrared/encoder_decoder/infrared.h,,
|
||||
Header,+,lib/infrared/worker/infrared_transmit.h,,
|
||||
Header,+,lib/infrared/worker/infrared_worker.h,,
|
||||
@ -167,9 +170,6 @@ Header,+,lib/mlib/m-rbtree.h,,
|
||||
Header,+,lib/mlib/m-tuple.h,,
|
||||
Header,+,lib/mlib/m-variant.h,,
|
||||
Header,+,lib/nfc/nfc_device.h,,
|
||||
Header,+,lib/one_wire/ibutton/ibutton_key.h,,
|
||||
Header,+,lib/one_wire/ibutton/ibutton_protocols.h,,
|
||||
Header,+,lib/one_wire/ibutton/ibutton_worker.h,,
|
||||
Header,+,lib/one_wire/maxim_crc.h,,
|
||||
Header,+,lib/one_wire/one_wire_host.h,,
|
||||
Header,+,lib/one_wire/one_wire_host_timing.h,,
|
||||
|
|
@ -35,6 +35,7 @@
|
||||
"appframe",
|
||||
"assets",
|
||||
"one_wire",
|
||||
"ibutton",
|
||||
"misc",
|
||||
"mbedtls",
|
||||
"lfrfid",
|
||||
|
@ -87,6 +87,7 @@ libs = env.BuildModules(
|
||||
"fatfs",
|
||||
"flipper_format",
|
||||
"one_wire",
|
||||
"ibutton",
|
||||
"infrared",
|
||||
"littlefs",
|
||||
"mbedtls",
|
||||
|
24
lib/ibutton/SConscript
Normal file
24
lib/ibutton/SConscript
Normal file
@ -0,0 +1,24 @@
|
||||
Import("env")
|
||||
|
||||
env.Append(
|
||||
LINT_SOURCES=[
|
||||
Dir("."),
|
||||
],
|
||||
CPPPATH=[
|
||||
"#/lib/ibutton",
|
||||
],
|
||||
SDK_HEADERS=[
|
||||
File("ibutton_key.h"),
|
||||
File("ibutton_worker.h"),
|
||||
File("ibutton_protocols.h"),
|
||||
],
|
||||
)
|
||||
|
||||
libenv = env.Clone(FW_LIB_NAME="ibutton")
|
||||
libenv.ApplyLibFlags()
|
||||
|
||||
sources = libenv.GlobRecursive("*.c*")
|
||||
|
||||
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
|
||||
libenv.Install("${LIB_DIST_DIR}", lib)
|
||||
Return("lib")
|
@ -11,9 +11,6 @@ env.Append(
|
||||
File("one_wire_host_timing.h"),
|
||||
File("one_wire_host.h"),
|
||||
File("one_wire_slave.h"),
|
||||
File("ibutton/ibutton_key.h"),
|
||||
File("ibutton/ibutton_worker.h"),
|
||||
File("ibutton/ibutton_protocols.h"),
|
||||
File("maxim_crc.h"),
|
||||
],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user