BLE Application Framework #25
Replies: 5 comments 12 replies
-
One way I see us accomplishing Baremetal compatibility is by using (as most BLE examples do now) the It appears to be compatible with Baremetal. It can also take advantage of Threads when they are available. The only con I see to this approach is the added code size from EventQueue and its supporting dependencies. I think it may be worth it in this case though. From a recent build with mbed-os master the Another code-size-related design choice I'm debating is whether to require the use of the EDIT: The recently-added Again, I don't think the code size/RAM overhead of these classes is significant enough compared to the benefits of using them. |
Beta Was this translation helpful? Give feedback.
-
I have been thinking about this more and starting an implementation as a proof-of-concept for the software architecture. I've analyzed the code in mbed-os-example-ble a bit and started to see some common pieces that always have to be duplicated. So I started scheming with how to best encapsulate those pieces in the most modular way. Maybe I'm being a bit too creative with this, but I have been trying to come up with a framework architecture that works with all the different BLE modes of operation while trying to keep memory consumption to a minimum. I've been playing with a concept called "MixIns" that are like static decorators. Rather than composing a decorated object at runtime, it is done statically with template classes. I am also trying to avoid the "Call Super" code smell by making using of the template method pattern. I guess the use of the In all the BLE examples, regardless of the application (eg: beacon, observer, gatt server, etc), there are always the steps of initializing the BLE subsystem, possibly the Security Manager, and setting up things like Privacy and the GATT table. See a few references here:
I used the existing classes in the ARMmbed/mbed-os-ble-utils repository as a base for the framework. I think @paul-szczepanek-arm and @rajkan01 were on the right track with the In my existing code, the base class of every BLE application will be the The BLEProcess class encapsulates the standard BLE initialization that must take place for any BLE application. After the BLE instance is initialized, it performs standard initialization such as setting up preferred phys (which can be set using the JSON configuration system). It then calls the virtual
Side note: one potential issue I'm seeing with this is if the order of So, for example, the As in the above example, the Ultimately, to define custom applications, the user will have to subclass a composite I have been working on some PlantUML diagrams to show the overall architecture but they are not yet complete. I started working on some proof-of-concept code which you can check out here: https://github.com/AGlass0fMilk/mbed-os-ble-utils/tree/ble-app-framework @pan- What do you think of this so far? Do you have any ideas for an alternate framework architecture? |
Beta Was this translation helpful? Give feedback.
-
I think some testing/profiling tools would be really useful for such a framework. Beyond these i would also like to suggest a basic signal generator that could generate different type of test signals. One signal could be discrete (like values generated by the HeartRateService example). Another signal would be a continuous one, i think the sinus wave would fit best (with that we can easily notice distortions/packetlosses on the receiving side). Also the signal sampling rate should be adjustable between 1/600 - 500Hz so that we could find out safe zones for different application scenarios rapidly. |
Beta Was this translation helpful? Give feedback.
-
Is the design of the mbed-os BLE code helping or hindering efforts to make it easier to build a dev friendly interface? Seems like most of the discussion is about adding on top of what already exists. Is there any modifications we should make there that can simplify this? |
Beta Was this translation helpful? Give feedback.
-
Are there any equivalents you folks like outside of the realm of MCUs? Something you wish it could be like? I've never developed a peripheral outside of embedded uses, but I've seen folks make stuff out there like bleno2 for node, and a library for python I can't remember the name of. I have used noble and another python library I can't remember the name of to make central devices though. |
Beta Was this translation helpful? Give feedback.
-
Starting this discussion now as I'm beginning a number of new BLE-enabled projects at the moment.
I have worked on several Mbed BLE applications over the past few years and I found myself repeatedly starting projects the same way.
It's usually:
mbed-os-example-ble
mbed-os-example-ble
BLEProcess
class in mbed-os-ble-utils.What I'd like to come up with is a framework that integrates the common code from the steps above. This helps save time when starting a new BLE project, encourages the use of best practices learned by experience, and helps avoid encountering inadvertent issues like ARMmbed/mbed-os#13916 (where the solution is a non-obvious consequence of the BLE stack's implementation).
So, I'd like to get everyone's ideas for the design goals of a theoretical BLE Application Framework.
A few of mine are:
PlatformMutex
to provide synchronization)We should also be working towards providing modular out-of-the-box support for commonly-used services (BLE UART Service for debug UART, DFU Service, ???)
I'm going to start working with the code in this repository as the ideas develop.
Beta Was this translation helpful? Give feedback.
All reactions