summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2023-07-02 16:32:53 +0200
committercbdev <cb@cbcdn.com>2023-07-02 16:32:53 +0200
commit2b3f7614188d766db3d31a54e7d4e2c57ebab93a (patch)
tree11344a39894f9595d42f122f6c61695989b7d3e0
parentd17413ffe8186f82977d0d1e98d5955b4d51b50d (diff)
downloadnfcommander-2b3f7614188d766db3d31a54e7d4e2c57ebab93a.tar.gz
nfcommander-2b3f7614188d766db3d31a54e7d4e2c57ebab93a.tar.bz2
nfcommander-2b3f7614188d766db3d31a54e7d4e2c57ebab93a.zip
Basic write commands
-rw-r--r--reader.c5
-rw-r--r--reader_yhy.c18
2 files changed, 19 insertions, 4 deletions
diff --git a/reader.c b/reader.c
index f90ea52..7bc20e3 100644
--- a/reader.c
+++ b/reader.c
@@ -8,6 +8,7 @@
#include "nfcommander.h"
#include "reader.h"
#include "config.h"
+#include "command.h"
#define MAX_PLUGIN_PATH NAME_MAX
#define DEFAULT_POLL_TIMEOUT 1000
@@ -148,8 +149,7 @@ static int reader_process(){
printf("Slot %2lu: ", n);
reader_print_tag(tags[n].info);
printf(" valid\n");
- printf("%s\n", tags[n].info.static_data);
- //TODO
+ command_start(&(tags[n].info));
return 0;
}
@@ -159,6 +159,7 @@ static int reader_process(){
else{
if(tags[n].flags & FLAG_ACTIVE){
//tag was removed - free any allocated members
+ command_stop(&(tags[n].info));
tag_info_free(&(tags[n].info));
printf("Tag in slot %lu removed\n", n);
}
diff --git a/reader_yhy.c b/reader_yhy.c
index 704a053..5174ef9 100644
--- a/reader_yhy.c
+++ b/reader_yhy.c
@@ -142,11 +142,19 @@ uint8_t read_ntag(nfc_tag_info_t* tag){
return FLAG_TAG_DATA_VALID;
}
+void write_ntag(nfc_tag_info_t* tag){
+ //TODO
+}
+
uint8_t read_mifare(nfc_tag_info_t* tag){
//TODO
return FLAG_TAG_LOCKED;
}
+void write_mifare(nfc_tag_info_t* tag){
+ //TODO
+}
+
int scan(){
nfc_tag_info_t card = {
0
@@ -154,7 +162,7 @@ int scan(){
uint16_t atqa = 0;
uint8_t sak = 0;
- uint8_t flags;
+ uint8_t flags = 0;
for(yhy_sync_request(reader_fd, 1, &atqa); atqa; yhy_sync_request(reader_fd, 0, &atqa)){
sak = 0;
@@ -201,7 +209,13 @@ int scan(){
reader_tag_present(flags, &card);
break;
case TAG_WRITE_REQUESTED:
- //TODO write card data
+ //write card data
+ if(card.type == tag_ntag){
+ write_ntag(&card);
+ }
+ else if(card.type == tag_mifare1){
+ write_mifare(&card);
+ }
break;
}