diff options
-rw-r--r-- | examples/src/bin/ble_bas_peripheral.rs | 4 | ||||
-rw-r--r-- | examples/src/bin/ble_peripheral_onoff.rs | 6 | ||||
-rw-r--r-- | nrf-softdevice-macro/src/lib.rs | 8 |
3 files changed, 11 insertions, 7 deletions
diff --git a/examples/src/bin/ble_bas_peripheral.rs b/examples/src/bin/ble_bas_peripheral.rs index ff30375..511513b 100644 --- a/examples/src/bin/ble_bas_peripheral.rs +++ b/examples/src/bin/ble_bas_peripheral.rs @@ -69,7 +69,7 @@ async fn bluetooth_task(sd: &'static Softdevice) { // Run the GATT server on the connection. This returns when the connection gets disconnected. let res = gatt_server::run(&conn, &server, |e| match e { - ServerEvent::BatteryService(e) => match e { + ServerEvent::Bas(e) => match e { BatteryServiceEvent::BatteryLevelNotificationsEnabled => { info!("battery notifications enabled") } @@ -77,7 +77,7 @@ async fn bluetooth_task(sd: &'static Softdevice) { info!("battery notifications disabled") } }, - ServerEvent::FooService(e) => match e { + ServerEvent::Foo(e) => match e { FooServiceEvent::FooWrite(val) => { info!("wrote foo: {}", val); if let Err(e) = server.foo.foo_notify(&conn, val + 1) { diff --git a/examples/src/bin/ble_peripheral_onoff.rs b/examples/src/bin/ble_peripheral_onoff.rs index 82d0599..067f1d4 100644 --- a/examples/src/bin/ble_peripheral_onoff.rs +++ b/examples/src/bin/ble_peripheral_onoff.rs @@ -62,16 +62,16 @@ async fn run_bluetooth(sd: &'static Softdevice, server: &Server) { info!("advertising done!"); let res = gatt_server::run(&conn, server, |e| match e { - ServerEvent::FooService(FooServiceEvent::FooWrite(val)) => { + ServerEvent::Foo(FooServiceEvent::FooWrite(val)) => { info!("wrote foo level: {}", val); if let Err(e) = server.foo.foo_notify(&conn, val + 1) { info!("send notification error: {:?}", e); } } - ServerEvent::FooService(FooServiceEvent::FooNotificationsEnabled) => { + ServerEvent::Foo(FooServiceEvent::FooNotificationsEnabled) => { info!("notifications enabled") } - ServerEvent::FooService(FooServiceEvent::FooNotificationsDisabled) => { + ServerEvent::Foo(FooServiceEvent::FooNotificationsDisabled) => { info!("notifications disabled") } }) diff --git a/nrf-softdevice-macro/src/lib.rs b/nrf-softdevice-macro/src/lib.rs index 4766954..f78e0e6 100644 --- a/nrf-softdevice-macro/src/lib.rs +++ b/nrf-softdevice-macro/src/lib.rs @@ -78,15 +78,19 @@ pub fn gatt_server(_args: TokenStream, item: TokenStream) -> TokenStream { )); if let syn::Type::Path(p) = &field.ty { + let name_pascal = format_ident!( + "{}", + inflector::cases::pascalcase::to_pascal_case(&name.to_string()) + ); let event_enum_ty = p.path.get_ident().unwrap(); let event_enum_variant = format_ident!("{}Event", event_enum_ty); code_event_enum.extend(quote_spanned!(span=> - #event_enum_ty(#event_enum_variant), + #name_pascal(#event_enum_variant), )); code_on_write.extend(quote_spanned!(span=> if let Some(e) = self.#name.on_write(handle, data) { - return Some(#event_enum_name::#event_enum_ty(e)); + return Some(#event_enum_name::#name_pascal(e)); } )); } |