Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Monkey.Robotics HM-10 BLE Generic binary data transfer

$
0
0

Hi!
After adding a comment to a post without getting any feedback, I hope this is not deemed a duplicate.
If so maybe I should have opened a new thread instead of making the comment.

I created a Xamarin forms Android tab App using the Bluetooth 2.0 specification using a Bluetooth Chat example which works fine.
Now I must change over to Bluetooth BLE so we can support IOS.
Our App connects from the mobile phone (Android,IOS) to our proprietary hardware by way of a simple HM-10 BLE chip
I need to transfer binary data (up to 576 bytes) in both directions so I understand I will need to implement multiple low level messages.

The Monkey.Robotics project is very appealing in that it provides C# code that hides the platform differences.
I have not worked with Apple productions since the late 90s.
On the other hand the Monkey.Robotics project is marked beta and is a moving target if I have to change platform code to get it to work.
It also may include a lot of code that I would not need making possibly my App even larger yet.
I just need generic Characteristic Write and Read functionality.
I played around with the Monkey BtLeExplorer, it found my hardware's HM-10 device and I could send a simple 16 byte binary message to my hardware by
changing the CharacteristicDetail_TISwitch page's SwitchToggled() code.
My hardware returned almost immediately a binary reply but at the var c = await characteristic.ReadAsync(); line a single 0x00 byte was received.

I would like to try to get the Monkey.Robotics working in my project.
What I would like to do, is to duplicate the way I previously did things with the old chat demo code.
a) Have a single dialog DeviceList popup that the scan function populates.
b) The user selects the Device causing it to connect.
c) Since I use always the same characteristics, I do not want the user to see the Services or Characteristic list.
d) I work only with a single device so I need only a single instance of the below (I think)
IAdapter adapter, IDevice device, IService service, ICharacteristic characteristic
e) After the device connection, I would use a background thread to read and write data and receive notification upon disconnect.
After Device selection I would like the popup to disappear showing my tabbed Forms App.
User requests would "talk" to the background thread sending and receiving data.

1) I tried adding the Monkey BtLeExplorer code to my existing Forms project and get an error.
The Monkey BtLeExplorer project that I did not create myself does not complain.
https://forums.xamarin.com/discussion/45071/monkey-robotics-install-issue-pcl-targets-to-be-removed-how

    Adding Monkey.Robotics...
    Attempting to resolve dependency 'Newtonsoft.Json (= 6.0.8)'.
    Adding 'Newtonsoft.Json 7.0.1' to SpiritUtil.
    For adding package 'Newtonsoft.Json 7.0.1' to project 'SpiritUtil' that targets 'portable-net45+win+wp80+MonoAndroid10+xamarinios10+MonoTouch10',
    >> Assembly references are being added from 'lib\portable-net45+wp80+win8+wpa81+dnxcore50'
    Added reference 'Newtonsoft.Json' to project 'SpiritUtil'.
    Added file 'packages.config'.
    Added file 'packages.config' to project 'SpiritUtil'.
    Successfully added 'Newtonsoft.Json 7.0.1' to SpiritUtil.
    Adding 'Monkey.Robotics 0.5.2' to SpiritUtil.
    Could not install package 'Monkey.Robotics 0.5.2'. You are trying to install this package into a project that targets 'portable-net45+win+wp80+MonoAndroid10+xamarinios10+MonoTouch10', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

2) If anyone has already done this and has code examples or other feedback I would greatly appreciate it.

Thanks a million
David


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>