public final class MqttPlugin extends PluginAncestor
MScriptInterface.IGNORE_INHERITED_METHOD, MScriptInterface.NOT_MSCRIPT_METHOD, MScriptInterface.TO_PLUGIN| Constructor and Description |
|---|
MqttPlugin() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
INTERNAL USE ONLY
|
void |
connectAndSubscribe()
makes connection to MQTT server and subscribe to the subTopic.
|
org.eclipse.paho.client.mqttv3.MqttConnectOptions |
getConnectionOptions()
returns MQTT connection option object to be used to connect to MQTT server.
|
String |
getPluginDesc() |
String |
getPluginID()
INTERNAL USE ONLY
|
void |
initialize(MbtScriptExecutor scriptExec_p)
INTERNAL USE ONLY
|
void |
sendBytes(byte[] byteArray_p)
sends a message.
|
Object |
sendReceiveBytes(byte[] byteArray_p,
long timeoutMillis_p)
sends a byte[] message, wait for the result and return the results.
|
Object |
sendReceiveString(String msg_p,
long timeoutMillis_p)
sends a message, wait for the result and return the results.
|
void |
sendString(String msg_p)
sends a message.
|
void |
setAutoConnect(boolean autoConnect_p)
sets plugin to automatically makes connection to MQTT server on starting.
|
void |
setRequiredOptions(String clientID_p,
String brokerURL_p,
String pubTopic_p,
int pubQoS_p,
String subTopic_p,
int subQoS_p) |
void |
setResultTimeoutMillis(long resultTimeoutMillis_p)
timeout in milliseconds to wait for the result response from the client.
|
void |
setUsernamePassword(String username_p,
String password_p)
sets user name and password to be used to connect to MQTT.
|
void |
start()
Internal use, called when model execution starts (after MBT_Start trigger).
|
enterInitialState, exitFinalStatepublic void initialize(MbtScriptExecutor scriptExec_p)
INTERNAL USE ONLY
public void close()
INTERNAL USE ONLY
close in class PluginAncestorpublic String getPluginID()
INTERNAL USE ONLY
getPluginID in class PluginAncestorpublic String getPluginDesc()
getPluginDesc in class PluginAncestorpublic void setAutoConnect(boolean autoConnect_p)
autoConnect_p - boolean true or falsepublic void setRequiredOptions(String clientID_p, String brokerURL_p, String pubTopic_p, int pubQoS_p, String subTopic_p, int subQoS_p)
clientID_p - brokerURL_p - pubTopic_p - pubQoS_p - subTopic_p - subQoS_p - public void setResultTimeoutMillis(long resultTimeoutMillis_p)
resultTimeoutMillis_p - public void start()
throws Exception
start in class PluginAncestorExceptionpublic void connectAndSubscribe()
throws Exception
Exceptionpublic Object sendReceiveString(String msg_p, long timeoutMillis_p)
msg_p - string messagetimeoutMillis_p - timeout waiting for the results.public Object sendReceiveBytes(byte[] byteArray_p, long timeoutMillis_p)
byteArray_p - byte[] messagetimeoutMillis_p - timeout waiting for the results.public void sendString(String msg_p) throws org.eclipse.paho.client.mqttv3.MqttException
msg_p - a stringorg.eclipse.paho.client.mqttv3.MqttExceptionpublic void sendBytes(byte[] byteArray_p)
throws org.eclipse.paho.client.mqttv3.MqttException
byteArray_p - byte[] messageorg.eclipse.paho.client.mqttv3.MqttExceptionpublic org.eclipse.paho.client.mqttv3.MqttConnectOptions getConnectionOptions()
Copyright TestOptimal, LLC