KeyDuino forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Un échange d'information autour de la carte KeyDuino
 
HomeHome  Latest imagesLatest images  RegisterRegister  Log inLog in  

 

 keyduino_android_control example

Go down 
2 posters
AuthorMessage
mcba
Newbie
Newbie



Messages : 8
Reputation : 0
Date d'inscription : 2017-01-19

keyduino_android_control example Empty
PostSubject: keyduino_android_control example   keyduino_android_control example EmptyThu 19 Jan - 1:49

I'm having trouble with the keyduino_android_control example - it doesn't establish the llcp link to my phone (google pixel xl running Andoid 7.1.1). The keyduino otherwise appears to be ok (e.g., the tag_identification example works).

[SOLVED: see message below. I hadn't enabled Android Beam in the settings menu.]

I have installed the NFC Talker app, I click on "KEYDUINO COMMAND", and then try pressing various buttons on the screen while the phone is very close to the keyduino. The keyduino app sends garbage to the serial port and then appears to crash. I suspect that the garbage may come from the use of the String class in the GET_NDEF function: as far as I can see, the return value from GET_NDEF is a pointer to a local variable that isn't defined once the function returns. The String class looks very dangerous.

Further investigation shows that nfc.read() in GET_NDEF is returning -2, which in turn comes from llcp.waitForConnection(timeout) (note that "timeout" is not used in the code). I suspect that there is something wrong with the llcp handshaking.

Any chance of a fix? Or a pointer as to how to debug this further?

Regards, Michael


Last edited by mcba on Sat 21 Jan - 4:42; edited 1 time in total
Back to top Go down
mcba
Newbie
Newbie



Messages : 8
Reputation : 0
Date d'inscription : 2017-01-19

keyduino_android_control example Empty
PostSubject: Re: keyduino_android_control example   keyduino_android_control example EmptyThu 19 Jan - 2:03

Replying to my own message:

I just found the DEBUG switch in KeyDuino.cpp. It produces the following output from nfc.read() and an attempt to communicate from the phone:

SAMConfig

Write:  14 1 14 1
Ack:  0 0 FF 0 FF 0
Read:   0 0 FF 2 FE D5 15 16 0SAMConfig

Write:  14 1 14 1
Ack:  0 0 FF 0 FF 0
Read:   0 0 FF 2 FE D5 15 16 0
Write:  8C 0 0 0 0 0 0 40 1 FE F BB BA A6 C9 89 0 0 0 0 0 0 0 0 FF FF 1 FE F BB BA A6 C9 89 0 0 6 46 66 6D 1 1 10 0
Ack:  0 0 FF 0 FF 0
Read:   0 0 FF 28 D8 D5 8D 15 25 D4 0 77 C8 A1 4D 4A C 21 DB A 61 0 0 0 32 46 66 6D 1 1 12 2 2 7 FF 3 2 0 13 4 1 64 7 1 3 B1 0
Write:  86
Ack:  0 0 FF 0 FF 0
Read:   0 0 FF 3 FD D5 87 29 7B 0status is not ok

The "29" byte in the last packet indicates that the link was terminated.


Last edited by mcba on Sat 21 Jan - 3:05; edited 1 time in total
Back to top Go down
mcba
Newbie
Newbie



Messages : 8
Reputation : 0
Date d'inscription : 2017-01-19

keyduino_android_control example Empty
PostSubject: Re: keyduino_android_control example   keyduino_android_control example EmptyThu 19 Jan - 4:33

Me again.

I tried again, this time with the large external antenna on the keyduino, and the response is different. Still not working, but more hopeful in that I see messages bouncing back and forth.
Back to top Go down
mcba
Newbie
Newbie



Messages : 8
Reputation : 0
Date d'inscription : 2017-01-19

keyduino_android_control example Empty
PostSubject: Re: keyduino_android_control example   keyduino_android_control example EmptyThu 19 Jan - 5:38

Me again, again.

OK, so with the external aerial I get this handshaking during the attempt to set up the link:

Write:  14 1 14 1
Ack:  0 0 FF 0 FF 0
Read:   0 0 FF 2 FE D5 15 16 0
Write:  8C 0 0 0 0 0 0 40 1 FE F BB BA A6 C9 89 0 0 0 0 0 0 0 0 FF FF 1 FE F BB BA A6 C9 89 0 0 6 46 66 6D 1 1 10 0
Ack:  0 0 FF 0 FF 0
Read:   0 0 FF 28 D8 D5 8D 15 25 D4 0 32 51 BC 28 2E D7 11 6C B0 BE 0 0 0 32 46 66 6D 1 1 12 2 2 7 FF 3 2 0 13 4 1 64 7 1 3 44 0
Waiting for a CONNECT PDU

That last "Read" packet signifies that communication has been established.  However, LLCP::waitForConnection then waits for a CONNECT PDU that never arrives. Instead, there are SYMM packets bouncing back and forth, which keep the link up but don't activate SNEP.


Last edited by mcba on Sat 21 Jan - 3:04; edited 2 times in total
Back to top Go down
mcba
Newbie
Newbie



Messages : 8
Reputation : 0
Date d'inscription : 2017-01-19

keyduino_android_control example Empty
PostSubject: Re: keyduino_android_control example   keyduino_android_control example EmptySat 21 Jan - 3:00

More progress. I tried nfc_talker with a Galaxy S3, and it worked. The S3 sends a CONNECT PDU immediately after the link is established, whereas the Pixel XL doesn't send a CONNECT PDU, but is happy to send/get SYMM PDUs. So... the link is open (212 kbps, DEP, active mode) at the lowest level, but for some reason the more recent version of Android is not sending a CONNECT (and I don't receive the "Touch to beam" pop-up). I suspect that there have been some Android changes, and nfc_talker needs updating.

