xamarin / Monkey.BluetoothLE

BluetoothLE abstraction for use with Xamarin projects, including Xamarin.Forms.
Apache License 2.0
349 stars 223 forks source link

IOS Bluetooth LE Descriptors list is never initialized #21

Open MichaelRoop opened 9 years ago

MichaelRoop commented 9 years ago

In the Robotics.Mobile.Core.iOS->Bluetooth->LE->Descriptor.cs line71

The this._descriptors is never initialized. It looks like the check should be if (this._descriptors == null) instead of if (this._descriptors != null). This is the only place the new is called

    public IList<IDescriptor> Descriptors {
        get {
            // if we haven't converted them to our xplat objects
            if (this._descriptors != null) {
                this._descriptors = new List<IDescriptor> ();
                // convert the internal list of them to the xplat ones
                foreach (var item in this._nativeCharacteristic.Descriptors) {
                    this._descriptors.Add (new Descriptor (item));
                }
            }
            return this._descriptors;
        }
    }
bryancostanich commented 9 years ago

@conceptdev - i vaguely recall this changing (i'm pretty sure it used to be a ==) due to a community code change, do you recall here?

conceptdev commented 9 years ago

I presume @MichaelRoop means Characteristic.cs (not Descriptor.cs).

The git history suggests it's always been != which does seem wrong... I guess we need to test it out!

MichaelRoop commented 9 years ago

Yes indeed, the Descriptors property in Chracteristic.cs

From: Craig Dunn [mailto:notifications@github.com] Sent: Tuesday, March 03, 2015 6:51 PM To: xamarin/Monkey.Robotics Cc: MichaelRoop Subject: Re: [Monkey.Robotics] IOS Bluetooth LE Descriptors list is never initialized (#21)

I presume @MichaelRoop https://github.com/MichaelRoop means Characteristic.cs (not Descriptor.cs).

The git history suggests it's always been != which does seem wrong... I guess we need to test it out!

— Reply to this email directly or view it on GitHub https://github.com/xamarin/Monkey.Robotics/issues/21#issuecomment-77056391 . https://github.com/notifications/beacon/AA_lACVIj9r5H8pOazhzajsHFj5q3TYUks5nxjJOgaJpZM4Dc386.gif

Dentaku1992 commented 9 years ago

Dear sir Thanks for developing Monkey Robotics, it has helped me a great deal developing an app for my master's thesis.I have successfully implemented a Bluetooth Low Enery communications app, though I have some questions.Is it possible for me to add my own UUID's to the list of known characteristics in the BLE characteristic list?The json string I mean is the one in this file:https://github.com/xamarin/Monkey.Robotics/blob/master/Source/Platform%20Stacks/Robotics.Mobile.Core/Bluetooth/LE/KnownCharacteristics.json Since I'm developing a proof-of-concept with a lot of new characteristics, I would like to add some values to that list.Is this possible, and if so, how?I have already tried the LoadItemsFromJson() method by placing the KnownCharacteristics.json file in the Xamarin.Forms resources as well as the Android specific resources, yet no result has been seen. Thanks in advanceGert-Jan

Date: Tue, 3 Mar 2015 14:50:57 -0800 From: notifications@github.com To: Monkey.Robotics@noreply.github.com Subject: Re: [Monkey.Robotics] IOS Bluetooth LE Descriptors list is never initialized (#21)

I presume @MichaelRoop means Characteristic.cs (not Descriptor.cs).

The git history suggests it's always been != which does seem wrong... I guess we need to test it out!

— Reply to this email directly or view it on GitHub.

MichaelRoop commented 9 years ago

Hi Get-Jan,

I never saw the LoadItemsFromJson() method but I submitted a pull request on a branch that loads custom sets of characteristic GUIDs for the characteristic TYPES used in the library.

We used this to talk to a BlueRadio module rather than the module used on the target Netduino shield. The Monkey Robotics team is looking over the branch to see if it can be included in the project or modified for inclusion. If it is included you would just need to create a derived class which has the specific list of characteristic GUIDs. This would just be for the GUIDs of the characteristic TYPES they already handle in the library

If the branch does not get included I can confirm that it can be done. You can always modify your copy of the code and compile it. If you need to handle characteristic TYPES other than those handled in the library then it would be extra work

Michael Roop

From: Dentaku1992 [mailto:notifications@github.com] Sent: Wednesday, March 04, 2015 3:43 AM To: xamarin/Monkey.Robotics Cc: MichaelRoop Subject: Re: [Monkey.Robotics] IOS Bluetooth LE Descriptors list is never initialized (#21)

Dear sir Thanks for developing Monkey Robotics, it has helped me a great deal developing an app for my master's thesis.I have successfully implemented a Bluetooth Low Enery communications app, though I have some questions.Is it possible for me to add my own UUID's to the list of known characteristics in the BLE characteristic list?The json string I mean is the one in this file:https://github.com/xamarin/Monkey.Robotics/blob/master/Source/Platform%20Stacks/Robotics.Mobile.Core/Bluetooth/LE/KnownCharacteristics.json Since I'm developing a proof-of-concept with a lot of new characteristics, I would like to add some values to that list.Is this possible, and if so, how?I have already tried the LoadItemsFromJson() method by placing the KnownCharacteristics.json file in the Xamarin.Forms resources as well as the Android specific resources, yet no result has been seen. Thanks in advanceGert-Jan

Date: Tue, 3 Mar 2015 14:50:57 -0800 From: notifications@github.com To: Monkey.Robotics@noreply.github.com Subject: Re: [Monkey.Robotics] IOS Bluetooth LE Descriptors list is never initialized (#21)

I presume @MichaelRoop means Characteristic.cs (not Descriptor.cs).

The git history suggests it's always been != which does seem wrong... I guess we need to test it out!

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/xamarin/Monkey.Robotics/issues/21#issuecomment-77109983 .

sktron commented 9 years ago

EDIT: btw, the file is of course Characteristic.cs, not Descriptor.cs And, I downloaded the project a few weaks ago.

In the Droid part it is indeed ==, not !=. So I've changed it in the Anroid part to if (this._descriptors == null), which results in a null reference exception a few lines below: foreach (var item in this._nativeCharacteristic.Descriptors) { with _nativeCharacteristic.Descriptors being null.

Any idea what could be the cause?