Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bde88f6934 |
11 changed files with 8 additions and 17 deletions
|
|
@ -132,6 +132,7 @@ 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)
|
||||||
|
|
||||||
|
|
|
||||||
BIN
hardware/housing/c_its-companion-housing-bottom-2mm.3mf
Normal file
BIN
hardware/housing/c_its-companion-housing-bottom-2mm.3mf
Normal file
Binary file not shown.
BIN
hardware/housing/c_its-companion-housing-bottom-7mm.3mf
Normal file
BIN
hardware/housing/c_its-companion-housing-bottom-7mm.3mf
Normal file
Binary file not shown.
BIN
hardware/housing/c_its-companion-housing-bottom-9mm.3mf
Normal file
BIN
hardware/housing/c_its-companion-housing-bottom-9mm.3mf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
hardware/housing/c_its-companion-housing-lid.3mf
Normal file
BIN
hardware/housing/c_its-companion-housing-lid.3mf
Normal file
Binary file not shown.
Binary file not shown.
19
src/ble.rs
19
src/ble.rs
|
|
@ -110,7 +110,6 @@ 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();
|
||||||
|
|
@ -121,7 +120,6 @@ 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(",")
|
||||||
|
|
@ -134,7 +132,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, &short_name).await {
|
match advertise(&mut peripheral, &server).await {
|
||||||
Ok(conn) => {
|
Ok(conn) => {
|
||||||
info!("BLE: New client connected");
|
info!("BLE: New client connected");
|
||||||
|
|
||||||
|
|
@ -178,19 +176,16 @@ 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; 31]; // 37 bytes payload - 6 byte address
|
let mut advertiser_data = [0; 35];
|
||||||
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), // 2+ 1 byte
|
AdStructure::Flags(LE_GENERAL_DISCOVERABLE | BR_EDR_NOT_SUPPORTED),
|
||||||
AdStructure::ServiceUuids128(&[service_uuid]), // 2+16 byte = 21
|
AdStructure::ServiceUuids128(&[service_uuid]),
|
||||||
AdStructure::ShortenedLocalName(short_name.as_bytes()), // 2+ 8 byte = 31
|
|
||||||
],
|
],
|
||||||
&mut advertiser_data[..],
|
&mut advertiser_data[..],
|
||||||
)?;
|
)?;
|
||||||
|
|
@ -198,11 +193,7 @@ async fn advertise<'values, 'server, C: Controller>(
|
||||||
let advertiser = peripheral
|
let advertiser = peripheral
|
||||||
.advertise(
|
.advertise(
|
||||||
&trouble_host::advertise::AdvertisementParameters {
|
&trouble_host::advertise::AdvertisementParameters {
|
||||||
primary_phy: PhyKind::Le2M,
|
timeout: Some(embassy_time::Duration::from_secs(2)),
|
||||||
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,13 +222,12 @@ 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!(
|
||||||
"C-ITS ESP {:02x}:{:02x}:{:02x}",
|
"ESP32 C-ITS {:02x}{:02x}{:02x}",
|
||||||
serial[0],
|
serial[0],
|
||||||
serial[1],
|
serial[1],
|
||||||
serial[2]
|
serial[2]
|
||||||
);
|
);
|
||||||
let short_name = alloc::format!("V2X {:02x}{:02x}", serial[1], serial[2]); // max 8 chars!
|
spawner.spawn(ble::run(controller, name).expect("Failed to spawn BLE task"));
|
||||||
spawner.spawn(ble::run(controller, name, short_name).expect("Failed to spawn BLE task"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup GNSS:
|
// Setup GNSS:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue