Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mqttopia

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mqttopia

  • 0.1.18
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Mqttopia

Mqttopia is a Ruby-based project designed to facilitate interactions with MQTT protocols. It provides a modular architecture for handling MQTT clients, subscriptions, and data serialization, making it easier to integrate MQTT into your applications.


Features

  • Configurable MQTT client with options for hosts, port, SSL, and authentication.
  • Subscription handling for dynamic topics.
  • Data serialization modules to standardize payloads.
  • Custom Rake tasks for initializing configuration files.

Installation

Bundler

gem 'mqttopia', '~> 0.1.0'

Manual

gem install mqttopia

Usage

Configuring Mqttopia

You can create or update the mqttopia.rb file using the included Rake task:

bundle exec rails generate mqttopia:install

The generated mqttopia.rb will contain:

Mqttopia.configure do |config|
  config.hosts = ["localhost"]
  config.port = 1883
  config.username = "user"
  config.password = "xxxx"
  config.ssl = true
end

Example: Subscribing and Publishing Messages

client = Mqttopia::Client.instance

# Subscribe to a topic
client.subscribe('test/#') do |response|
  puts "Received: #{response}"
end

# Publish a message to a topic
client.publish('test/topic', 'Hello, MQTT')

MQTT subscriptions

  • MQTT subscriptions

Topic Name Structure

  • send data : illa/{entity}/{entity_id}/{operation}/send/user/{user_id}
  • ask data : illa/{entity}/{entity_id}/{operation}/ask/user/{user_id}
  • operation : trip_metrics, test_debug, ..etc.
  • entity: trips
  • user/{user_id} is optional

Rake Tasks

Available Tasks

  • Initialize Configuration File:

    Creates mqttopia_initialize.rb with default configurations.

    bundle exec rake mqttopia:initialize
    

Project Structure

mqttopia/
├── lib/
│   ├── mqttopia/               # Modules for mqttopia gem
│   |   ├── helpers/            # Helper Modules
│   |   ├── serializers/        # Modules for payload serialization
│   |   ├── subscriptions/      # MQTT Topics's events and services
│   |   └── topics/             # MQTT Topic constants [name, regex, service, serializer]
│   |── tasks/                  # Rake tasks
│   ├── mqttopia.rb             # Main entry point for the gem
│   ├── client.rb               # MQTT client implementation
│   └── logger.rb               # Logging setup
└── test/                       # Minitest-based test suite

Contributing

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature-branch-name
  3. Commit your changes: git commit -m "Add new feature"
  4. Push the branch: git push origin feature-branch-name
  5. Open a Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for more information.


Contact

If you have any questions or need further assistance, feel free to open an issue or contact the maintainer.


Acknowledgements

Special thanks to all contributors and users who have made this project possible.

FAQs

Package last updated on 19 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc