Skip to content

AWS.IoTWireless reference

Source: src/AWS/IoTWireless/DeleteQueuedMessages.ts

Runtime binding for iotwireless:DeleteQueuedMessages — delete queued downlink messages for the bound wireless device from a deployed Lambda or Task.

Section titled “DeleteQueuedMessages: Purging the Downlink Queue”

Provide the DeleteQueuedMessagesHttp implementation layer on the Function effect, bind the device in the init phase, then call the returned client at runtime.

// init
const deleteQueued = yield* AWS.IoTWireless.DeleteQueuedMessages(device);
// runtime — "*" deletes every queued message
yield* deleteQueued({ MessageId: "*" });
// on the Function effect:
// .pipe(Effect.provide(AWS.IoTWireless.DeleteQueuedMessagesHttp))

Source: src/AWS/IoTWireless/Destination.ts

An AWS IoT Core for LoRaWAN destination — the routing rule that delivers uplink messages from wireless devices to an AWS IoT rule or MQTT topic.

The destination name is its identity (changing it replaces the destination); the expression, expression type, description, role, and tags all update in place.

Route uplinks to an IoT rule

import * as IoTWireless from "alchemy/AWS/IoTWireless";
const destination = yield* IoTWireless.Destination("Uplinks", {
expressionType: "RuleName",
expression: "process_sensor_uplinks",
roleArn: deliveryRole.roleArn,
});

Publish uplinks straight to an MQTT topic

const destination = yield* IoTWireless.Destination("Uplinks", {
expressionType: "MqttTopic",
expression: "sensors/uplinks",
roleArn: deliveryRole.roleArn,
});
const deliveryRole = yield* IAM.Role("IotWirelessDelivery", {
assumeRolePolicyDocument: {
Version: "2012-10-17",
Statement: [{
Effect: "Allow",
Principal: { Service: "iotwireless.amazonaws.com" },
Action: ["sts:AssumeRole"],
}],
},
policies: [{
policyName: "deliver",
policyDocument: {
Version: "2012-10-17",
Statement: [{
Effect: "Allow",
Action: ["iot:DescribeEndpoint", "iot:Publish"],
Resource: ["*"],
}],
},
}],
});
Section titled “Destination: Consuming Uplinks in a Function”

Uplinks are delivered through AWS IoT Core. For a RuleName destination, IoTWireless.consumeUplinks (see DestinationEventSource) creates the named IoT rule targeting the current Lambda and invokes the handler for every uplink. Alternatively, point an MqttTopic destination at a topic and consume it with AWS.IoT.consumeTopicMessages.

const destination = yield* IoTWireless.Destination("Uplinks", {
expressionType: "RuleName",
expression: "sensor_uplinks",
roleArn: deliveryRole.roleArn,
});
// inside the Function effect (provide Lambda.WirelessDestinationEventSource):
yield* IoTWireless.consumeUplinks(destination, (uplinks) =>
uplinks.pipe(
Stream.runForEach((uplink) => processUplink(uplink)),
Effect.orDie,
),
);

Source: src/AWS/IoTWireless/DestinationEventSource.ts

Event source connecting an IoT Wireless Destination to the hosting compute — every uplink a wireless device sends through the destination invokes the handler.

The destination must use expressionType: "RuleName". At deploy time the Lambda implementation (Lambda.WirelessDestinationEventSource) creates the IoT topic rule the destination’s expression names, with a Lambda action targeting the current function, and grants iot.amazonaws.com permission to invoke it; at runtime it dispatches uplink invocations to the handler.

Use the consumeUplinks helper rather than the service directly, and provide Lambda.WirelessDestinationEventSource on the hosting function.

export default IngestFunction.make(
{ main: import.meta.url },
Effect.gen(function* () {
const destination = yield* IoTWireless.Destination("Uplinks", {
expressionType: "RuleName",
expression: "sensor_uplinks",
roleArn: deliveryRole.roleArn,
});
// deploy: creates the `sensor_uplinks` IoT rule targeting this Lambda
// runtime: handles every uplink routed through the destination
yield* IoTWireless.consumeUplinks(destination, (uplinks) =>
uplinks.pipe(
Stream.runForEach((uplink) =>
Effect.log(uplink.WirelessDeviceId, uplink.PayloadData),
),
Effect.orDie,
),
);
return {};
}).pipe(Effect.provide(Lambda.WirelessDestinationEventSource)),
);

