Skip to content

Latest commit

 

History

History
142 lines (104 loc) · 4.77 KB

mep-803.md

File metadata and controls

142 lines (104 loc) · 4.77 KB
  MEP: 803
  Title: Sensor Data Contract
  Status: Draft
  Type: Standards
  Created: 2023-04-19
  Updated: 2023-12-12

MEP-803: Device Profile Contract

Simple Summary

Specification that allows the application owner (MEP-801) to create device profiles and link profiles to devices.

Abstract

Motivation

Terminology

  • Device Profile - Goes to Chirpstack VM
    • Decode function
    • IoT Parameter
    • Custom Parameter
    • Freq
  • Custom Parameter
    • The Chirpstack VM publish the data in the reward call
    • Goes inside the sensor NFT (on-chain data)
    • Is claimed in the MEP805

The reward calculation should be done on Chirpstack VM MEP805 is to claim the rewards, not to calculate rewards (off-chain worker)

(there is an opportunity to remove MEP805 if the claim is done on MEP804)

Specification

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

Every MEP-803 compliant contract must implement the following interface:

pragma solidity ^0.8.18;

/// @title MEP803 (ISO Sensor Profiles)
interface IIMEP803 {
    /// @dev This event gets emitted when a device profile added
    ///  The parameters is the index of profile, owner and name.
    event ProfileCreated(uint256 idx, address owner, string name, string url);

    /// @dev This event gets emitted when a device profile renamed
    ///  The parameters is the index of app, owner and name.
    event ProfileRenamed(uint256 idx, address owner, string name);

    /// @dev This event gets emitted when a device profile url changed
    ///  The parameters is the index of app, owner and url.
    event ProfileUrlChanged(uint256 idx, address owner, string url);

    /// @dev This event gets emitted when a device profile downlink price changed
    ///  The parameters is the index of app, owner and the new price.
    event DownlinkPriceChanged(
        uint256 idx,
        address owner,
        uint256 downlinkPrice
    );

    /// @notice Return the name of contract, use to identiry the version of the contract
    function name() external view returns (string memory);

    /// @notice Create a device profile
    /// @param _name The name of of the device profile
    /// @param _url The url of of the device profile
    /// @param _downlinkPrice The price for Downlink, unit in MXC
    function createProfile(
        string memory _name,
        string memory _url,
        uint256 _downlinkPrice
    ) external returns (uint256);

    /// @notice rename a device profile
    /// @param _idx The device profile index
    /// @param _name The name of of the device profile
    function renameProfile(uint256 _idx, string memory _name) external;

    /// @notice Set the url of the device profile
    /// @param _idx The device profile index
    /// @param _url The url of of the device profile
    function setProfileUrl(uint256 _idx, string memory _url) external;

    /// @notice Set the Downlink Price of the device profile
    /// @param _idx The device profile index
    /// @param _downlinkPrice The price for Downlink, unit in MXC
    function setDownlinkPrice(uint256 _idx, uint256 _downlinkPrice) external;

    /// @notice Return the number of profiles belong to the sender.
    function ownerProfileIdxCount() external view returns (uint256);

    /// @notice Return a list of profiles belong to the sender. Up to 10.
    /// @param _offset The starting index of owner's profile
    function getOwnerProfileList(
        uint256 _offset
    ) external view returns (DeviceProfile[] memory);
}

And this public accessible state values:

struct DeviceProfile {
    uint256 idx;
    string name;
    address owner;
    string url;
    bool active;
    uint256 downlinkPrice;
}

contract Storage1 {
    using Counters for Counters.Counter;

    /// @notice Device Profile list
    mapping(uint256 => DeviceProfile) public deviceProfileList;
    Counters.Counter public deviceProfileCount;

    /// @notice Device Profile idx list for each owner
    mapping(address => uint256[]) public ownerProfileIdxList;
}

Rationale

To create a Device Profile in ISO Application, the profile is created at the point of calling the createProfile() interface and event is emitted containing the device profile index, device profile name, business owner address and the URL.

Prior to the creating a Device Profile, the business owner (BO) needs to ready the device profile JSON file on a reliable internet storage (unauthorised accessible via HTTP or HTTPS). Then the BO could provides the URL when creating the device profile.

Alternatively, BO could submit their Device Profiles to https://github.com/MatchX-GmbH/iso-device-profile for a better storage management.