Git Product home page Git Product logo

nobutt's Introduction

WARNING: Work in progress. This project is in the early stages of development and may not be ready for use. It is not recommended for production use at this time.

ANOTHER WARNING: I am a dummy-dumb-dumb, so this project may have the following issues (and possibly more):

  • The Buttplug protocol might be implemented incorrectly
  • A better test utility may already exist, but I am not aware of it
  • I might not fully understand certain aspects of Buttplug application development, making this project potentially useless

NoButt

buttplug.io server mock to test your applications without a physical device.

What is NoButt?

It's recommended to read the Buttplug Protocol Spec first. Here is a brief overview:

The common architecture of an application that uses the Buttplug protocol consists of the following components:

  • Application: An application provides specific UI/UX in front of a Buttplug Client. Examples include:
    • A simple slider to control a toy from a web page
    • A 3D game
    • A typing tutor that makes the toy vibrate more as you type words correctly.
  • Client: A library in a specific language that offers a convenient and abstracted way to access the Buttplug protocol.
  • Server: The server that communicates with the devices and the client using the Buttplug protocol.
  • Devices: The hardware that the server communicates with.
graph LR
    Application --> Client
    Client <--> | Buttplug Protocol | Server
    Server <--> | Device Protocol | Device1([Device 1])
    Server <--> | Device Protocol | Device2([Device 2])
    Server <--> | Device Protocol | Device3([Device 3])
Loading

However, there is a problem: you need a physical device to test your application or client library. Surprisingly, there isn't a readily available mock server to test applications without a physical device (I can only assume that every developer has a buttplug at home or reimplements a server mock).

NoButt is a simple server mock that implements the Buttplug protocol. It allows you to test your application without a physical device.

Our architecture now looks like this:

graph LR
    Application --> Client
    Client <--> | Buttplug Protocol | NoButt[NoButt Server Mock]
    NoButt --> Device1([Virtual Device 1])
    NoButt --> Device2([Virtual Device 2])
    NoButt --> Device3([Virtual Device 3])
Loading

NoButt communicates with the client by properly implementing the Buttplug protocol and maintaining the state of virtual devices.

This project can be useful for both application and client library developers. Some use cases include:

  • Testing your application without a physical device
  • Testing in CI/CD environments
  • Testing against different device configurations

How to use NoButt

NoButt server communicates via the Buttplug protocol through a websocket connection at ws://localhost:12345.

To manage the server and its state (add/remove devices, get device state, etc.), you can use the following methods:

1. As a Python package

graph LR
    Code[Your Code] <--> NoButt[NoButt Server Instance]
    Client <--> | Buttplug Protocol | NoButt
Loading

2. Via API

graph LR
    Code[Your Code] <--> | API calls | APIAdapter[API Adapter]
    subgraph APIAdapter[API Adapter]
        NoButt[NoButt Server Mock]
    end

    Client <--> | Buttplug Protocol | NoButt
Loading

3. Web UI

graph LR
    Developer <--> Browser

    subgraph Browser
        NoButtUI[NoButt UI]
    end
    Client <--> | Buttplug Protocol | NoButt

    subgraph UIAdapter[UI Adapter]
        NoButt[NoButt Server Mock]
    end
    NoButtUI <--> | Internal Protocol | UIAdapter
Loading

nobutt's People

Contributors

butvinm avatar ssskrut avatar

Watchers

 avatar  avatar

nobutt's Issues

Server-side devices management

Server should store a list of devices which consists of spec (Device object from the protocol schemes) and state.

Devices must provide methods to change their own state accordingly to the available actuators.

In response to the Client requests the Server must properly maintain devices states and synchronize them with UI.

User should be able to set predefined set of devices, add devices dynamically and dump devices list to the persist file.

Write a README

It's been a while since the project was created. It is worth to write a full-fledged README

Add commit name check via GitHub Actions

The suggested commit name design here:
<branch-id>: <commit-name>

So issue #1 will have commits like this (on branch 1-issue-fix for example):

1: Chore main.py
1: Fix script.sh
1: Add note to README.md 

Update internal arch spec and move it to docs

  • Create docs folder with dev.md file and mode internal message specification from CONTRIBUTING.md into it
  • Add a note to the CONTRIBUTING.md that developers can refer to docs
  • Update message specification to consist with our latest decision about reusing NoButt protocol messages

Some problem with schema.json

Here is a converted into typescript schema of DeviceAdded command and it looks empty, doesn't it?

/**
 * Sent by the server whenever a device is added to the system. Can happen at any time after
 * identification stage (i.e. after client is connected), as it is assumed many server
 * implementations will support devices with hotplugging capabilities that do not require
 * specific scanning/discovery sessions.
 *
 * Represents a device with its properties and messages.
 */
export interface DeviceAdded {}

It is a device_added.json schema:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "https://github.com/butvinm/nobutt/tree/master/spec/messages/v3/device_added.json",
    "title": "DeviceAdded",
    "description": "Sent by the server whenever a device is added to the system. Can happen at any time after identification stage (i.e. after client is connected), as it is assumed many server implementations will support devices with hotplugging capabilities that do not require specific scanning/discovery sessions.",
    "type": "object",
    "required": [
        "Id"
    ],
    "allOf": [
        {
            "$ref": "../types/device.json"
        }
    ],
    "properties": {
        "Id": {
            "$ref": "../types/id.json"
        }
    },
    "additionalProperties": false
}

And this is a device_list one:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "https://github.com/butvinm/nobutt/tree/master/spec/messages/v3/device_list.json",
    "title": "DeviceList",
    "description": "Server reply to a client request for a device list.",
    "type": "object",
    "required": [
        "Id",
        "Devices"
    ],
    "properties": {
        "Id": {
            "$ref": "../types/id.json"
        },
        "Devices": {
            "type": "array",
            "items": {
                "$ref": "../types/device.json"
            }
        }
    },
    "additionalProperties": false
}

Probably a typo in a "allOf" field

Define json schemas

Define our custom json schemas for the protocol messages with versioning
Set up proper models generation for python

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.