brookpatten / Mono.BlueZ

Wrappers & Classes for interfacing with bluetooth via BlueZ from Mono
MIT License
15 stars 12 forks source link

Compiling Project #3

Open milanalvarado opened 7 years ago

milanalvarado commented 7 years ago

Hello, I am green in utilizing this project. I ran a git clone of the project in powershell. I opened it up in vs 2017 rc to attempt to compile it.

The point of utilizing this is to basically set it up on a raspberry pi 3 so that I can make the built-in chip on the pi 3 as a ble peripheral where I can ultimately connect a ble client (eg. lightblue app on android or iOs) and read and write to the gatt of the pi3.

Is this possible to make the raspberry pi 3 a BLE peripheral using with this Library? Is it possible to compile the way am attempting to compile on windows 10 in vs 2017 rc? If it is not, is there any info to do what I am trying to do? Why is it that the dbus-sharp reference inside of mono-bluez is unavailable when I open it in vs 2017 rc?
Do I need to clone dbus-sharp as a stand-alone project, and then compile and then add the reference into my Mono.Bluez project??

If I clone dbus-sharp as a stand-alone project and attempt to compile, I noticed it errors out with the following messages.

dbuserror

Thanks in advance for any insight on this matter.

Milan

brookpatten commented 7 years ago

It appears you're using an old version of mono.posix, and possibly have not cloned recursively to include submodules (which would have also fetched dbus-sharp).

The library might need some additions to act as a BLE peripheral, the real question is will blueZ adequately do what you are trying to do.

Regardless, I wouldn't recommend doing any of this on VS on windows. You'd be much better off just installing monodevelop on the pi3 and working there.

milanalvarado commented 7 years ago

Even after recursive command, it did not work. Solution to make it compile was to remove reference to Mono.Posix, add reference in vs 2017 rc for Package Manager Jetbrains.Mono.Posix, and Jetbrains.Mono.Unix.Utils, and then it compiled. I will keep you updated on my progress. Thanks.

milanalvarado commented 7 years ago

After compiling and pushing to raspberry pi 3 running debian jessie, it would not work.
Here is a dump of the response in the raspi3 prompt:

sudo mono monoBluez/Mono.BlueZ.Console.exe Path info Service:org.bluez agentPath:/agent profilePath:/profiles blueZPath:/org/bluez Path Root:/ AppDomain.UnhandledException: Object reference not set to an instance of an object at Mono.BlueZ.Console.PebbleBootstrap.GetObject[ProfileManager1] (System.String busName, DBus.ObjectPath path) [0x00000] in :0 at Mono.BlueZ.Console.PebbleBootstrap.Run (Boolean doDiscovery, System.String adapterName) [0x00000] in :0 at Mono.BlueZ.Console.MainClass.Main (System.String[] args) [0x00000] in :0 [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object at Mono.BlueZ.Console.PebbleBootstrap.GetObject[ProfileManager1] (System.String busName, DBus.ObjectPath path) [0x00000] in :0 at Mono.BlueZ.Console.PebbleBootstrap.Run (Boolean doDiscovery, System.String adapterName) [0x00000] in :0 at Mono.BlueZ.Console.MainClass.Main (System.String[] args) [0x00000] in :0

I used both PebbleBootstrap, and BlendMicroBootstratp( I doubt this would work). Below are the default Service, and blueZPath that I left intact.
string Service = "org.bluez"; //both at root var agentPath = new ObjectPath ("/agent"); var profilePath = new ObjectPath ("/profiles"); var blueZPath = new ObjectPath ("/org/bluez");

  1. Is there anything that appears to be off in the dump?
  2. Is there anything that I should do differently to configure for Raspi3 with Debian Jessie for the Native BLE?
  3. Is there any commands to confirm that I have the Bluez configured as expected for Raspi3?
  4. Currently, I am running this mono proj in /home/pi/monoBluez Directory. Is there a preferred location to run the mono app? 5.FYI, currently using bluetoothd v 5.23 mono 3.28 bluez 5.43

thanks

brookpatten commented 7 years ago

It's hard to really know what's going on just from an NRE, but I would guess that it's not finding the gatt stuff registered in dbus, likely because bluez isn't running in experimental mode.

I would change your systemd config to start bluez in experimental mode and see if that helps. http://blog.mrgibbs.io/bluez-5-39-ble-setup-on-the-raspberry-pi/

milanalvarado commented 7 years ago

I'll check to see if bluez is in experimental mode. As far as the Service = "org.bluez" and blueZPath = "/org/bluez"...do those seem like these values are still ok? are there raspi3 or linux commands to confirm these settings?

ghost commented 6 years ago

You should try installing the latest version of bluez (which is now 5.48). You could find information how to install the latest version here: https://learn.adafruit.com/install-bluez-on-the-raspberry-pi/installation.

I've update the class BlendMicroBootstrap to support the new API on how to register an application. GattManager1.RegisterProfile and GattManager1.UnregisterProfile are now deprecated.