Example #1
0
        // Setup function
        public void Setup()
        {
            _ledState = false;

            BluetoothInfo();

            // Create Bluetooth transport object
            _bluetoothTransport = new BluetoothTransport
            {
                //CurrentBluetoothDeviceInfo = BluetoothUtils.DeviceByAdress("98-D3-31-B0-FB-B5")
                CurrentBluetoothDeviceInfo = BluetoothUtils.DeviceByAdress("20:13:07:26:10:08")
            };

            // Create Serial Port transport object
            // Note that for some boards (e.g. Sparkfun Pro Micro) DtrEnable may need to be true.
            _serialTransport = new SerialTransport
            {
                CurrentSerialSettings = { PortName = "COM16", BaudRate = 9600, DtrEnable = false } // object initializer
            };

            // Initialize the command messenger with the Serial Port transport layer
            _cmdMessenger = new CmdMessenger(_bluetoothTransport)
            {
                BoardType = BoardType.Bit16     // Set if it is communicating with a 16- or 32-bit Arduino board
            };

            // Tell CmdMessenger if it is communicating with a 16 or 32 bit Arduino board

            // Attach the callbacks to the Command Messenger
            AttachCommandCallBacks();

            // Start listening
            _cmdMessenger.Connect();
        }
Example #2
0
        static BaseViewModel()
        {
            // Create Serial Port object
            // Note that for some boards (e.g. Sparkfun Pro Micro) DtrEnable may need to be true.
            _bluetoothTransport = new BluetoothTransport
            {
                DeviceName = "EMS01_1152"
            };

            // Initialize the command messenger with the Serial Port transport layer
            // Set if it is communicating with a 16- or 32-bit Arduino board
            _cmdMessenger = new CmdMessenger(_bluetoothTransport, BoardType.Bit16);

            // Attach to NewLinesReceived for logging purposes
            _cmdMessenger.NewLineReceived += NewLineReceived;

            // Attach to NewLineSent for logging purposes
            _cmdMessenger.NewLineSent += NewLineSent;


            _cmdMessenger.Attach(OnUnknownCommand);
            _cmdMessenger.Attach((int)Commands.Acknowledge, OnAcknowledge);
            _cmdMessenger.Attach((int)Commands.Error, OnError);
        }