npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

milesight-load-controller-api

v2024.11.15-0

Published

The Milesight Load Controller API is an internal tool exclusively accessible to our backend team

Downloads

89

Readme

Milesight Load Controller API

Description

The Milesight Load Controller API is a microservice built using the NestJS framework. It serves as a command hub for managing Milesight WS558 load controllers through lorawan downlink commands. This service is responsible for:

  • Managing load controller pin states
  • Configuring device reporting intervals
  • Handling device discovery and listing
  • Coordinating with AWS IoT and Wireless IoT services
  • Managing downlink message delivery through RabbitMQ

Core Features

Device Management

  • Device Discovery: List and manage Milesight load controller devices
  • Pin Control: Granular control over individual device pins
  • Reporting Configuration: Customizable device reporting intervals
  • Multi-vendor Support: Native support for Milesight WS558 load controllers

Command Processing

  • Downlink Management: Robust downlink command processing
  • State Control: Comprehensive pin state management
  • Message Queue Integration: RabbitMQ-based command distribution

Architecture

Core Components

  1. API Layer:

    • RESTful endpoints for device control
    • Validation pipeline
    • Error handling
  2. Service Layer:

    • Load Controller Service: Handles device-specific command logic
    • Downlink Service: Manages message queue operations
    • AWS Integration Service: Handles AWS IoT operations
  3. Integration Points:

    • AWS IoT Core
    • AWS IoT Wireless
    • RabbitMQ message queue

Requirements

  • Node 20.15.0
  • RabbitMQ 3.9.11
  • AWS Account with IoT Core access

Additional Requirements for Docker

  • Docker 20.10^
  • Docker Compose 1.27^

Configuration

Environment Variables

| Variable Name | Description | Default Value | Required | |--------------|-------------|---------------|-----------| | NODE_ENV | Application environment | development | Yes | | STAGE | Deployment stage | development | Yes | | MILESIGHT_LOAD_CONTROLLER_API_PORT | API port | 9061 | Yes | | MILESIGHT_LOAD_CONTROLLER_DOWNLINK_FPORT | Downlink port | 85 | Yes | | AMQP_HOST | RabbitMQ host | localhost | Yes | | AMQP_USERNAME | RabbitMQ username | guest | Yes | | AMQP_PASSWORD | RabbitMQ password | guest | Yes | | AMQP_PORT | RabbitMQ port | 5672 | Yes | | AMQP_VHOST | RabbitMQ virtual host | / | Yes | | AMQP_PREFETCH | RabbitMQ prefetch count | 200 | Yes | | AMQP_DOWNLINK_EXCHANGE | RabbitMQ exchange | hardware.downlinkexchange | Yes | | AWS_REGION | AWS region | us-east-1 | Yes | | AWS_ACCESS_KEY_ID | AWS access key | - | Yes | | AWS_SECRET_ACCESS_KEY | AWS secret key | - | Yes | | ELASTIC_APM_ENABLED | Enable/disable Elastic APM | false | No | | ELASTIC_APM_SERVER_URL | Elastic APM server URL | http://localhost:8200 | No | | TRANSACTION_SAMPLE_RATE | APM transaction sample rate | 1.0 | No | | ELASTIC_APM_SECRET_TOKEN | Elastic APM secret token | - | No |

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Service Dependencies

The Load Controller API provides the following core functionalities:

Device Management

  • List available load controllers
  • Control device pin states
  • Configure reporting intervals
  • Endpoints:
    • GET /load-controller

      // Query Parameters
      {
        maxResult?: number; // 1-250, default 25
        nextToken?: string;
      }
      
      // Response
      {
        "message": "Retrieved device list details",
        "result": {
          "things": [...],
          "nextToken": "..."
        }
      }
    • POST /load-controller/pin-status

      // Request Body
      {
        "deviceEui": "string",
        "serialNumber": "string", // optional
        "pinStatus": {
          "key": boolean // e.g., {"0": true, "1": false}
        }
      }
      
      // Response
      {
        "message": "Successfully sent set pin status command",
        "result": true
      }
    • POST /load-controller/reporting-interval

      // Request Body
      {
        "deviceEui": "string",
        "serialNumber": "string", // optional
        "seconds": number // 60-1800 seconds
      }
      
      // Response
      {
        "message": "Successfully sent set reporting interval command",
        "result": true
      }

External Service Dependencies

The service integrates with the following external services:

| Service | Purpose | |---------|----------| | AWS IoT Core | Device management and discovery | | AWS IoT Wireless | LoRaWAN communication | | RabbitMQ | Message queue for downlink commands |

Monitoring and Logging

  • Standardized logging through NestJS Logger
  • Error tracking and debugging support
  • APM integration for performance monitoring
  • RabbitMQ message tracking

License

This project is proprietary software. All rights reserved. This source code is protected under international copyright law. No part of this source code may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of GlacierGrid.

Version: 2024.11.14
Author: Jeff Robert Dagala
Copyright: © 2024 GlacierGrid. All rights reserved.