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

MicroBitUtilityService - replaces PR 178 #287

Merged

Conversation

martinwork
Copy link
Collaborator

A fresh branch from current master.
Replaces #178

TODO: How should the service and characteristic UUIDs determined?
This currently uses the micro:bit base UUID plus 1 and 2.

TODO: MICROBIT_ID_UTILITY - ID definitions have moved into codal-core

MicroBitUtilityService.h/cpp - BLE service providing replies to simple client requests
MicroBitUtilityTypes.h - Details of the service requests that support reading MicroBitLog data
MicroBitCompat.h - Define MICROBIT_ID_UTILITY for service events
MicroBitConfig.h - Macros to control creation in pairing / application mode, default pairing mode only.
MicroBit.cpp - Create service according to config macros. To create in BLEManager::init would need to pass MicroBitLog.
MicroBitBLEChar.cpp - Changed DMESGF to DMESG.

@JohnVidler JohnVidler added the enhancement New feature or request label Mar 24, 2023
@JohnVidler JohnVidler added this to the v0.2.51 milestone Mar 24, 2023
@microbit-carlos microbit-carlos modified the milestones: v0.2.51, v0.2.52 Mar 27, 2023
@microbit-carlos microbit-carlos removed this from the v0.2.52 milestone Mar 27, 2023
* a temporary fiber is created as necessary.
*/
#ifndef MicroBitUtilityService_FIBER
#define MicroBitUtilityService_FIBER 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to hold both these implementations in the final revision @martinwork? or shall we just pick one? (e.g. the event based approach?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please pick one - whichever you think is the best idea.

@martinwork
Copy link
Collaborator Author

@finneyj I updated from master and removed the MicroBitUtilityService_FIBER option. It compiles, but I haven't tested it yet.

@martinwork
Copy link
Collaborator Author

@finneyj I tested it now, using https://github.com/martinwork/microbit-v2-samples/tree/test-mydata.

I had to modify MicroBit.cpp for the panic 071 problem. Would you like me to add a commit for that here? Make a separate PR?

@finneyj
Copy link
Contributor

finneyj commented May 25, 2023

Thanks @martinwork!

Yes please - working up a PR for the 071 panic would be fabulous, thank you!

{
if ( workspace)
{
if ( workspace->lock)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this safe @martinwork? If I understand correctly, this code will silently ignore incoming requests if a request is already being processed? Is that conventional for BLE apps? Seems quite lossy?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe my thinking was that the each request would expect a reply (both current ones do), and the client wouldn't send multiple requests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's ok - we just need to record somewhere in docs that we don't permit overlapping transactions.

if ( workspace->replyState == replyStateClear)
{
int block = min( request->batchlen, sizeof( reply_t) - offsetof( reply_t, data));
int result = log.readData(workspace->reply.data, request->index, block, (DataFormat) request->format, request->length);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean we're very likely to see a sequence of 20 byte read operations from the log @martinwork? That might add quite a bit of latency, compared to one larger read operation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't most of the 20 byte reads be from uBit,log's cache? I suppose there's a fair bit of code for each read to arrive at the memcpy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you're quite right! I forgot we applied the block cache from the file system API into the log reads... All good there then.

I'm not worried about the cache lookup/memcpy cost. It will be insignificant compared to all the BLE/I2C latency...

@finneyj
Copy link
Contributor

finneyj commented May 25, 2023

Generally looks good to me @martinwork! Thanks for the contribution!

I do think we should keep this aligned with the USB based mailbox implementation we drafted for reading the log in due course - just so that we can keep and consistent API for both USB and BLE based transactions. This is already pretty close though, and seeing as we don't want to hold this up any longer, I suggest we tackle that down the line - perhaps by aligning the USB implementation with your BLE one here...

@martinwork
Copy link
Collaborator Author

Thanks for checking it @finneyj

@finneyj
Copy link
Contributor

finneyj commented May 25, 2023

I'm happy to merge then @martinwork - thanks for the work and quick responses. Unless you have any further thoughts @JohnVidler?

@JohnVidler JohnVidler added this to the v0.2.57 milestone Jul 3, 2023
@JohnVidler JohnVidler merged commit 2b8b410 into lancaster-university:master Jul 13, 2023
@microbit-carlos microbit-carlos modified the milestones: v0.2.57, v0.2.56 Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants