0 Replies Latest reply: Jul 31, 2012 3:06 AM by VANPERSIE RSS

    Required: javax.bluetooth.RemoteDevice!   What compiler expect

    VANPERSIE
      Hi
      I have download a package as a bluetooth application from here
      http://public.dhe.ibm.com/software/dw/wireless/btevents-src.zip

      but I have a simple problem in the second code

      The compiler gives an error in this method

      public void incomingCall(PhoneEvent event) {
      btManager.sendMessage("bluetooth.livingroom.TelevisionMonitor", "incomingCall:"+event.getCaller());
      }
      method sendMessage in class com.ibm.btevents.BTManager cannot be applied to given types
      required: javax.bluetooth.RemoteDevice,java.lang.String
      found: java.lang.String,java.lang.String

      when I returned to java API     I found the requird should be string

      RemoteDevice(java.lang.String address)
      Creates a Bluetooth device based upon its address.

      Can someone help plz.
      package com.ibm.btevents;
      
      import javax.bluetooth.RemoteDevice;
       
      public class BTManager {
      
          private BTTransmitter transmitter;
          private BTReceiver receiver;
          private BTDiscoverer discoverer;
          
          /**
           * Create a new BTManager
           */
          public BTManager() {
              transmitter = new BTTransmitter();
              transmitter.start();
              receiver = new BTReceiver();
              receiver.start();
              discoverer = new BTDiscoverer();
              discoverer.start();
          }
          
          /**
           * Create a new BTManager and register the the given listener
           * @param listener
           */
          public BTManager(BTEventListener listener) {
              transmitter = new BTTransmitter();
              transmitter.addBTEventListener(listener);
              transmitter.start();
              receiver = new BTReceiver();
              receiver.addBTEventListener(listener);
              receiver.start();
              discoverer = new BTDiscoverer();
              discoverer.addBTEventListener(listener);
              discoverer.start();
          }
      
          /**
           * Add a new listener for BTEvents
           * @param listener
           */
          public void addBTEventListener(BTEventListener listener) {
              transmitter.addBTEventListener(listener);
              receiver.addBTEventListener(listener);
              discoverer.addBTEventListener(listener);
          }
      
          /**
           * Carry out a new search for devices within range
           */
          public void searchForDevices() {
              discoverer.searchForDevices();
          }
      
          /**
           * Send a meesage to a remote device
           * @param device
           * @param message
           * @throws DeviceNotFoundException
           */
          public void sendMessage(RemoteDevice device, String message) throws DeviceNotFoundException {
              transmitter.sendMessage(device, message);
          }
      
          /**
           * Check if the necessary bluetooth classes are available
           * @return true if the API is available, false otherwise
           */
          public boolean bluetoothAPIAvailable() {
              try {
                  Class.forName("javax.bluetooth.LocalDevice");
                  return true;
              } catch (ClassNotFoundException ex) {
                  return false;
              }
          }
          
          /**
           * Returns a cached copy of the discovered devices
           * @return an array of RemoteDevices
           */
          public RemoteDevice[] getDevices() {
            return discoverer.getDevices();
        }
      }
       
      
      package Bluetooth.livingroom;
       
      
      import com.ibm.btevents.*;
      
      public class TelephoneMonitor extends MIDlet implements BTEventListener, PhoneListener {
      
        private BTManager btManager;
      
        public TelephoneMonitor() {
            btManager = new BTManager(this);
        }
      
        *public void incomingCall(PhoneEvent event) {*
         *btManager.sendMessage("bluetooth.livingroom.TelevisionMonitor", "incomingCall:"+event.getCaller());*
        *}*
      
        public void callEnded(PhoneEvent event) {
            btManager.sendMessage(
                    "bluetooth.livingroom.TelevisionMonitor",
                    "callEnded:"+event.getDuration()
            );
        }
      
        public void messageReceived(BTEvent event) {}
        public void messageSent(BTEvent event) {}
        public void devicesDiscovered(BTEvent event) {}
        public void diagnosticMessage(BTEvent event) {}
      
      }