diff --git a/BTDemo/pom.xml b/BTDemo/pom.xml
new file mode 100644
index 0000000..95ace51
--- /dev/null
+++ b/BTDemo/pom.xml
@@ -0,0 +1,63 @@
+
+
+ 4.0.0
+
+ com.codename1
+ cn1-bluetooth
+ 1.0-SNAPSHOT
+
+ com.codename1.btle
+ BTDemo
+ 1.0-SNAPSHOT
+ jar
+
+ BTDemo
+
+
+
+ com.codenameone
+ codenameone-core
+ ${cn1.version}
+
+
+ com.codenameone
+ codenameone-javase
+ ${cn1.version}
+
+
+ com.codename1
+ cn1-bluetooth-lib
+ ${project.version}
+ pom
+
+
+
+
+
+
+ com.codenameone
+ codenameone-maven-plugin
+ ${cn1.plugin.version}
+
+ com.codename1.btle.BTDemo
+
+
+
+
+ build
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ 1.8
+ 1.8
+
+
+
+
+
diff --git a/BTDemo/src/com/codename1/btle/BTDemo.java b/BTDemo/src/main/java/com/codename1/btle/BTDemo.java
similarity index 81%
rename from BTDemo/src/com/codename1/btle/BTDemo.java
rename to BTDemo/src/main/java/com/codename1/btle/BTDemo.java
index 5a452c4..a79fdc9 100644
--- a/BTDemo/src/com/codename1/btle/BTDemo.java
+++ b/BTDemo/src/main/java/com/codename1/btle/BTDemo.java
@@ -1,7 +1,5 @@
package com.codename1.btle;
-import ca.weblite.codename1.json.JSONException;
-import ca.weblite.codename1.json.JSONObject;
import com.codename1.bluetoothle.Bluetooth;
import com.codename1.components.MultiButton;
import com.codename1.ui.Display;
@@ -96,19 +94,17 @@ public void actionPerformed(ActionEvent evt) {
@Override
public void actionPerformed(ActionEvent evt) {
- try {
- JSONObject res = (JSONObject) evt.getSource();
- System.out.println("response " + res);
-
- if (res.getString("status").equals("scanResult")) {
- //if this is a new device add it
- if (!devices.containsKey(res.getString("address"))) {
- devices.put(res.getString("address"), res);
- updateUI();
- }
+ Map res = (Map) evt.getSource();
+ System.out.println("response " + res);
+
+ String status = (String) res.get("status");
+ if ("scanResult".equals(status)) {
+ //if this is a new device add it
+ String address = (String) res.get("address");
+ if (!devices.containsKey(address)) {
+ devices.put(address, res);
+ updateUI();
}
- } catch (JSONException ex) {
- ex.printStackTrace();
}
}
}, null, true, Bluetooth.SCAN_MODE_LOW_POWER, Bluetooth.MATCH_MODE_STICKY,
@@ -147,13 +143,13 @@ public void stop() {
public void destroy() {
}
- private void updateUI() throws JSONException {
+ private void updateUI() {
devicesCnt.removeAll();
Set keys = devices.keySet();
for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
String address = (String) iterator.next();
- JSONObject obj = (JSONObject) devices.get(address);
- MultiButton mb = new MultiButton(obj.getString("name"));
+ Map obj = (Map) devices.get(address);
+ MultiButton mb = new MultiButton((String) obj.get("name"));
mb.setTextLine2(address);
devicesCnt.add(mb);
}
diff --git a/BTDemo/codenameone_settings.properties b/BTDemo/src/main/resources/codenameone_settings.properties
similarity index 100%
rename from BTDemo/codenameone_settings.properties
rename to BTDemo/src/main/resources/codenameone_settings.properties
diff --git a/BTDemo/src/theme.res b/BTDemo/src/main/resources/theme.res
similarity index 100%
rename from BTDemo/src/theme.res
rename to BTDemo/src/main/resources/theme.res
diff --git a/pom.xml b/pom.xml
index c38fab9..4831d13 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,6 +68,7 @@
javase
win
lib
+ BTDemo