summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-08-28 15:50:01 -0700
committerKeith Packard <keithp@keithp.com>2011-08-28 15:50:01 -0700
commitcf72c2f5a69a736c28a9b63e124d510ef41a9f5d (patch)
tree5b6b54f669e169c1e46747dd842eae27aba963d8
parent3d478a39f2ede7b805bbe568cc1c8ecc176d7a04 (diff)
altosui: Add bluetooth bits back in
Stub out functions on mac/windows for now. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--altosui/Altos.java2
-rw-r--r--altosui/AltosConfigureUI.java33
-rw-r--r--altosui/AltosDeviceDialog.java36
-rw-r--r--altosui/Makefile.am3
-rw-r--r--altosui/libaltos/libaltos.c78
-rw-r--r--altosui/libaltos/libaltos.h5
6 files changed, 109 insertions, 48 deletions
diff --git a/altosui/Altos.java b/altosui/Altos.java
index e4f974f9..aa2fd77a 100644
--- a/altosui/Altos.java
+++ b/altosui/Altos.java
@@ -498,5 +498,5 @@ public class Altos {
public final static String bt_product_telebt = bt_product_telebt();
-// public static AltosBTKnown bt_known = new AltosBTKnown();
+ public static AltosBTKnown bt_known = new AltosBTKnown();
}
diff --git a/altosui/AltosConfigureUI.java b/altosui/AltosConfigureUI.java
index bcb9636b..980068c0 100644
--- a/altosui/AltosConfigureUI.java
+++ b/altosui/AltosConfigureUI.java
@@ -52,8 +52,7 @@ public class AltosConfigureUI
JRadioButton serial_debug;
-// BLUETOOTH
-// JButton manage_bluetooth;
+ JButton manage_bluetooth;
JButton manage_frequencies;
final static String[] font_size_names = { "Small", "Medium", "Large" };
@@ -241,19 +240,18 @@ public class AltosConfigureUI
c.anchor = GridBagConstraints.WEST;
pane.add(serial_debug, c);
-// BLUETOOTH
-// manage_bluetooth = new JButton("Manage Bluetooth");
-// manage_bluetooth.addActionListener(new ActionListener() {
-// public void actionPerformed(ActionEvent e) {
-// AltosBTManage.show(owner, Altos.bt_known);
-// }
-// });
-// c.gridx = 0;
-// c.gridy = row++;
-// c.gridwidth = 2;
-// c.fill = GridBagConstraints.NONE;
-// c.anchor = GridBagConstraints.WEST;
-// pane.add(manage_bluetooth, c);
+ manage_bluetooth = new JButton("Manage Bluetooth");
+ manage_bluetooth.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ AltosBTManage.show(owner, Altos.bt_known);
+ }
+ });
+ c.gridx = 0;
+ c.gridy = row;
+ c.gridwidth = 2;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.WEST;
+ pane.add(manage_bluetooth, c);
manage_frequencies = new JButton("Manage Frequencies");
manage_frequencies.addActionListener(new ActionListener() {
@@ -262,9 +260,8 @@ public class AltosConfigureUI
}
});
manage_frequencies.setToolTipText("Configure which values are shown in frequency menus");
-// BLUETOOTH
-// c.gridx = 2;
- c.gridx = 1;
+ c.gridx = 2;
+ c.gridx = 2;
c.gridy = row++;
c.gridwidth = 2;
c.fill = GridBagConstraints.NONE;
diff --git a/altosui/AltosDeviceDialog.java b/altosui/AltosDeviceDialog.java
index fa9587bc..610bb73e 100644
--- a/altosui/AltosDeviceDialog.java
+++ b/altosui/AltosDeviceDialog.java
@@ -30,8 +30,7 @@ public class AltosDeviceDialog extends JDialog implements ActionListener {
private JList list;
private JButton cancel_button;
private JButton select_button;
-// BLUETOOTH
-// private JButton manage_bluetooth_button;
+ private JButton manage_bluetooth_button;
private Frame frame;
private int product;
@@ -42,17 +41,15 @@ public class AltosDeviceDialog extends JDialog implements ActionListener {
private AltosDevice[] devices() {
java.util.List<AltosDevice> usb_devices = AltosUSBDevice.list(product);
int num_devices = usb_devices.size();
-// BLUETOOTH
-// java.util.List<AltosDevice> bt_devices = Altos.bt_known.list(product);
-// num_devices += bt_devices.size();
+ java.util.List<AltosDevice> bt_devices = Altos.bt_known.list(product);
+ num_devices += bt_devices.size();
AltosDevice[] devices = new AltosDevice[num_devices];
for (int i = 0; i < usb_devices.size(); i++)
devices[i] = usb_devices.get(i);
-// BLUETOOTH
-// int off = usb_devices.size();
-// for (int j = 0; j < bt_devices.size(); j++)
-// devices[off + j] = bt_devices.get(j);
+ int off = usb_devices.size();
+ for (int j = 0; j < bt_devices.size(); j++)
+ devices[off + j] = bt_devices.get(j);
return devices;
}
@@ -75,10 +72,9 @@ public class AltosDeviceDialog extends JDialog implements ActionListener {
cancel_button.setActionCommand("cancel");
cancel_button.addActionListener(this);
-// BLUETOOTH
-// manage_bluetooth_button = new JButton("Manage Bluetooth");
-// manage_bluetooth_button.setActionCommand("manage");
-// manage_bluetooth_button.addActionListener(this);
+ manage_bluetooth_button = new JButton("Manage Bluetooth");
+ manage_bluetooth_button.setActionCommand("manage");
+ manage_bluetooth_button.addActionListener(this);
select_button = new JButton("Select");
select_button.setActionCommand("select");
@@ -152,8 +148,7 @@ public class AltosDeviceDialog extends JDialog implements ActionListener {
buttonPane.add(Box.createHorizontalGlue());
buttonPane.add(cancel_button);
buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
-// BLUETOOTH
-// buttonPane.add(manage_bluetooth_button);
+ buttonPane.add(manage_bluetooth_button);
buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPane.add(select_button);
@@ -173,12 +168,11 @@ public class AltosDeviceDialog extends JDialog implements ActionListener {
public void actionPerformed(ActionEvent e) {
if ("select".equals(e.getActionCommand()))
value = (AltosDevice)(list.getSelectedValue());
-// BLUETOOTH
-// if ("manage".equals(e.getActionCommand())) {
-// AltosBTManage.show(frame, Altos.bt_known);
-// update_devices();
-// return;
-// }
+ if ("manage".equals(e.getActionCommand())) {
+ AltosBTManage.show(frame, Altos.bt_known);
+ update_devices();
+ return;
+ }
setVisible(false);
}
diff --git a/altosui/Makefile.am b/altosui/Makefile.am
index e2e42d84..c4d1e611 100644
--- a/altosui/Makefile.am
+++ b/altosui/Makefile.am
@@ -118,7 +118,8 @@ altosui_JAVA = \
AltosGraphUI.java \
AltosDataChooser.java \
AltosVersion.java \
- AltosVoice.java
+ AltosVoice.java \
+ $(altosui_BT)
JFREECHART_CLASS= \
jfreechart.jar
diff --git a/altosui/libaltos/libaltos.c b/altosui/libaltos/libaltos.c
index d1f445bd..a3796ee3 100644
--- a/altosui/libaltos/libaltos.c
+++ b/altosui/libaltos/libaltos.c
@@ -598,7 +598,6 @@ altos_list_finish(struct altos_list *usbdevs)
free(usbdevs);
}
-#if HAS_BLUETOOTH
struct altos_bt_list {
inquiry_info *ii;
int sock;
@@ -730,7 +729,6 @@ no_sock:
no_file:
return NULL;
}
-#endif /* HAS_BLUETOOTH */
#endif
@@ -844,6 +842,48 @@ altos_list_finish(struct altos_list *list)
free(list);
}
+struct altos_bt_list {
+ int sock;
+ int dev_id;
+ int rsp;
+ int num_rsp;
+};
+
+#define INQUIRY_MAX_RSP 255
+
+struct altos_bt_list *
+altos_bt_list_start(int inquiry_time)
+{
+ return NULL;
+}
+
+int
+altos_bt_list_next(struct altos_bt_list *bt_list,
+ struct altos_bt_device *device)
+{
+ return 0;
+}
+
+void
+altos_bt_list_finish(struct altos_bt_list *bt_list)
+{
+}
+
+void
+altos_bt_fill_in(char *name, char *addr, struct altos_bt_device *device)
+{
+ strncpy(device->name, name, sizeof (device->name));
+ device->name[sizeof(device->name)-1] = '\0';
+ strncpy(device->addr, addr, sizeof (device->addr));
+ device->addr[sizeof(device->addr)-1] = '\0';
+}
+
+struct altos_file *
+altos_bt_open(struct altos_bt_device *device)
+{
+ return NULL;
+}
+
#endif
@@ -1180,4 +1220,38 @@ altos_getchar(struct altos_file *file, int timeout)
return file->in_data[file->in_read++];
}
+struct altos_bt_list *
+altos_bt_list_start(int inquiry_time)
+{
+ return NULL;
+}
+
+int
+altos_bt_list_next(struct altos_bt_list *bt_list,
+ struct altos_bt_device *device)
+{
+ return 0;
+}
+
+void
+altos_bt_list_finish(struct altos_bt_list *bt_list)
+{
+ free(bt_list);
+}
+
+void
+altos_bt_fill_in(char *name, char *addr, struct altos_bt_device *device)
+{
+ strncpy(device->name, name, sizeof (device->name));
+ device->name[sizeof(device->name)-1] = '\0';
+ strncpy(device->addr, addr, sizeof (device->addr));
+ device->addr[sizeof(device->addr)-1] = '\0';
+}
+
+struct altos_file *
+altos_bt_open(struct altos_bt_device *device)
+{
+ return NULL;
+}
+
#endif
diff --git a/altosui/libaltos/libaltos.h b/altosui/libaltos/libaltos.h
index 363a84fd..a05bed4c 100644
--- a/altosui/libaltos/libaltos.h
+++ b/altosui/libaltos/libaltos.h
@@ -93,9 +93,6 @@ altos_flush(struct altos_file *file);
PUBLIC int
altos_getchar(struct altos_file *file, int timeout);
-// #define HAS_BLUETOOTH 1
-#if HAS_BLUETOOTH
-
PUBLIC struct altos_bt_list *
altos_bt_list_start(int inquiry_time);
@@ -111,6 +108,4 @@ altos_bt_fill_in(char *name, char *addr, struct altos_bt_device *device);
PUBLIC struct altos_file *
altos_bt_open(struct altos_bt_device *device);
-#endif
-
#endif /* _LIBALTOS_H_ */