Source: src/AWS/IoTWireless/DeviceProfile.ts

An AWS IoT Core for LoRaWAN device profile — the hardware-level LoRaWAN parameters (MAC version, regional band, RX windows, device classes) shared by devices of the same model.

Device profiles are immutable after creation: any change to name, loRaWAN, or sidewalk replaces the profile. Only tags update in place.

US915 OTAA Device Profile

import * as IoTWireless from "alchemy/AWS/IoTWireless";
const profile = yield* IoTWireless.DeviceProfile("SensorModel", {
loRaWAN: {
MacVersion: "1.0.3",
RegParamsRevision: "RP002-1.0.1",
RfRegion: "US915",
MaxEirp: 10,
SupportsJoin: true,
},
});

Sidewalk Device Profile

const profile = yield* IoTWireless.DeviceProfile("SidewalkModel", {
sidewalk: {},
});

Source: src/AWS/IoTWireless/GetPositionEstimate.ts

Runtime binding for iotwireless:GetPositionEstimate — resolve an estimated position (as a GeoJSON payload stream) from raw measurement data — WiFi access points, cell towers, GNSS scans, or an IP address — using third-party solvers, from a deployed Lambda or Task. Account-level: it is not tied to any registered device.

GetPositionEstimate: Estimating a Position

Section titled “GetPositionEstimate: Estimating a Position”

Provide the GetPositionEstimateHttp implementation layer on the Function effect, bind the capability in the init phase, then call the returned client at runtime. The GeoJsonPayload is a byte Stream — decode it with Stream.mkString(Stream.decodeText(...)).

// init
const estimate = yield* AWS.IoTWireless.GetPositionEstimate();
// runtime
const { GeoJsonPayload } = yield* estimate({
WiFiAccessPoints: [
{ MacAddress: "A0:EC:F9:1E:32:C1", Rss: -66 },
{ MacAddress: "A0:EC:F9:15:72:5E", Rss: -72 },
],
});
// on the Function effect:
// .pipe(Effect.provide(AWS.IoTWireless.GetPositionEstimateHttp))

Source: src/AWS/IoTWireless/GetResourcePosition.ts

Runtime binding for iotwireless:GetResourcePosition — read the bound wireless device’s position (WGS84, returned as a GeoJSON payload stream) from a deployed Lambda or Task.

GetResourcePosition: Reading Device Position

Section titled “GetResourcePosition: Reading Device Position”

Provide the GetResourcePositionHttp implementation layer on the Function effect, bind the device in the init phase, then call the returned client at runtime. The GeoJsonPayload is a byte Stream — decode it to a string with Stream.mkString(Stream.decodeText(...)).

// init
const getPosition = yield* AWS.IoTWireless.GetResourcePosition(device);
// runtime
const { GeoJsonPayload } = yield* getPosition();
const geoJson = GeoJsonPayload === undefined
? undefined
: yield* Stream.mkString(Stream.decodeText(GeoJsonPayload));
// on the Function effect:
// .pipe(Effect.provide(AWS.IoTWireless.GetResourcePositionHttp))

Source: src/AWS/IoTWireless/GetServiceEndpoint.ts

Runtime binding for iotwireless:GetServiceEndpoint — read the account’s CUPS or LNS endpoint (and its server trust certificate) from a deployed Lambda or Task. Useful for gateway provisioning flows.

GetServiceEndpoint: Reading the Service Endpoint

Section titled “GetServiceEndpoint: Reading the Service Endpoint”

Provide the GetServiceEndpointHttp implementation layer on the Function effect, bind the capability in the init phase, then call the returned client at runtime.

// init
const getEndpoint = yield* AWS.IoTWireless.GetServiceEndpoint();
// runtime
const { ServiceEndpoint } = yield* getEndpoint({ ServiceType: "LNS" });
// on the Function effect:
// .pipe(Effect.provide(AWS.IoTWireless.GetServiceEndpointHttp))

Source: src/AWS/IoTWireless/GetWirelessDeviceStatistics.ts

