NFC paring¶
To increase security you can benefit of NFC to exchange encryption keys.
Warning
these features are only available on platforms that support NFC protocol: cordova and android Java.
Warning
Documentation is not available for Android yet
NFC pairing modes¶
You have three available NFC pairing modes. This mode is configured on your tap. You can access it with getNfcPairingMode()
function.
import { Tap } from '@iotize/device-client.js/device';
import { NfcPairingMode } from '@iotize/device-client.js/device/model';
let tap: Tap; // ... init your tap
let pairingMode: NfcPairingMode = (
await tap.service.interface.getNfcPairingMode()
).body();
console.log(`NFC pairing mode: ${NfcPairingMode[pairingMode]}`);
No pairing¶
A user can connect directly to the BLE or WiFi. This is the default mode.
Pairing mandatory¶
A user has to connect through NFC before being authorized to use BLE or Wifi.
import { Tap } from '@iotize/device-client.js/device';
import { BLEComProtocol } from '@iotize/cordova-plugin-iotize-ble';
import { NFCComProtocol } from '@iotize/device-com-nfc.cordova';
let nfcProtocol: NFCComProtocol; // ...
// Connect and login with NFC
let tap: Tap = Tap.fromProtocol(nfcProtocol);
await tap.connect();
await tap.nfcPairing();
// enable encryption if needed
await tap.enableEncryption(true);
let bleAddress: string = (await tap.service.interface.getBleAddress()).body()!;
// Instantiate ble protocol
let bleProtocol = new BLEComProtocol(bleAddress);
// Configure your Tap instance with the protocol
tap.useComProtocol(bleProtocol);
// Then connect
await tap.connect();
Pairing AND login mandatory¶
Same as Pairing mandatory + login function is only available when connected with NFC.
See this workflow example with cordova:
import { Tap } from '@iotize/device-client.js/device';
import { BLEComProtocol } from '@iotize/cordova-plugin-iotize-ble';
import { NFCComProtocol } from '@iotize/device-com-nfc.cordova';
let nfcProtocol: NFCComProtocol; // ...
// Connect and login with NFC
let tap: Tap = Tap.fromProtocol(nfcProtocol);
await tap.connect();
await tap.nfcPairing();
await tap.login('username', 'password');
let bleAddress: string = (await tap.service.interface.getBleAddress()).body()!;
// Instantiate ble protocol
let bleProtocol = new BLEComProtocol(bleAddress);
// Configure your Tap instance with the protocol
tap.useComProtocol(bleProtocol);
// Then connect
await tap.connect();