| 1 | import type * as iotw from "@distilled.cloud/aws/iot-wireless"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { WirelessDevice } from "./WirelessDevice.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Request for {@link SendDataToWirelessDevice}. The bound device's id is |
| 8 | * injected automatically. |
| 9 | */ |
| 10 | export interface SendDataToWirelessDeviceRequest extends Omit< |
| 11 | iotw.SendDataToWirelessDeviceRequest, |
| 12 | "Id" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Runtime binding for `iotwireless:SendDataToWirelessDevice` — queue a |
| 17 | * downlink message to the bound wireless device from a deployed Lambda or |
| 18 | * Task. The message is delivered the next time the device opens a receive |
| 19 | * window. |
| 20 | * |
| 21 | * ### Sending Downlink Messages |
| 22 | * Provide the `SendDataToWirelessDeviceHttp` implementation layer on the |
| 23 | * Function effect, bind the device in the init phase, then call the |
| 24 | * returned client at runtime. |
| 25 | * |
| 26 | * **Example:** Queue a Downlink to a LoRaWAN Device |
| 27 | * ```typescript |
| 28 | * // init |
| 29 | * const sendData = yield* AWS.IoTWireless.SendDataToWirelessDevice(device); |
| 30 | * |
| 31 | * // runtime — PayloadData is base64-encoded |
| 32 | * const { MessageId } = yield* sendData({ |
| 33 | * PayloadData: Buffer.from("hello").toString("base64"), |
| 34 | * TransmitMode: 1, |
| 35 | * WirelessMetadata: { LoRaWAN: { FPort: 1 } }, |
| 36 | * }); |
| 37 | * // on the Function effect: |
| 38 | * // .pipe(Effect.provide(AWS.IoTWireless.SendDataToWirelessDeviceHttp)) |
| 39 | * ``` |
| 40 | * |
| 41 | * @binding |
| 42 | */ |
| 43 | export interface SendDataToWirelessDevice extends Binding.Service< |
| 44 | SendDataToWirelessDevice, |
| 45 | "AWS.IoTWireless.SendDataToWirelessDevice", |
| 46 | ( |
| 47 | device: WirelessDevice, |
| 48 | ) => Effect.Effect< |
| 49 | ( |
| 50 | request: SendDataToWirelessDeviceRequest, |
| 51 | ) => Effect.Effect< |
| 52 | iotw.SendDataToWirelessDeviceResponse, |
| 53 | iotw.SendDataToWirelessDeviceError |
| 54 | > |
| 55 | > |
| 56 | > {} |
| 57 | export const SendDataToWirelessDevice = |
| 58 | Binding.Service<SendDataToWirelessDevice>( |
| 59 | "AWS.IoTWireless.SendDataToWirelessDevice", |
| 60 | ); |