Skip to content

Conversation

@adria0
Copy link

@adria0 adria0 commented Nov 13, 2025

Summary
Add an example for sending messages over BLE

Related Issues
Closes #78

@CLAassistant
Copy link

CLAassistant commented Nov 13, 2025

CLA assistant check
All committers have signed the CLA.


// Get MyInfo from the first message of stream
// -----------------------------------------------------------------------
let RecievedPacket::MyInfo(my_node_info) = RecievedPacket::from(packet_rx.recv().await) else {
Copy link
Contributor

Choose a reason for hiding this comment

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

I saw this in the other example code in issue.

This is guaranteed to be the first packet sent by the firmware I assume?

Copy link
Author

Choose a reason for hiding this comment

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

I assume it! It always happen so...

use meshtastic::Message;

struct Router {
sent: VecDeque<MeshPacket>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is sent used for anything in the example, or do you just want to show that the router is informed when messages are sent by send_text() ?

Copy link
Author

Choose a reason for hiding this comment

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

Is used to get the packet id, used later when checking for the ACK

}
}

async fn get_ble_device() -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for showing discovery also, when device is not specified in the command line options.

@andrewdavidmackenzie
Copy link
Contributor

Reviewed and commented, in case it helps.
Thanks for this, I needed it when learning how to use the crate.

Arguably, it could close #63 too?
Maybe a comment in docs on packet router trait to the example could help implementers find this?

@adria0
Copy link
Author

adria0 commented Nov 14, 2025

Arguably, it could close #63 too?

I expect this!

Maybe a comment in docs on packet router trait to the example could help implementers find this?

Mmmm... @andrewdavidmackenzie is not still not clear for me the design decisions behind the PacketRouter, so not really able to comment it.

Maybe if I implement some kind of router some day it would have more sense to me?

And thanks for the review 🙌

@andrewdavidmackenzie
Copy link
Contributor

You've implemented a router here, it's just quite simple, which makes sense as there is not much other app logic that needs it.

I think for some simple sending scenarios, not needing a router at all (but supplying from node id) would make sense.

@adria0
Copy link
Author

adria0 commented Nov 14, 2025

You've implemented a router here, it's just quite simple, which makes sense as there is not much other app logic that needs it.

I would say a "real router", forwarding packets and so on.

I think for some simple sending scenarios, not needing a router at all (but supplying from node id) would make sense.

Agree

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to send a message via BLE

3 participants