How to retrieve SSID and Password from an NDEF record

Asked by Juan Trujillo on 2015-07-03

I need to retrieve the SSID and password from an NDEF record and I don't know how to do it... Does nfcpy provide this functionality or do I need to do it by myself?

For example, this is my NDEF record:

  type = 'application/vnd.wfa.wsc'
  name = '1'
  data = "\x10J\x00\x01\x10\x10\x0e\x002\x10&\x00\x01\x01\x10E\x00\x04Wxyz\x10 \x03\x00\x02\x00\x01\x10\x0f\x00\x02\x00\x01\x10'\x00\x0bAbcdefg1234\x10 \x00\x0 6\xff\xff\xff\xff\xff\xff"

Thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
nfcpy Edit question
Assignee:
No assignee Edit question
Solved by:
Juan Trujillo
Solved:
2015-07-06
Last query:
2015-07-06
Last reply:
2015-07-06

Try nfc.ndef.WifiConfigRecord(record). With your example data (but had to make two changes to the data string, maybe it's pasted incorrectly):

data = bytearray("\x10J\x00\x01\x10\x10\x0e\x002\x10&\x00\x01\x01\x10E\x00\x04Wxyz\x10\x03\x00\x02\x00\x01\x10\x0f\x00\x02\x00\x01\x10'\x00\x0bAbcdefg1234\x10 \x00\x06\xff\xff\xff\xff\xff\xff")
record = nfc.ndef.Record('application/vnd.wfa.wsc', '1', data)
print nfc.ndef.WifiConfigRecord(record).pretty()
identifier = '1'
version = 1.0
network name = Wxyz
network key = Abcdefg1234
authentication = Open
encryption = None
mac address = ff:ff:ff:ff:ff:ff
shareable = False

I'm using an app from Google Play Store called "NFC tools" ( https://play.google.com/store/apps/details?id=com.wakdev.wdnfc&hl=en).

When I open the app, I go under Write -> Add a record -> Wi-Fi network.

For example, if I use "HELLO" as SSID and "WORLD" as password. This is the output of "print tag.ndef.message.pretty()":

NXP PN532 on /dev/ttyAMA0
Type2Tag ATQ=4400 SAK=00 UID=04299b0a853280
record 1
  type = 'application/vnd.wfa.wsc'
  name = '1'
  data = "\x10J\x00\x01\x10\x10\x0e\x00-\x10&\x00\x01\x01\x10E\x00\x05HELLO\x10\x03\x00\x02\x00\x01\x10\x0f\x00\x02\x00\x01\x10'\x00\x05WORLD\x10 \x00\x06\xff\xff\xff\xff\xff\xff"

And if I try "print record.WifiConfigRecord(record).pretty()" it reports an error:

...
    print record.WifiConfigRecord(record).pretty()
AttributeError: 'Record' object has no attribute 'WifiConfigRecord'

Any ideas?

Thanks for all the help so far!!!

My bad. I have to use "print nfc.ndef.WifiConfigRecord(record).pretty()" instead.

Thanks!