Runtime binding for iotwireless:GetWirelessDeviceStatistics — read the bound wireless device’s operating information (last uplink time, RSSI/SNR gateway metadata, battery level, device state) from a deployed Lambda or Task.

GetWirelessDeviceStatistics: Reading Device Statistics

Section titled “GetWirelessDeviceStatistics: Reading Device Statistics”

Provide the GetWirelessDeviceStatisticsHttp implementation layer on the Function effect, bind the device in the init phase, then call the returned client at runtime.

// init
const getStats = yield* AWS.IoTWireless.GetWirelessDeviceStatistics(device);
// runtime
const stats = yield* getStats();
const lastSeen = stats.LastUplinkReceivedAt;
// on the Function effect:
// .pipe(Effect.provide(AWS.IoTWireless.GetWirelessDeviceStatisticsHttp))

Source: src/AWS/IoTWireless/GetWirelessGatewayStatistics.ts

Runtime binding for iotwireless:GetWirelessGatewayStatistics — read the bound wireless gateway’s operating information (connection status, last uplink time) from a deployed Lambda or Task.

GetWirelessGatewayStatistics: Reading Gateway Statistics

Section titled “GetWirelessGatewayStatistics: Reading Gateway Statistics”

Provide the GetWirelessGatewayStatisticsHttp implementation layer on the Function effect, bind the gateway in the init phase, then call the returned client at runtime.

// init
const getStats = yield* AWS.IoTWireless.GetWirelessGatewayStatistics(gateway);
// runtime
const stats = yield* getStats();
const online = stats.ConnectionStatus === "Connected";
// on the Function effect:
// .pipe(Effect.provide(AWS.IoTWireless.GetWirelessGatewayStatisticsHttp))

Source: src/AWS/IoTWireless/ListQueuedMessages.ts

Runtime binding for iotwireless:ListQueuedMessages — list the downlink messages queued for the bound wireless device from a deployed Lambda or Task.

Section titled “ListQueuedMessages: Inspecting the Downlink Queue”

Provide the ListQueuedMessagesHttp implementation layer on the Function effect, bind the device in the init phase, then call the returned client at runtime.

// init
const listQueued = yield* AWS.IoTWireless.ListQueuedMessages(device);
// runtime
const { DownlinkQueueMessagesList } = yield* listQueued();
const pending = DownlinkQueueMessagesList?.length ?? 0;
// on the Function effect:
// .pipe(Effect.provide(AWS.IoTWireless.ListQueuedMessagesHttp))

Source: src/AWS/IoTWireless/SendDataToWirelessDevice.ts

Runtime binding for iotwireless:SendDataToWirelessDevice — queue a downlink message to the bound wireless device from a deployed Lambda or Task. The message is delivered the next time the device opens a receive window.

Section titled “SendDataToWirelessDevice: Sending Downlink Messages”

Provide the SendDataToWirelessDeviceHttp implementation layer on the Function effect, bind the device in the init phase, then call the returned client at runtime.

// init
const sendData = yield* AWS.IoTWireless.SendDataToWirelessDevice(device);
// runtime — PayloadData is base64-encoded
const { MessageId } = yield* sendData({
PayloadData: Buffer.from("hello").toString("base64"),
TransmitMode: 1,
WirelessMetadata: { LoRaWAN: { FPort: 1 } },
});
// on the Function effect:
// .pipe(Effect.provide(AWS.IoTWireless.SendDataToWirelessDeviceHttp))

Source: src/AWS/IoTWireless/ServiceProfile.ts

An AWS IoT Core for LoRaWAN service profile — the network-level parameters (data-rate bounds, gateway metadata reporting, roaming permissions) shared by a fleet of wireless devices.

Service profiles are immutable after creation: any change to name or loRaWAN replaces the profile. Only tags update in place.

Default Service Profile

import * as IoTWireless from "alchemy/AWS/IoTWireless";
const profile = yield* IoTWireless.ServiceProfile("Fleet");

Service Profile with Gateway Metadata

const profile = yield* IoTWireless.ServiceProfile("Fleet", {
loRaWAN: { AddGwMetadata: true, DrMin: 0, DrMax: 10 },
tags: { team: "iot" },
});
const device = yield* IoTWireless.WirelessDevice("Sensor", {
type: "LoRaWAN",
destinationName: destination.destinationName,
loRaWAN: {
DevEui: "1122334455667788",
ServiceProfileId: profile.serviceProfileId,
DeviceProfileId: deviceProfile.deviceProfileId,
OtaaV1_0_x: { AppKey: "...", AppEui: "..." },
},
});