I tried modifying the General Bytes sent by tgInitTarget to provide additional information for LLCP (e.g., well known services that are supported, and only offering connection-based communication), but this didn't help.

At this stage I think that the KeyDuino is OK, the llcp/snep software is OK, and that the problem lies with the Android end.
Back to top Go down
mcba
Newbie
Newbie



Messages : 8
Reputation : 0
Date d'inscription : 2017-01-19

keyduino_android_control example Empty
PostSubject: Re: keyduino_android_control example   keyduino_android_control example EmptySat 21 Jan - 4:44

SOLVED! It turns out that the newer version of Android has a setting to turn on/off Android Beam, and mine was off. How embarrassing. In the meantime I've learned more than I ever wanted to about NFC, LLCP, SNEP, etc.
Back to top Go down
MrStein
KeyDuino TEAM
MrStein


Messages : 85
Reputation : 4
Date d'inscription : 2015-10-10
Age : 30
Localisation : Lille, FRANCE

keyduino_android_control example Empty
PostSubject: Re: keyduino_android_control example   keyduino_android_control example EmptySat 21 Jan - 10:38

Hi mcba!
Sorry for the late answer and thank you for the feedback, we will add a note on the github for android beam.

Just for information, what do you want to do with the KeyDuino? Just discovering NFC or a real project? Smile
Back to top Go down
https://keyduino.forumsactifs.com
mcba
Newbie
Newbie



Messages : 8
Reputation : 0
Date d'inscription : 2017-01-19

keyduino_android_control example Empty
PostSubject: Re: keyduino_android_control example   keyduino_android_control example EmptySat 21 Jan - 21:33

If possible, it would be good to update nfc_talker.apk to check for Android Beam being enabled. Some relevant code is here (I can't post a link due to forum rules, just google search for android-beam-activate-programmatically).

The reason I'm exploring KeyDuino is that in the past I used the IR blaster on my previous Android phone to interface with a battery management system that I designed. I was surprised to find my new phone didn't have an IR blaster, so I've been looking around for the simplest way of interfacing the phone to hardware. Of Wifi, Bluetooth, NFC, it appeared that the latter was the easiest. Although in retrospect Bluetooth may be better since it doesn't have that annoying "touch to beam" pop-up. Another possibility would be a Bluetooth to IR blaster interface - there is one called Klikr that looks promising, but they haven't released an SDK.

The nice thing about IR is that it is easy to add to something like an ATtiny85 to allow it to communicate wirelessly. I have a bootloader that allows me to program an ATtiny85 over IR, and use this regularly to program over 100 of them simultaneously.

I like the KeyDuino, very nice hardware and software. Congratulations!
Back to top Go down
MrStein
KeyDuino TEAM
MrStein


Messages : 85
Reputation : 4
Date d'inscription : 2015-10-10
Age : 30
Localisation : Lille, FRANCE

keyduino_android_control example Empty
PostSubject: Re: keyduino_android_control example   keyduino_android_control example EmptySun 22 Jan - 13:48

Thank you for the link, we will have a look at this Smile

For your project, do you have the link for programming over the air? I made a lot of projects with attiny  but never try that! and what about use this for your phone and still use IR?

Oh and thank you for the KeyDuino!
Back to top Go down
https://keyduino.forumsactifs.com
mcba
Newbie
Newbie



Messages : 8
Reputation : 0
Date d'inscription : 2017-01-19

keyduino_android_control example Empty
PostSubject: Re: keyduino_android_control example   keyduino_android_control example EmptySun 22 Jan - 20:39

Thanks for the pointer to the Kiwik. I guess that the shape of it is governed by an internal supercapacitor to store power for the transmission. It says that it is a "learning" remote, which implies an IR receiver, although I can't see one on the device. Perhaps it is there.

My bootloader is based on TinySafeBoot (google for the link) with a few changes, e.g., CRC checking of every 64-bytes in such a way as to cope with transmission errors - you can repeatedly send the entire boot image, and the ATtiny will only update a given 64-byte segment if its CRC is OK; the ATtiny will only boot the new image if it passes an additional CRC16. Contact me off-line (I presume you can see my email address) if you want more information.
Back to top Go down
Sponsored content





keyduino_android_control example Empty
PostSubject: Re: keyduino_android_control example   keyduino_android_control example Empty

Back to top Go down
 
keyduino_android_control example
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
KeyDuino forum :: KeyDuino informations & questions :: SOFTWARE questions & informations-
Jump to: