Skip to content

Commit ac36070

Browse files
authored
Merge pull request #140 from jose-acevedoflores/jose/lang_id_optional
Make LangID optional on get_string()
2 parents 0ca8f09 + 55aecdd commit ac36070

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/class.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ pub trait UsbClass<B: UsbBus> {
4343
///
4444
/// * `index` - A string index allocated earlier with
4545
/// [`UsbAllocator`](crate::bus::UsbBusAllocator).
46-
/// * `lang_id` - The language ID for the string to retrieve.
46+
/// * `lang_id` - The language ID for the string to retrieve. If the requested lang_id is not
47+
/// valid it will default to EN_US.
4748
fn get_string(&self, index: StringIndex, lang_id: LangID) -> Option<&str> {
4849
let _ = (index, lang_id);
4950
None

src/device.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,10 @@ impl<B: UsbBus> UsbDevice<'_, B> {
567567
Err(_err) => {
568568
#[cfg(feature = "defmt")]
569569
defmt::warn!(
570-
"Receive unknown LANGID {:#06X}, reject the request",
570+
"Receive unknown LANGID {:#06X}, default to EN_US",
571571
_err.number
572572
);
573-
xfer.reject().ok();
574-
return;
573+
LangID::EN_US
575574
}
576575

577576
Ok(req_lang_id) => req_lang_id,

0 commit comments

Comments
 (0)