Skip to content

ZigBee Use Case Examples

bradreevmx edited this page Jul 13, 2018 · 1 revision

Table of Contents

User install of ZigBeeDeviceCompliance contract
Device discovery and verification process
Search for certified FW updates

Certification process

Compile and Launch Contract
Add an Admin
Remove an Admin
Add a Tester
Remove a Tester


Actor: User

User install of ZigBeeDeviceCompliance contract

Device discovery and verification process

  • Device joins gateway
  • This use case assumes:
    • The ZigBeeDeviceCompliance contract was loaded and assigned the name: Compliance.
    • The DeviceInfo contract was loaded and assigned the name: DeviceInfo.
    • The DeviceSecurity contract was loaded and assigned the name: DeviceSecurity.
  • Gateway Reads Identification Attributes from Device
    • MfgName = Read Attribute (TBD, TBD)
    • ModelName = Read Attribute (TBD, TBD)
    • HwVersion = Read Attribute (TBD, TBD)
    • FwVersion = Read Attribute (TBD, TBD)
  • Gateway generates ZigBee Certification ID
    • CertificationId = hash(MfgName, ModelName, FwVersion, "ZigBee")
  • Read ZigBee certification record and save ModelId
    • var Result = Compliance.Read(CertificationId);
    • var Tester = Result[0];
    • var MfgModelId = Result[1];
    • var ExpirationDate = Result[2];
    • var ComplianceData = Result[3];
    • var CertValid = Result[4];
  • Verify device certification
    • ExpirationData > Today's date
    • Valid = true

Search for certified FW updates

  • This process assumes the gateway has the data from Device discovery and verification process
  • Read Family tree to check for new certified fw versions
    • var KeyMMH = '{"Mfg":"MfgName","Model":"ModelName","HwVer":"HwVersion"}';
    • var Result = Compliance.ReadFamily(KeyMMH);
    • var FamilyValid = Result[2];
    • var SubCount = Result[3];
    • Read each sub family and look for a newer approved version
      • var Result = Compliance.ReadSubFamily(KeyMMH, Loop);
      • var SubFamilyString = Result[1];
      • "CertVersionName" = parse JSON payload for "FwVer" and compare against current device version.
  • The following steps are to be followed if there is a newer FwVer available.
  • Loop through DeviceSecurity records with ModelId and new FW version name.
    • var TotalVersions = DeviceSecurity.ReadCount(MfgModelId);
    • var Result = DeviceSecurity.Read(MfgModelId, Loop);
    • var VersionName = Result[2];
    • if VersionName = CertVersionName then save URI
      • var Uri = Result[3];
  • Pull image from Manufacturer's Update URI
    • Image = https URI
  • Update device

Actor: Admin and Tester

Certification process

  • This use case assumes:
    • The ZigBeeDeviceCompliance contract was loaded and assigned the name: Compliance.
    • The DeviceInfo contract was loaded and assigned the name: DeviceInfo.
    • The DeviceSecurity contract was loaded and assigned the name: DeviceSecurity.
    • Predefined addresses. (Note, not all parties need all addresses)
      • var Mfg1 = "0xXXXXXX";
      • var Admin1 = "0xXXXXXX";
      • var Tester1 = "0xXXXXX";
      • ComplianceModelId1 is the hash of Mfg Name, Model Name, Fw Version, "ZigBee"
  • Manufacturer creates DeviceInfo Record
    • DeviceInfo.Write(ModelId1, JsonData, Mfg1, {Mfg1,gas:470000});
  • Manufacturer creates DeviceSecurity Record
    • DeviceSecurity.Write(ModelId1, TestMudV1, TestSecurityDescriptionV1, TestVersionNameV1, TestUriV1,{Mfg1,gas:4700000});
  • Tester verifies operation and submits Compliance Record
    • Compliance.Write(ComplianceModelId1, ModelId1, ExpirationDate, ComplianceData, {Tester1,gas:470000});
  • Admin approves certification
    • Compliance.WriteValid(ComplainceModelId1, true, {Admin1,gas:470000});
    • Compliance.Read(ComplianceModelId1);
  • Admin updates family tree
    • var KeyMMHF = '{"Mfg":"MfgA","Model":"ModelB","HwVer":"Hw1","FwVer":"Fw1"}';
    • var KeyMMH = '{"Mfg":"MfgA","Model":"ModelB","HwVer":"Hw1"}';
    • var KeyMM = '{"Mfg":"MfgA","Model":"ModelB"}';
    • var KeyM = '{"Mfg":"MfgA"}';
    • Compliance.WriteFamilyTree(KeyM, KeyMM, KeyMMH, KeyMMHF1,{Admin1,gas:4700000});
    • Complaince.ReadFamily(KeyM);
    • Complaince.ReadFamily(KeyMM);
    • Complaince.ReadFamily(KeyMMH);
    • Complaince.ReadFamily(KeyMMHF);

Actor: Admin

Compile and Launch Contract

  • See Build and Test for more details
  • Install ComplianceBlockchain
  • Install DeviceInfo
  • Install DeviceSecurity
  • Clone ZigBeeDeviceCompliance
  • Compile project
  • Launch Contract
  • Push ZigBeeDeviceCompliance.js and ZigbeeDeviceComplianceAddress.js files back to repository

Add an Admin

  • This use case assumes:
    • The contract was loaded and assigned the name: Compliance.
    • Predefined address
      • var Admin1 = "0xXXXXXX";
      • var Admin2 = "0xXXXXXX";
  • Add New Admin to Index 1
    • Compliance.WriteAdmin(1,Admin2,{from:Admin1,gas:470000});
  • Read Admin List
    • Compliance.ReadAdminList();

Remove an Admin

  • This use case assumes:
    • The contract was loaded and assigned the name: Compliance.
    • Predefined address
      • var Admin1 = "0xXXXXXX";
      • var Admin2 = "0xXXXXXX";
  • Overwrite Index 1 with NULL
    • Compliance.WriteAdmin(1,0,{from:Admin1,gas:470000});
  • Read Admin List
    • Compliance.ReadAdminList();

Add a Tester

  • This use case assumes:
    • The contract was loaded and assigned the name: Compliance.
    • Predefined address
      • var Admin1 = "0xXXXXXX";
      • var Tester1 = "0xXXXXXX";
    • The Admin List contains a Admin1.
  • Add Tester1 to Tester Index 0
    • Compliance.WriteTester(1,Tester1,{from:Admin1,gas:470000});
  • Read tester List
    • Compliance.ReadTesterList();

Remove a Tester

  • This use case assumes:
    • The contract was loaded and assigned the name: Compliance.
    • Predefined address
      • var Admin1 = "0xXXXXXX";
      • var Tester1 = "0xXXXXXX";
  • Overwrite Tester Index 0 with NULL
    • Compliance.WriteTester(1,0,{from:Admin1,gas:470000});
  • Read Tester List
    • Compliance.ReadTesterList();

Clone this wiki locally