Class BluetoothDevice

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class BluetoothDevice
    extends TypedAtomicActor
    This Actor is simulation of a Bluetooth adapter in a Bluetooth enabled device. The simulation is functional, i.e. the hardware is not simulated. Instead, we provide an abstraction based on the Bluetooth dynamics found in popular platforms such as Android and iOS.

    The Actor consists of six IO ports: four TypedIOPorts, and two WirelessIOPort. The wired ports simulate the adapters connection to peripheral hardware. The wired input port will accept a String whose value is equivalent to an acceptable command that can be found in the following list:

    COMMAND_SWITCHON : Switch on this bluetooth device actor.

    COMMAND_SWITCHOFF : Swtich off this bluetooth device actor.

    COMMAND_SCAN : Scan for other discoverable bluetooth device actors on this wireless channel.

    COMMAND_STOPSCAN : Stop scanning for other discoverable bluetooth device actors on this wireless channel.

    COMMAND_CONNECT : Connect to a paired bluetooth device actor on the same wireless channel. The device name to connect must be sent to the wired input details port.

    COMMAND_DISCONNECT : Disconnect to a connected bluetooth device actor. The device name to disconnect from must be send to the wired input details port.

    COMMAND_PAIR : Pair to a found bluetooth device actor on this wireless channel. The device name to pair to must be sent to the wired input details port.

    COMMAND_UNPAIR : Unpair from a previously paired bluetooth device actor on this wireless channel. Note that this does not cause the other actor to unpair, a behavior particular to bluetooth. The device name to unpair from must be sent to the wired input details port.

    COMMAND_DISCOVERABLE : Makes this bluetooth device actor discoverable to other scanning bluetooth device actors on the same channel.

    COMMAND_HIDE : Makes this bluetooth device actor no longer discoverable.

    COMMAND_SENDDATA : Initiate the sending of data. The name of the device to send data to must be sent to the wired input details port. The data must be sent to the wired input data port. The device to send data to must be found, paired, and connected with this bluetooth device actor

    COMMAND_NOCOMMAND : The default command, which means that no token was available on the wired input port.

    To issue a command to this actor, only use the lower case equivalent of the second work, after the COMMAND_. Parsing occurs intenerally.

    This actor can exist in 4 states, who vary in behavior: Off, Idle, Connected, and Scanning.

    The dynamics of the actor are evaluated via a state machine implemented as a switch-case structure found in the fire() method.

    In the event that there is a horrible failure, an incorrect input is received, or an input is not available when one is expected (i.e. when commanding connection or sending data,) an IllegalActionException will be thrown.

    If all goes according to plan, the status of the iteration will be output to the wired output port. The token output to this port may also contain an generic piece of data. To retrieve this data, a downstream actor must call the getData() function on the output token. If this data is a string, it will be output if toString() is called, along with the status. The resulting String will be comma delimited, with the format Status,Data.

    Since:
    Ptolemy II 11.0
    Version:
    $Id$
    Author:
    Phillip Azar
    Pt.AcceptedRating:
    Pt.ProposedRating:
    • Field Detail

      • wiredInput

        public TypedIOPort wiredInput
        The input port for wired communication, which could potentially facilitate communication with other devices/components/actors which are not wireless that interact with this actor. This port is of type String, and will be checked internally against a list of valid commands.
      • wiredInputDetails

        public TypedIOPort wiredInputDetails
        The input port for details about wired communications, which will contain a device identifier. The type of this port is String.
      • wiredInputData

        public TypedIOPort wiredInputData
        The input port for data to be sent. This will only be checked when the command to send data has been issued, and further will only be checked when in the connected state. This port is of type General.
      • wiredOutput

        public TypedIOPort wiredOutput
        The output port for wired communication, which could potentially facilitate communication with other devices/components/actors which are not wireless that interact with this actor. This port is of type General.
      • wirelessInput

        public WirelessIOPort wirelessInput
        The input port for wireless communication, which accepts a BluetoothRecordToken - this is to ensure that any RecordToken at this port only comes from another BluetoothDevice. This port is of type General.
      • wirelessInputChannelName

        public StringParameter wirelessInputChannelName
        Name of the wireless input channel. This is a string that defaults to "WirelessInputChannel".
      • wirelessOutput

        public WirelessIOPort wirelessOutput
        The output port for wireless communication, which will output a BluetoothResponseToken of type General.
      • wirelessOutputChannelName

        public StringParameter wirelessOutputChannelName
        Name of the wireless output channel. This is a string that defaults to "WirelessOutputChannel".