Source: src/AWS/IoTWireless/TestWirelessDevice.ts

Runtime binding for iotwireless:TestWirelessDevice — simulate a provisioned device by sending an uplink data payload of Hello on behalf of the bound wireless device, from a deployed Lambda or Task. Useful for verifying a destination’s routing without radio hardware.

Provide the TestWirelessDeviceHttp implementation layer on the Function effect, bind the device in the init phase, then call the returned client at runtime.

// init
const testDevice = yield* AWS.IoTWireless.TestWirelessDevice(device);
// runtime
const { Result } = yield* testDevice();
// on the Function effect:
// .pipe(Effect.provide(AWS.IoTWireless.TestWirelessDeviceHttp))

Source: src/AWS/IoTWireless/UpdateResourcePosition.ts

Runtime binding for iotwireless:UpdateResourcePosition — set the bound wireless device’s static position (WGS84, as a GeoJSON payload) from a deployed Lambda or Task.

UpdateResourcePosition: Updating Device Position

Section titled “UpdateResourcePosition: Updating Device Position”

Provide the UpdateResourcePositionHttp implementation layer on the Function effect, bind the device in the init phase, then call the returned client at runtime.

// init
const updatePosition = yield* AWS.IoTWireless.UpdateResourcePosition(device);
// runtime — coordinates are [longitude, latitude, altitude]
yield* updatePosition({
GeoJsonPayload: JSON.stringify({
type: "Point",
coordinates: [-122.33, 47.61, 10],
}),
});
// on the Function effect:
// .pipe(Effect.provide(AWS.IoTWireless.UpdateResourcePositionHttp))

Source: src/AWS/IoTWireless/WirelessDevice.ts

An AWS IoT Core for LoRaWAN (or Amazon Sidewalk) wireless device — the cloud registration of a physical radio, wired to a Destination for uplink routing and to a DeviceProfile / ServiceProfile pair for its radio parameters.

The device’s radio identity (type, DevEui, activation keys) is immutable — changing it replaces the device. The name, description, destination, positioning, profile references, and tags update in place.

OTAA v1.0.x LoRaWAN Device

import * as IoTWireless from "alchemy/AWS/IoTWireless";
const device = yield* IoTWireless.WirelessDevice("Sensor", {
type: "LoRaWAN",
destinationName: destination.destinationName,
loRaWAN: {
DevEui: "1122334455667788",
DeviceProfileId: deviceProfile.deviceProfileId,
ServiceProfileId: serviceProfile.serviceProfileId,
OtaaV1_0_x: {
AppKey: Redacted.make("00112233445566778899aabbccddeeff"),
AppEui: "8877665544332211",
},
},
});

Repoint a device at a different destination

const device = yield* IoTWireless.WirelessDevice("Sensor", {
type: "LoRaWAN",
destinationName: otherDestination.destinationName, // updates in place
loRaWAN: { ... },
});

Source: src/AWS/IoTWireless/WirelessGateway.ts

An AWS IoT Core for LoRaWAN wireless gateway — the cloud registration of a physical LoRaWAN gateway (packet forwarder), keyed by its unique 64-bit GatewayEui.

The gateway’s radio identity (GatewayEui, RfRegion, sub-bands, beaconing) is immutable — changing it replaces the gateway. The name, description, EUI/NetID filters, MaxEirp, and tags update in place.

US915 Gateway

import * as IoTWireless from "alchemy/AWS/IoTWireless";
const gateway = yield* IoTWireless.WirelessGateway("RooftopGw", {
loRaWAN: {
GatewayEui: "aa555a0000000001",
RfRegion: "US915",
},
tags: { site: "hq" },
});

Gateway with join filters

const gateway = yield* IoTWireless.WirelessGateway("RooftopGw", {
loRaWAN: {
GatewayEui: "aa555a0000000001",
RfRegion: "US915",
JoinEuiFilters: [["0000000000000001", "00000000000000ff"]],
MaxEirp: 30,
},
});