Tích hợp hệ thống ngoài

Kết nối VieLang IoT với AWS IoT, Azure IoT Hub, Kafka, RabbitMQ, OPC-UA, Modbus, và các cloud platform khác

Tích hợp hệ thống ngoài

VieLang IoT hỗ trợ tích hợp hai chiều với nhiều cloud platform, message broker, và giao thức công nghiệp.

Loại tích hợp

Platform Integrations

Nhận dữ liệu từ các IoT platform khác và forward về VieLang IoT:

PlatformMô tả
AWS IoTAWS IoT Core rules
Azure IoT HubEvent Hub consumer group
Google Cloud IoTPub/Sub subscription
IBM Watson IoTMQTT bridge
ParticleWebhook từ Particle Cloud

Message Broker Integrations

BrokerProtocol
Apache KafkaKafka Consumer
RabbitMQAMQP
Apache PulsarPulsar Consumer
MQTT BrokerMQTT bridge (bất kỳ broker nào)

Network Server Integrations (LPWAN)

NetworkGiao thức
ChirpStackHTTP/MQTT
The Things Network (TTN)MQTT
The Things Stack (TTS)MQTT
Actility ThingParkHTTP
SigfoxHTTP callback
LORIOTHTTP/MQTT
KPN ThingsHTTP

Uplink/Downlink (Custom)

TypeMô tả
HTTPWebhook từ bất kỳ nguồn nào
MQTTSubscribe MQTT topic ngoài
TCPRaw TCP socket
UDPRaw UDP datagram
OPC-UAIndustrial protocol

Ví dụ: Tích hợp Kafka

Nhận dữ liệu từ Kafka topic, parse và lưu vào thiết bị:

Integration setup:

Integration type: Kafka Name: Production Sensor Data Bootstrap servers: kafka:9092 Topics: factory.sensors.telemetry Group ID: vielang-consumer Decoder function (JavaScript):
var data = decodeToJson(payload); var deviceName = data.device_id; var telemetry = { temperature: data.temp, humidity: data.hum, pressure: data.pres }; var attributes = { firmware: data.fw_version }; return { deviceName: deviceName, deviceType: "sensor", telemetry: [{ ts: data.timestamp, values: telemetry }], attributes: attributes };

Ví dụ: Tích hợp The Things Network (TTN)

Nhận uplink từ LoRa devices qua TTN:

Integration type: The Things Stack Community MQTT server: eu1.cloud.thethings.network Username: app-id@ttn Password: [API Key] Topics: v3/{app-id}/devices/+/up

Decoder cho payload LoRa:

var data = decodeToJson(payload); var deviceEUI = data.end_device_ids.dev_eui; // Decode LoRa payload (base64 → bytes → telemetry) var bytes = atob(data.uplink_message.frm_payload); var temperature = (bytes.charCodeAt(0) << 8 | bytes.charCodeAt(1)) / 100; var humidity = bytes.charCodeAt(2); return { deviceName: deviceEUI, deviceType: "lora-sensor", telemetry: [{ ts: Date.parse(data.uplink_message.received_at), values: { temperature: temperature, humidity: humidity } }] };

Ví dụ: AWS IoT Core

Forward dữ liệu từ AWS IoT Rules đến VieLang IoT:

Trên AWS IoT:

-- AWS IoT Rule query SELECT * FROM 'sensors/#'
Action: HTTP → https://vielang.io/api/v1/${topic}/telemetry Headers: X-Authorization: Bearer [API Key]

Hoặc qua MQTT bridge:

Integration type: AWS IoT Access Key ID: AKIAXXXXXXXXXXXXXXXX Secret Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Region: ap-southeast-1 Topic filter: sensors/+/data

Downlink (Gửi lệnh từ VieLang về thiết bị)

Với integration hỗ trợ downlink, dùng Rule Engine để gửi lệnh ngược:

Ví dụ: Gửi downlink qua TTN khi alarm tạo

Rule Chain: [Alarm Created] → [REST API Call] URL: https://eu1.cloud.thethings.network/api/v3/as/applications/{app}/devices/{dev}/down/push Method: POST Body: { "downlinks": [{ "frm_payload": "base64-encoded-command", "f_port": 1, "priority": "NORMAL" }] }

OPC-UA (Industrial)

Kết nối với SCADA/DCS hệ thống công nghiệp qua OPC-UA:

Integration type: OPC-UA Endpoint URL: opc.tcp://plc.factory.local:4840 Security mode: SignAndEncrypt Certificate: [PEM] Node mapping: ns=2;s=Temperature.Value → temperature (telemetry) ns=2;s=Motor.Status → motor_status (attribute) ns=2;s=Production.Count → production_count (telemetry) Polling interval: 5000ms

Modbus (qua IoT Gateway)

Kết nối thiết bị Modbus qua VieLang IoT Gateway:

# gateway-config.json connectors: - name: Modbus Factory Floor type: modbus host: 192.168.1.200 port: 502 devices: - name: PLC-01 unitId: 1 attributes: - tag: firmware type: 16bit_uint address: 1000 telemetry: - tag: temperature type: float address: 2000 multiplier: 0.1 - tag: rpm type: 16bit_uint address: 2002

Converter Functions

Tất cả integration có thể dùng JavaScript decoder để parse payload:

// Biến có sẵn: // payload - raw bytes (Uint8Array) // metadata - headers/metadata // msgType - loại message function decodeToJson(payload) { return JSON.parse(String.fromCharCode.apply(null, new Uint8Array(payload))); } // Return object: return { deviceName: "device-identifier", deviceType: "optional-type", telemetry: [{ ts: Date.now(), values: { key: value } }], attributes: { key: value }, customerName: "optional-customer" };