GithubHelp home page GithubHelp logo

mockerbee's Introduction

👷 Project is still a draft ! roadmap is still not clearly defined. your comments are welcome

Device Mocker with ZCL API is a powerful library for simulating devices with different ZCL clusters, designed for developers working on IoT devices with Zigbee communication.

Built with modern C++ features, Device Mocker supports both C and C++ APIs and can be easily integrated into your existing project.

Device Mocker is designed to be easy to use, with a simple API that allows you to create a device with just a few lines of code.

Prerequisites

  • CMake 3.10 or later
  • C++ compiler with C++23 support (Recommended clang-17)

Code quality checks

  • libsanitizer
  • clang-tidy
  • cppcheck
  • clang-format

CI Test

CMake

Documentation

Concepts

Endpoint & Device & Device Pool

A pool of devices is a collection of devices. A device is a collection of endpoints. each endpoint is a collection of clusters.

A pool has an associated PAN (Personal Area Network) object. Each device in the pool can be in this PAN or not.

A device pool can be enhanced to hold multiple PANs. But it is not considered in the current implementation.

Cluster

ZCL cluster representation object. it mirror a ZCL cluster with all its attributes as if it running on a real device.

Each cluster command is defined by:

  • A command descriptor.
  • A command executer = a free function that takes a cluster object as a first argument.

The commands are not methods of the cluster object. this is needed because a command can be executed from runtime id resolved from a command ID. using:

class Device
{
  ...

  template <typename... Args>
  zcl::ZclStatus execute_cluster_command(const endpoint_id_t     ep_id,
                                         const zcl::cluster_id_t cluster_id,
                                         const zcl::command_id_t command_id,
                                         bool is_common, Args... args);
}
Create a device pool and communicate with devices
  // Create a device pool with a PAN ID
  device::Pool pool(pan_id);

  // Instantiate a device using a device class
  device::OnOffDevice device(mac_address);

  // Open the pan
  pool.pan.set_permit_joining(true);

  // Make it join the PAN
  device.join_pan(pool.get_pan());

  // Communicate with the device
  device.execute_cluster_command(
      1, zcl::on_off_cluster::cluster_descriptor.id,
      zcl::on_off_cluster::setOffCmdDescriptor.get_id(), false);



Custom clusters and devices

Adding custom cluster

A custom cluster can be added by inheriting from the Cluster class and passing the required attribute descriptors and commands.

namespace my_rocket_cluster_namespace
{
// Cluster descriptor
const cluster_descriptor_t cluster_descriptor{/*id=*/0xF001,
                                              /*is_msp=*/true,
                                              /*description=*/"My rocket cluster"};

const commands_map_t on_off_commands_map = {
    {liftOffCommandDescriptor,
     static_cast<const CommandBase* const>(&liftOffCommand)},
};

// OnOffCluster class
class MyRocketCluster : public Cluster
{
 public:
  RocketCluster()
      : Cluster(
            /*descriptor=*/cluster_descriptor,
            /*attribute_descriptors=*/
            {altitudeAttributeDescriptor, speedAttributeDescriptor,
             coordinatesAttributeDescriptor},
            /*commands_map=*/
  {
  }
};
Add custom device

A device class can be created by inheriting from the Device class and passing the required endpoints with their clusters to the base class constructor.

class OnOffDevice : public Device
{
 public:
  explicit OnOffDevice(const MacAddress& mac_address)
      : Device(mac_address,
               {Endpoint{1, {zcl::on_off_cluster::OnOffCluster()}},
                Endpoint{2, {zcl::my_cluster_namespace::MyCluster()}}
               }){};
};

mockerbee's People

Contributors

zakaria-fadli-netatmo avatar zakaria1193 avatar

Stargazers

 avatar

Watchers

 avatar

mockerbee's Issues

implement Event Class

Event consumer:

As a user

  • i should be able to receive events

    • It is my responsability to implemement
    • extern process_event(Event *event)
  • The device should report events

    • nwk management events
      • DeviceAnnouncementEven
      • LeaveEvent
      • JoinEvent
    • Cluster specific events (reportings)
      • The device should notify me through periodic events and state changes by calling my “event_consumer_callback”, event should
      • ReportingEvent

Fix Readme

readme should specify that the end goal is not only zigbee devices but also matter devices that use the zcl

Remove namespace zcl

zcl namespace should only be for headers in zcl forlder,
files such as device.hpp should use the global namespace

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.