Comments (7)
Android has always looked for a notification characteristic because it is required. This has never been any different.
from shiny.
@aritchie thank you for your reply. I can guarantee that with 2.7.2 subscribing to the characteristic which had no descriptor with WhenNotificationReceived
actually worked. The OnNext was called perfectly even if the EnableNotifications
failed to complete.
from shiny.
Then send a reproducible case with the issue!
from shiny.
@aritchie Yes, sure.
This is the code using the v3 of Shiny:
private async Task WhenConnected(IPeripheral P)
{
var characteristics = await P.GetAllCharacteristicsAsync();
Command = characteristics.FirstOrDefault(c => c.Uuid == BLECharacteristicCommandUuid);
if(Command != null)
{
P.NotifyCharacteristic(Command).ObserveOn(RxApp.MainThreadScheduler).Subscribe(notification =>
{
Log($"COMMAND CHANGED {Encoding.UTF8.GetString(notification.Data)}");
},
(notifyEx) => Log($"Error while enabling notifications for COMMAND. {notifyEx.Message}"));
}
}
// peripheral is IPeripheral
whenConnected = peripheral.WhenConnected().Subscribe(conn => _ = WhenConnected(conn));
In this example, when calling NotifyCharacteristic
the error handler is called and I am not able to process any notifications in the OnNext handler.
This is the code I have for version 2.7.2
var d = await peripheral.GetAllCharacteristics();
d.FirstOrDefault(_ => _.Uuid.ToGuid() == BT_CHARACTERISTIC_COMMAND_UUID);
if(d != null)
{
TaskCompletionSource<bool> enableCommandNotificationTask = new TaskCompletionSource<bool>();
CommandNotifyDisposable = Command.WhenNotificationReceived().Subscribe(g =>
{
Log(string.Format("COMMAND CHANGED {0}", Encoding.UTF8.GetString(g.Data)));
},
err => Log("Error"));
Command.EnableNotifications(true).Subscribe(encd =>
{
Log("Command notifications enabled");
},
err =>
{
Log(string.Format("Error while enabling notifications for command {0}", err.Message));
});
}
The EnableNotifications
calls the error method, however, when a notification is received on the characteristic which has no descriptor, the OnNext is called properly.
If you need more details let me know
from shiny.
Ok so really this is more of a feature request. You would like the methods NotifyCharacteristic to be EnableNotification with a separate hook method. This is something I can consider for a future release, but honestly, I don't want to support the non-standard cases. I also merged these methods because people don't understand subscribing/unsubscribing/resubscribing post reconnect. It's a support case I don't want again
from shiny.
Yes, I would like to be able to process any notification received on the a Characteristic even if it has no descriptor.
Is there something I could do to workaround that Exception at the moment?
from shiny.
Not with the current implementation that I can think of. You can always create your own implementation.
from shiny.
Related Issues (20)
- [Bug]: HOT 1
- [Bug]: Shiny Push Notification - Delegate On Entry HOT 2
- [Bug]: PushManager never returns a value from the RequestAccess task. HOT 4
- [Feature Request]: Support Push notifications for iOS Simulator HOT 1
- [Bug]: BLE CharacteristicInfo Discovery HOT 6
- [Bug]: Notification doesn't appear when the app is running HOT 3
- [Bug]: System.ObjectDisposedException: ObjectDisposed_Generic ObjectDisposed_ObjectName_Name, Android.OS.PowerManager HOT 13
- [Bug]: Notification not clickable HOT 2
- [Bug]: The devices are not disconnected with 2 Bluetooth connections HOT 1
- [Feature Request]:HttpTransferStore not Found in MAUI HOT 5
- [Bug]: The Setup Muai essentials media picker option has a bug at building time HOT 1
- Push: OnEntry / OnReceived not fired when running in background / or closed HOT 1
- [Bug]: Shiny Unregister() HOT 3
- [Feature Request]: Add Exception and Logger Property to LogStore SQLite HOT 2
- [Bug]: Push notification iOS simulator HOT 1
- [Bug]: Push notification on iOS causes multiple calls to OnReceived and app crashing HOT 7
- [Bug]: BLE Android peripheral renaming does not update peripheral advertisement name HOT 1
- [Bug]: Click on notification poppup => 'This window is already associated with an active Activity (MauiShinyJobNotify.MainActivity). HOT 4
- [Bug]: Get/Read two or more Characteristics with same serviceUuid and characteristicUuid not working properly HOT 4
- [Bug]: OnNewToken repeatadly called HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shiny.