Skip to content

Instantly share code, notes, and snippets.

@Webdevava
Created March 15, 2025 10:10
Show Gist options
  • Save Webdevava/003d6852f446c858f20e6e21951e07a8 to your computer and use it in GitHub Desktop.
Save Webdevava/003d6852f446c858f20e6e21951e07a8 to your computer and use it in GitHub Desktop.

Device-Lambda Communication Payloads

This document details the exact payloads exchanged between the IoT device and the Lambda function during different stages of the meter installation process.

Step 1: Initial Request

Device to Lambda:

{
  "METER_ID": "12345",
  "HHID": "6789"
}

Lambda to Device (Valid):

{
  "hhid_status": "valid",
  "otp": "1234"
}

Lambda to Device (Invalid):

{
  "hhid_status": "invalid"
}

Step 2: OTP Verification

Device to Lambda:

{
  "METER_ID": "12345",
  "OTP": "1234"
}

Lambda to Device (Valid):

{
  "otp_status": "valid"
}

Lambda to Device (Invalid):

{
  "otp_status": "invalid"
}

Step 3: SIM Details Assignment

Device to Lambda:

{
  "METER_ID": "12345",
  "HHID": "6789",
  "SIM1_IMSI": "123456789012345",
  "SIM2_IMSI": "234567890123456",
  "SIM1_PASS": true,
  "SIM2_PASS": false
}

Lambda to Device:

{
  "members_and_submeters_config": {
    "max_members": "5",
    "max_submeters": "1"
  }
}

Step 4: Submeter MAC Validation

Device to Lambda:

{
  "METER_ID": "12345",
  "connected_submeters_mac_addr": "AA:BB:CC:DD:EE:FF, 11:22:33:44:55:66"
}

Lambda to Device (Valid):

{
  "submeter_validation": {
    "submeter_mac": "AA:BB:CC:DD:EE:FF, 11:22:33:44:55:66",
    "status": "valid, valid",
    "bounded_serial_number": "1234567890, 1234567891"
  }
}

Lambda to Device (Invalid):

{
  "submeter_validation": {
    "submeter_mac": "AA:BB:CC:DD:EE:FF, 11:22:33:44:55:66",
    "status": "invalid, invalid",
    "bounded_serial_number": ""
  }
}

Database Updates

MongoDB Collections and Fields

Meter Collection

Fields modified during the process:

  • associated: Set to true when submeter MAC validation succeeds
  • associated_with: Set to HHID when OTP verification succeeds
  • is_assigned: Set to true when submeter MAC validation succeeds
  • SIM1_IMSI: Updated during SIM details assignment
  • SIM2_IMSI: Updated during SIM details assignment
  • SIM1_PASS: Updated during SIM details assignment
  • SIM2_PASS: Updated during SIM details assignment
  • submeter_mac: Updated during submeter MAC validation

Household Collection

Fields modified during the process:

  • otp: Set during initial request, cleared after OTP verification
  • is_assigned: Set to true when submeter MAC validation succeeds
  • bounded_serial_numbers: Set during submeter MAC validation

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment