useProtocolRun(props: Props, deps?: any)

Requires:
@ray-js/panel-sdk≥1.8.0

Description

Execute the corresponding callback based on the device communication protocol type

Parameters

ParameterTypeRequiredDescription
YesA configuration object containing devId and callbacks for each protocol type
depsanyNoOptional dependencies; changes will regenerate the executor function

Return Value

Type: any
An executor function that triggers the corresponding callback based on the device's protocol type when called

Examples

Example

import { useProtocolRun } from '@ray-js/panel-sdk';

function ProtocolHandler() {
  const run = useProtocolRun({
    devId: 'device123',
    wifi: () => console.log('Wi-Fi device'),
    zigbee: () => console.log('Zigbee device'),
    sigMesh: () => console.log('SIG Mesh device'),
    default: () => console.log('Other protocols'),
  });

  useEffect(() => {
    run();
  }, [run]);
}