Code Monkey home page Code Monkey logo

Comments (5)

cloudxxx8 avatar cloudxxx8 commented on August 16, 2024

this issue is duplicated to #17 and fixed by #19
For device-mqtt, please set up MQTT broker first and modify configuration-driver.toml. The related to document will be available in the community web site soon

from device-mqtt-go.

wangnuannuan avatar wangnuannuan commented on August 16, 2024

but I have set up MQTT broker first:
This is the setting in configuration.toml:

# Pre-define Devices
[[DeviceList]]
  Name = "MQTT test device"
  Profile = "Test.Device.MQTT.Profile"
  Description = "MQTT device is created for test purpose"
  Labels = [ "MQTT", "test"]
  [DeviceList.Addressable]
    name = "Gateway address"
    Protocol = "TCP"
    Address = "127.0.0.1"
    Port = 1883
    Publisher = "CommandPublisher"
    user = "admin"
    password = "public"
    topic = "CommandTopic"

# Pre-define Schedule Configuration
[[Schedules]]
Name = "mqtt-30sec-schedule"
Frequency = "PT30S"

[[ScheduleEvents]]
Name = "readRandnum"
Schedule = "mqtt-30sec-schedule"
  [ScheduleEvents.Addressable]
  HTTPMethod = "GET"
  Path = "/api/v1/device/name/MQTT test device/testrandnum"

This is broker using with node.js

var mosca = require('mosca');

var settings = {
  port: 1883
};

var server = new mosca.Server(settings);

server.on('clientConnected', function(client) {
    console.log('client connected', client.id);
});

// fired when a message is received
server.on('published', function(packet, client) {
  console.log('Published', packet.payload);
});

server.on('ready', setup);

// fired when the mqtt server is ready
function setup() {
  console.log('Mosca server is up and running');
}

from device-mqtt-go.

cloudxxx8 avatar cloudxxx8 commented on August 16, 2024

@wangnuannuan The MQTT broker connection settings is under configuration-driver.toml

[Incoming]
Protocol = "tcp"
Host = "0.0.0.0"
Port = 1883
Username = "admin"
Password = "public"
Qos = 0
KeepAlive = 3600
MqttClientId = "IncomingDataSubscriber"
Topic = "DataTopic"

[Response]
Protocol = "tcp"
Host = "0.0.0.0"
Port = 1883
Username = "admin"
Password = "public"
Qos = 0
KeepAlive = 3600
MqttClientId = "CommandResponseSubscriber"
Topic = "ResponseTopic"

The driver can't define any new properties in configuration.toml so far, so we create another TOML file to store the driver specific properties. That is the part we should improve in the future.

from device-mqtt-go.

wangnuannuan avatar wangnuannuan commented on August 16, 2024

I also modify the setting in configurations-driver.toml: Host = "0.0.0.0" to Host = "127.0.0.1"

from device-mqtt-go.

cloudxxx8 avatar cloudxxx8 commented on August 16, 2024

@wangnuannuan the 127.0.0.1 means the localhost of this MQTT Device Service container. You should modify it to the host name or IP address of your MQTT broker. If you run the broker on your host, the IP might look like 172.17.0.1 for the default docker network setting.

from device-mqtt-go.

Related Issues (20)

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.