Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3d92462ed | ||
|
|
e47266f410 | ||
|
|
9a820356ff | ||
| 75bad1e97a |
11 changed files with 17 additions and 8 deletions
|
|
@ -132,7 +132,6 @@ Additional hardware:
|
||||||
The housing is a FreeCAD model at [hardware/housing/c_its-companion-housing.FCStd](./hardware/housing/c_its-companion-housing.FCStd), but the same folder also contains finished 3mf models that can be loaded into a 3D printer slicer.
|
The housing is a FreeCAD model at [hardware/housing/c_its-companion-housing.FCStd](./hardware/housing/c_its-companion-housing.FCStd), but the same folder also contains finished 3mf models that can be loaded into a 3D printer slicer.
|
||||||
Exports are available for:
|
Exports are available for:
|
||||||
|
|
||||||
- 2mm: no battery (just display standoffs)
|
|
||||||
- 7mm: EREMIT 654060 (6.5x40x60 mm) LiPo battery
|
- 7mm: EREMIT 654060 (6.5x40x60 mm) LiPo battery
|
||||||
- 9mm: Some 9x40x60 mm LiPo battery, e.g. LP803860 (2000 mAh)
|
- 9mm: Some 9x40x60 mm LiPo battery, e.g. LP803860 (2000 mAh)
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
hardware/housing/c_its-companion-housing-bottom-v1.1-7mm.3mf
Normal file
BIN
hardware/housing/c_its-companion-housing-bottom-v1.1-7mm.3mf
Normal file
Binary file not shown.
BIN
hardware/housing/c_its-companion-housing-bottom-v1.1-9mm.3mf
Normal file
BIN
hardware/housing/c_its-companion-housing-bottom-v1.1-9mm.3mf
Normal file
Binary file not shown.
BIN
hardware/housing/c_its-companion-housing-lid-v1.1.3mf
Normal file
BIN
hardware/housing/c_its-companion-housing-lid-v1.1.3mf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
19
src/ble.rs
19
src/ble.rs
|
|
@ -110,6 +110,7 @@ pub async fn run(
|
||||||
CONTROLLER_SLOTS,
|
CONTROLLER_SLOTS,
|
||||||
>,
|
>,
|
||||||
name: alloc::string::String,
|
name: alloc::string::String,
|
||||||
|
short_name: alloc::string::String,
|
||||||
) {
|
) {
|
||||||
let mut resources: HostResources<DefaultPacketPool, CONNECTIONS_MAX, L2CAP_CHANNELS_MAX> =
|
let mut resources: HostResources<DefaultPacketPool, CONNECTIONS_MAX, L2CAP_CHANNELS_MAX> =
|
||||||
HostResources::new();
|
HostResources::new();
|
||||||
|
|
@ -120,6 +121,7 @@ pub async fn run(
|
||||||
..
|
..
|
||||||
} = stack.build();
|
} = stack.build();
|
||||||
|
|
||||||
|
info!("BLE name: {name} (short: {short_name})");
|
||||||
info!(
|
info!(
|
||||||
"Starting advertising and GATT service for {}",
|
"Starting advertising and GATT service for {}",
|
||||||
crate::util::get_rx_feature_list().join(",")
|
crate::util::get_rx_feature_list().join(",")
|
||||||
|
|
@ -132,7 +134,7 @@ pub async fn run(
|
||||||
|
|
||||||
let _ = embassy_futures::join::join(ble_task(runner), async {
|
let _ = embassy_futures::join::join(ble_task(runner), async {
|
||||||
loop {
|
loop {
|
||||||
match advertise(&mut peripheral, &server).await {
|
match advertise(&mut peripheral, &server, &short_name).await {
|
||||||
Ok(conn) => {
|
Ok(conn) => {
|
||||||
info!("BLE: New client connected");
|
info!("BLE: New client connected");
|
||||||
|
|
||||||
|
|
@ -176,16 +178,19 @@ pub fn update(payload: BleSendable) {
|
||||||
async fn advertise<'values, 'server, C: Controller>(
|
async fn advertise<'values, 'server, C: Controller>(
|
||||||
peripheral: &mut Peripheral<'values, C, DefaultPacketPool>,
|
peripheral: &mut Peripheral<'values, C, DefaultPacketPool>,
|
||||||
server: &'server Server<'values>,
|
server: &'server Server<'values>,
|
||||||
|
// name in advertisement, max. 8 characters
|
||||||
|
short_name: &'values str,
|
||||||
) -> Result<GattConnection<'values, 'server, DefaultPacketPool>, BleHostError<C::Error>> {
|
) -> Result<GattConnection<'values, 'server, DefaultPacketPool>, BleHostError<C::Error>> {
|
||||||
let mut advertiser_data = [0; 35];
|
let mut advertiser_data = [0; 31]; // 37 bytes payload - 6 byte address
|
||||||
let service_uuid = Uuid::from(0xc0b7_0000_d4f4_4000_ada8_f99a_02ee_315c_u128)
|
let service_uuid = Uuid::from(0xc0b7_0000_d4f4_4000_ada8_f99a_02ee_315c_u128)
|
||||||
.as_raw()
|
.as_raw()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let len = AdStructure::encode_slice(
|
let len = AdStructure::encode_slice(
|
||||||
&[
|
&[
|
||||||
AdStructure::Flags(LE_GENERAL_DISCOVERABLE | BR_EDR_NOT_SUPPORTED),
|
AdStructure::Flags(LE_GENERAL_DISCOVERABLE | BR_EDR_NOT_SUPPORTED), // 2+ 1 byte
|
||||||
AdStructure::ServiceUuids128(&[service_uuid]),
|
AdStructure::ServiceUuids128(&[service_uuid]), // 2+16 byte = 21
|
||||||
|
AdStructure::ShortenedLocalName(short_name.as_bytes()), // 2+ 8 byte = 31
|
||||||
],
|
],
|
||||||
&mut advertiser_data[..],
|
&mut advertiser_data[..],
|
||||||
)?;
|
)?;
|
||||||
|
|
@ -193,7 +198,11 @@ async fn advertise<'values, 'server, C: Controller>(
|
||||||
let advertiser = peripheral
|
let advertiser = peripheral
|
||||||
.advertise(
|
.advertise(
|
||||||
&trouble_host::advertise::AdvertisementParameters {
|
&trouble_host::advertise::AdvertisementParameters {
|
||||||
timeout: Some(embassy_time::Duration::from_secs(2)),
|
primary_phy: PhyKind::Le2M,
|
||||||
|
secondary_phy: PhyKind::Le2M,
|
||||||
|
timeout: Some(embassy_time::Duration::from_secs(3)),
|
||||||
|
interval_min: embassy_time::Duration::from_millis(150),
|
||||||
|
interval_max: embassy_time::Duration::from_secs(1),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
Advertisement::ConnectableScannableUndirected {
|
Advertisement::ConnectableScannableUndirected {
|
||||||
|
|
|
||||||
|
|
@ -222,12 +222,13 @@ async fn main(spawner: Spawner) -> ! {
|
||||||
let controller = ble::make_controller(peripherals.BT);
|
let controller = ble::make_controller(peripherals.BT);
|
||||||
let serial = &mac.as_bytes()[3..6];
|
let serial = &mac.as_bytes()[3..6];
|
||||||
let name = alloc::format!(
|
let name = alloc::format!(
|
||||||
"ESP32 C-ITS {:02x}{:02x}{:02x}",
|
"C-ITS ESP {:02x}:{:02x}:{:02x}",
|
||||||
serial[0],
|
serial[0],
|
||||||
serial[1],
|
serial[1],
|
||||||
serial[2]
|
serial[2]
|
||||||
);
|
);
|
||||||
spawner.spawn(ble::run(controller, name).expect("Failed to spawn BLE task"));
|
let short_name = alloc::format!("V2X {:02x}{:02x}", serial[1], serial[2]); // max 8 chars!
|
||||||
|
spawner.spawn(ble::run(controller, name, short_name).expect("Failed to spawn BLE task"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup GNSS:
|
// Setup GNSS:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue