Skip to content

Commit

Permalink
Fix hardcoded port, readme
Browse files Browse the repository at this point in the history
  • Loading branch information
locka99 committed Nov 21, 2018
1 parent 20f385d commit 59b9d42
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
18 changes: 14 additions & 4 deletions samples/mqtt-client/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
This is a simple OPC UA client hooked up to an MQTT client. It demonstrates a simple bridging app
This is a simple OPC UA client hooked up to an MQTT client. It demonstrates how you might write a bridging app
that subscribes to variables from an OPC server and publishes them to an MQTT broker.

The default MQTT server broker.hivemq.com:1883 which you can observe from the client:
To run the sample:

1. Run either simple-server or 3rd-party/node-opcua/server.js in one console
2. Run mqtt-client in another

This will subscribe to some nodes on the server and publish them to a MQTT broker, (default broker.hivemq.com:1883).

e.g. when node "ns=2;s=v1" changes, it publishes it's value to the "opcua-rust/mqtt-client/2/v1" topic on the server.

You can observe happening by running another MQTT client that subscribes to this same topic. The easiest way is this:

1. Open http://www.hivemq.com/demos/websocket-client/
2. Connect with the default values
3. Subscribe to opcua-rust/#
2. Click "Connect" to the broker with the pre-filled values
3. Click "Add New Topic Subscription", enter "opcua-rust/mqtt-client/#" as the topic and click "Subscribe"
4. You should see messages arrive that were published
11 changes: 7 additions & 4 deletions samples/mqtt-client/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
//! This is a sample OPC UA Client that connects to the specified server, fetches some
//! values before exiting.
#[macro_use]
extern crate clap;
extern crate rumqtt;

extern crate opcua_client;
extern crate opcua_console_logging;

use std::sync::{Arc, Mutex, RwLock, mpsc};
use std::path::PathBuf;
use std::thread;
use std::{
path::PathBuf,
sync::{Arc, Mutex, RwLock, mpsc},
thread,
};

use rumqtt::{MqttClient, MqttOptions, QoS};
use clap::{App, Arg};
Expand Down Expand Up @@ -53,7 +56,7 @@ fn main() {
.get_matches();

let mqtt_host = m.value_of("host").unwrap().to_string();
let mqtt_port = 1883; // value_t_or_exit!(m, "port", u16);
let mqtt_port = value_t_or_exit!(m, "port", u16);
let config_file = m.value_of("config").unwrap().to_string();
let endpoint_id = m.value_of("id").unwrap().to_string();

Expand Down
1 change: 1 addition & 0 deletions tools/certificate-creator/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[macro_use]
extern crate clap;
extern crate opcua_core;

Expand Down

0 comments on commit 59b9d42

Please sign in to comment.