Home→Forums→MonoBrick Communication Library→Monobrick on Android
Tagged: monobrick android
- This topic has 7 replies, 4 voices, and was last updated 10 years, 10 months ago by Anders Søborg.
-
AuthorPosts
-
December 16, 2013 at 18:48 #3311
Edgard NetoParticipantHello all,
I’ve been using monobrick for a while now but I’ve decided to start using it with android.
Although I dont understand how to get it to work in android ? I’ve been trying to use Xamarin Studio Android, but I can’t understand how to add the libraries (monobrick for Android) into my project.
Can anyone help me to do that ? Or at least a good tutorial for Monobrick for Android.Thanks.
December 19, 2013 at 19:42 #3316
Anders SøborgKeymasterHi – thanks for using MonoBrick Communication library
Start off by downloading the Monobrick Communication Library for Android. The first thing you need to do is to check if Bluetooth is turned on. This can be done by using the static property on the Bluetooth class as shown below.
MonoBrick.Bluetooth<BrickCommand,BrickReply>.IsEnabled
If Bluetooth is not turned on use the following code to turn it on
MonoBrick.Bluetooth<BrickCommand,BrickReply>.Enable();
Once Bluetooth has been turned on use the following code to get a list of paired devices
MonoBrick.Bluetooth.BondDevices
If you know the device name you can also call
MonoBrick.Bluetooth.GetBondDevice(string deviceName);
Use the Bluetooth device to create a Bluetooth connection instance and create a brick class followed by opening the connection. The code below sums it all up.
var device = MonoBrick.Bluetooth<MonoBrick.EV3.Command, MonoBrick.EV3.Reply>.GetBondDevice("youDeviceName"); var connection = new Bluetooth<MonoBrick.EV3.Command, MonoBrick.EV3.Reply>(device); var brick = new MonoBrick.EV3.Brick<MonoBrick.EV3.Sensor,MonoBrick.EV3.Sensor,MonoBrick.EV3.Sensor,MonoBrick.EV3.Sensor>(connection); brick.Connection.Open();
Replace EV3 namespace with NXT namespace depending on your device
Let me know how it goes
Anders
- This reply was modified 10 years, 11 months ago by Anders Søborg.
December 30, 2013 at 12:43 #3671
Jacek SParticipantHi,
Do I need to buy license for xamarin studio? I think xamarin free starter limitation to 64kb IL size is not sufficient (monobrick library have more than 100kb). Are there any alternatives to use monobrick library for android without buying xamarin license?Jacek
December 30, 2013 at 23:37 #3676
Anders SøborgKeymasterHi Jacek
Are there any alternatives to use monobrick library for android without buying xamarin license?
No Sorry – but if you are a student you can get a discount…
Anders
January 17, 2014 at 13:14 #3852
Marcin KrzewskiParticipantHi Anders
I did as you said and I’m getting an error in the line
var device = MonoBrick.Bluetooth<MonoBrick.EV3.Command, MonoBrick.EV3.Reply>.GetBondDevice("youDeviceName");
saying'MonoBrick.Bluetooth<MonoBrick.EV3.Command,MonoBrick.EV3.Reply>' does not contain a definition for 'GetBondDevice' D:\Projekty\EV3\Kama2\Kama2\Activity1.cs
I copied the bluetooth class from the test project. Do you know the solution to that? How should the definition of the GetBondDevice method look like?Marcin
January 17, 2014 at 20:49 #3857
Anders SøborgKeymasterHi Marcin
You need to use the Android DLL. This DLL has another implementation of the Bluetooth connection. One of the differences is the GetBondDevice…
Anders
January 20, 2014 at 17:18 #3865
Marcin KrzewskiParticipantHi Anders
I still can’t connect.
"youDeviceName"
Should it be my phone name or my ev3 brick name? And does it matter if I turn on bluetooth and pair devices before I run the app on my phone? Or should I do it in the app using the code you provided? Btw. I dont exactly know what you mean by"This can be done by using the static property on the Bluetooth class"
Sorry if my questions are dumb, I’m still learning.
Marcin
January 21, 2014 at 21:17 #3868
Anders SøborgKeymasterHi Again
There are no such things as dumb questions! I am just happy that people are using me software…
Should it be my phone name or my ev3 brick name? And does it matter if I turn on bluetooth and pair devices before I run the app on my phone?
Yes you need to pair you phone with the brick before running the program…
Just quoting what I wrote above
Once Bluetooth has been turned on use the following code to get a list of paired devices
MonoBrick.Bluetooth.BondDevices
If you know the device name you can also callMonoBrick.Bluetooth.GetBondDevice(string deviceName);
-
AuthorPosts
You must be logged in to reply to this topic.
Follow