Communication Status
The BLE, LAN, and MQTT capabilities of each GizDevice maintain independent state. Send control or read commands only after a capability reaches ONLINE_CONTROLLABLE.
Read and observe status
import { GizCapacityStatus } from '@gizwits/smart-sdk';
const currentStatus = device.bleCapability.getStatus();
const unsubscribeStatus = device.bleCapability.subscribeStatus().subscribe(
(status: GizCapacityStatus): void => {
const controllable = status === GizCapacityStatus.ONLINE_CONTROLLABLE;
// Update ArkUI controls from controllable.
}
);OFFLINE means the transport is unavailable. ONLINE means discovered or connected but not controllable. ONLINE_CONTROLLABLE means authentication or login has completed.
MQTT cloud status
The MQTT module updates status automatically from authentication, bound-device profiles, network connectivity, and topic subscriptions:
const unsubscribeCloud = device.mqttCapability.subscribeStatus().subscribe((status): void => {
// Cloud transport status changed.
});GizState constraints
const current = device.lanCapability.subscribeStatus().getValue();
const unsubscribeBound = device.subscribeBoundState().subscribe((isBound: boolean): void => {
// subscribe emits the current value immediately by default.
});Call every unsubscribe function when the page disappears. Consumers should only read and subscribe to SDK-owned GizState objects; do not call setValue() or clearSubscribers() to mutate internal state.