MAXREFDES143#: DeepCover Embedded Security in IoT Authenticated Sensing & Notification

Dependencies:   MaximInterface mbed

The MAXREFDES143# is an Internet of Things (IoT) embedded security reference design, built to protect an industrial sensing node by means of authentication and notification to a web server. The hardware includes a peripheral module representing a protected sensor node monitoring operating temperature and remaining life of a filter (simulated through ambient light sensing) and an mbed shield representing a controller node responsible for monitoring one or more sensor nodes. The design is hierarchical with each controller node communicating data from connected sensor nodes to a web server that maintains a centralized log and dispatches notifications as necessary. The mbed shield contains a Wi-Fi module, a DS2465 coprocessor with 1-Wire® master function, an LCD, LEDs, and pushbuttons. The protected sensor node contains a DS28E15 authenticator, a DS7505 temperature sensor, and a MAX44009 light sensor. The mbed shield communicates to a web server by the onboard Wi-Fi module and to the protected sensor node with I2C and 1-Wire. The MAXREFDES143# is equipped with a standard shield connector for immediate testing using an mbed board such as the MAX32600MBED#. The simplicity of this design enables rapid integration into any star-topology IoT network requiring the heightened security with low overhead provided by the SHA-256 symmetric-key algorithm.

More information about the MAXREFDES143# is available on the Maxim Integrated website.

Revision:
25:37ea43ff81be
Parent:
20:cdba71cb5506
Child:
28:e5cdaf13d299
diff -r 434330962308 -r 37ea43ff81be main.cpp
--- a/main.cpp	Wed Oct 19 13:23:41 2016 -0500
+++ b/main.cpp	Fri Dec 16 10:47:34 2016 -0600
@@ -33,7 +33,7 @@
 
 #include <sstream>
 
-#include "common.hpp"
+#include "SensorData.hpp"
 #include "WebServerInterface.hpp"
 #include "Factory.hpp"
 #include "SensorNode.hpp"
@@ -71,9 +71,10 @@
 
 /// @{
 /// LCD display colors.
-static const Display::Color Teal(0x00, 0xB2, 0xA9);
-static const Display::Color Red(0xFF, 0x00, 0x00);
-static const Display::Color Green(0x00, 0xFF, 0x00);
+static const Display::Color Teal = { 0x00, 0xB2, 0xA9 };
+static const Display::Color Red = { 0xFF, 0x00, 0x00 };
+static const Display::Color Green = { 0x00, 0xFF, 0x00 };
+static const Display::Color Purple = { 0x6E, 0x25, 0x85 };
 /// @}
 
 /// @{
@@ -87,7 +88,6 @@
 static Display lcd(i2c, 0x78, 0x98);
 static DS2465 ds2465(i2c, 0x30);
 static SensorNode sensorNode(i2c, 0x90, 0x94, ds2465);
-static Factory factory;
 static ESP8266 esp8266(D1, D0, D2, D3, 38400);
 static WebServerInterface webIntf(esp8266, &pc);
 /// @}
@@ -104,7 +104,7 @@
 static bool buttonPressed(DigitalIn & button); ///< Checks if button is pressed (returns true) and waits for release.
 static void displayStatus(Status status); ///< Display status message on LCD.
 static void displaySensorData(const SensorData & sensorData); ///< Display sensor data on the LCD.
-static bool readWebSessionId(std::string & sessionId); ///< Read device's web session ID from it's nonvolatile storage.
+static bool readWebSessionId(OneWire::RomId & sessionId); ///< Read device's web session ID from it's nonvolatile storage.
 
 #ifdef ASSEMBLY_TEST
 #include "AssemblyTest.cpp"
@@ -138,13 +138,18 @@
       // Read session ID
       if (result)
       {
-        result = readWebSessionId(webIntf.sessionId);
+        OneWire::RomId sessionId;
+        result = readWebSessionId(sessionId);
+        if (result)
+        {
+            webIntf.setSessionId(sessionId);
+        }
       }
       
       // Provision DS2465 with master secret and page data
       if (result)
       {
-        result = factory.provision(ds2465);
+        result = provisionCoprocessor(ds2465);
       }
       
       if (result)
@@ -207,7 +212,7 @@
     case ProvisioningSensorNode:      
       if (!buttonPressed(invalidateButton)) // Provision normally
       {
-        if (factory.provision(sensorNode, true))
+        if (provisionSensorNode(sensorNode, true))
         {
           nextStatus = NormalOperation;
         }
@@ -219,7 +224,7 @@
       else // Invalidate button also pressed; Load invalid secret
       {        
         // Provision with invalid secret
-        if (factory.provision(sensorNode, false))
+        if (provisionSensorNode(sensorNode, false))
         {
           nextStatus = NormalOperation;
         }
@@ -403,7 +408,7 @@
     break;
     
   case DisplaySessionId:
-    lcd.writeLine("ID: " + webIntf.sessionId, Display::FirstLine);
+    lcd.writeLine("ID: " + webIntf.sessionIdString(), Display::FirstLine);
     lcd.writeLine("Provision to begin", Display::SecondLine);
     lcd.setBackLightColor(Teal);
     break;
@@ -434,7 +439,7 @@
     
   case SensorNodeNotAuthentic:
     lcd.writeMessage("Sensor Node Not Authentic");
-    lcd.setBackLightColor(Red);
+    lcd.setBackLightColor(Purple);
     break;
     
   case ControllerInitializationError:
@@ -458,19 +463,19 @@
 static void displaySensorData(const SensorData & sensorData)
 { 
   std::ostringstream stream;
-  stream << "Chiller Temp: " << (int)sensorData.temp << "C";
+  stream << "Chiller Temp: " << static_cast<int>(sensorData.temp) << "C";
   lcd.writeCompleteLine(stream.str(), Display::FirstLine);
   stream.str(""); // Clear stream
-  stream << "Filter Life: " << (unsigned int)sensorData.filterLife << "%";
+  stream << "Filter Life: " << static_cast<unsigned int>(sensorData.filterLife) << "%";
   lcd.writeCompleteLine(stream.str(), Display::SecondLine);
-  lcd.setBackLightColor((sensorData.tempAlarm() || sensorData.filterLifeAlarm()) ? Red : Green);
+  lcd.setBackLightColor(Green);
 }
 
 /// Read the Session ID to use with the web server from ROM.
 /// @note Session ID is taken from the ROM ID of the MAX66242.
 /// @param[out] Session ID string.
 /// @returns True on success.
-static bool readWebSessionId(std::string & sessionId)
+static bool readWebSessionId(OneWire::RomId & sessionId)
 {  
   const uint8_t I2C_address = 0x32;
   const uint8_t ROM_address = 0x68;
@@ -480,11 +485,11 @@
   if (i2c.write(I2C_address, reinterpret_cast<const char *>(&ROM_address), 1) != 0)
     return false;
   // Read ROM ID
-  if (i2c.read(I2C_address, reinterpret_cast<char *>(&(static_cast<RomId::ByteBuffer &>(romId))), RomId::byteLen) != 0)
+  if (i2c.read(I2C_address, reinterpret_cast<char *>(romId.buffer.data()), romId.buffer.size()) != 0)
     return false;
   // Check if CRC valid
-  if (!romId.crc8Valid())
+  if (!romId.valid())
     return false;
-  sessionId = byteArrayToHexString(romId, RomId::byteLen);
+  sessionId = romId;
   return true;
 }
\ No newline at end of file