Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

characteristic.ValueUpdated never triggeed #780

Open
manudev-1 opened this issue Nov 19, 2023 · 9 comments
Open

characteristic.ValueUpdated never triggeed #780

manudev-1 opened this issue Nov 19, 2023 · 9 comments

Comments

@manudev-1
Copy link

Steps to reproduce

  1. image
  2. image
  3. image
  4. image
  5. image
  6. Arduino's Code:
  • 6.1
#include <ArduinoBLE.h>
#include <Arduino.h>

const char * deviceServiceUuid = "ffe0ecd2-3d16-4f8d-90de-e89e7fc396a5";
const char * deviceServiceReqUuid = "d8de624e-140f-4a22-8594-e2216b84a5f2";
const char * deviceServiceResUuid = "DF2D5AFD-1CDE-4CAC-92F1-0452992D7692";

const int eventListener = 2;

BLEService appService(deviceServiceUuid);
BLECharacteristic appReqChar(deviceServiceReqUuid, BLEWrite | BLERead, 4);
BLECharacteristic appResChar(deviceServiceResUuid, BLERead | BLENotify, 4);

String inputString = "CALL";
byte byteArray[4];

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  BLE.setDeviceName("Arduino UNO R4");
  BLE.setLocalName("Arduino UNO R4");

  if(!BLE.begin()){
    Serial.println("Starting BLE Module FAILED");
    while(1);
  }

  BLE.setAdvertisedService(appService);
  appService.addCharacteristic(appReqChar);
  appService.addCharacteristic(appResChar);
  BLE.addService(appService);

  BLE.advertise();
  
  pinMode(eventListener, INPUT);

  inputString.getBytes(byteArray, 4);

}

const uint8_t* currentValue = appReqChar.value();
uint8_t newValue;

void loop() {
  BLEDevice central = BLE.central();
  if(central){
    Serial.println("CONNECTED");
    if(digitalRead(eventListener) == HIGH){
      appResChar.writeValue(byteArray, 4);
    }
    else{
      appResChar.writeValue((int8_t)0);
    }
  }
  delay(1000);
}
  • 6.2 b2cd0b93-0564-4111-8e11-6cc0be810cf0

Expected behavior

I would like my application to scan the bluetooth devices next to it that show them on a list and that when the user presses on one of the devices in the list it will start a connection. I’m trying to use my arduino uno r4, and it when the app is connected changes the value of the feature shown in the code, and I would like inside the event to show me the message sent by the arduino.

Actual behavior

Everything starts correctly but the value change listening event never runs.

Crashlog

No exception

Configuration

Version of the Plugin: 3.0.0

Platform: Android 13.0 - API 33

Device: Xiaomi 2201117TY

@smsissuechecker
Copy link

Hi @manudev-1,

I'm the friendly issue checker.
Thanks for using the issue template 🌟
I appreciate it very much. I'm sure, the maintainers of this repository will answer, soon.

@marcusebm
Copy link

Hi, any news to this topic? I have the same problem with .net maui 8. And different Android devices.

The same code is running on windows.

Not tested on ios.

@janusw
Copy link
Member

janusw commented Feb 13, 2024

I think there are some API changes in API level 33 which might cause this. Can someone confirm that the problem only occurs with API 33 and above (Android 13/14), but works with API 32 and below (Android 12 and earlier)?

@marcusebm
Copy link

marcusebm commented Feb 15, 2024

It does not work with Android 6.0 (API23).

Can I support in any other way?

@janusw
Copy link
Member

janusw commented Feb 15, 2024

It does not work with Android 6.0 (API23).

That's surprising. Maybe you're doing something wrong? (Android 6 is pretty ancient, anyway.)

Can I support in any other way?

Do you see characteristics updates working with any Plugin.BLE version (on any Android version)?

@marcusebm
Copy link

marcusebm commented Feb 15, 2024

Could be that I do something wrong. I use the following lines of code which should work.

this.receiveCharacteristic = await service.GetCharacteristicAsync(GattIdentifiers.UartGattCharacteristicReceiveId); this.receiveCharacteristic.ValueUpdated += (o, args) => { var receivedBytes = args.Characteristic.Value; };

The same code is working if I run the App on windows.

I tried all Plugin.BLE versions since version 3.x (including prereleases)

To provide you a background. I use the following example ( https://www.jenx.si/2020/08/13/bluetooth-low-energy-uart-service-with-xamarin-forms/ ) while I also try to connect to this Nordic BLE-uart example.

@marcusebm
Copy link

Hi all,

it seems that my "ReadCharacter_ValueUpdated" is called (Android 12 API 31).

But only 2-3 times at the beginning. After the connected give the information that no att channel is available. and no buffer for sending the nottification.

Windows is still running.

@marcusebm
Copy link

Hi all,

I could test it today and it is also running on Android 6.

But values seems not to be valid and complete. Also receiving stop working after a while.

Are there any limitations on Android devices or rules that must be followed?

@marcusebm
Copy link

After a lot of testes I see that there seems to be a limitation in the package size in Android. Something like 20 bytes?

Could anyone confirm this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants