chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
706 stars 556 forks source link

share wifi configuration #279

Closed marouan-fr closed 6 years ago

marouan-fr commented 6 years ago

I'm trying to share wifi configuration to other device something like "WIFI:T:WPA;S:[ssid];P:[password];H:false;" for QrCode.

i found a "universal wifi URI : wifi://[network ssid]/[wep|wpa|open]/[network key] " but it dosent seems to work, the other device get it as a string

this.nfc.share([this.ndef.uriRecord('wifi://' + this.info.ssid + '/wpa/' + this.info.pass)])
          .then(() => {
            console.log('Shared via NFC');
          })
          .catch((e) => {
             console.log(e)
          });

I'm using the latest Ionic 3 , testing with android 6 devices

don commented 6 years ago

@Madm0x I think the trick is getting the phone receiving the data to interpret it correctly.

My Nexus 5X will create NFC tags with WiFi info. Open settings, choose WiFi settings, long press the network you want, enter the password, and write the data to a tag. It creates a MIME media record of type application/vnd.wfa.wsc. You should be able to use NXP TagInfo to reverse engineer the record format.

I'd assume if you get the format correct you can beam this data to another Android with nfc.share.