Aniston NexusDocs
Open Aniston Nexus

PLCs, field buses and gateways

Connect PLCs, meters and field buses through the Aniston Nexus Gateway, map registers and send controls safely.

Equipment that cannot talk MQTT or HTTP itself (PLCs, energy meters, DG controllers, chillers) is read by a gateway on site: the Aniston Nexus Gateway, built by Aniston from the open-source IoT Gateway (Apache-2.0, source in gateway/). It polls Modbus, BACnet, OPC UA, BLE, CAN, SNMP, REST and other sources and sends the values over MQTT as many devices behind one gateway device.

Set up a gateway

  1. Create a device for the gateway and tick Is gateway. Copy its access token.
  2. Run the gateway next to the equipment. Download the image from your own server (https://<server>/downloads/nexus-gateway-<version>.tar.gz), docker load -i it, and start it with the docker-compose file the device wizard or the gateway page gives you (it holds the host, port and token). The image is built from this repository only (docker-local/gateway/build.sh); it never installs packages at run time and does not contact any update server.
  3. Add connectors (one per bus or protocol) and their device lists.
  4. Open the gateway device in Aniston Nexus: the Gateway widgets show connector status, logs and the devices it created. Devices behind the gateway appear as normal devices.

Install on a site machine

deploy/site/install-gateway.sh does step 2 in one command on an Ubuntu or Debian machine that already has Docker and the Compose plugin (sudo apt-get install docker.io docker-compose-plugin). Copy the script to the machine and run:

sudo NEXUS_GW_TOKEN='<gateway access token>' ./install-gateway.sh --server https://<server>

It downloads https://<server>/downloads/nexus-gateway-<version>.tar.gz (the newest one listed, or --version 3.8.6), checks it against the .sha256 file published next to it (both build.sh and the EC2 deploy write one; without it the script warns), runs docker load, writes docker-compose.yml and .env (mode 600, holds the token) into /opt/nexus-gateway and starts the container nexus-gateway with restart: unless-stopped. Configuration, extensions and logs are folders next to the compose file (config/, extensions/, logs/); on the first start the gateway fills config/ with its defaults.

OptionMeaning
--server URLYour Aniston Nexus server (https:// required; --allow-http only on a trusted LAN)
--token TOKEN, --token-file FILEGateway device access token; the NEXUS_GW_TOKEN variable keeps it out of ps. A re-install keeps the saved token
--version VImage version (default: newest on the server)
--mqtt-host H, --mqtt-port PMQTT endpoint (default: the server's host, port 1883)
--dir DIRInstall folder (default /opt/nexus-gateway)
--checkContainer status, connection settings (token masked) and the last 50 log lines
--uninstallStops and removes the container only; config, logs and the image stay, so a re-install continues

Re-running the install with a newer --version upgrades the gateway and keeps its configuration. The script never prints the token in full. MQTT over TLS (port 8883) needs the TLS settings in config/tb_gateway.json after the first start.

The BMS package has complete, validated samples in solutions/nexus-bms/gateway/:

FileConnector
tb_gateway.jsonMain configuration: MQTT to Aniston Nexus, file storage for outages
modbus_tcp_energy_meters.jsonModbus TCP energy meters and solar inverters
modbus_rtu_dg_ups.jsonModbus RTU (RS-485, 9600 8N1): DG set controllers and a UPS
bacnet_hvac.jsonBACnet/IP: AHUs, chillers, cooling tower, VRF indoor units

The register addresses and object ids in the samples are examples of a typical layout, not a commissioned map. Replace them with the manufacturer's register map or BACnet PICS before connecting real equipment.

Register and object mapping

For every value, check against the manufacturer's documentation:

SettingModbusBACnet
AddressRegister number (0- or 1-based: check), function code 3 (holding) or 4 (input), coils 1/2Object type and instance (analogInput:1)
Type16int, 16uint, 32float, 32int, 64float, bits, stringFrom the object; presentValue
Byte / word orderbyteOrder BIG/LITTLE and wordOrder for 32/64-bit valuesn/a
Scalingmultiplier and divider (e.g. 0.1 for tenths of a volt)Usually engineering units already
PollingpollPeriod per device (ms); keep the bus load in mind on RS-485pollPeriod; COV subscription where supported
KeyThe telemetry key the profile, alarms and dashboards expect (see the package CONTRACT.md)Same

Use the keys of the target device profile exactly; the BMS keys are defined once in solutions/nexus-bms/tools/bms_catalog.py and listed in solutions/nexus-bms/CONTRACT.md.

Payload decoders

Raw payloads (binary LoRa frames, vendor JSON) are converted to telemetry in one of three places:

  • in the gateway connector (converters of the IoT Gateway),
  • in the companion service nexus-services: the ChirpStack bridge (below) and the cloud bridge (Sigfox, TTN, Google Cloud Pub/Sub, below) share a declarative byte-layout decoder (no code),
  • or in a rule chain with a script transformation node (TBEL or JavaScript).

A byte layout names, per value, the first byte (offset), the type (u8, s8, u16, s16, u24, u32, s32, float32), big or little endian, scale and add (raw * scale + add), optional bits (start and length inside the raw integer), and checks such as expect (a version byte) and noValue (0xFFFF = no reading). The built-in preset nexus-water-level-v1 is the Water Level Unit sample frame of this project (01, levelRawMm u16, supply mV u16, faultCode u8, optional sensor time u32 epoch seconds). It is our own format, not a vendor's; no vendor frame format is built in, so describe the OEM's frame with a layout once the sensor is chosen. Reference: nexus-services/src/main/java/com/aniston/nexus/services/cloudbridge/README.md, section "Binary payloads".

Decode as close to the source as possible, and keep the raw value as a separate key while commissioning.

LoRaWAN with your own ChirpStack

The companion service nexus-services has a ChirpStack v4 bridge (package lora, off by default). It subscribes to ChirpStack's MQTT integration, decodes uplinks and posts them to the device whose sensorId attribute equals the DevEUI; gateway statistics go to the matching LoRa Gateway device.

Enable it in docker-local/services/water.env (production: .env):

WATER_LORA_ENABLED=true
WATER_LORA_BROKERURL=tcp://chirpstack-mosquitto:1883
WATER_LORA_USERNAME=...
WATER_LORA_PASSWORD=...

and restart nexus-services. Its status (connection, decoded/failed counts, last error) is at /api/water/v1/lora/status. Details: nexus-services/src/main/java/com/aniston/nexus/services/lora/README.md. A simulator for tests is in solutions/nexus-water/tools/lora_sim/.

The byte-layout decoder is selected with WATER_LORA_DECODER=nexus-water-level-v1, or WATER_LORA_DECODER=layout and WATER_LORA_DECODERLAYOUT=<preset name or layout JSON> (optionally WATER_LORA_DECODERFPORTS=2).

Set up ChirpStack, gateways and devices from the UI: see LoRaWAN and connecting devices.

Other IoT clouds (cloud bridge)

The cloudbridge package of nexus-services (off by default, WATER_CLOUDBRIDGE_ENABLED=true) brings data from other clouds in and posts it like a device, so the device's rule chain runs. Connectors are managed by tenant administrators at /api/water/v1/cloudbridge/connectors:

SourceConnectorHow
The Things Network / The Things Stack v3MQTT or webhook, preset ttn-v3Device = TTN device id; binary frm_payload can be decoded with a byte layout
AWS IoT Core, Azure IoT Hub (Event Grid), HiveMQ, any MQTT brokerMQTT or webhook, presets aws-iot-shadow, aws-iot-topic, azure-iothub-eventgrid, generic
SigfoxWebhook, preset sigfoxSigfox backend custom callback (POST, JSON body with device, time, data, seqNumber, lqi, snr, rssi, station); secret in the X-Bridge-Secret header or as the last URL segment. Device = Sigfox device id (attribute sigfoxDeviceId); data (hex) decoded with a byte layout
Google Cloud Pub/SubKind PUBSUB, preset gcp-pubsubPull subscription through the REST API with a service account key (Docker secret); a message is acknowledged only after its telemetry was accepted

Other LoRaWAN network servers (LORIOT, ThingPark …) are not integrated; see Not included. Details and recipes: nexus-services/src/main/java/com/aniston/nexus/services/cloudbridge/README.md.

Connection health

WhereWhat it tells you
Device active flag and lastActivityTimeWhether the device (or the gateway on its behalf) sent anything within the inactivity timeout
Gateway widgetsConnector state, errors, recent logs
Water – Device Health dashboardBattery, signal, last report and data quality of the water level units
nexus-services /api/water/v1/lora/statusLoRa bridge connection and decode errors

Controls (RPC)

Dashboards send commands as RPC (setValue, setState …) to a device; the gateway forwards them to the connector, which writes the register or object. Only expose controls that the controller accepts remotely, show the confirmed state (read back from the equipment), not the requested state, and require confirmation for anything that moves equipment. Simulators in solutions/*/tools/simulator.py answer RPCs for testing; a simulated reply is not proof that a physical actuator moved.