Deploy a secure Cloud-connected IoT device network complete with Edge computing capabilities
computer while working in the MPLAB X IDE.
// This will get called every 1 second only while we have a valid Cloud connection static void sendToCloud(void) { static char json[PAYLOAD_SIZE]; static char publishMqttTopic[PUBLISH_TOPIC_SIZE];
//This handles messages published from the MQTT server when subscribed static void receivedFromCloud(uint8_t *topic, uint8_t *payload) { char *toggleToken = “\”toggle\”:”; char *subString; ledTickState_t ledState; sprintf(mqttSubscribeTopic, “$aws/things/%s/shadow/ update/delta”, cid); if (strncmp((void*) mqttSubscribeTopic, (void*) topic, strlen(mqttSubscribeTopic)) == 0) { if ((subString = strstr((char*)payload, toggleToken))) { if (subString[strlen(toggleToken)] == ‘1’) { setToggleState(TOGGLE_ON); ledState.Full2Sec = LED_ON_STATIC; LED_modeYellow(ledState); } else { setToggleState(TOGGLE_OFF); ledState.Full2Sec = LED_OFF_STATIC; LED_modeYellow(ledState); } holdCount = 2; } } debug_printer(SEVERITY_NONE, LEVEL_NORMAL, “topic: %s”, topic); debug_printer(SEVERITY_NONE, LEVEL_NORMAL,
AWS Greengrass-ready solution Microchip makes augmenting their IoT network with Edge computing resources based on AWS Greengrass nearly as simple as deploying Cloud-connected endpoints. For the Edge computing platform, Microchip provides its ATSAMA5D27-WLSOM1 wireless (WL) system-on-module (SoM) with AWS qualified AWS Greengrass support. As with the Microchip endpoint boards, the ATSAMA5D27-WLSOM1 provides a comprehensive hardware platform designed to connect easily to AWS IoT Core services (Figure 5). For its host processor, the WLSOM1 uses the low-power SAMA5D27 system-in-package (SiP) ATSAMA5D27C-LD2G-CU, which integrates Microchip’s high-performance Arm Cortex-A5 processor-based SAMA5D27, which contains two gigabits (Gbits) of low-power double data rate 2 synchronous dynamic random- access memory (LPDDR2-SDRAM). As with its endpoint boards, Microchip’s WLSOM1 includes a certified wireless module. In this case, Microchip uses its ATWILC3000, which supports both Wi-Fi and Bluetooth connectivity with coexistence
ledTickState_t ledState; int rawTemperature = 0; int light = 0; int len = 0; memset((void*)publishMqttTopic, 0, sizeof(publishMqttTopic)); sprintf(publishMqttTopic, “%s/sensors”, cid);
// This part runs every CFG_SEND_INTERVAL seconds if (shared_networking_params.haveAPConnection) { rawTemperature = SENSORS_getTempValue(); light = SENSORS_getLightValue(); len = sprintf(json,”{\”Light\”:%d,\”Temp\”:%d.%02d}”, light,rawTemperature/100,abs(rawTemperature)%100); } if (len >0) { CLOUD_publishData((uint8_t*)publishMqttTopic ,(uint8_t*)json, len); if (holdCount) { holdCount--; } else { ledState.Full2Sec = LED_BLIP; LED_modeYellow(ledState); } }
Figure 5: The Microchip ATSAMA5D27-WLSOM1 integrates a full complement of devices required to deliver an AWS IoT Greengrass qualified Edge computing system. Image source: Microchip Technology
Figure 6: To ensure secure communications transactions, AWS Cloud services and AWS IoT Greengrass groups rely on multiple certificates backed by private keys stored in endpoints and the Greengrass Core device Image source: Amazon Web Service
“payload: %s”, payload); updateDeviceShadow(); }
with its MPLAB X integrated development environment (IDE), Cloud-based MPLAB Xpress IDE, and free MPLAB XC compilers. For debugging, each board includes the Microchip PICkit
On-Board (PKOB) nano debugger, which eliminates the need for an additional debugging hardware interface. Developers access the PKOB debugger through the USB connection to their personal
Listing 1: Developers can examine code samples in Microchip’s software repositories to a gain better understanding of key design patterns such as exchanging MQTT messages with Cloud services as shown in these two functions. Image source: Microchip Technology
we get technical
50
51
Powered by FlippingBook