Encrypted communication¶
It's recommended to enable encrypted communication with your IoTize device if you are not using secure protocol.
import { IoTizeDevice } from '@iotize/device-client.js/device'; let device: IoTizeDevice = ...; // your device try{ await device.enableEncryption(true); // Now all requests will be encrypted let response = await device .service .getSerialNumber(); // Once you are done, you can stop encryption await device.enableEncryption(false); } catch (err){ // Encryption cannot be enabled if there is an error. // This may happen for example if your device is not connected... }
import com.iotize.android.device.device.impl.IoTizeDevice; // ... IoTizeDevice device = ...; // your device // Enable encryption (it may throw an error) device.enableEncryption(true); // Now all requests will be encrypted // Use your device object as usual String serialNumber = device.service.device.getSerialNumber().get(); // ... // Once you are done, you can stop encryption device.enableEncryption(false);