# - [smarthome](https://developers.home.google.com/reference/local-home/modules/smarthome.html).
- [DataFlow](https://developers.home.google.com/reference/local-home/modules/smarthome.dataflow.html).
- UdpRequestData

Request to send a local device command over UDP datagram.
Commands are sent to the device using [DeviceManager.send](https://developers.home.google.com/reference/local-home/interfaces/smarthome.devicemanager.html#send).

Example UDP command:

    const payload = new Uint8Array([0x00, 0xFF, 0x00, 0xFF]);

    const command = new DataFlow.UdpRequestData();
    command.requestId = request.requestId;
    command.deviceId = 'device-id';
    command.port = 5555;
    command.data = Buffer.from(payload).toString('hex');
    command.expectedResponsePackets = 1;

[## Handle the response](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.udprequestdata#handle-the-response)

If the command succeeds, [DeviceManager.send](https://developers.home.google.com/reference/local-home/interfaces/smarthome.devicemanager.html#send) returns a
[UdpResponseData](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.udpresponsedata.html) result. For commands with
[UdpRequestData.expectedResponsePackets](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.udprequestdata#expectedresponsepackets) set, the result contains a
[UdpResponse](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.udpresponse.html).

    const command = new DataFlow.UdpRequestData();
    command.expectedResponsePackets = 1;
    ...

    localHomeApp.getDeviceManager()
     .send(command)
     .then((result: DataFlow.CommandSuccess) => {
       const udpResult = result as DataFlow.UdpResponseData;
       const packets = udpResult.udpResponse.responsePackets;
     })
     .catch((err: IntentFlow.HandlerError) => {
       // Handle command error
     });

### Implements

- [UdpRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.udprequestdata)

### Implemented by

- [UdpRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.udprequestdata)

## Index

### Properties

- [data](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.udprequestdata#data)
- [deviceId](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.udprequestdata#deviceid)
- [expectedResponsePackets](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.udprequestdata#expectedresponsepackets)
- [port](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.udprequestdata#port)
- [protocol](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.udprequestdata#protocol)
- [requestId](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.udprequestdata#requestid)

## Properties

### data

data: string Inherited from [BleRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata).[data](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata#data)
Payload sent to the target device

### deviceId

deviceId: string Inherited from [BleRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata).[deviceId](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata#deviceid)
Device ID of the target device.

### Optional expectedResponsePackets

expectedResponsePackets: undefined \| number Inherited from [UdpOptions](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.udpoptions.html).[expectedResponsePackets](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.udpoptions.html#expectedresponsepackets)
Expected number of UDP response packets. Actual number of packets
received in the [UdpResponseData](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.udpresponsedata.html) may not match expected value if
timeout of 1 second is exceeded.

### port

port: number Inherited from [UdpOptions](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.udpoptions.html).[port](https://developers.home.google.com/reference/local-home/interfaces/smarthome.dataflow.udpoptions.html#port)
Port number on the target device

### protocol

protocol: [Protocol](https://developers.home.google.com/reference/local-home/enums/smarthome.constants.protocol.html) Inherited from [BleRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata).[protocol](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata#protocol)
Protocol to use when sending this command

### requestId

requestId: string Inherited from [BleRequestData](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata).[requestId](https://developers.home.google.com/reference/local-home/classes/smarthome.dataflow.blerequestdata#requestid)
Request ID from the associated `EXECUTE` intent.