Giter Club home page Giter Club logo

Comments (9)

Velorexe avatar Velorexe commented on August 15, 2024

Hey @DucampGaspard

You didn't miss anything, this is a mistake on my part! In the SubscribeToCharacteristic class there's a check to see if a UUID is a short 4-bit part of the first 8-bits UUID, since most BLE services and characteristics only differ in the that part (where 0000[unique 4-bit ID]-0000-1000-8000-00805f9b34fb will remain the same for most services and characteristics).

So I've added a _customGatt field to most commands that interact with services and characteristics to see if it's a custom GATT UUID (128-bit) or short UUID (4-bit). At the Start() it checks if the _customGatt field is true or not, but this field is not set in the constructor.

I'll roll out a fix in around an hour or so!

from unity-android-bluetooth-low-energy.

Velorexe avatar Velorexe commented on August 15, 2024

If you're able to pull the new version of development ( #10 ) then the issue should be fixed if you pass true as the last argument if you're using a 128-bit UUID instead of an 4-bit UUID. Let me know if this works for you, if so I'll roll out the fix into master.

from unity-android-bluetooth-low-energy.

DucampGaspard avatar DucampGaspard commented on August 15, 2024

Thanks a lot, it works perfectly now ! 😊

Regarding the subscription to multiple characteristics, it seems that I receive notifications only for the first one, e.g. :

  • the battery info if I do :
BleManager.Instance.QueueCommand(new SubscribeToCharacteristic(_deviceUuid, UUID_BATTERY_SERVICE.Get8BitUuid(), UUID_CHARACTERISTIC_BATTERY_LEVEL.Get8BitUuid());

BleManager.Instance.QueueCommand(new SubscribeToCharacteristic(_deviceUuid, UUID_PROCESSING_SERVICE, UUID_CHARACTERISTIC_PROCESSING, true));
  • the result of the processing (an integer) if I first subscribe to this characteristic.

Can we have concurrent subscriptions and notifications, or just one at the time ?

from unity-android-bluetooth-low-energy.

Velorexe avatar Velorexe commented on August 15, 2024

Interesting, from what I see there shouldn't be a reason why 2 concurrent subscriptions shouldn't work. There are 2 constructors for the SubscribeToCharacteristic class, one where you can also add a method that needs to execute when the Characteristic updates it's value. Could you try that one with both? Pass in a simple lambda like

(x) => Debug.Log("Battery" + x.Length) for both methods to see if they're updating.

I'll also setup a local BLE server with two subscribe Characteristics to see if I can reproduce the issue.

from unity-android-bluetooth-low-energy.

Velorexe avatar Velorexe commented on August 15, 2024

Alright, so I found a wrong check inside the CommandReceived method of SubscribeToCharacteristic, perhaps this should fix the issue that you were having. It has been pulled in to development ( #12 )

from unity-android-bluetooth-low-energy.

DucampGaspard avatar DucampGaspard commented on August 15, 2024

Regarding this function I think there is an issue as well line 59 (and 68) where you check for :

string.Equals(obj.Service, DeviceAddress) &&

instead of

string.Equals(obj.Service, Service) &&

Nevertheless, and with this changed, I still can't manage to get both messages simultaneously.

from unity-android-bluetooth-low-energy.

Velorexe avatar Velorexe commented on August 15, 2024

Haha, must have written this code when sleep deprived or something. This afternoon I'll have a fix for you, I'll have access to the BLE server by then.

from unity-android-bluetooth-low-energy.

DucampGaspard avatar DucampGaspard commented on August 15, 2024

Hahaha no problem and thank you for your reactivity !

I have another question regarding the BleObject.GetByteMessage() function, at the moment it's defined as follows :

public byte[] GetByteMessage() => Convert.FromBase64String(command);

Shouldn't we convert the base64_message attribute of the received message ? For example using something like :

#region Message
public string Message => base64_message;
[SerializeField]
private string base64_message = string.Empty;
#endregion

public byte[] GetByteMessage() => Convert.FromBase64String(base64_message);

from unity-android-bluetooth-low-energy.

Velorexe avatar Velorexe commented on August 15, 2024

Yeah, seems like when I rewrote the project I forgot to add the base64message field, since that is given by received JSON.
Good catch!

from unity-android-bluetooth-low-energy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.