Amazon Sidewalk max payload size.

0

The Payload data for IoT Wireless SendDataToWirelessDevice to states that the max payload size can be up to 2048. I see in the API docs for sidewalk that there is a max MTU of 255 for BLE and 44 for LORA. Does that mean anything over these MTU lengths needs to be sent in separate messages or can you send up to 2048 and the MTU chunks are handled by the gateway?

Thanks, Luke

asked a year ago116 views
1 Answer
0

I hope this helps anyone still looking for an answer to this question.

For Sidewalk devices:

  1. While SendDataToWirelessDevice API can accept payloads up to 2048 bytes, the actual transmission is constrained by the MTU limits:
  • BLE: 255 bytes MTU
  • LoRa: 44 bytes MTU

The fragmentation of larger payloads depends on the connection type:

For BLE:

  • The Sidewalk gateway will automatically handle fragmenting messages larger than 255 bytes
  • You can send payloads up to 2048 bytes, and the gateway manages the chunking

For LoRa:

  • Due to bandwidth and power constraints, it's recommended to keep messages within the 44-byte MTU
  • While fragmentation is possible, it's best practice to manage message sizes at the application level for LoRa to optimize power consumption and transmission reliability

Best Practices:

  • For BLE: You can utilize the full 2048 bytes as the gateway handles fragmentation
  • For LoRa: Design your application to work with smaller payloads (≤44 bytes) when possible to ensure optimal performance

Detailed Implementation:

BLE Implementation Example:

import boto3

def send_large_payload_ble(wireless_device_id, payload, session):
    client = boto3.client('iotwireless')
    
    try:
        # For BLE, you can send the full payload (up to 2048 bytes)
        response = client.send_data_to_wireless_device(
            Id=wireless_device_id,
            TransmitMode='0',  # 0 for unacknowledged
            PayloadData=payload,
            WirelessMetadata={
                'Sidewalk': {
                    'Sequence': session
                }
            }
        )
        return response
    except Exception as e:
        print(f"Error sending data: {e}")

LoRa Implementation Example:

import boto3
import math

def send_large_payload_lora(wireless_device_id, payload, session):
    client = boto3.client('iotwireless')
    LORA_MTU = 44
    
    # Split payload into chunks
    chunks = [payload[i:i + LORA_MTU] for i in range(0, len(payload), LORA_MTU)]
    total_chunks = len(chunks)
    
    for index, chunk in enumerate(chunks):
        try:
            # Add metadata to chunk (sequence number and total chunks)
            chunk_metadata = {
                'chunk_number': index + 1,
                'total_chunks': total_chunks,
                'session_id': session
            }
            
            # Combine metadata and chunk data
            formatted_chunk = format_chunk_with_metadata(chunk_metadata, chunk)
            
            response = client.send_data_to_wireless_device(
                Id=wireless_device_id,
                TransmitMode='1',  # 1 for acknowledged
                PayloadData=formatted_chunk,
                WirelessMetadata={
                    'Sidewalk': {
                        'Sequence': session
                    }
                }
            )
            
            # Wait for acknowledgment before sending next chunk
            wait_for_ack(response)
            
        except Exception as e:
            print(f"Error sending chunk {index + 1}: {e}")
            # Implement retry logic here

Additional Considerations:

  1. Error Handling:
  • Implement retry mechanisms for failed transmissions
  • Track successful delivery of all chunks
  • Handle timeout scenarios
  1. Device-side Implementation:
def receive_and_reassemble_lora():
    chunks = {}
    
    while True:
        chunk = receive_chunk()
        metadata = extract_metadata(chunk)
        
        # Store chunk
        session_id = metadata['session_id']
        if session_id not in chunks:
            chunks[session_id] = {}
            
        chunks[session_id][metadata['chunk_number']] = chunk
        
        # Check if all chunks received
        if len(chunks[session_id]) == metadata['total_chunks']:
            return reassemble_payload(chunks[session_id])
  1. Monitoring and Logging:
def monitor_transmission(session_id):
    cloudwatch = boto3.client('cloudwatch')
    
    # Monitor metrics
    cloudwatch.put_metric_data(
        Namespace='IoTWireless',
        MetricData=[
            {
                'MetricName': 'TransmissionLatency',
                'Value': transmission_time,
                'Unit': 'Milliseconds'
            }
        ]
    )
AWS
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions