Notes: (AWS re:Invent 2020 IOT303) Developing and Deploying Modern Edge Applications at Scale

Abstract

This session brought by Richard Barry, the founder of FreeRTOS, is helpful to understand quickly, when face development and deployment of IoT edge devices at scale. The key points to be faced Architecture , Process and Details.

Of course, we can choose to implement all the architectures, processes and details by ourselves, or choose existing solutions on the market, such as open source projects such as FreeRTOS, which has been integrated to various AWS IoT services (such as generating encryption keys, establishing encrypted communication channels and data transmission). So that your product team has more options and flexibility in the process of technology selection.

This session is recommended for everyone “ who want to quickly grasp the IoT edge device development options, deployment architecture and process ”.



Topic

Developing and deploying modern edge applications at scale

Speaker

  • Richard Barry, AWS Speaker (Senior Principal Engineer, IoT, AWS) (FreeRTOS Founder!)

Content

What to expect from this session

  • Learn about AWS options for device software
  • Understand the value AWS provides to the FreeRTOS user base
  • Look at the functionality of new libraries
  • See how to use that functionality in your projects
  • See how to use that functionality at a huge scale

AWS IoT

Device and cloud software

Options for device software

  • AWS IoT Device SDKs
  • FreeRTOS
  • AWS IoT Greengrass
  • (create your own:)

FreeRTOS

Growing user base over 18 years

The yellow line indicates switching to GitHub repo base.

Amazon’s contributions to the community

  • Global presence
  • New functionality
  • Kernel ports and enhancements
  • Simplified licensing so open with no lock-in
  • Professional incidence response processes
  • Security expertise
  • Long-term support

Free RTOS: Latest capabilities

IoT reference integrations (devices.amazonaws.com)

Reference integrations: Internal view

Refactoring for distribution from FreeRTOS.org

  • AWS IoT Device SDK for Embedded C (used by reference integrations)
    • Standard protocols
    • AWS IoT Device SDK for Embedded C
      • Shadow client
      • Job client
      • OTA
      • Etc.

Libraries in FreeRTOS and AWS GitHub accounts

Creating and updateing connected applications

Use case 1: Updating brownfield applications

coreMQTT network interface

static MQTTStatus_t prvCreateMQTTConectionWithBroker( MQTTContext_t * pxMQTTContext, 
                                                      NetworkContext_t * pxNetworkContext )

{
    MQTTStatus_t xResult;
    MQTTConnectionInfo_t xConnectInfo;
    TransportInterface_t xTransport;

    /* Fill in Transport Interface send and receive function pointers. */
    xTransport.pNetworkContext = pxNetworkContext;
    xTransport.send = my_tls_send_function;
    xTransport.recv = my_tls_recv_function;

    /* Initialize MQTT library. */
    xResult = MQTT_Init( pxMQTTContext, &xTransport, prvGetTimeMs, prvEventCallback, &xBuffer );
    return xResult;
}

Single-threaded code example: Publish()

static void prvMQTTPublishToTopic( MQTTContext_t * pxMQTTContext )
{
    MQTTStatus_t xResult;
    MQTTPublishInfo_t xMQTTPublishInfo;

    /* Some fields are not used by this demo so start with everything at 0. */
    memset( (void * ) &xMQTTPublishInfo, 0x00, sizeof( xMQTTPublishInfo ) );

    /* This demo use QoS0. */
    xMQTTPublishInfo.qos = MQTTQoS1;
    xMQTTPublishInfo.retain = false;
    xMQTTPublishInfo.pTopicName = mqttexampleTOPIC;
    xMQTTPublishInfo.topicNameLength = ( uint16_t ) strlen( mqttexampleTOPIC );
    xMQTTPublishInfo.pPayload = mqttexampleMESSAGE;
    xMQTTPublishInfo.payloadLength = strlen( mqttexampleMESSAGE );

    /* Send PUBLISH packet. Packet ID is not used for a QoS0 publish. */
    xResult = MQTT_Publish( pxMQTTContext, &xMQTTPublishInfo, 0U );
    assert( xResult == MQTTSuccess );
}

Single-threaded code example: ProcessLoop()

/* Publish messages with Qos0, send and process keep alive messages. */
LogInfo( ( "Publish to the MQTT topic %s.", mqttexampeTOPIC ) );
prvMQTTPublishToTopic ( &xMQTTContext );

/* Process incoming publish echo, since application subscribed to the same
* topic the broker will send publish message back to the application. */
LogInfo( ( "Attempt to receive publish message from broker." ) );
xMQTTStatus = MQTT_ProcessLoop( &xMQTTContext, mqttexamplePROCESS_LOOP_TIMEOUT_MS );
assert( xMQTTStatus == MQTTSuccess );

Use case 2: Multithreaded integration

Making coreMQTT thread safe

Structure of the agent (daemon) task

static void prvMQTTAgentTask( void *pvParameters )
{
    for( ;; )
    {
        /* Wait with timeout for next command. */
        xCommand.xCommandType = NONE;
        xQueueReceive( xCommandQueue, &xCommand, exampleTICKS_TO_WAIT );

        switch( xCommand.xCommandType )
        {
            case PUBLISH:
                pxPublishInfo = xCommand.pxCmdContext->pxPublishInfo;
                MQTT_Publish( &globalMqttContext, pxPublishInfo, usPacketId );
                break;

            case /* Etc. for all other command types. */
        }

        MQTT_ProcessLoop( &globalMqttContext, 0 );
    }
}

Scaling secure IoT applications

Reference integrations: TLS

Authentication (AuthN): Proving your identity

Reference integrations: Provisioning

  • Key storage method!

corePKCS #11: API to cryptographic tokens

FreeRTOS functionalityRequired PKCS #11 API family
AnyInitialize, Finalize, Open/Close Session, GetSlotList, Login
TLSRandom, Sign, FindObject, GetAttributeValue
FreeRTOS+TCPRandom
Over-the-air updateVerify, Digest, FindObject, GetAttributeValue
ProvisioningGenerateKeyPair, CreateObject, DestroyObject, InitToken, GetTokenInfo

How to do this efficiently at AWS IoT scale?

Provisioning IoT devices at scale

Provisioning and registration options

Just-in-time provisioning

Conclusions

Loading comments…