Skip to content

Demo doesn't work #19

@GDN-GR

Description

@GDN-GR

Try to build and test the demo but it never execure evt.getSource();

hi.add(new Button(new Command("start scan") {

        @Override
        public void actionPerformed(ActionEvent evt) {
            updateAction("start scan");
            try {
                bt.startScan((ActionListener) evt1 -> {
                            try {
                                JSONObject res = (JSONObject) evt1.getSource();
                                System.out.println("response " + res);
                                updateAction("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);
                                        updateAction("Dispositivi: " + devices.size());
                                        updateUI();
                                    }
                                }
                            } catch (JSONException ex) {
                                Log.e(ex);
                            }
                        }, null, true, Bluetooth.SCAN_MODE_LOW_POWER, Bluetooth.MATCH_MODE_STICKY,
                        Bluetooth.MATCH_NUM_MAX_ADVERTISEMENT, Bluetooth.CALLBACK_TYPE_ALL_MATCHES);
            }catch (IOException ex) {
                Log.e(ex);
            } 
        }
    }));

How can I get the list of the devices?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions