- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将 Mqtt 程序与 java 代码集成。以下是我的 java 代码,我需要通过 MQTT 代理连接向设备发送消息....因此,我需要发送消息,例如:3G SETT; 56:1024;通过 mqtt broker 连接到设备。所以我需要在程序中调用 mqtt 连接方法...
告诉我具体在哪里编写和编辑代码以及在哪里集成mqtt代理代码
import java.util.Scanner;
public class message implements MqttCallback
{
static int option;
static Scanner sc = new Scanner(System.in);
static boolean go = true; // for starting main outer loop
static boolean run = true;
static String ip;
static String entire_address,topic;
static int port;
static String apn;
static String msg;
static void operator_apn() {
System.out.println("Enter operator APN");
apn = sc.next();
msg = "3gc SETT;" + 0 + 1 + ":" + apn + ";";
System.out.println("Your message Format is:" + msg);
System.out.println("Enter Topic Name");
topic=sc.next();
System.out.println("Enter Modem Ip address");
ip=sc.next();
System.out.println("Enter Modem Port Number");
port=sc.nextInt();
entire_address=ip+":"+port;
System.out.print("Entire Address is:"+entire_address);
}
static void apn_user_id() {
String username, msg;
System.out.println("Enter APN UserName");
username = sc.next();
msg = "3gc SETT;" + 0 + 2 + ":" + username + ";";
System.out.println("Your APN UserName Format is:" + msg);
}
static void apn_user_password() {
String password, msg;
System.out.println("Enter APN Password");
password = sc.next();
msg = "3gc SETT;" + 0 + 3 + ":" + password + ";";
System.out.println("Your APN Password Format is:" + msg);
}
static void primary_server_ip() {
String ip, msg;
System.out.println("Enter Server primary ip");
ip = sc.next();
msg = "3gc SETT;" + 4 + ":" + ip + ";";
System.out.println("Your Primary Server ip Format is:" + msg);
}
static void primary_server_port() {
String msg;
int port;
System.out.println("Enter Primary server port");
port = sc.nextInt();
msg = "3g SETT;" + 5 + ":" + port + ";";
System.out.println("Your Primary Server port Format is:" + msg);
}
static void secondary_server_ip() {
String ip, msg;
System.out.println("Enter Server secondary ip");
ip = sc.next();
msg = "3gc SETT;" + 6 + ":" + ip + ";";
System.out.println("Your Secondary Server ip Format is:" + msg);
}
static void secondary_server_port() {
String msg;
int port;
System.out.println("Enter Secondary server port");
port = sc.nextInt();
msg = "3g SETT;" + 7 + ":" + port + ";";
System.out.println("Your Secondary Server port Format is:" + msg);
}
static void fota_apn() {
String apn, msg;
System.out.println("Enter FOTA APN");
apn = sc.next();
msg = "3gc SETT;" + 8 + ":" + apn + ";";
System.out.println("Your FOTA APN Format is:" + msg);
}
static void fota_server_ip() {
String ip, msg;
System.out.println("Enter FOTA Server ip");
ip = sc.next();
msg = "3gc SETT;" + 9 + ":" + ip + ";";
System.out.println("Your FOTA Server ip Format is:" + msg);
}
static void fota_server_port() {
String msg;
int port;
System.out.println("Enter FOTA server port");
port = sc.nextInt();
msg = "3g SETT;" + 10 + ":" + port + ";";
System.out.println("Your FOTA Server port Format is:" + msg);
}
static void connection_retry_time() {
String msg;
int time;
System.out.println("Enter Connection Retry Time");
time = sc.nextInt();
msg = "3g SETT;" + 11 + ":" + time + ";";
System.out.println("Your Connection Retry Time Format is:" + msg);
}
static void keep_alive_time() {
String msg;
int time;
System.out.println("Enter Keep Alive Time");
time = sc.nextInt();
msg = "3g SETT;" + 12 + ":" + time + ";";
System.out.println("Your Keep Alive Time Format is:" + msg);
}
static void mp_size() {
String msg;
int size;
System.out.println("Enter MP Size");
size = sc.nextInt();
msg = "3g SETT;" + 13 + ":" + size + ";";
System.out.println("Your MP Size Format is:" + msg);
}
static void mh_size() {
String msg;
int size;
System.out.println("Enter MH Size");
size = sc.nextInt();
msg = "3g SETT;" + 14 + ":" + size + ";";
System.out.println("Your MH Size Format is:" + msg);
}
static void message_queing_username() {
String username, msg;
System.out.println("Enter Message Queing UserName");
username = sc.next();
msg = "3gc SETT;" + 22 + ":" + username + ";";
System.out.println("Your Message Queing UserName Format is:" + msg);
}
static void message_queing_password() {
String password, msg;
System.out.println("Enter Message Queing password");
password = sc.next();
msg = "3gc SETT;" + 23 + ":" + password + ";";
System.out.println("Your Message Queing password Format is:" + msg);
}
static void data_center_smsc_number() {
long number;
String msg;
System.out.println("Enter Data Center SMSC Mobile Number");
number = sc.nextLong();
msg = "3gc SETT;" + 24 + ":" + number + ";";
System.out.println("Your Data Center SMSC Mobile Number Format is:"
+ msg);
}
static void application_instant_time() {
String msg;
int time;
System.out.println("Enter Application Instant Time");
time = sc.nextInt();
msg = "3g SETT;" + 51 + ":" + time + ";";
System.out.println("Your Application Instant Time Setting Format is:"
+ msg);
}
static void app_billing_time() {
String msg;
int time;
System.out.println("Enter Application Billing Time");
time = sc.nextInt();
msg = "3g SETT;" + 52 + ":" + time + ";";
System.out.println("Your Application Billing Time Setting Format is:"
+ msg);
}
static void app_load_time() {
String msg;
int time;
System.out.println("Enter Application Load Time");
time = sc.nextInt();
msg = "3g SETT;" + 53 + ":" + time + ";";
System.out.println("Your Application Load Time Setting Format is:"
+ msg);
}
static void app_event_time() {
String msg;
int time;
System.out.println("Enter Application Event Time");
time = sc.nextInt();
msg = "3g SETT;" + 54 + ":" + time + ";";
System.out.println("Your Application Event Time Setting Format is:"
+ msg);
}
static void identify_time() {
String msg;
int time;
System.out.println("Enter Identify Time");
time = sc.nextInt();
msg = "3g SETT;" + 55 + ":" + time + ";";
System.out.println("Your Identifyt Time Setting Format is:" + msg);
}
static void app_identify_log() {
String msg;
int log;
System.out.println("Enter Application Identify Log");
log = sc.nextInt();
msg = "3g SETT;" + 56 + ":" + log + ";";
System.out.println("Your Application Identify Log Format is:" + msg);
}
static void app_instant_log() {
String msg;
int log;
System.out.println("Enter Application Instant log");
log = sc.nextInt();
msg = "3g SETT;" + 57 + ":" + log + ";";
System.out.println("Your Application Instant log Setting Format is:"
+ msg);
}
static void app_bill_log() {
String msg;
int log;
System.out.println("Enter Application Bill Log");
log = sc.nextInt();
msg = "3g SETT;" + 58 + ":" + log + ";";
System.out.println("Your Application Instant Bill Log Format is:" + msg);
}
static void app_load_log() {
String msg;
int log;
System.out.println("Enter Application Load Log");
log = sc.nextInt();
msg = "3g SETT;" + 59 + ":" + log + ";";
System.out.println("Your Application Load Log Format is:" + msg);
}
static void app_event_log() {
String msg;
int log;
System.out.println("Enter Application Event Log");
log = sc.nextInt();
msg = "3g SETT;" + 60 + ":" + log + ";";
System.out.println("Your Application Event Log Format is:" + msg);
}
static void load_survey_days() {
String msg;
int days;
System.out.println("Enter Load Survey Days");
days = sc.nextInt();
msg = "3g SETT;" + 61 + ":" + days + ";";
System.out.println("Your Load Survey Days Format is:" + msg);
}
static void schedule_interval() {
String msg;
int interval;
System.out.println("Enter Schedule Interval");
interval = sc.nextInt();
msg = "3g SETT;" + 62 + ":" + interval + ";";
System.out.println("Your Schedule Interval Format is:" + msg);
}
static void dlms_password() {
String password, msg;
System.out.println("Enter DLMS Password");
password = sc.next();
msg = "3g SETT;" + 63 + ":" + password + ";";
System.out.println("Your DLMS Password Format is:" + msg);
}
static void dia_time() {
int time;
String msg;
System.out.println("Enter DIA Time");
time = sc.nextInt();
msg = "3g SETT;" + 64 + ":" + time + ";";
System.out.println("Your DIA Time Format is:" + msg);
}
static void dia_sample() {
int sample;
String msg;
System.out.println("Enter DIA Sample");
sample = sc.nextInt();
msg = "3g SETT;" + 65 + ":" + sample + ";";
System.out.println("Your DIA Time Sample is:" + msg);
}
static void schedule_enable() {
int schedule;
String msg;
System.out.println("Enter Schedule Enable");
schedule = sc.nextInt();
msg = "3g SETT;" + 66 + ":" + schedule + ";";
System.out.println("Your Schedule Enable Format is:" + msg);
}
static void schedule_hour() {
int time;
String msg;
System.out.println("Enter Schedule Hour");
time = sc.nextInt();
msg = "3g SETT;" + 67 + ":" + time + ";";
System.out.println("Your Schedule Hour Format is:" + msg);
}
static void schedule_mins() {
int time;
String msg;
System.out.println("Enter Schedule Mins");
time = sc.nextInt();
msg = "3g SETT;" + 68 + ":" + time + ";";
System.out.println("Your Schedule Mins Format is:" + msg);
}
static void event_order_request() {
int order_request;
String msg;
System.out.println("Enter Event Order Request");
order_request = sc.nextInt();
msg = "3g SETT;" + 69 + ":" + order_request + ";";
System.out.println("Your Event Order request Format is:" + msg);
}
static void event_fifo() {
int fifo;
String msg;
System.out.println("Enter Event FIFO");
fifo = sc.nextInt();
msg = "3g SETT;" + 70 + ":" + fifo + ";";
System.out.println("Your Event FIFO Format is:" + msg);
}
static void app_send_load_select() {
int load;
String msg;
System.out.println("Enter App Send Load Select");
load = sc.nextInt();
msg = "3g SETT;" + 71 + ":" + load + ";";
System.out.println("Your App Send Load Select Format is:" + msg);
}
public static void main(String[] args) throws MqttException {
while (go == true) {
while (run == true) {
System.out.println("\n 1.Enter operator APN \n 2.Enter APN userId \n 3.Enter APN password \n 4.Enter primary server ip \n 5.Enter primary server port \n"
+ " 6.Enter Secondary Server IP \n 7.Enter Secondary Server Port \n 8.Enter FOTA APN \n 9.Enter FOTA Server IP \n 10.Enter FOTA server Port \n"
+ " 11.Enter Connection Retry Time \n 12.Enter Keep Alive Time \n 13.Enter MP Size \n 14.Enter MH Size \n"
+ " 15.Enter Message Queing UserName \n 16.Enter Message Queing Password \n 17.Enter Data Center SMSC Number \n 18.Enter App Instant Time \n"
+ " 19.Enter App Billing Time \n 20.Enter App Load Time \n 21.Enter App Event Time \n 22.Enter Identify Time \n 23.Enter App Identify Log \n"
+ " 24.Enter App Instant Time \n 25.Enter App Bill Log \n 26.Enter App Load Log \n 27.Enter App Event Log \n 28.Enter Load Survey Days \n"
+ " 29.Enter Schedule Interval \n 30.Enter DLMS Password \n 31.Enter DIA Time \n 32.Enter DIA Sample \n 33.Enter Schedule Enable \n"
+ " 34.Enter Schedule Hour \n 35.Enter Schedule Mins \n 36.Enter Event Order Request \n 37.Enter Event FIFO \n 38.Enter App Send Load Select \n"
+ " 39.Change Meter \n 40.Restart Meter ");
System.out.println("Enter your option:");
option = sc.nextInt();
switch (option) {
case 1:
operator_apn();
sendMessage();
break;
case 2:
apn_user_id();
message.sendMessage();
break;
case 3:
apn_user_password();
message.sendMessage();
break;
case 4:
primary_server_ip();
message.sendMessage();
break;
case 5:
primary_server_port();
message.sendMessage();
break;
case 6:
secondary_server_ip();
message.sendMessage();
break;
case 7:
secondary_server_port();
message.sendMessage();
break;
case 8:
fota_apn();
message.sendMessage();
break;
case 9:
fota_server_ip();
message.sendMessage();
break;
case 10:
fota_server_port();
message.sendMessage();
break;
case 11:
connection_retry_time();
message.sendMessage();
break;
case 12:
keep_alive_time();
message.sendMessage();
break;
case 13:
mp_size();
message.sendMessage();
break;
case 14:
mh_size();
message.sendMessage();
break;
case 15:
message_queing_username();
message.sendMessage();
break;
case 16:
message_queing_password();
message.sendMessage();
break;
case 17:
data_center_smsc_number();
message.sendMessage();
break;
case 18:
application_instant_time();
message.sendMessage();
break;
case 19:
app_billing_time();
message.sendMessage();
break;
case 20:
app_load_time();
message.sendMessage();
break;
case 21:
app_event_time();
message.sendMessage();
break;
case 22:
identify_time();
message.sendMessage();
break;
case 23:
app_identify_log();
message.sendMessage();
break;
case 24:
app_instant_log();
message.sendMessage();
break;
case 25:
app_bill_log();
message.sendMessage();
break;
case 26:
app_load_log();
message.sendMessage();
break;
case 27:
app_event_log();
message.sendMessage();
break;
case 28:
load_survey_days();
message.sendMessage();
break;
case 29:
schedule_interval();
message.sendMessage();
break;
case 30:
dlms_password();
message.sendMessage();
break;
case 31:
dia_time();message.sendMessage();
break;
case 32:
dia_sample();
message.sendMessage();
break;
case 33:
schedule_enable();
message.sendMessage();
break;
case 34:
schedule_hour();
message.sendMessage();
break;
case 35:
schedule_mins();
message.sendMessage();
break;
case 36:
event_order_request();
message.sendMessage();
break;
case 37:
event_fifo();
message.sendMessage();
break;
case 38:
app_send_load_select();
message.sendMessage();
break;
case 39:
System.out.println("Change Meter");
break;
case 40:
System.out.println("Restart");
break;
default:
System.err.println("Invalid Option");
}
run = false;
}
if (run == false) {
System.out.println("\nWould you like to run again? Y/N");
char again = sc.next().charAt(0);
again = Character.toUpperCase(again);
if (again == 'Y') {
run = true;
} else if (again == 'N') {
System.out.println("Exit.");
go = false;
} else {
System.err.println("Invalid entry. Try again.");
}
}
最佳答案
使用 Java Paho MQTT 库,您应该查看示例以了解如何实现发布到 MQTT 代理的客户端。
通常首先你应该实现 .connect
方法到 Broker,然后你使用 .publish
方法发送包含 payload< 的消息
到 MQTT Broker 中的特定 topic
。
你应该看看 sample Paho app .
还有实现的Paho client tests .
关于java - mqtt 与 java 的集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29599146/
Windows 集成 (NTLM) 身份验证和 Windows 集成 (Kerberos) 之间有什么区别? 如何在IIS6中实现这些 w.r.t. MSDN 最佳答案 Kerberos 和 NTLM
Keycloak是一个用 Java 编写的开源身份验证和身份管理解决方案。它提供了一个nodejs适配器,使用它我能够成功地与express集成。这是有效的路由文件: 'use strict'
这是我关于 Bamboo 的第二个问题 ( My First One )。阅读建议信息后我的理解是,我需要一个构建工具,例如 nAnt 或 MSbuild 来编写一个获取源代码并构建它的脚本(我正在开
可用于将第三方应用程序与 jira 4.3 集成的身份验证方案有哪些?显然,从客户那里获取用户名和密码听起来很荒谬。另外,我知道 oauth 身份验证仅适用于版本 5。请告诉我。谢谢。 附注。我不是在
我有一个使用 DDS 的旧版 C++ 应用程序用于异步通信/消息传递。我需要将此应用程序集成到使用 JMS 进行消息传递的 JavaEE 环境中。除了构建独立的 JMS/DDS 桥接模块之外,我还有其
我正在尝试使用 Whatsapp 发送测试消息,但收到此错误消息: "error":{"code":27,"description":"Recipient not available on chann
我想将 photologue 与我的 Django 应用程序集成,并使用它在车辆库存中显示照片......有点像 Boost Motor Group Inc. 提供的内容。我已经集成了该应用程序,所以
我目前正在尝试弄清楚如何与 fujitsu scansnap 扫描仪集成,但没有从 fujitsu 找到有关 fujitsu scansnap 管理器如何调用您的应用程序并将文件发送到您的应用程序的详
在我的项目中,我使用了 9 个(九个)int-ip:udp-inbound-channel-adapter 和一个 jms:inbound-channel-adapter。 Jms 适配器从服务器接收
在我们当前的原型(prototype)中,大多数标准 HTML 控件都被小程序取代,最重要的是表单提交由小程序触发。 有没有一种方法可以像 一样在服务器端调用关联的操作 ? 本文Applet and
是否可以使用 twilio 号码从 whatsapp 发送/接收短信?有人用whatsapp试过twilio吗?我问过客服,如果可能的话,他说,不确定,但很多人都问过这个问题。 最佳答案 万一其他人来
我们办公室中几乎不存在版本控制,这显然导致了很多麻烦。我们想使用SVN和Notepad++进行设置...任何人都对如何实现此目标有任何想法?我已经开始研究并浏览了这个网站: http://www.sw
曾经有提供这种集成的 spring-modules 项目;但是,该项目现已弃用。现在有没有人继续支持这种集成?谢谢。 最佳答案 工作正在进行中。 http://blog.athico.com/sear
我的理解是,根据 http://wiki.dbpedia.org/Datasets,DBpedia 从 YAGO 获取类层次结构,而不是实体。 .但是,类似 http://dbpedia.org/cl
任何人都可以帮助我如何将 OpenCMS 与 Java Spring Web 应用程序集成。已经用谷歌搜索并浏览了很多网站但没有用。所以,请帮助我。 最佳答案 我认为将 SpringMVC 与 Ope
我正在尝试使用新的 migs getaway (MPGS) 我遵循了下一个 url 中的代码 https://ap-gateway.mastercard.com/api/documentation/i
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve thi
我有一个 cmake 项目。我想轻松完成以下操作 搜索光标下任何变量、函数等的声明、定义和引用,这些可能在外部头文件中声明,其路径是在CMakeLists.txt中使用INCLUDE_DIRECTOR
有人能给我指点一下 Objective-C(或 c/c++)库的方向,或者教通过 FTP 上传或下载的教程(Objective-C)吗?最好能展示如何将文件下载到临时目录,然后稍后上传?我不介意针对
集成()给出了非常错误的答案: integrate(function (x) dnorm(x, -5, 0.07), -Inf, Inf, subdivisions = 10000L) # 2.127
我是一名优秀的程序员,十分优秀!