altosui: Add bluetooth bits back in
authorKeith Packard <keithp@keithp.com>
Sun, 28 Aug 2011 22:50:01 +0000 (15:50 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 28 Aug 2011 22:50:01 +0000 (15:50 -0700)
Stub out functions on mac/windows for now.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/Altos.java
altosui/AltosConfigureUI.java
altosui/AltosDeviceDialog.java
altosui/Makefile.am
altosui/libaltos/libaltos.c
altosui/libaltos/libaltos.h

index e4f974f9bedd22dc43b6aaf74a99052cc3133aa6..aa2fd77af1df35b7d44cee6fe4c6c973eb4d474c 100644 (file)
@@ -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();
 }
index bcb9636bd3e176be858479e2d753fde299435c70..980068c0076fa4b867cb992269518f248fa48918 100644 (file)
@@ -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;
index fa9587bc8d48d2b895c0c6b8e0c5754d9c99efff..610bb73e76dfbae75fc6ab59c5b9f85755e7c477 100644 (file)
@@ -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);
        }
 
index e2e42d84a308200c1de300d67e5c5e25eb86aaab..c4d1e611ff41ce5f6d2d81f3389735d37b9fd6c1 100644 (file)
@@ -118,7 +118,8 @@ altosui_JAVA = \
        AltosGraphUI.java \
        AltosDataChooser.java \
        AltosVersion.java \
-       AltosVoice.java
+       AltosVoice.java \
+       $(altosui_BT)
 
 JFREECHART_CLASS= \
     jfreechart.jar
index d1f445bd488f14757bf1cb267593df7a5fd95598..a3796ee380e9d0b2a3516719b946cfe3c5d0e276 100644 (file)
@@ -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
index 363a84fd0eed65b080723f83d6e3697c3f69532d..a05bed4c2e6c9038873461e4c9f5c630f1770506 100644 (file)
@@ -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_ */