[FL-1744] CLI: rename tm to ikey, add onewire search command (#672)
* CLI: rename tm to ikey, add onewire search command * Cli onewire: removed delimiters in addresses Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
08f7a290a4
commit
941b733046
@ -10,18 +10,20 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
void ibutton_cli(Cli* cli, string_t args, void* context);
|
void ibutton_cli(Cli* cli, string_t args, void* context);
|
||||||
|
void onewire_cli(Cli* cli, string_t args, void* context);
|
||||||
|
|
||||||
// app cli function
|
// app cli function
|
||||||
extern "C" void ibutton_cli_init() {
|
extern "C" void ibutton_cli_init() {
|
||||||
Cli* cli = static_cast<Cli*>(furi_record_open("cli"));
|
Cli* cli = static_cast<Cli*>(furi_record_open("cli"));
|
||||||
cli_add_command(cli, "tm", CliCommandFlagDefault, ibutton_cli, cli);
|
cli_add_command(cli, "ikey", CliCommandFlagDefault, ibutton_cli, cli);
|
||||||
|
cli_add_command(cli, "onewire", CliCommandFlagDefault, onewire_cli, cli);
|
||||||
furi_record_close("cli");
|
furi_record_close("cli");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ibutton_cli_print_usage() {
|
void ibutton_cli_print_usage() {
|
||||||
printf("Usage:\r\n");
|
printf("Usage:\r\n");
|
||||||
printf("tm read\r\n");
|
printf("ikey read\r\n");
|
||||||
printf("tm <write | emulate> <key_type> <key_data>\r\n");
|
printf("ikey <write | emulate> <key_type> <key_data>\r\n");
|
||||||
printf("\t<key_type> choose from:\r\n");
|
printf("\t<key_type> choose from:\r\n");
|
||||||
printf("\tDallas (8 bytes key_data)\r\n");
|
printf("\tDallas (8 bytes key_data)\r\n");
|
||||||
printf("\tCyfral (2 bytes key_data)\r\n");
|
printf("\tCyfral (2 bytes key_data)\r\n");
|
||||||
@ -232,3 +234,51 @@ void ibutton_cli(Cli* cli, string_t args, void* context) {
|
|||||||
|
|
||||||
string_clear(cmd);
|
string_clear(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onewire_cli_print_usage() {
|
||||||
|
printf("Usage:\r\n");
|
||||||
|
printf("onewire search\r\n");
|
||||||
|
};
|
||||||
|
|
||||||
|
void onewire_cli_search(Cli* cli) {
|
||||||
|
OneWireMaster onewire(&ibutton_gpio);
|
||||||
|
uint8_t address[8];
|
||||||
|
bool done = false;
|
||||||
|
|
||||||
|
printf("Search started\r\n");
|
||||||
|
|
||||||
|
onewire.start();
|
||||||
|
while(!done) {
|
||||||
|
if(onewire.search(address, true) != 1) {
|
||||||
|
printf("Search finished\r\n");
|
||||||
|
onewire.reset_search();
|
||||||
|
done = true;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
printf("Found: ");
|
||||||
|
for(uint8_t i = 0; i < 8; i++) {
|
||||||
|
printf("%02X", address[i]);
|
||||||
|
}
|
||||||
|
printf("\r\n");
|
||||||
|
}
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
onewire.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void onewire_cli(Cli* cli, string_t args, void* context) {
|
||||||
|
string_t cmd;
|
||||||
|
string_init(cmd);
|
||||||
|
|
||||||
|
if(!args_read_string_and_trim(args, cmd)) {
|
||||||
|
string_clear(cmd);
|
||||||
|
onewire_cli_print_usage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(string_cmp_str(cmd, "search") == 0) {
|
||||||
|
onewire_cli_search(cli);
|
||||||
|
}
|
||||||
|
|
||||||
|
string_clear(cmd);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user