Skip to content
This repository has been archived by the owner on Apr 5, 2020. It is now read-only.

WinRT -> BlueTooth, USB allowing multiple Brick connections, any name. New event when brick disconnected #14

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

BananaScheriff
Copy link

Well see my changes and rate ^_^ Needed these changes for my engineer app, so thought about sharing now that I know they work.

Instead of choosing only first device in USB/BT, let user choose what device to connect by selecting it with known ID and Name. Also enable to connect to same named bricks as ID is always different .

Made _comm public, for easier access to event placed in Communations.
Enabling with BrickDosconnected to handle disconnection. For example, reconnecting or moving to mainPage instead of crashing - what often happened.

BananaScheriff and others added 9 commits January 18, 2016 23:03
Added: 
		private readonly string _deviceName;
        	private readonly string _deviceId;

ConnectAsyncInternal():
DeviceInformation brick = (from d in devices where d.Id == _deviceId select d).FirstOrDefault();
making possible connecting to selected USB device, not first one.
Added:
public event EventHandler<BrickDisconnectedEventArgs> BrickDisconnected;
implementing changed version of ICommunication allowing to detecd when brick disconnected, not used in USB
Added:
	        private readonly string _deviceName;
	        private readonly string _deviceId;
        	public event EventHandler<BrickDisconnectedEventArgs> BrickDisconnected;

ConnectAsyncInternal():
DeviceInformation device = (from d in devices where d.Id == _deviceId select d).FirstOrDefault()

PollInput(IAsyncAction operation):
catch(System.Exception)
                {
                    if (BrickDisconnected != null)
                        BrickDisconnected.Invoke(this, new BrickDisconnectedEventArgs() {Details =  "Brick disconnected due to unexpected behavior" });
                }

Allowing connecting to selected BT device, not only with name "EV3".
Added event fired, when connected brick is disconnected, allowing to make back-up plan in case of disconnecting instead of app crashing bug.
Same as with BT, wasnt using, so dont know if it can connect to multiple bricks at one, note made it work that way.
public ICommunication _comm { get; set; }
its now public!
You can get my events to fire in Your app! Rejoice!
added my event args, dont know why, they feel useless
Added:
        event EventHandler<BrickDisconnectedEventArgs> BrickDisconnected;

Event allowing developer to handle unexpected disconnection of brick.
GetDevices returning all devices capable of connecting(not implemented everywhere, BT,USB in WinRT)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant