0
我会用XBee发送Java Map,但是我在Git存储库中看到它们如何发送byte []。我怎样才能发送我的地图? 我觉得为此使用Python,但我更喜欢对所有人使用Java,除非发送消息,否则不要使用Java。发送Java Map <Integer,String>与XBee
这是我的代码:
public class Comunicacion {
/* Constants */
private static final String PORT = "ttyUSB0";
private static final int BAUD_RATE = 9600;
private static Map<Integer, String> dataToSend = new HashMap<Integer, String>();
public static void main(String[] args) {
XBeeDevice myDevice = new XBeeDevice(PORT, BAUD_RATE);
byte[] dataInByte = dataToSend.getBytes();
try {
myDevice.open();
System.out.format("Sending broadcast data: '%s'", new String(dataInByte));
myDevice.sendBroadcastData(dataInByte);
System.out.println(" >> Success");
} catch (XBeeException e) {
System.out.println(" >> Error");
e.printStackTrace();
System.exit(1);
} finally {
myDevice.close();
}
}