├── .gitignore ├── renovate.json ├── src ├── utils │ ├── mod.rs │ ├── array.rs │ ├── byteutil.rs │ └── crc16.rs ├── lib.rs ├── message │ ├── fit_check.rs │ ├── response.rs │ ├── set_noise_reduction.rs │ ├── mute_earbud.rs │ ├── touch_updated.rs │ ├── find_my_bud.rs │ ├── voice_wakeup_listening_status.rs │ ├── anc_updated.rs │ ├── set_touchpad_option.rs │ ├── touchpad_action.rs │ ├── manager.rs │ ├── usage_report.rs │ ├── simple.rs │ ├── status_updated.rs │ ├── bytebuff.rs │ ├── lock_touchpad.rs │ ├── ambient_mode.rs │ ├── ids.rs │ ├── bud_property.rs │ ├── mod.rs │ ├── debug.rs │ └── extended_status_updated.rs └── model.rs ├── Cargo.toml ├── examples ├── send.rs ├── find_my_buds.rs └── receive.rs ├── README.md ├── Cargo.lock └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | src/main.rs 3 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /src/utils/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod byteutil; 2 | pub mod crc16; 3 | pub mod array; 4 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | pub mod message; 3 | pub mod model; 4 | pub mod utils; 5 | -------------------------------------------------------------------------------- /src/message/fit_check.rs: -------------------------------------------------------------------------------- 1 | use super::{ 2 | ids, 3 | simple::{self, Simple}, 4 | }; 5 | 6 | pub fn new(run: bool) -> Simple { 7 | simple::new(ids::CHECK_THE_FIT_OF_EARBUDS, { 8 | if run { 9 | 1 10 | } else { 11 | 0 12 | } 13 | }) 14 | } 15 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "galaxy_buds_rs" 3 | version = "0.2.10" 4 | authors = ["jojii "] 5 | edition = "2018" 6 | readme = "README.md" 7 | license = "GPL-3.0" 8 | license-file = "LICENSE" 9 | repository = "https://github.com/JojiiOfficial/GalaxyBuds-rs" 10 | description = "The Galaxy Buds rfcomm protocol reverse engineered" 11 | 12 | [dependencies] 13 | async-std = "1.12" 14 | bluetooth-serial-port-async = "0.6" 15 | serde = { version = "1.0", features = ["derive"] } 16 | -------------------------------------------------------------------------------- /src/utils/array.rs: -------------------------------------------------------------------------------- 1 | pub fn arraycopy(src: &[T], src_pos: usize, dest: &mut Vec, dest_post: usize, length: usize) 2 | where 3 | T: Copy + Default, 4 | { 5 | if length + dest_post > dest.len() { 6 | dest.resize(length + dest_post, T::default()); 7 | } 8 | 9 | dest[dest_post..(length + dest_post)].clone_from_slice(&src[src_pos..(length + src_pos)]); 10 | 11 | /* for i in 0..length { */ 12 | /* dest[i + dest_post] = src[i + src_pos]; */ 13 | /* } */ 14 | } 15 | -------------------------------------------------------------------------------- /src/message/response.rs: -------------------------------------------------------------------------------- 1 | use super::{ids, simple}; 2 | 3 | pub fn new_status_updated() -> simple::Simple { 4 | simple::new_response(ids::STATUS_UPDATED, 0) 5 | } 6 | 7 | pub fn new_extended_status_updated() -> simple::Simple { 8 | simple::new_response(ids::EXTENDED_STATUS_UPDATED, 0) 9 | } 10 | 11 | pub fn new_version_info() -> simple::Simple { 12 | simple::new_response(ids::VERSION_INFO, 0) 13 | } 14 | 15 | pub fn new_voice_wake_up_event() -> simple::Simple { 16 | simple::new_response(ids::VOICE_WAKE_UP_EVENT, 0) 17 | } 18 | -------------------------------------------------------------------------------- /src/message/set_noise_reduction.rs: -------------------------------------------------------------------------------- 1 | use super::{ids, Payload}; 2 | 3 | /// Enable/Disable ANC for your earbuds 4 | #[derive(Debug, Clone, Copy)] 5 | pub struct SetNoiseReduction { 6 | pub noise_reduction: bool, 7 | } 8 | 9 | pub fn new(noise_reduction: bool) -> SetNoiseReduction { 10 | SetNoiseReduction { noise_reduction } 11 | } 12 | 13 | impl Payload for SetNoiseReduction { 14 | fn get_data(&self) -> Vec { 15 | vec![self.noise_reduction.into()] 16 | } 17 | 18 | fn get_id(&self) -> u8 { 19 | ids::SET_NOISE_REDUCTION 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/message/mute_earbud.rs: -------------------------------------------------------------------------------- 1 | use super::{ids, Payload}; 2 | 3 | // Only available in FindMyGear mode 4 | #[derive(Debug)] 5 | pub struct MuteEarbud { 6 | pub left_muted: bool, 7 | pub right_muted: bool, 8 | } 9 | 10 | pub fn new(left_muted: bool, right_muted: bool) -> MuteEarbud { 11 | MuteEarbud { 12 | left_muted, 13 | right_muted, 14 | } 15 | } 16 | 17 | impl Payload for MuteEarbud { 18 | fn get_data(&self) -> Vec { 19 | vec![self.left_muted.into(), self.right_muted.into()] 20 | } 21 | 22 | fn get_id(&self) -> u8 { 23 | ids::MUTE_EARBUD 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/message/touch_updated.rs: -------------------------------------------------------------------------------- 1 | use super::{ids, Payload}; 2 | 3 | #[derive(Debug, Clone, Copy)] 4 | pub struct TouchUpdated { 5 | pub status: bool, 6 | } 7 | 8 | /// New touch updated payload 9 | pub fn new(arr: &[u8]) -> TouchUpdated { 10 | TouchUpdated { 11 | status: arr[0] == 1, 12 | } 13 | } 14 | 15 | impl Payload for TouchUpdated { 16 | fn get_id(&self) -> u8 { 17 | ids::TOUCH_UPDATED 18 | } 19 | } 20 | 21 | // Allow Into TouchUpdated from message 22 | impl Into for super::Message { 23 | fn into(self) -> TouchUpdated { 24 | new(self.get_payload_bytes()) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/message/find_my_bud.rs: -------------------------------------------------------------------------------- 1 | use super::{ids, Payload}; 2 | 3 | /// Find my bud 4 | /// set start to true and send the payload to start the 5 | /// feature. Set start to false and send the payloaod again 6 | /// to stop it. 7 | #[derive(Debug, Clone, Copy)] 8 | pub struct FindMyBud { 9 | pub start: bool, 10 | } 11 | 12 | pub fn new(start: bool) -> FindMyBud { 13 | FindMyBud { start } 14 | } 15 | 16 | impl Payload for FindMyBud { 17 | fn get_data(&self) -> Vec { 18 | vec![] 19 | } 20 | 21 | fn get_id(&self) -> u8 { 22 | if self.start { 23 | ids::FIND_MY_EARBUDS_START 24 | } else { 25 | ids::FIND_MY_EARBUDS_STOP 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/message/voice_wakeup_listening_status.rs: -------------------------------------------------------------------------------- 1 | use super::{ids, Payload}; 2 | 3 | #[derive(Debug, Clone, Copy)] 4 | pub struct VoicewakeUpListeningStatus { 5 | pub voice_wakeup_listening_status: bool, 6 | } 7 | 8 | pub fn new(arr: &[u8]) -> VoicewakeUpListeningStatus { 9 | VoicewakeUpListeningStatus { 10 | voice_wakeup_listening_status: arr[0] == 1, 11 | } 12 | } 13 | 14 | impl Payload for VoicewakeUpListeningStatus { 15 | fn get_id(&self) -> u8 { 16 | ids::VOICE_WAKE_UP_LISTENING_STATUS 17 | } 18 | } 19 | 20 | impl Into for super::Message { 21 | fn into(self) -> VoicewakeUpListeningStatus { 22 | new(self.get_payload_bytes()) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/message/anc_updated.rs: -------------------------------------------------------------------------------- 1 | use super::{ids, Payload}; 2 | 3 | // Whether the buds live changed the anc status by a touchpad event 4 | #[derive(Debug, Clone, Copy)] 5 | pub struct AncModeUpdated { 6 | pub anc_enabled: bool, 7 | } 8 | 9 | impl AncModeUpdated { 10 | pub fn new(arr: &[u8]) -> Self { 11 | Self { 12 | anc_enabled: arr[0] == 1, 13 | } 14 | } 15 | } 16 | 17 | impl Payload for AncModeUpdated { 18 | fn get_id(&self) -> u8 { 19 | ids::NOISE_REDUCTION_MODE_UPDATE 20 | } 21 | } 22 | 23 | // Allow parsing Message to a StatusUpdate 24 | impl Into for super::Message { 25 | fn into(self) -> AncModeUpdated { 26 | AncModeUpdated::new(self.get_payload_bytes()) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/message/set_touchpad_option.rs: -------------------------------------------------------------------------------- 1 | use super::{ 2 | bud_property::{BudProperty, TouchpadOption}, 3 | ids, Payload, 4 | }; 5 | 6 | /// Lock or unlock the touchpad 7 | #[derive(Debug, Clone, Copy)] 8 | pub struct SetTouchpadOption { 9 | left_option: TouchpadOption, 10 | right_option: TouchpadOption, 11 | } 12 | 13 | pub fn new(left_option: TouchpadOption, right_option: TouchpadOption) -> SetTouchpadOption { 14 | SetTouchpadOption { 15 | left_option, 16 | right_option, 17 | } 18 | } 19 | 20 | impl Payload for SetTouchpadOption { 21 | fn get_data(&self) -> Vec { 22 | vec![self.left_option.encode(), self.right_option.encode()] 23 | } 24 | 25 | fn get_id(&self) -> u8 { 26 | ids::SET_TOUCHPAD_OPTION 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/message/touchpad_action.rs: -------------------------------------------------------------------------------- 1 | use super::{bud_property, ids, Payload}; 2 | 3 | #[derive(Debug, Clone, Copy)] 4 | pub struct TouchAction { 5 | pub side: bud_property::Side, 6 | pub touch_count: u8, 7 | } 8 | 9 | /// New touch updated payload 10 | pub fn new(arr: &[u8]) -> TouchAction { 11 | TouchAction { 12 | side: { 13 | if arr[0] == 1 { 14 | bud_property::Side::Left 15 | } else { 16 | bud_property::Side::Right 17 | } 18 | }, 19 | touch_count: arr[1], 20 | } 21 | } 22 | 23 | impl Payload for TouchAction { 24 | fn get_id(&self) -> u8 { 25 | ids::TOUCHPAD_ACTION 26 | } 27 | } 28 | 29 | // Allow Into TouchAction from message 30 | impl Into for super::Message { 31 | fn into(self) -> TouchAction { 32 | new(self.get_payload_bytes()) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/message/manager.rs: -------------------------------------------------------------------------------- 1 | use super::{ids, Payload}; 2 | 3 | /// Enable/Disable ANC for your earbuds 4 | #[derive(Debug, Clone, Copy)] 5 | pub struct SetManagerInfo { 6 | pub client_type: u8, // WearableApp = 1, others unknow 7 | pub is_samsung_device: bool, 8 | pub android_sdk: u8, 9 | } 10 | 11 | pub fn new(is_samsung_device: bool, android_sdk: u8) -> SetManagerInfo { 12 | SetManagerInfo { 13 | client_type: 1, 14 | is_samsung_device, 15 | android_sdk, 16 | } 17 | } 18 | 19 | impl Payload for SetManagerInfo { 20 | fn get_data(&self) -> Vec { 21 | vec![ 22 | self.client_type, 23 | { 24 | if self.is_samsung_device { 25 | 1 26 | } else { 27 | 2 28 | } 29 | }, 30 | self.android_sdk, 31 | ] 32 | } 33 | 34 | fn get_id(&self) -> u8 { 35 | ids::MANAGER_INFO 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/message/usage_report.rs: -------------------------------------------------------------------------------- 1 | use crate::{message::bytebuff::ByteBuff, utils::byteutil}; 2 | use std::collections::HashMap; 3 | 4 | use super::{ids, Payload}; 5 | 6 | #[derive(Debug)] 7 | pub struct UsageReport { 8 | data: HashMap, 9 | } 10 | 11 | impl UsageReport { 12 | pub fn new(buf: &[u8]) -> Option { 13 | let buff = ByteBuff::new(&buf); 14 | let len = byteutil::to_u8(buff.get(0)) as usize; 15 | 16 | if buff.len() - 1 != len * 9 { 17 | return None; 18 | } 19 | 20 | let mut data: HashMap = HashMap::new(); 21 | 22 | for i in 0..len { 23 | let pos = i * 9 + 1; 24 | let s_sub = buff.range(pos, 5); 25 | let key = String::from_utf8(s_sub.to_vec()).unwrap(); 26 | let val = buff.get_int(pos + 5); 27 | data.insert(key, val); 28 | } 29 | 30 | Some(UsageReport { data }) 31 | } 32 | } 33 | 34 | pub struct UsageReportSend; 35 | 36 | impl Payload for UsageReportSend { 37 | fn get_id(&self) -> u8 { 38 | ids::USAGE_REPORT 39 | } 40 | 41 | fn get_data(&self) -> Vec { 42 | vec![0] 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/utils/byteutil.rs: -------------------------------------------------------------------------------- 1 | pub fn to_u8(b: u8) -> i32 { 2 | b as i32 & 255 3 | } 4 | 5 | pub fn int_to_u32(v: u32) -> u32 { 6 | v & 4294967295 7 | } 8 | 9 | pub fn value_of_left(b: u8) -> u8 { 10 | (b & 0xF0) >> 4 11 | } 12 | 13 | pub fn value_of_right(b: u8) -> u8 { 14 | b & 0x0F 15 | } 16 | 17 | pub fn from_short(i: i32) -> [u8; 2] { 18 | [i as u8, (i >> 8) as u8] 19 | } 20 | 21 | pub fn to_short(arr: &[u8], offset: usize) -> i16 { 22 | ((arr[offset + 1] as i16 & 0xFF) << 8) | (arr[offset] as i16 & 0xFF) 23 | } 24 | 25 | pub fn calc_current(byte: i16) -> f64 { 26 | let float = byte as f64 * 1.0E-4; 27 | let formatted = format!("{}", float); 28 | 29 | if formatted.len() > 6 { 30 | formatted[0..6].to_string().parse::().unwrap_or(float) 31 | } else { 32 | float 33 | } 34 | } 35 | 36 | pub fn to_serial_number(arr: &[u8], offset: usize, len: usize) -> String { 37 | let mut sn_arr: Vec = Vec::new(); 38 | 39 | for i in 0..len { 40 | sn_arr.push(arr[i + offset]); 41 | if sn_arr[i] == 0 { 42 | return "".to_string(); 43 | } 44 | } 45 | 46 | String::from_utf8(sn_arr).unwrap_or_default() 47 | } 48 | -------------------------------------------------------------------------------- /examples/send.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | use galaxy_buds_rs::message::{self, bud_property::EqualizerType, Payload}; // Note: Import 'Payload' to be able to convert the message to bytes 3 | 4 | use async_std::io::prelude::*; 5 | use bluetooth_serial_port_async::{BtAddr, BtProtocol, BtSocket}; /* https://crates.io/crates/bluetooth-serial-port-async */ 6 | use std::{env, error::Error, str::FromStr}; 7 | 8 | async fn run() -> Result<(), Box> { 9 | let address = env::args().nth(1).unwrap(); 10 | 11 | let mut socket = BtSocket::new(BtProtocol::RFCOMM).expect("RFCOMM"); 12 | socket 13 | .connect(BtAddr::from_str(address.as_ref()).expect("Address")) 14 | .expect("Socket not connecting"); 15 | 16 | // Get the stream of the socket. Only call this function 17 | // once and keep using the stream 18 | let mut stream = socket.get_stream(); 19 | 20 | // Lock the touchpads 21 | let send_msg = message::lock_touchpad::new(true); 22 | stream.write(&send_msg.to_byte_array()).await?; 23 | 24 | // Set the equalizer to 'bass boost' 25 | let send_msg = message::simple::new_equalizer(EqualizerType::BassBoost); 26 | stream.write(&send_msg.to_byte_array()).await?; 27 | 28 | Ok(()) 29 | } 30 | 31 | fn main() -> Result<(), Box> { 32 | async_std::task::block_on(run()) 33 | } 34 | -------------------------------------------------------------------------------- /src/message/simple.rs: -------------------------------------------------------------------------------- 1 | use super::{ 2 | bud_property::{BudProperty, EqualizerType}, 3 | ids, simple, Payload, 4 | }; 5 | 6 | #[derive(Debug, Clone, Copy)] 7 | pub struct Simple { 8 | pub data: u8, 9 | msg_id: u8, 10 | response: bool, 11 | } 12 | 13 | /// New simple message 14 | pub fn new(msg_id: u8, data: u8) -> Simple { 15 | Simple { 16 | msg_id, 17 | data, 18 | response: false, 19 | } 20 | } 21 | 22 | /// New simple response 23 | pub fn new_response(msg_id: u8, data: u8) -> Simple { 24 | Simple { 25 | msg_id, 26 | data, 27 | response: true, 28 | } 29 | } 30 | 31 | impl Payload for Simple { 32 | fn get_data(&self) -> Vec { 33 | vec![self.data] 34 | } 35 | 36 | fn get_id(&self) -> u8 { 37 | self.msg_id 38 | } 39 | 40 | fn is_response(&self) -> bool { 41 | self.response 42 | } 43 | } 44 | 45 | // 'simple' based messages used in the protocol 46 | 47 | pub fn new_equalizer(d: EqualizerType) -> simple::Simple { 48 | simple::new(ids::EQUALIZER, d.encode()) 49 | } 50 | 51 | pub fn new_adjust_sound_sync(adjust: bool) -> simple::Simple { 52 | simple::new(ids::ADJUST_SOUND_SYNC, adjust.into()) 53 | } 54 | 55 | pub fn new_voice_noti_prepare(status: bool) -> simple::Simple { 56 | simple::new(ids::VOICE_NOTI_STATUS, status.into()) 57 | } 58 | -------------------------------------------------------------------------------- /src/message/status_updated.rs: -------------------------------------------------------------------------------- 1 | use super::bud_property::{BudProperty, Placement, Side}; 2 | use super::{ids, Payload}; 3 | 4 | #[derive(Debug, Clone, Copy)] 5 | pub struct StatusUpdate { 6 | pub revision: u8, 7 | pub battery_left: i8, 8 | pub battery_right: i8, 9 | pub coupled: bool, 10 | pub primary_earbud: u8, 11 | pub placement_left: Placement, 12 | pub placement_right: Placement, 13 | pub wearing_left: bool, 14 | pub wearing_right: bool, 15 | pub battery_case: i8, 16 | } 17 | 18 | pub fn new(arr: &[u8]) -> StatusUpdate { 19 | let placement_left = Placement::value(arr[5], Side::Left); 20 | let placement_right = Placement::value(arr[5], Side::Right); 21 | 22 | StatusUpdate { 23 | revision: arr[0], 24 | battery_left: arr[1] as i8, 25 | battery_right: arr[2] as i8, 26 | coupled: arr[3] == 1, 27 | primary_earbud: arr[4], 28 | placement_left, 29 | placement_right, 30 | wearing_left: placement_left == Placement::Ear, 31 | wearing_right: placement_right == Placement::Ear, 32 | battery_case: arr[6] as i8, 33 | } 34 | } 35 | 36 | impl Payload for StatusUpdate { 37 | fn get_id(&self) -> u8 { 38 | ids::STATUS_UPDATED 39 | } 40 | } 41 | 42 | // Allow parsing Message to a StatusUpdate 43 | impl Into for super::Message { 44 | fn into(self) -> StatusUpdate { 45 | new(self.get_payload_bytes()) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GalaxyBuds-rs 2 | [![crates](https://img.shields.io/crates/dv/galaxy_buds_rs?style=flat-square)](https://crates.io/crates/galaxy_buds_rs) 3 | ![PRs](https://img.shields.io/badge/PRs-welcome-56cc14?style=flat-square) 4 | 5 | A reverse engineered rust wrapper for the GalaxyBuds bluetooth protocol. Can be used to communicate with your earbuds using rust. 6 | You can find a cli tool controlling your Earbuds on linux [here](https://github.com/JojiiOfficial/LiveBudsCli) 7 | 8 | #### To use: 9 | Add this to your Cargo.toml 10 | ``` 11 | galaxy_buds_rs = "0.2.1" 12 | ``` 13 | Or if you have `cargo edit`: 14 | ``` 15 | cargo add galaxy_buds_rs 16 | ``` 17 | 18 | # Features 19 | 20 | ### Receiving 21 | - [x] Status update 22 | - [x] Extended status update 23 | - [x] Get all debug data 24 | - [x] Touch updated 25 | - [x] Voice wakeup listening update 26 | - [x] Touchpad tap action 27 | - [ ] Version info 28 | 29 | ### Sending 30 | - [x] Un/Lock touchpad 31 | - [x] Set noisereduction 32 | - [x] Set Equalizer 33 | - [x] Adjust sound sync 34 | - [x] Mute earbud 35 | - [x] Find my earbuds 36 | - [x] Prepare voice notification (notifications TTS) 37 | - [x] Set touchpad option 38 | - [ ] Update time 39 | 40 | # Examples 41 | 42 | ### Receive 43 | Set the `address` value in `examples/receive.rs` to your Buds' mac address and run following: 44 | ```bash 45 | cargo --example receive 46 | ``` 47 | 48 | ### Send 49 | Set the `address` value in `examples/send.rs` to your Buds' mac address and run following: 50 | ```bash 51 | cargo --example send 52 | ``` 53 | -------------------------------------------------------------------------------- /examples/find_my_buds.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | use galaxy_buds_live_rs::message::{self, Payload}; // Note: Import 'Payload' to be able to convert the message to bytes 3 | 4 | use async_std::io::prelude::*; 5 | use bluetooth_serial_port_async::{BtAddr, BtProtocol, BtSocket}; /* https://crates.io/crates/bluetooth-serial-port-async */ 6 | use std::{error::Error, str::FromStr, thread::sleep, time::Duration}; 7 | 8 | async fn run() -> Result<(), Box> { 9 | let address = ""; 10 | 11 | let mut socket = BtSocket::new(BtProtocol::RFCOMM).unwrap(); 12 | socket.connect(&BtAddr::from_str(address).unwrap()).unwrap(); 13 | 14 | // Get the stream of the socket. Only call this function 15 | // once and keep using the stream 16 | let mut stream = socket.get_stream(); 17 | 18 | let mut find = message::find_my_bud::new(true); 19 | 20 | // Start making noise 21 | stream.write(&find.to_byte_array()).await?; 22 | sleep(Duration::from_secs(3)); 23 | 24 | // mute left 25 | let mute = message::mute_earbud::new(true, false); 26 | stream.write(&mute.to_byte_array()).await?; 27 | sleep(Duration::from_secs(3)); 28 | 29 | // mute right 30 | let mute = message::mute_earbud::new(false, true); 31 | stream.write(&mute.to_byte_array()).await?; 32 | sleep(Duration::from_secs(3)); 33 | 34 | // stop 35 | find.start = false; 36 | stream.write(&find.to_byte_array()).await?; 37 | 38 | Ok(()) 39 | } 40 | 41 | fn main() -> Result<(), Box> { 42 | async_std::task::block_on(run()) 43 | } 44 | -------------------------------------------------------------------------------- /examples/receive.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | use galaxy_buds_rs::{ 3 | message::{self, ids, Message}, 4 | model::Model, 5 | }; 6 | 7 | use async_std::io::prelude::*; 8 | use bluetooth_serial_port_async::{BtAddr, BtProtocol, BtSocket}; 9 | use std::{env, error::Error, str::FromStr}; 10 | 11 | async fn run() -> Result<(), Box> { 12 | let address = env::args().nth(1).unwrap(); 13 | 14 | let mut socket = BtSocket::new(BtProtocol::RFCOMM).unwrap(); 15 | socket 16 | .connect(BtAddr::from_str(address.as_ref()).unwrap()) 17 | .unwrap(); 18 | 19 | // Get the stream of the socket. Only call this function 20 | // once and keep using the stream 21 | let mut stream = socket.get_stream(); 22 | 23 | let mut buffer = [0; 2048]; 24 | loop { 25 | let num_bytes_read = stream.read(&mut buffer[..]).await.unwrap(); 26 | let buff = &buffer[0..num_bytes_read]; 27 | 28 | let id = buff[3].to_be(); 29 | let message = Message::new(buff, Model::Buds); 30 | println!("{:?}", buff); 31 | 32 | if id == 242 { 33 | continue; 34 | } 35 | 36 | // Print touchpad taps 37 | if id == ids::TOUCHPAD_ACTION { 38 | let msg: message::touchpad_action::TouchAction = message.into(); 39 | println!("{:?}", msg); 40 | continue; 41 | } 42 | 43 | // Print status updates 44 | if id == ids::STATUS_UPDATED { 45 | let msg: message::status_updated::StatusUpdate = message.into(); 46 | println!("{:?}", msg); 47 | continue; 48 | } 49 | } 50 | } 51 | 52 | fn main() -> Result<(), Box> { 53 | async_std::task::block_on(run()) 54 | } 55 | -------------------------------------------------------------------------------- /src/message/bytebuff.rs: -------------------------------------------------------------------------------- 1 | use std::convert::TryInto; 2 | 3 | use super::super::utils::byteutil; 4 | 5 | pub(crate) struct ByteBuff<'a> { 6 | data: &'a [u8], 7 | } 8 | 9 | impl<'a> ByteBuff<'a> { 10 | // Create a new ByteBuff 11 | pub(crate) fn new(arr: &[u8]) -> ByteBuff { 12 | ByteBuff { data: arr } 13 | } 14 | 15 | #[inline] 16 | pub fn len(&self) -> usize { 17 | self.data.len() 18 | } 19 | 20 | #[inline] 21 | pub fn range(&self, offset: usize, len: usize) -> &[u8] { 22 | &self.data[offset..offset + len] 23 | } 24 | 25 | pub fn get_int(&self, offset: usize) -> u32 { 26 | let b: [u8; 4] = self.data[offset..offset + 4].try_into().unwrap(); 27 | u32::from_le_bytes(b) 28 | } 29 | 30 | // Get a value at the given offset 31 | pub fn get(&self, offset: usize) -> u8 { 32 | self.data[offset] 33 | } 34 | 35 | // Return a short value starting from offset 36 | pub fn get_short(&self, offset: usize) -> i16 { 37 | byteutil::to_short(&self.data, offset) 38 | } 39 | 40 | // Get a bool value at the given offset 41 | pub fn get_bool(&self, offset: usize) -> bool { 42 | self.get(offset) == 1 43 | } 44 | 45 | pub fn bin_digit_val(&self, offset: usize, pos: usize) -> u8 { 46 | self.get(offset) & (1 << pos) 47 | } 48 | 49 | pub fn bin_digit_bool(&self, offset: usize, pos: usize) -> bool { 50 | self.get(offset) & (1 << pos) == (1 << pos) 51 | } 52 | 53 | pub fn get_hex_str(&self, offset: usize, len: usize) -> String { 54 | let mut s = String::new(); 55 | 56 | for i in offset..offset + len { 57 | s.push_str(&format!("{:02x}", self.get(i))); 58 | 59 | if i != offset + len - 1 { 60 | s.push(':') 61 | } 62 | } 63 | 64 | s 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/message/lock_touchpad.rs: -------------------------------------------------------------------------------- 1 | use super::{extended_status_updated::ExtTapLockStatus, ids, Payload}; 2 | 3 | /// Lock or unlock the touchpad 4 | #[derive(Debug, Clone, Copy)] 5 | pub struct LockTouchpad { 6 | pub lock: bool, 7 | } 8 | 9 | pub fn new(lock: bool) -> LockTouchpad { 10 | LockTouchpad { lock } 11 | } 12 | 13 | impl Payload for LockTouchpad { 14 | fn get_data(&self) -> Vec { 15 | vec![self.lock.into()] 16 | } 17 | 18 | fn get_id(&self) -> u8 { 19 | ids::LOCK_TOUCHPAD 20 | } 21 | } 22 | 23 | #[derive(Debug, Clone, Copy)] 24 | pub struct ExtLockTouchpad { 25 | // Plax next track 26 | pub double_tap: bool, 27 | // Play/Pause track 28 | pub tap_on: bool, 29 | // Custom action 30 | pub touch_and_hold: bool, 31 | pub touch_controls: bool, 32 | // Previous track 33 | pub tripple_tap: bool, 34 | } 35 | 36 | impl ExtLockTouchpad { 37 | pub fn from_ext_tap_lock_status(st: ExtTapLockStatus) -> Self { 38 | Self { 39 | double_tap: st.double_tap_on, 40 | tap_on: st.tap_on, 41 | touch_and_hold: st.touch_an_hold_on, 42 | touch_controls: st.touch_controls_on, 43 | tripple_tap: st.triple_tap_on, 44 | } 45 | } 46 | 47 | pub fn new( 48 | double_tap: bool, 49 | tap_on: bool, 50 | touch_and_hold: bool, 51 | touch_controls: bool, 52 | tripple_tap: bool, 53 | ) -> Self { 54 | Self { 55 | double_tap, 56 | tap_on, 57 | touch_and_hold, 58 | touch_controls, 59 | tripple_tap, 60 | } 61 | } 62 | } 63 | 64 | impl Payload for ExtLockTouchpad { 65 | fn get_id(&self) -> u8 { 66 | ids::LOCK_TOUCHPAD 67 | } 68 | 69 | fn get_data(&self) -> Vec { 70 | vec![ 71 | self.touch_controls as u8, 72 | self.tap_on as u8, 73 | self.double_tap as u8, 74 | self.tripple_tap as u8, 75 | self.touch_and_hold as u8, 76 | 0, 77 | 0, 78 | ] 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/utils/crc16.rs: -------------------------------------------------------------------------------- 1 | const CRC16TAB: [i32; 256] = [ 2 | 0, 4129, 8258, 12387, 16516, 20645, 24774, 28903, 33032, 37161, 41290, 45419, 49548, 53677, 3 | 57806, 61935, 4657, 528, 12915, 8786, 21173, 17044, 29431, 25302, 37689, 33560, 45947, 41818, 4 | 54205, 50076, 62463, 58334, 9314, 13379, 1056, 5121, 25830, 29895, 17572, 21637, 42346, 46411, 5 | 34088, 38153, 58862, 62927, 50604, 54669, 13907, 9842, 5649, 1584, 30423, 26358, 22165, 18100, 6 | 46939, 42874, 38681, 34616, 63455, 59390, 55197, 51132, 18628, 22757, 26758, 30887, 2112, 6241, 7 | 10242, 14371, 51660, 55789, 59790, 63919, 35144, 39273, 43274, 47403, 23285, 19156, 31415, 8 | 27286, 6769, 2640, 14899, 10770, 56317, 52188, 64447, 60318, 39801, 35672, 47931, 43802, 27814, 9 | 31879, 19684, 23749, 11298, 15363, 3168, 7233, 60846, 64911, 52716, 56781, 44330, 48395, 36200, 10 | 40265, 32407, 28342, 24277, 20212, 15891, 11826, 7761, 3696, 65439, 61374, 57309, 53244, 48923, 11 | 44858, 40793, 36728, 37256, 33193, 45514, 41451, 53516, 49453, 61774, 57711, 4224, 161, 12482, 12 | 8419, 20484, 16421, 28742, 24679, 33721, 37784, 41979, 46042, 49981, 54044, 58239, 62302, 689, 13 | 4752, 8947, 13010, 16949, 21012, 25207, 29270, 46570, 42443, 38312, 34185, 62830, 58703, 54572, 14 | 50445, 13538, 9411, 5280, 1153, 29798, 25671, 21540, 17413, 42971, 47098, 34713, 38840, 59231, 15 | 63358, 50973, 55100, 9939, 14066, 1681, 5808, 26199, 30326, 17941, 22068, 55628, 51565, 63758, 16 | 59695, 39368, 35305, 47498, 43435, 22596, 18533, 30726, 26663, 6336, 2273, 14466, 10403, 52093, 17 | 56156, 60223, 64286, 35833, 39896, 43963, 48026, 19061, 23124, 27191, 31254, 2801, 6864, 10931, 18 | 14994, 64814, 60687, 56684, 52557, 48554, 44427, 40424, 36297, 31782, 27655, 23652, 19525, 19 | 15522, 11395, 7392, 3265, 61215, 65342, 53085, 57212, 44955, 49082, 36825, 40952, 28183, 32310, 20 | 20053, 24180, 11923, 16050, 3793, 7920, 21 | ]; 22 | 23 | pub fn crc16_ccitt(barr: &[u8], i: usize) -> i32 { 24 | let mut i2 = 0 as i32; 25 | for i3 in 0..i { 26 | i2 = CRC16TAB[(((i2 >> 8) ^ barr[i3 as usize] as i32) & 255) as usize] ^ (i2 << 8); 27 | } 28 | 29 | 65535 & i2 30 | } 31 | 32 | pub fn crc16_ccitt2(barr: &[u8], i: usize, i2: usize) -> i32 { 33 | let mut i3: i32 = 0; 34 | let mut i = i; 35 | 36 | while i < i2 { 37 | i3 = CRC16TAB[(((i3 >> 8) ^ barr[i] as i32) & 255) as usize] ^ (i3 << 8); 38 | i += 1; 39 | } 40 | 41 | 65535 & i3 42 | } 43 | -------------------------------------------------------------------------------- /src/message/ambient_mode.rs: -------------------------------------------------------------------------------- 1 | use super::{ids, Payload}; 2 | 3 | // Whether the buds enabled the ambient_mode themselves. 4 | #[derive(Debug, Clone, Copy)] 5 | pub struct AmbientModeUpdated { 6 | pub ambient_mode: bool, 7 | } 8 | 9 | impl AmbientModeUpdated { 10 | pub fn new(arr: &[u8]) -> Self { 11 | Self { 12 | ambient_mode: arr[0] == 1, 13 | } 14 | } 15 | } 16 | 17 | impl Payload for AmbientModeUpdated { 18 | fn get_id(&self) -> u8 { 19 | ids::AMBIENT_MODE_UPDATED 20 | } 21 | } 22 | 23 | // Allow parsing Message to a StatusUpdate 24 | impl Into for super::Message { 25 | fn into(self) -> AmbientModeUpdated { 26 | AmbientModeUpdated::new(self.get_payload_bytes()) 27 | } 28 | } 29 | 30 | // Set the ambient volume level 31 | #[derive(Debug, Copy, Clone)] 32 | pub struct SetAmbientVolume { 33 | pub new_volume_lvl: u8, 34 | } 35 | 36 | impl SetAmbientVolume { 37 | pub fn new(new_volume_lvl: u8) -> Self { 38 | Self { new_volume_lvl } 39 | } 40 | } 41 | 42 | impl Payload for SetAmbientVolume { 43 | fn get_id(&self) -> u8 { 44 | ids::AMBIENT_VOLUME 45 | } 46 | 47 | fn get_data(&self) -> Vec { 48 | // 1 is lowest, 4 is highest. 49 | // However the buds expect it from 0-3. 50 | vec![self.new_volume_lvl - 1] 51 | } 52 | } 53 | 54 | // Set the ambient mode: enabled or disabled 55 | #[derive(Debug, Copy, Clone)] 56 | pub struct SetAmbientMode { 57 | pub enabled: bool, 58 | } 59 | 60 | impl SetAmbientMode { 61 | pub fn new(enabled: bool) -> Self { 62 | Self { enabled } 63 | } 64 | } 65 | 66 | impl Payload for SetAmbientMode { 67 | fn get_id(&self) -> u8 { 68 | ids::SET_AMBIENT_MODE 69 | } 70 | 71 | fn get_data(&self) -> Vec { 72 | vec![{ 73 | if self.enabled { 74 | 1 75 | } else { 76 | 0 77 | } 78 | }] 79 | } 80 | } 81 | 82 | // Set the extra high ambient mode: enabled or disabled 83 | #[derive(Debug, Copy, Clone)] 84 | pub struct SetExtraHighVolume { 85 | pub enabled: bool, 86 | } 87 | 88 | impl SetExtraHighVolume { 89 | pub fn new(enabled: bool) -> Self { 90 | Self { enabled } 91 | } 92 | } 93 | 94 | impl Payload for SetExtraHighVolume { 95 | fn get_id(&self) -> u8 { 96 | ids::EXTRA_HIGH_AMBIENT 97 | } 98 | 99 | fn get_data(&self) -> Vec { 100 | vec![{ 101 | if self.enabled { 102 | 1 103 | } else { 104 | 0 105 | } 106 | }] 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/message/ids.rs: -------------------------------------------------------------------------------- 1 | pub const ADJUST_SOUND_SYNC: u8 = 133; 2 | pub const CHECK_THE_FIT_OF_EARBUDS: u8 = 157; 3 | pub const CHECK_THE_FIT_OF_EARBUDS_RESULT: u8 = 158; 4 | pub const DEBUG_GET_ALL_DATA: u8 = 38; 5 | pub const DEBUG_SERIAL_NUMBER: u8 = 41; 6 | pub const DEBUG_SKU: u8 = 34; 7 | pub const EQUALIZER: u8 = 134; 8 | pub const EXTENDED_STATUS_UPDATED: u8 = 97; 9 | pub const FIND_MY_EARBUDS_START: u8 = 160; 10 | pub const FIND_MY_EARBUDS_STOP: u8 = 161; 11 | pub const FOTA_CONTROL: u8 = 188; 12 | pub const FOTA_DEVICE_INFO_SW_VERSION: u8 = 180; 13 | pub const FOTA_DOWNLOAD_DATA: u8 = 189; 14 | pub const FOTA_EMERGENCY: u8 = 186; 15 | pub const FOTA_OPEN: u8 = 187; 16 | pub const FOTA_RESULT: u8 = 185; 17 | pub const FOTA_UPDATE: u8 = 190; 18 | pub const GAME_MODE: u8 = 135; 19 | pub const GET_FMM_CONFIG: u8 = 173; 20 | pub const LOCK_TOUCHPAD: u8 = 144; 21 | pub const LOG_COREDUMP_COMPLETE: u8 = 51; 22 | pub const LOG_COREDUMP_DATA: u8 = 50; 23 | pub const LOG_COREDUMP_DATA_DONE: u8 = 56; 24 | pub const LOG_COREDUMP_DATA_SIZE: u8 = 49; 25 | pub const LOG_SESSION_CLOSE: u8 = 59; 26 | pub const LOG_SESSION_OPEN: u8 = 58; 27 | pub const LOG_TRACE_COMPLETE: u8 = 54; 28 | pub const LOG_TRACE_DATA: u8 = 53; 29 | pub const LOG_TRACE_DATA_DONE: u8 = 57; 30 | pub const LOG_TRACE_ROLE_SWITCH: u8 = 55; 31 | pub const LOG_TRACE_START: u8 = 52; 32 | pub const MANAGER_INFO: u8 = 136; 33 | pub const MSG_ID_OUTSIDE_DOUBLE_TAP: u8 = 149; 34 | pub const MUTE_EARBUD: u8 = 162; 35 | pub const MUTE_EARBUD_STATUS_UPDATED: u8 = 163; 36 | pub const NOISE_REDUCTION_MODE_UPDATE: u8 = 155; 37 | pub const PASS_THROUGH: u8 = 159; 38 | pub const RESET: u8 = 80; 39 | pub const SAMPLE: u8 = 255; 40 | pub const SELF_TEST: u8 = 171; 41 | pub const SET_FMM_CONFIG: u8 = 172; 42 | pub const SET_IN_BAND_RINGTONE: u8 = 138; 43 | pub const SET_NOISE_REDUCTION: u8 = 152; 44 | pub const SET_SEAMLESS_CONNECTION: u8 = 175; 45 | pub const SET_TOUCHPAD_OPTION: u8 = 146; 46 | pub const SET_VOICE_WAKE_UP: u8 = 151; 47 | pub const STATUS_UPDATED: u8 = 96; 48 | pub const TOUCHPAD_OTHER_OPTION: u8 = 147; 49 | pub const TOUCH_UPDATED: u8 = 145; 50 | pub const TOUCHPAD_ACTION: u8 = 45; 51 | pub const UPDATE_TIME: u8 = 167; 52 | pub const USAGE_REPORT: u8 = 64; 53 | pub const VERSION_INFO: u8 = 99; 54 | pub const VOICE_NOTI_STATUS: u8 = 164; 55 | pub const VOICE_NOTI_STOP: u8 = 165; 56 | pub const VOICE_WAKE_UP_EVENT: u8 = 154; 57 | pub const VOICE_WAKE_UP_LANGUAGE: u8 = 153; 58 | pub const VOICE_WAKE_UP_LISTENING_STATUS: u8 = 156; 59 | 60 | // Buds+ 61 | pub const AMBIENT_MODE_UPDATED: u8 = 129; 62 | pub const AMBIENT_VOLUME: u8 = 132; 63 | pub const AMBIENT_WEARING_STATUS_UPDATED: u8 = 137; 64 | pub const SET_AMBIENT_MODE: u8 = 128; 65 | pub const EXTRA_HIGH_AMBIENT: u8 = 150; 66 | pub const SET_SIDETONE: u8 = 139; 67 | -------------------------------------------------------------------------------- /src/model.rs: -------------------------------------------------------------------------------- 1 | use std::fmt::Display; 2 | 3 | /// The device model. 4 | #[derive(Debug, Copy, Clone, PartialEq)] 5 | pub enum Model { 6 | Buds, 7 | BudsPlus, 8 | BudsLive, 9 | BudsPro, 10 | BudsPro2, 11 | Buds2, 12 | } 13 | 14 | impl Display for Model { 15 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 16 | write!(f, "{}", self.full_name()) 17 | } 18 | } 19 | 20 | /// Features which are only available by certain models. 21 | #[derive(Debug, Copy, Clone, PartialEq)] 22 | pub enum Feature { 23 | Anc, 24 | AmbientSound, 25 | ExtraHighAmbientVolume, 26 | AmbientVoiceFocus, 27 | BatteryType, 28 | OutsideDoubleTap, 29 | RelieveAmbient, 30 | Sidetone, 31 | VoiceWakeup, 32 | AdjustSoundSync, 33 | // Extended Touchpad lock 34 | ExtTouchpadLock, 35 | } 36 | 37 | impl Model { 38 | /// Returns all available features for the given model. 39 | pub fn get_features(&self) -> Vec { 40 | match self { 41 | Model::Buds => { 42 | vec![ 43 | Feature::BatteryType, 44 | Feature::AmbientSound, 45 | Feature::AmbientVoiceFocus, 46 | ] 47 | } 48 | 49 | Model::BudsPlus => { 50 | vec![ 51 | Feature::AmbientSound, 52 | Feature::OutsideDoubleTap, 53 | Feature::Sidetone, 54 | Feature::ExtraHighAmbientVolume, 55 | Feature::AdjustSoundSync, 56 | ] 57 | } 58 | 59 | Model::BudsLive => { 60 | vec![ 61 | Feature::Anc, 62 | Feature::RelieveAmbient, 63 | Feature::VoiceWakeup, 64 | Feature::AdjustSoundSync, 65 | ] 66 | } 67 | 68 | Model::BudsPro => { 69 | vec![Feature::Anc, Feature::VoiceWakeup, Feature::AdjustSoundSync] 70 | } 71 | 72 | 73 | Model::BudsPro2 => { 74 | vec![Feature::Anc, Feature::VoiceWakeup, Feature::AdjustSoundSync] 75 | } 76 | 77 | Model::Buds2 => { 78 | vec![ 79 | Feature::Anc, 80 | Feature::AmbientSound, 81 | Feature::OutsideDoubleTap, 82 | Feature::AdjustSoundSync, 83 | Feature::ExtTouchpadLock, 84 | ] 85 | } 86 | } 87 | } 88 | 89 | pub fn full_name(&self) -> &'static str { 90 | match *self { 91 | Model::Buds => "Galaxy Buds", 92 | Model::BudsPlus => "Galaxy Buds+", 93 | Model::BudsLive => "Galaxy Buds Live", 94 | Model::BudsPro => "Galaxy Buds Pro", 95 | Model::BudsPro2 => "Galaxy Buds Pro 2", 96 | Model::Buds2 => "Galaxy Buds 2", 97 | } 98 | } 99 | 100 | /// Returns true whether a model has the given feature. 101 | pub fn has_feature(&self, feature: Feature) -> bool { 102 | self.get_features().iter().any(|i| *i == feature) 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/message/bud_property.rs: -------------------------------------------------------------------------------- 1 | use crate::utils::byteutil; 2 | 3 | /// A property value of a single earbud 4 | pub trait BudProperty { 5 | type Item; 6 | 7 | /// Get the corresponding value of a byte based on the 8 | /// side of the earbud (left/right) 9 | fn side_val(val: u8, side: Side) -> u8 { 10 | match side { 11 | Side::Left => byteutil::value_of_left(val), 12 | Side::Right => byteutil::value_of_right(val), 13 | } 14 | } 15 | 16 | /// Get the property item decoded based on 17 | /// the side and msg byte 18 | fn value(val: u8, side: Side) -> Self::Item { 19 | Self::decode(Self::side_val(val, side)) 20 | } 21 | 22 | /// Decode the value. Returns a property variant 23 | fn decode(val: u8) -> Self::Item; 24 | 25 | /// Needs to be implemented to send a 26 | /// property variant inside a msg payload 27 | fn encode(&self) -> u8; 28 | } 29 | 30 | /// The side of an earbud. 31 | #[derive(Debug, PartialEq, Clone, Copy)] 32 | pub enum Side { 33 | Left, 34 | Right, 35 | } 36 | 37 | impl From for Side { 38 | fn from(inp_side: bool) -> Side { 39 | if !inp_side { 40 | Side::Right 41 | } else { 42 | Side::Left 43 | } 44 | } 45 | } 46 | 47 | // Helper func to match with ease 48 | pub fn match_site(left: T, right: T, side: Side) -> T { 49 | match side { 50 | Side::Left => left, 51 | Side::Right => right, 52 | } 53 | } 54 | 55 | /// Where an earbud is placed in the 56 | /// physical real life world 57 | #[derive(Debug, PartialEq, Copy, Clone)] 58 | pub enum Placement { 59 | InOpenCase, 60 | Outside, 61 | Ear, 62 | InCloseCase, 63 | Undetected, 64 | } 65 | 66 | /// Placement comes inside some payloads so 67 | /// define the decode() here 68 | impl BudProperty for Placement { 69 | type Item = Placement; 70 | 71 | fn decode(val: u8) -> Placement { 72 | match val { 73 | 1 => Placement::Ear, 74 | 2 => Placement::Outside, 75 | 3 => Placement::InOpenCase, 76 | 4 => Placement::InCloseCase, 77 | _ => Placement::Undetected, 78 | } 79 | } 80 | 81 | fn encode(&self) -> u8 { 82 | match *self { 83 | Placement::Ear => 1, 84 | Placement::Outside => 2, 85 | Placement::InOpenCase => 3, 86 | Placement::InCloseCase => 4, 87 | Placement::Undetected => 0, 88 | } 89 | } 90 | } 91 | 92 | /// Which option is set for holding the touchpad 93 | #[derive(Debug, PartialEq, Copy, Clone)] 94 | pub enum TouchpadOption { 95 | NoiseCanceling, 96 | VoiceCommand, 97 | Volume, 98 | Spotify, 99 | Undetected, 100 | Disconnect, 101 | Custom, 102 | } 103 | 104 | impl BudProperty for TouchpadOption { 105 | type Item = TouchpadOption; 106 | 107 | fn encode(&self) -> u8 { 108 | match *self { 109 | TouchpadOption::VoiceCommand => 1, 110 | TouchpadOption::NoiseCanceling => 2, 111 | TouchpadOption::Volume => 3, 112 | TouchpadOption::Spotify => 4, 113 | TouchpadOption::Custom => 5, 114 | TouchpadOption::Disconnect => 6, 115 | TouchpadOption::Undetected => 0, 116 | } 117 | } 118 | 119 | fn decode(val: u8) -> TouchpadOption { 120 | match val { 121 | 1 => TouchpadOption::VoiceCommand, 122 | 2 => TouchpadOption::NoiseCanceling, 123 | 3 => TouchpadOption::Volume, 124 | 4 => TouchpadOption::Spotify, 125 | 5 => TouchpadOption::Custom, 126 | 6 => TouchpadOption::Disconnect, 127 | _ => TouchpadOption::Undetected, 128 | } 129 | } 130 | } 131 | 132 | /// The selected EqualizerType 133 | #[derive(Debug, PartialEq, Copy, Clone)] 134 | pub enum EqualizerType { 135 | Normal, 136 | BassBoost, 137 | Soft, 138 | Dynamic, 139 | Clear, 140 | TrebleBoost, 141 | Undetected, 142 | } 143 | 144 | impl BudProperty for EqualizerType { 145 | type Item = EqualizerType; 146 | 147 | fn decode(val: u8) -> EqualizerType { 148 | match val { 149 | 0 => EqualizerType::Normal, 150 | 1 => EqualizerType::BassBoost, 151 | 2 => EqualizerType::Soft, 152 | 3 => EqualizerType::Dynamic, 153 | 4 => EqualizerType::Clear, 154 | 5 => EqualizerType::TrebleBoost, 155 | _ => EqualizerType::Undetected, 156 | } 157 | } 158 | 159 | fn encode(&self) -> u8 { 160 | match *self { 161 | EqualizerType::Normal => 0, 162 | EqualizerType::BassBoost => 1, 163 | EqualizerType::Soft => 2, 164 | EqualizerType::Dynamic => 3, 165 | EqualizerType::Clear => 4, 166 | EqualizerType::TrebleBoost => 5, 167 | EqualizerType::Undetected => 10, 168 | } 169 | } 170 | } 171 | 172 | /// AmbientType 173 | #[derive(Debug, PartialEq, Copy, Clone)] 174 | pub enum AmbientType { 175 | Normal, 176 | VoiceFocus, 177 | } 178 | 179 | impl BudProperty for AmbientType { 180 | type Item = AmbientType; 181 | 182 | fn decode(val: u8) -> AmbientType { 183 | match val { 184 | 1 => AmbientType::VoiceFocus, 185 | _ => AmbientType::Normal, 186 | } 187 | } 188 | 189 | fn encode(&self) -> u8 { 190 | match *self { 191 | AmbientType::Normal => 0, 192 | AmbientType::VoiceFocus => 1, 193 | } 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /src/message/mod.rs: -------------------------------------------------------------------------------- 1 | mod bytebuff; 2 | 3 | pub mod ambient_mode; 4 | pub mod anc_updated; 5 | pub mod bud_property; 6 | pub mod debug; 7 | pub mod extended_status_updated; 8 | pub mod find_my_bud; 9 | pub mod fit_check; 10 | pub mod ids; 11 | pub mod lock_touchpad; 12 | pub mod manager; 13 | pub mod mute_earbud; 14 | pub mod response; 15 | pub mod set_noise_reduction; 16 | pub mod set_touchpad_option; 17 | pub mod simple; 18 | pub mod status_updated; 19 | pub mod touch_updated; 20 | pub mod touchpad_action; 21 | pub mod usage_report; 22 | pub mod voice_wakeup_listening_status; 23 | 24 | use crate::{ 25 | model::Model, 26 | utils::{ 27 | self, byteutil, 28 | crc16::{self, crc16_ccitt}, 29 | }, 30 | }; 31 | 32 | /// End of message 33 | pub const EOM: u8 = 221; 34 | /// Begin of message 35 | pub const BOM: u8 = 253; 36 | 37 | /// Message contains the data of a message and 38 | /// its into a `msg` trait implementing parsed 39 | /// payload. In addition it contains some nice 40 | /// functions which are dependend on the data 41 | #[derive(Debug, Clone)] 42 | pub struct Message { 43 | // the data of the message 44 | data: Vec, 45 | model: Model, 46 | } 47 | 48 | /// Msg defines the trait which need to be 49 | /// implemented by an inner message (msg). 50 | pub trait Payload { 51 | /// Getter for the message ID 52 | fn get_id(&self) -> u8; 53 | 54 | /// The payload data encoded for sending 55 | fn get_data(&self) -> Vec { 56 | vec![] 57 | } 58 | 59 | fn is_response(&self) -> bool { 60 | false 61 | } 62 | 63 | /// Create a message byte array from a message. This 64 | /// is required to send a message to the buds. 65 | fn to_byte_array(&self) -> Vec { 66 | let id = Self::get_id(&self); 67 | let payload_data = Self::get_data(&self); 68 | let payload_len = payload_data.len(); 69 | 70 | let i2 = payload_len + 3; 71 | let i3 = i2 + 4; 72 | 73 | let mut b_arr: Vec = vec![0; i3]; 74 | b_arr[0] = BOM; 75 | b_arr[i3 - 1 as usize] = EOM; 76 | 77 | let create_header = Self::create_header(self, i2 as i32); 78 | b_arr[1] = create_header[0]; 79 | b_arr[2] = create_header[1]; 80 | 81 | let mut b_arr2: Vec = vec![0; i2]; 82 | b_arr2[0] = id; 83 | utils::array::arraycopy(&payload_data, 0, &mut b_arr2, 1, payload_data.len()); 84 | 85 | let crc16_ccitt = crc16::crc16_ccitt(&b_arr2, b_arr2.len() - 2); 86 | 87 | let barr2_len = b_arr2.len(); 88 | b_arr2[barr2_len - 2] = (crc16_ccitt & 255) as u8; 89 | b_arr2[barr2_len - 1] = ((crc16_ccitt >> 8) & 255) as u8; 90 | utils::array::arraycopy(&b_arr2, 0, &mut b_arr, 3, b_arr2.len()); 91 | 92 | b_arr 93 | } 94 | 95 | /// Create a header for the message 96 | fn create_header(&self, i: i32) -> [u8; 2] { 97 | let mut from_short = byteutil::from_short(i & 1023); 98 | 99 | // use the msg's value here since its only used to send 100 | // messages and we want to have control over this 101 | // value from msg, not Message 102 | if self.is_response() { 103 | from_short[1] |= 16; 104 | } 105 | 106 | from_short 107 | } 108 | } 109 | 110 | impl Message { 111 | /// Create a new message object from read data 112 | #[inline] 113 | pub fn new>>(data: I, model: Model) -> Message { 114 | Message { 115 | data: data.into(), 116 | model, 117 | } 118 | } 119 | 120 | /// Get the payload length of the message 121 | #[inline] 122 | pub fn get_payload_length(&self) -> i32 { 123 | self.get_u8() & 1023 124 | } 125 | 126 | /// Check whether the message is a fragment or not. Fragments seem 127 | /// only to be used in Fota messages 128 | #[inline] 129 | pub fn is_fragment(&self) -> bool { 130 | self.get_u8() & 8192 != 0 131 | } 132 | 133 | /// Checks if a message is a response 134 | #[inline] 135 | pub fn is_response(&self) -> bool { 136 | (self.get_u8() & 4096) != 0 137 | } 138 | 139 | /// Return the header of the message 140 | #[inline] 141 | pub fn get_u8(&self) -> i32 { 142 | (byteutil::to_u8(self.data[2]) << 8) + byteutil::to_u8(self.data[1]) 143 | } 144 | 145 | /// Get the payload start index of the messages data 146 | #[inline] 147 | pub fn get_payload_start_index() -> usize { 148 | 3 149 | } 150 | 151 | /// Return the bytes of the payload within the message 152 | #[inline] 153 | pub fn get_payload_bytes(&self) -> &[u8] { 154 | &self.data[Self::get_payload_start_index() + 1..] 155 | } 156 | 157 | /// Get the message id 158 | #[inline] 159 | pub fn get_id(&self) -> u8 { 160 | self.data[3] 161 | } 162 | 163 | /// Returns `true` if the given message really represents a message that should/can be parsed 164 | #[inline] 165 | pub fn is_message(&self) -> bool { 166 | self.data 167 | .get(self.get_payload_length() as usize + 3) 168 | .map(|i| *i == 221) 169 | .unwrap_or_default() 170 | } 171 | 172 | /// Verify that the message is correctly received using the last 2 bytes of the message as crc 173 | /// checksum 174 | pub fn check_crc(&self) -> bool { 175 | if self.data.len() < 5 { 176 | return false; 177 | } 178 | 179 | let mut b_arr = self.payload_with_chsum().to_vec(); 180 | let l = b_arr.len(); 181 | 182 | let b = b_arr[l - 1]; 183 | b_arr[l - 1] = b_arr[b_arr.len() - 2]; 184 | b_arr[l - 2] = b; 185 | 186 | crc16_ccitt(&b_arr, l) == 0 187 | } 188 | 189 | /// Returns the messages payload with the checksum 190 | #[inline] 191 | fn payload_with_chsum(&self) -> &[u8] { 192 | let start = Self::get_payload_start_index(); 193 | let end = self.data.len() - 1; 194 | &self.data[start..end] 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /src/message/debug.rs: -------------------------------------------------------------------------------- 1 | use crate::model::Model; 2 | 3 | use super::{ 4 | bud_property::{match_site, Side}, 5 | bytebuff::ByteBuff, 6 | ids, 7 | utils::byteutil, 8 | Payload, 9 | }; 10 | 11 | #[derive(Debug, Copy, Clone)] 12 | pub enum DebugVariant { 13 | SerialNumber, 14 | GetAllData, 15 | Sku, 16 | } 17 | 18 | /// Debug 19 | #[derive(Debug, Clone, Copy)] 20 | pub struct Debug { 21 | variant: DebugVariant, 22 | } 23 | 24 | pub fn new(variant: DebugVariant) -> Debug { 25 | Debug { variant } 26 | } 27 | 28 | impl Payload for Debug { 29 | fn get_data(&self) -> Vec { 30 | vec![] 31 | } 32 | 33 | fn get_id(&self) -> u8 { 34 | match self.variant { 35 | DebugVariant::SerialNumber => ids::DEBUG_SERIAL_NUMBER, 36 | DebugVariant::GetAllData => ids::DEBUG_GET_ALL_DATA, 37 | DebugVariant::Sku => ids::DEBUG_SKU, 38 | } 39 | } 40 | } 41 | 42 | #[derive(Debug, Default, Clone)] 43 | pub struct GetAllData { 44 | pub msg_version: u8, 45 | pub revision: u8, 46 | pub hw_version: String, 47 | pub bt_address_right: String, 48 | pub bt_address_left: String, 49 | pub proximity_left: i16, 50 | pub proximity_left_offset: i16, 51 | pub proximity_right: i16, 52 | pub proximity_right_offset: i16, 53 | pub thermistor_left: f32, 54 | pub thermistor_right: f32, 55 | pub adc_soc_left: i16, 56 | pub adc_vcell_left: f32, 57 | pub adc_current_left: f64, 58 | pub adc_soc_right: i16, 59 | pub adc_vcell_right: f32, 60 | pub adc_current_right: f64, 61 | pub gyro_left_x: i16, 62 | pub gyro_left_y: i16, 63 | pub gyro_left_z: i16, 64 | pub gyro_right_x: i16, 65 | pub gyro_right_y: i16, 66 | pub gyro_right_z: i16, 67 | pub cradle_batt_left: u8, 68 | pub cradle_batt_right: u8, 69 | } 70 | 71 | impl GetAllData { 72 | pub fn parse(arr: &[u8], model: Model) -> Option { 73 | let buff = ByteBuff::new(arr); 74 | 75 | let rev = (buff.get(1) & 240) >> 4; 76 | 77 | let hw_version = { 78 | let buff1 = buff.get(1); 79 | format!("rev{}{}", rev, buff1 & 15) 80 | }; 81 | 82 | if model == Model::Buds { 83 | return None; 84 | } 85 | 86 | if model == Model::BudsPro2 { 87 | return None; 88 | } 89 | 90 | let mut data; 91 | if model == Model::Buds2 { 92 | data = Self { 93 | msg_version: buff.get(0), 94 | revision: rev, 95 | hw_version, 96 | bt_address_left: buff.get_hex_str(6, 6).to_uppercase(), 97 | bt_address_right: buff.get_hex_str(12, 6).to_uppercase(), 98 | proximity_left: buff.get_short(30), 99 | proximity_left_offset: buff.get_short(32), 100 | proximity_right: buff.get_short(34), 101 | proximity_right_offset: buff.get_short(36), 102 | thermistor_left: buff.get_short(38) as f32 * 0.1_f32, 103 | thermistor_right: buff.get_short(40) as f32 * 0.1_f32, 104 | // batt left 105 | adc_soc_left: buff.get_short(42), 106 | adc_vcell_left: buff.get_short(44) as f32 * 0.01, 107 | adc_current_left: byteutil::calc_current(buff.get_short(46)), 108 | // batt right 109 | adc_soc_right: buff.get_short(48), 110 | adc_vcell_right: buff.get_short(50) as f32 * 0.01, 111 | adc_current_right: byteutil::calc_current(buff.get_short(52)), 112 | cradle_batt_left: buff.get(82), 113 | cradle_batt_right: buff.get(83), 114 | ..Default::default() 115 | }; 116 | } else { 117 | data = Self { 118 | msg_version: buff.get(0), 119 | revision: (buff.get(1) & 240) >> 4, 120 | hw_version, 121 | bt_address_left: buff.get_hex_str(6, 6).to_uppercase(), 122 | bt_address_right: buff.get_hex_str(12, 6).to_uppercase(), 123 | proximity_left: buff.get_short(30), 124 | proximity_left_offset: buff.get_short(32), 125 | proximity_right: buff.get_short(34), 126 | proximity_right_offset: buff.get_short(36), 127 | thermistor_left: buff.get_short(38) as f32 * 0.1_f32, 128 | thermistor_right: buff.get_short(40) as f32 * 0.1_f32, 129 | adc_soc_left: buff.get_short(42), 130 | adc_vcell_left: buff.get_short(44) as f32 * 0.01, 131 | adc_current_left: byteutil::calc_current(buff.get_short(46)), 132 | adc_soc_right: buff.get_short(48), 133 | adc_vcell_right: buff.get_short(50) as f32 * 0.01, 134 | adc_current_right: byteutil::calc_current(buff.get_short(52)), 135 | cradle_batt_left: buff.get(82), 136 | cradle_batt_right: buff.get(83), 137 | ..Default::default() 138 | }; 139 | } 140 | 141 | if model == Model::BudsLive { 142 | data.gyro_left_x = buff.get_short(84); 143 | data.gyro_left_y = buff.get_short(86); 144 | data.gyro_left_z = buff.get_short(88); 145 | data.gyro_right_x = buff.get_short(90); 146 | data.gyro_right_y = buff.get_short(92); 147 | data.gyro_right_z = buff.get_short(94); 148 | } 149 | 150 | Some(data) 151 | } 152 | 153 | // Return the bluetooth address of the given bud 154 | pub fn get_bt_address(&self, side: Side) -> &str { 155 | match_site(&self.bt_address_left, &self.bt_address_right, side) 156 | } 157 | 158 | // Get the proximity 159 | pub fn get_proximity(&self, side: Side) -> i16 { 160 | match_site(self.proximity_left, self.proximity_right, side) 161 | } 162 | 163 | // Get the proximity_offset 164 | pub fn get_proximity_offset(&self, side: Side) -> i16 { 165 | match_site( 166 | self.proximity_left_offset, 167 | self.proximity_right_offset, 168 | side, 169 | ) 170 | } 171 | 172 | // Get thermistor 173 | pub fn get_thermistor(&self, side: Side) -> f32 { 174 | match_site(self.thermistor_left, self.thermistor_right, side) 175 | } 176 | 177 | // Get Adc SOC 178 | pub fn get_adc_soc(&self, side: Side) -> i16 { 179 | match_site(self.adc_soc_left, self.adc_soc_right, side) 180 | } 181 | 182 | // Get Adc vcell 183 | pub fn get_adc_vcell(&self, side: Side) -> f32 { 184 | match_site(self.adc_vcell_left, self.adc_vcell_right, side) 185 | } 186 | 187 | // Get Adc current 188 | pub fn get_adc_current(&self, side: Side) -> f64 { 189 | match_site(self.adc_current_left, self.adc_current_right, side) 190 | } 191 | 192 | // Get cradle battery 193 | pub fn get_cradle_battery(&self, side: Side) -> u8 { 194 | match_site(self.cradle_batt_left, self.cradle_batt_right, side) 195 | } 196 | 197 | // Get gyro x 198 | pub fn get_gyro_x(&self, side: Side) -> i16 { 199 | match_site(self.gyro_left_x, self.gyro_right_x, side) 200 | } 201 | 202 | // Get gyro y 203 | pub fn get_gyro_y(&self, side: Side) -> i16 { 204 | match_site(self.gyro_left_y, self.gyro_right_y, side) 205 | } 206 | 207 | // Get gyro z 208 | pub fn get_gyro_z(&self, side: Side) -> i16 { 209 | match_site(self.gyro_left_z, self.gyro_right_z, side) 210 | } 211 | } 212 | 213 | // Allow parsing Message to a GetAllData 214 | impl Into> for super::Message { 215 | fn into(self) -> Option { 216 | GetAllData::parse(self.get_payload_bytes(), self.model) 217 | } 218 | } 219 | 220 | #[derive(Debug, Clone)] 221 | pub struct SerialNumber { 222 | serial_number_left: String, 223 | serial_number_right: String, 224 | } 225 | 226 | impl SerialNumber { 227 | pub fn new(arr: &[u8]) -> Self { 228 | SerialNumber { 229 | serial_number_left: byteutil::to_serial_number(&arr, 0, 11), 230 | serial_number_right: byteutil::to_serial_number(&arr, 11, 11), 231 | } 232 | } 233 | } 234 | 235 | // Allow parsing Message to a SerialNumber 236 | impl Into for super::Message { 237 | fn into(self) -> SerialNumber { 238 | SerialNumber::new(self.get_payload_bytes()) 239 | } 240 | } 241 | 242 | #[derive(Debug, Clone)] 243 | pub struct Sku { 244 | sku_left: String, 245 | sku_right: String, 246 | } 247 | 248 | impl Sku { 249 | pub fn new(arr: &[u8]) -> Self { 250 | Sku { 251 | sku_left: byteutil::to_serial_number(&arr, 0, 14), 252 | sku_right: byteutil::to_serial_number(&arr, 14, 14), 253 | } 254 | } 255 | } 256 | 257 | // Allow parsing Message to a SerialNumber 258 | impl Into for super::Message { 259 | fn into(self) -> Sku { 260 | Sku::new(self.get_payload_bytes()) 261 | } 262 | } 263 | -------------------------------------------------------------------------------- /src/message/extended_status_updated.rs: -------------------------------------------------------------------------------- 1 | use super::bud_property::{BudProperty, EqualizerType, Placement, Side, TouchpadOption}; 2 | use super::{bud_property::AmbientType, bytebuff::ByteBuff}; 3 | use super::{ids, Payload}; 4 | use crate::model::Model; 5 | use serde::{Deserialize, Serialize}; 6 | 7 | pub const DEVICE_COLOR_BLACK: u8 = 2; 8 | pub const DEVICE_COLOR_PINK: u8 = 4; 9 | pub const DEVICE_COLOR_WHITE: u8 = 0; 10 | pub const DEVICE_COLOR_YELLOW: u8 = 3; 11 | pub const TYPE_KERNEL: u8 = 0; 12 | pub const TYPE_OPEN: u8 = 1; 13 | 14 | #[derive(Debug, Clone, Copy)] 15 | pub struct ExtendedStatusUpdate { 16 | pub revision: u8, 17 | pub ear_type: u8, 18 | pub battery_left: i8, 19 | pub battery_right: i8, 20 | pub coupled: bool, 21 | pub primary_earbud: Side, 22 | pub placement_left: Placement, 23 | pub placement_right: Placement, 24 | pub wearing_left: bool, 25 | pub wearing_right: bool, 26 | pub battery_case: i8, 27 | pub adjust_sound_sync: bool, 28 | pub equalizer_type: EqualizerType, 29 | pub touchpads_blocked: bool, 30 | pub touchpad_option_left: TouchpadOption, 31 | pub touchpad_option_right: TouchpadOption, 32 | pub noise_reduction: bool, 33 | pub voice_wake_up: bool, 34 | pub color_left: i16, 35 | pub color_right: i16, 36 | pub ambient_sound_enabled: bool, 37 | pub ambient_sound_volume: i32, 38 | pub extra_high_ambient: bool, 39 | pub ambient_mode: AmbientType, 40 | pub outside_double_tap: bool, 41 | pub tap_lock_status: ExtTapLockStatus, 42 | } 43 | 44 | #[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] 45 | pub struct ExtTapLockStatus { 46 | pub touch_an_hold_on: bool, 47 | pub triple_tap_on: bool, 48 | pub double_tap_on: bool, 49 | pub tap_on: bool, 50 | pub touch_controls_on: bool, 51 | } 52 | 53 | pub fn new(arr: &[u8], model: Model) -> ExtendedStatusUpdate { 54 | let buff = ByteBuff::new(&arr); 55 | 56 | let placement_left = Placement::value(buff.get(6), Side::Left); 57 | let placement_right = Placement::value(buff.get(6), Side::Right); 58 | 59 | let res = match model { 60 | Model::BudsLive => ExtendedStatusUpdate { 61 | revision: buff.get(0), 62 | ear_type: buff.get(1), 63 | battery_left: buff.get(2) as i8, 64 | battery_right: buff.get(3) as i8, 65 | coupled: buff.get_bool(4), 66 | primary_earbud: Side::from(buff.get_bool(5)), 67 | placement_left, 68 | placement_right, 69 | wearing_left: placement_left == Placement::Ear, 70 | wearing_right: placement_right == Placement::Ear, 71 | battery_case: buff.get(7) as i8, 72 | adjust_sound_sync: buff.get_bool(8), 73 | equalizer_type: EqualizerType::decode(buff.get(9)), 74 | touchpads_blocked: buff.get_bool(10), 75 | touchpad_option_left: TouchpadOption::value(buff.get(11), Side::Left), 76 | touchpad_option_right: TouchpadOption::value(buff.get(11), Side::Right), 77 | noise_reduction: buff.get_bool(12), 78 | voice_wake_up: buff.get_bool(13), 79 | color_left: buff.get_short(14), 80 | color_right: buff.get_short(16), 81 | ambient_sound_volume: 0, 82 | ambient_sound_enabled: false, 83 | ambient_mode: AmbientType::Normal, 84 | extra_high_ambient: false, 85 | outside_double_tap: false, 86 | tap_lock_status: ExtTapLockStatus::default(), 87 | }, 88 | 89 | Model::BudsPlus => ExtendedStatusUpdate { 90 | revision: buff.get(0), 91 | ear_type: buff.get(1), 92 | battery_left: buff.get(2) as i8, 93 | battery_right: buff.get(3) as i8, 94 | coupled: buff.get_bool(4), 95 | primary_earbud: Side::from(buff.get_bool(5)), 96 | placement_left, 97 | placement_right, 98 | wearing_left: placement_left == Placement::Ear, 99 | wearing_right: placement_right == Placement::Ear, 100 | battery_case: buff.get(7) as i8, 101 | adjust_sound_sync: buff.get_bool(10), 102 | equalizer_type: EqualizerType::decode(buff.get(11)), 103 | touchpads_blocked: buff.get_bool(12), 104 | touchpad_option_left: TouchpadOption::value(buff.get(13), Side::Left), 105 | touchpad_option_right: TouchpadOption::value(buff.get(13), Side::Right), 106 | color_left: buff.get_short(15), 107 | color_right: buff.get_short(17), 108 | voice_wake_up: false, 109 | noise_reduction: false, 110 | ambient_sound_enabled: buff.get_bool(8), 111 | ambient_sound_volume: buff.get(9) as i32, 112 | ambient_mode: AmbientType::Normal, 113 | extra_high_ambient: { 114 | if buff.get(0) >= 9 { 115 | buff.get_bool(19) 116 | } else { 117 | false 118 | } 119 | }, 120 | outside_double_tap: false, 121 | tap_lock_status: ExtTapLockStatus::default(), 122 | }, 123 | 124 | Model::BudsPro => ExtendedStatusUpdate { 125 | revision: buff.get(0), 126 | ear_type: buff.get(1), 127 | battery_left: buff.get(2) as i8, 128 | battery_right: buff.get(3) as i8, 129 | coupled: buff.get_bool(4), 130 | primary_earbud: Side::from(buff.get_bool(5)), 131 | placement_left, 132 | placement_right, 133 | wearing_left: placement_left == Placement::Ear, 134 | wearing_right: placement_right == Placement::Ear, 135 | battery_case: buff.get(7) as i8, 136 | adjust_sound_sync: buff.get_bool(8), 137 | equalizer_type: EqualizerType::decode(buff.get(9)), 138 | touchpads_blocked: buff.get_bool(10), 139 | touchpad_option_left: TouchpadOption::value(buff.get(11), Side::Left), 140 | touchpad_option_right: TouchpadOption::value(buff.get(11), Side::Right), 141 | noise_reduction: buff.get_bool(12), 142 | voice_wake_up: buff.get_bool(13), 143 | color_left: buff.get_short(14), 144 | color_right: buff.get_short(16), 145 | ambient_sound_volume: buff.get(23) as i32, 146 | ambient_sound_enabled: false, 147 | ambient_mode: AmbientType::Normal, 148 | extra_high_ambient: { 149 | if buff.get(0) < 3 { 150 | buff.get_bool(22) 151 | } else if buff.get(0) >= 6 { 152 | buff.get_bool(30) 153 | } else { 154 | false 155 | } 156 | }, 157 | outside_double_tap: false, 158 | tap_lock_status: ExtTapLockStatus::default(), 159 | }, 160 | 161 | Model::BudsPro2 => ExtendedStatusUpdate { 162 | revision: buff.get(0), 163 | ear_type: buff.get(1), 164 | battery_left: buff.get(2) as i8, 165 | battery_right: buff.get(3) as i8, 166 | coupled: buff.get_bool(4), 167 | primary_earbud: Side::from(buff.get_bool(5)), 168 | placement_left, 169 | placement_right, 170 | wearing_left: placement_left == Placement::Ear, 171 | wearing_right: placement_right == Placement::Ear, 172 | battery_case: buff.get(7) as i8, 173 | adjust_sound_sync: buff.get_bool(8), 174 | equalizer_type: EqualizerType::decode(buff.get(9)), 175 | touchpads_blocked: buff.get_bool(10), 176 | touchpad_option_left: TouchpadOption::value(buff.get(11), Side::Left), 177 | touchpad_option_right: TouchpadOption::value(buff.get(11), Side::Right), 178 | noise_reduction: buff.get_bool(12), 179 | voice_wake_up: buff.get_bool(13), 180 | color_left: buff.get_short(14), 181 | color_right: buff.get_short(16), 182 | ambient_sound_volume: buff.get(23) as i32, 183 | ambient_sound_enabled: false, 184 | ambient_mode: AmbientType::Normal, 185 | extra_high_ambient: { 186 | if buff.get(0) < 3 { 187 | buff.get_bool(22) 188 | } else if buff.get(0) >= 6 { 189 | buff.get_bool(30) 190 | } else { 191 | false 192 | } 193 | }, 194 | outside_double_tap: false, 195 | tap_lock_status: ExtTapLockStatus::default(), 196 | }, 197 | 198 | Model::Buds2 => ExtendedStatusUpdate { 199 | revision: buff.get(0), 200 | ear_type: buff.get(1), 201 | battery_left: buff.get(2) as i8, 202 | battery_right: buff.get(3) as i8, 203 | coupled: buff.get_bool(4), 204 | primary_earbud: Side::from(buff.get_bool(5)), 205 | placement_left, 206 | placement_right, 207 | wearing_left: placement_left == Placement::Ear, 208 | wearing_right: placement_right == Placement::Ear, 209 | battery_case: buff.get(7) as i8, 210 | adjust_sound_sync: buff.get_bool(8), 211 | equalizer_type: EqualizerType::decode(buff.get(9)), 212 | touchpads_blocked: buff.get_bool(10), // TODO this 213 | touchpad_option_left: TouchpadOption::value(buff.get(11), Side::Left), 214 | touchpad_option_right: TouchpadOption::value(buff.get(11), Side::Right), 215 | // noise controls 216 | noise_reduction: buff.get_bool(12), 217 | voice_wake_up: buff.get_bool(13), 218 | color_left: buff.get_short(14), 219 | color_right: buff.get_short(16), 220 | ambient_sound_volume: buff.get(23) as i32, 221 | ambient_sound_enabled: false, 222 | ambient_mode: AmbientType::Normal, 223 | extra_high_ambient: buff.get_bool(26), 224 | outside_double_tap: buff.get_bool(32), 225 | tap_lock_status: ExtTapLockStatus { 226 | touch_an_hold_on: buff.bin_digit_bool(10, 0), 227 | triple_tap_on: buff.bin_digit_bool(10, 1), 228 | double_tap_on: buff.bin_digit_bool(10, 2), 229 | tap_on: buff.bin_digit_bool(10, 3), 230 | touch_controls_on: buff.bin_digit_bool(10, 7), 231 | }, 232 | }, 233 | 234 | _ => unimplemented!(), 235 | }; 236 | /* 237 | println!("nc off: {}", buff.bin_digit_bool(21, 0)); 238 | println!("nc ambient: {}", buff.bin_digit_bool(21, 1)); 239 | println!("nc anc: {}", buff.bin_digit_bool(21, 2)); 240 | println!("amb level: {}", buff.get(23)); 241 | */ 242 | println!("{res:#?}"); 243 | res 244 | } 245 | 246 | impl Payload for ExtendedStatusUpdate { 247 | fn get_id(&self) -> u8 { 248 | ids::EXTENDED_STATUS_UPDATED 249 | } 250 | } 251 | 252 | /// Allow parsing a Message to an ExtendedStatusUpdate 253 | impl Into for super::Message { 254 | fn into(self) -> ExtendedStatusUpdate { 255 | new(self.get_payload_bytes(), self.model) 256 | } 257 | } 258 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "async-channel" 7 | version = "1.9.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" 10 | dependencies = [ 11 | "concurrent-queue", 12 | "event-listener 2.5.3", 13 | "futures-core", 14 | ] 15 | 16 | [[package]] 17 | name = "async-channel" 18 | version = "2.3.1" 19 | source = "registry+https://github.com/rust-lang/crates.io-index" 20 | checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a" 21 | dependencies = [ 22 | "concurrent-queue", 23 | "event-listener-strategy", 24 | "futures-core", 25 | "pin-project-lite", 26 | ] 27 | 28 | [[package]] 29 | name = "async-executor" 30 | version = "1.12.0" 31 | source = "registry+https://github.com/rust-lang/crates.io-index" 32 | checksum = "c8828ec6e544c02b0d6691d21ed9f9218d0384a82542855073c2a3f58304aaf0" 33 | dependencies = [ 34 | "async-task", 35 | "concurrent-queue", 36 | "fastrand 2.1.0", 37 | "futures-lite 2.3.0", 38 | "slab", 39 | ] 40 | 41 | [[package]] 42 | name = "async-global-executor" 43 | version = "2.4.1" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" 46 | dependencies = [ 47 | "async-channel 2.3.1", 48 | "async-executor", 49 | "async-io 2.3.3", 50 | "async-lock 3.4.0", 51 | "blocking", 52 | "futures-lite 2.3.0", 53 | "once_cell", 54 | ] 55 | 56 | [[package]] 57 | name = "async-io" 58 | version = "1.13.0" 59 | source = "registry+https://github.com/rust-lang/crates.io-index" 60 | checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" 61 | dependencies = [ 62 | "async-lock 2.8.0", 63 | "autocfg", 64 | "cfg-if 1.0.0", 65 | "concurrent-queue", 66 | "futures-lite 1.13.0", 67 | "log", 68 | "parking", 69 | "polling 2.8.0", 70 | "rustix 0.37.27", 71 | "slab", 72 | "socket2", 73 | "waker-fn", 74 | ] 75 | 76 | [[package]] 77 | name = "async-io" 78 | version = "2.3.3" 79 | source = "registry+https://github.com/rust-lang/crates.io-index" 80 | checksum = "0d6baa8f0178795da0e71bc42c9e5d13261aac7ee549853162e66a241ba17964" 81 | dependencies = [ 82 | "async-lock 3.4.0", 83 | "cfg-if 1.0.0", 84 | "concurrent-queue", 85 | "futures-io", 86 | "futures-lite 2.3.0", 87 | "parking", 88 | "polling 3.7.2", 89 | "rustix 0.38.34", 90 | "slab", 91 | "tracing", 92 | "windows-sys 0.52.0", 93 | ] 94 | 95 | [[package]] 96 | name = "async-lock" 97 | version = "2.8.0" 98 | source = "registry+https://github.com/rust-lang/crates.io-index" 99 | checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" 100 | dependencies = [ 101 | "event-listener 2.5.3", 102 | ] 103 | 104 | [[package]] 105 | name = "async-lock" 106 | version = "3.4.0" 107 | source = "registry+https://github.com/rust-lang/crates.io-index" 108 | checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" 109 | dependencies = [ 110 | "event-listener 5.3.1", 111 | "event-listener-strategy", 112 | "pin-project-lite", 113 | ] 114 | 115 | [[package]] 116 | name = "async-std" 117 | version = "1.12.0" 118 | source = "registry+https://github.com/rust-lang/crates.io-index" 119 | checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" 120 | dependencies = [ 121 | "async-channel 1.9.0", 122 | "async-global-executor", 123 | "async-io 1.13.0", 124 | "async-lock 2.8.0", 125 | "crossbeam-utils", 126 | "futures-channel", 127 | "futures-core", 128 | "futures-io", 129 | "futures-lite 1.13.0", 130 | "gloo-timers", 131 | "kv-log-macro", 132 | "log", 133 | "memchr", 134 | "once_cell", 135 | "pin-project-lite", 136 | "pin-utils", 137 | "slab", 138 | "wasm-bindgen-futures", 139 | ] 140 | 141 | [[package]] 142 | name = "async-task" 143 | version = "4.7.1" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" 146 | 147 | [[package]] 148 | name = "atomic-waker" 149 | version = "1.1.2" 150 | source = "registry+https://github.com/rust-lang/crates.io-index" 151 | checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" 152 | 153 | [[package]] 154 | name = "autocfg" 155 | version = "1.3.0" 156 | source = "registry+https://github.com/rust-lang/crates.io-index" 157 | checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" 158 | 159 | [[package]] 160 | name = "bitflags" 161 | version = "1.3.2" 162 | source = "registry+https://github.com/rust-lang/crates.io-index" 163 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 164 | 165 | [[package]] 166 | name = "bitflags" 167 | version = "2.6.0" 168 | source = "registry+https://github.com/rust-lang/crates.io-index" 169 | checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" 170 | 171 | [[package]] 172 | name = "blocking" 173 | version = "1.6.1" 174 | source = "registry+https://github.com/rust-lang/crates.io-index" 175 | checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" 176 | dependencies = [ 177 | "async-channel 2.3.1", 178 | "async-task", 179 | "futures-io", 180 | "futures-lite 2.3.0", 181 | "piper", 182 | ] 183 | 184 | [[package]] 185 | name = "bluetooth-serial-port-async" 186 | version = "0.6.3" 187 | source = "registry+https://github.com/rust-lang/crates.io-index" 188 | checksum = "60c2ea2fbe8638ca6c8d456000df6d77d856b18d43c2c96bdd0e338d99b599e8" 189 | dependencies = [ 190 | "async-std", 191 | "enum_primitive", 192 | "libc", 193 | "mio", 194 | "nix", 195 | ] 196 | 197 | [[package]] 198 | name = "bumpalo" 199 | version = "3.16.0" 200 | source = "registry+https://github.com/rust-lang/crates.io-index" 201 | checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" 202 | 203 | [[package]] 204 | name = "cc" 205 | version = "1.0.101" 206 | source = "registry+https://github.com/rust-lang/crates.io-index" 207 | checksum = "ac367972e516d45567c7eafc73d24e1c193dcf200a8d94e9db7b3d38b349572d" 208 | 209 | [[package]] 210 | name = "cfg-if" 211 | version = "0.1.10" 212 | source = "registry+https://github.com/rust-lang/crates.io-index" 213 | checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" 214 | 215 | [[package]] 216 | name = "cfg-if" 217 | version = "1.0.0" 218 | source = "registry+https://github.com/rust-lang/crates.io-index" 219 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 220 | 221 | [[package]] 222 | name = "concurrent-queue" 223 | version = "2.5.0" 224 | source = "registry+https://github.com/rust-lang/crates.io-index" 225 | checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" 226 | dependencies = [ 227 | "crossbeam-utils", 228 | ] 229 | 230 | [[package]] 231 | name = "crossbeam-utils" 232 | version = "0.8.20" 233 | source = "registry+https://github.com/rust-lang/crates.io-index" 234 | checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" 235 | 236 | [[package]] 237 | name = "enum_primitive" 238 | version = "0.1.1" 239 | source = "registry+https://github.com/rust-lang/crates.io-index" 240 | checksum = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180" 241 | dependencies = [ 242 | "num-traits 0.1.43", 243 | ] 244 | 245 | [[package]] 246 | name = "errno" 247 | version = "0.3.9" 248 | source = "registry+https://github.com/rust-lang/crates.io-index" 249 | checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" 250 | dependencies = [ 251 | "libc", 252 | "windows-sys 0.52.0", 253 | ] 254 | 255 | [[package]] 256 | name = "event-listener" 257 | version = "2.5.3" 258 | source = "registry+https://github.com/rust-lang/crates.io-index" 259 | checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" 260 | 261 | [[package]] 262 | name = "event-listener" 263 | version = "5.3.1" 264 | source = "registry+https://github.com/rust-lang/crates.io-index" 265 | checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" 266 | dependencies = [ 267 | "concurrent-queue", 268 | "parking", 269 | "pin-project-lite", 270 | ] 271 | 272 | [[package]] 273 | name = "event-listener-strategy" 274 | version = "0.5.2" 275 | source = "registry+https://github.com/rust-lang/crates.io-index" 276 | checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" 277 | dependencies = [ 278 | "event-listener 5.3.1", 279 | "pin-project-lite", 280 | ] 281 | 282 | [[package]] 283 | name = "fastrand" 284 | version = "1.9.0" 285 | source = "registry+https://github.com/rust-lang/crates.io-index" 286 | checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" 287 | dependencies = [ 288 | "instant", 289 | ] 290 | 291 | [[package]] 292 | name = "fastrand" 293 | version = "2.1.0" 294 | source = "registry+https://github.com/rust-lang/crates.io-index" 295 | checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" 296 | 297 | [[package]] 298 | name = "fuchsia-zircon" 299 | version = "0.3.3" 300 | source = "registry+https://github.com/rust-lang/crates.io-index" 301 | checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" 302 | dependencies = [ 303 | "bitflags 1.3.2", 304 | "fuchsia-zircon-sys", 305 | ] 306 | 307 | [[package]] 308 | name = "fuchsia-zircon-sys" 309 | version = "0.3.3" 310 | source = "registry+https://github.com/rust-lang/crates.io-index" 311 | checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" 312 | 313 | [[package]] 314 | name = "futures-channel" 315 | version = "0.3.30" 316 | source = "registry+https://github.com/rust-lang/crates.io-index" 317 | checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" 318 | dependencies = [ 319 | "futures-core", 320 | ] 321 | 322 | [[package]] 323 | name = "futures-core" 324 | version = "0.3.30" 325 | source = "registry+https://github.com/rust-lang/crates.io-index" 326 | checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" 327 | 328 | [[package]] 329 | name = "futures-io" 330 | version = "0.3.30" 331 | source = "registry+https://github.com/rust-lang/crates.io-index" 332 | checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" 333 | 334 | [[package]] 335 | name = "futures-lite" 336 | version = "1.13.0" 337 | source = "registry+https://github.com/rust-lang/crates.io-index" 338 | checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" 339 | dependencies = [ 340 | "fastrand 1.9.0", 341 | "futures-core", 342 | "futures-io", 343 | "memchr", 344 | "parking", 345 | "pin-project-lite", 346 | "waker-fn", 347 | ] 348 | 349 | [[package]] 350 | name = "futures-lite" 351 | version = "2.3.0" 352 | source = "registry+https://github.com/rust-lang/crates.io-index" 353 | checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" 354 | dependencies = [ 355 | "fastrand 2.1.0", 356 | "futures-core", 357 | "futures-io", 358 | "parking", 359 | "pin-project-lite", 360 | ] 361 | 362 | [[package]] 363 | name = "galaxy_buds_rs" 364 | version = "0.2.10" 365 | dependencies = [ 366 | "async-std", 367 | "bluetooth-serial-port-async", 368 | "serde", 369 | ] 370 | 371 | [[package]] 372 | name = "gloo-timers" 373 | version = "0.2.6" 374 | source = "registry+https://github.com/rust-lang/crates.io-index" 375 | checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" 376 | dependencies = [ 377 | "futures-channel", 378 | "futures-core", 379 | "js-sys", 380 | "wasm-bindgen", 381 | ] 382 | 383 | [[package]] 384 | name = "hermit-abi" 385 | version = "0.3.9" 386 | source = "registry+https://github.com/rust-lang/crates.io-index" 387 | checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" 388 | 389 | [[package]] 390 | name = "hermit-abi" 391 | version = "0.4.0" 392 | source = "registry+https://github.com/rust-lang/crates.io-index" 393 | checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" 394 | 395 | [[package]] 396 | name = "instant" 397 | version = "0.1.13" 398 | source = "registry+https://github.com/rust-lang/crates.io-index" 399 | checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" 400 | dependencies = [ 401 | "cfg-if 1.0.0", 402 | ] 403 | 404 | [[package]] 405 | name = "io-lifetimes" 406 | version = "1.0.11" 407 | source = "registry+https://github.com/rust-lang/crates.io-index" 408 | checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" 409 | dependencies = [ 410 | "hermit-abi 0.3.9", 411 | "libc", 412 | "windows-sys 0.48.0", 413 | ] 414 | 415 | [[package]] 416 | name = "iovec" 417 | version = "0.1.4" 418 | source = "registry+https://github.com/rust-lang/crates.io-index" 419 | checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" 420 | dependencies = [ 421 | "libc", 422 | ] 423 | 424 | [[package]] 425 | name = "js-sys" 426 | version = "0.3.69" 427 | source = "registry+https://github.com/rust-lang/crates.io-index" 428 | checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" 429 | dependencies = [ 430 | "wasm-bindgen", 431 | ] 432 | 433 | [[package]] 434 | name = "kernel32-sys" 435 | version = "0.2.2" 436 | source = "registry+https://github.com/rust-lang/crates.io-index" 437 | checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" 438 | dependencies = [ 439 | "winapi 0.2.8", 440 | "winapi-build", 441 | ] 442 | 443 | [[package]] 444 | name = "kv-log-macro" 445 | version = "1.0.7" 446 | source = "registry+https://github.com/rust-lang/crates.io-index" 447 | checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" 448 | dependencies = [ 449 | "log", 450 | ] 451 | 452 | [[package]] 453 | name = "libc" 454 | version = "0.2.155" 455 | source = "registry+https://github.com/rust-lang/crates.io-index" 456 | checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" 457 | 458 | [[package]] 459 | name = "linux-raw-sys" 460 | version = "0.3.8" 461 | source = "registry+https://github.com/rust-lang/crates.io-index" 462 | checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" 463 | 464 | [[package]] 465 | name = "linux-raw-sys" 466 | version = "0.4.14" 467 | source = "registry+https://github.com/rust-lang/crates.io-index" 468 | checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" 469 | 470 | [[package]] 471 | name = "log" 472 | version = "0.4.22" 473 | source = "registry+https://github.com/rust-lang/crates.io-index" 474 | checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" 475 | dependencies = [ 476 | "value-bag", 477 | ] 478 | 479 | [[package]] 480 | name = "memchr" 481 | version = "2.7.4" 482 | source = "registry+https://github.com/rust-lang/crates.io-index" 483 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 484 | 485 | [[package]] 486 | name = "mio" 487 | version = "0.6.23" 488 | source = "registry+https://github.com/rust-lang/crates.io-index" 489 | checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" 490 | dependencies = [ 491 | "cfg-if 0.1.10", 492 | "fuchsia-zircon", 493 | "fuchsia-zircon-sys", 494 | "iovec", 495 | "kernel32-sys", 496 | "libc", 497 | "log", 498 | "miow", 499 | "net2", 500 | "slab", 501 | "winapi 0.2.8", 502 | ] 503 | 504 | [[package]] 505 | name = "miow" 506 | version = "0.2.2" 507 | source = "registry+https://github.com/rust-lang/crates.io-index" 508 | checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" 509 | dependencies = [ 510 | "kernel32-sys", 511 | "net2", 512 | "winapi 0.2.8", 513 | "ws2_32-sys", 514 | ] 515 | 516 | [[package]] 517 | name = "net2" 518 | version = "0.2.39" 519 | source = "registry+https://github.com/rust-lang/crates.io-index" 520 | checksum = "b13b648036a2339d06de780866fbdfda0dde886de7b3af2ddeba8b14f4ee34ac" 521 | dependencies = [ 522 | "cfg-if 0.1.10", 523 | "libc", 524 | "winapi 0.3.9", 525 | ] 526 | 527 | [[package]] 528 | name = "nix" 529 | version = "0.19.1" 530 | source = "registry+https://github.com/rust-lang/crates.io-index" 531 | checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2" 532 | dependencies = [ 533 | "bitflags 1.3.2", 534 | "cc", 535 | "cfg-if 1.0.0", 536 | "libc", 537 | ] 538 | 539 | [[package]] 540 | name = "num-traits" 541 | version = "0.1.43" 542 | source = "registry+https://github.com/rust-lang/crates.io-index" 543 | checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" 544 | dependencies = [ 545 | "num-traits 0.2.19", 546 | ] 547 | 548 | [[package]] 549 | name = "num-traits" 550 | version = "0.2.19" 551 | source = "registry+https://github.com/rust-lang/crates.io-index" 552 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" 553 | dependencies = [ 554 | "autocfg", 555 | ] 556 | 557 | [[package]] 558 | name = "once_cell" 559 | version = "1.19.0" 560 | source = "registry+https://github.com/rust-lang/crates.io-index" 561 | checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" 562 | 563 | [[package]] 564 | name = "parking" 565 | version = "2.2.0" 566 | source = "registry+https://github.com/rust-lang/crates.io-index" 567 | checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" 568 | 569 | [[package]] 570 | name = "pin-project-lite" 571 | version = "0.2.14" 572 | source = "registry+https://github.com/rust-lang/crates.io-index" 573 | checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" 574 | 575 | [[package]] 576 | name = "pin-utils" 577 | version = "0.1.0" 578 | source = "registry+https://github.com/rust-lang/crates.io-index" 579 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 580 | 581 | [[package]] 582 | name = "piper" 583 | version = "0.2.3" 584 | source = "registry+https://github.com/rust-lang/crates.io-index" 585 | checksum = "ae1d5c74c9876f070d3e8fd503d748c7d974c3e48da8f41350fa5222ef9b4391" 586 | dependencies = [ 587 | "atomic-waker", 588 | "fastrand 2.1.0", 589 | "futures-io", 590 | ] 591 | 592 | [[package]] 593 | name = "polling" 594 | version = "2.8.0" 595 | source = "registry+https://github.com/rust-lang/crates.io-index" 596 | checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" 597 | dependencies = [ 598 | "autocfg", 599 | "bitflags 1.3.2", 600 | "cfg-if 1.0.0", 601 | "concurrent-queue", 602 | "libc", 603 | "log", 604 | "pin-project-lite", 605 | "windows-sys 0.48.0", 606 | ] 607 | 608 | [[package]] 609 | name = "polling" 610 | version = "3.7.2" 611 | source = "registry+https://github.com/rust-lang/crates.io-index" 612 | checksum = "a3ed00ed3fbf728b5816498ecd316d1716eecaced9c0c8d2c5a6740ca214985b" 613 | dependencies = [ 614 | "cfg-if 1.0.0", 615 | "concurrent-queue", 616 | "hermit-abi 0.4.0", 617 | "pin-project-lite", 618 | "rustix 0.38.34", 619 | "tracing", 620 | "windows-sys 0.52.0", 621 | ] 622 | 623 | [[package]] 624 | name = "proc-macro2" 625 | version = "1.0.86" 626 | source = "registry+https://github.com/rust-lang/crates.io-index" 627 | checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" 628 | dependencies = [ 629 | "unicode-ident", 630 | ] 631 | 632 | [[package]] 633 | name = "quote" 634 | version = "1.0.36" 635 | source = "registry+https://github.com/rust-lang/crates.io-index" 636 | checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" 637 | dependencies = [ 638 | "proc-macro2", 639 | ] 640 | 641 | [[package]] 642 | name = "rustix" 643 | version = "0.37.27" 644 | source = "registry+https://github.com/rust-lang/crates.io-index" 645 | checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" 646 | dependencies = [ 647 | "bitflags 1.3.2", 648 | "errno", 649 | "io-lifetimes", 650 | "libc", 651 | "linux-raw-sys 0.3.8", 652 | "windows-sys 0.48.0", 653 | ] 654 | 655 | [[package]] 656 | name = "rustix" 657 | version = "0.38.34" 658 | source = "registry+https://github.com/rust-lang/crates.io-index" 659 | checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" 660 | dependencies = [ 661 | "bitflags 2.6.0", 662 | "errno", 663 | "libc", 664 | "linux-raw-sys 0.4.14", 665 | "windows-sys 0.52.0", 666 | ] 667 | 668 | [[package]] 669 | name = "serde" 670 | version = "1.0.203" 671 | source = "registry+https://github.com/rust-lang/crates.io-index" 672 | checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" 673 | dependencies = [ 674 | "serde_derive", 675 | ] 676 | 677 | [[package]] 678 | name = "serde_derive" 679 | version = "1.0.203" 680 | source = "registry+https://github.com/rust-lang/crates.io-index" 681 | checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" 682 | dependencies = [ 683 | "proc-macro2", 684 | "quote", 685 | "syn", 686 | ] 687 | 688 | [[package]] 689 | name = "slab" 690 | version = "0.4.9" 691 | source = "registry+https://github.com/rust-lang/crates.io-index" 692 | checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" 693 | dependencies = [ 694 | "autocfg", 695 | ] 696 | 697 | [[package]] 698 | name = "socket2" 699 | version = "0.4.10" 700 | source = "registry+https://github.com/rust-lang/crates.io-index" 701 | checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" 702 | dependencies = [ 703 | "libc", 704 | "winapi 0.3.9", 705 | ] 706 | 707 | [[package]] 708 | name = "syn" 709 | version = "2.0.68" 710 | source = "registry+https://github.com/rust-lang/crates.io-index" 711 | checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" 712 | dependencies = [ 713 | "proc-macro2", 714 | "quote", 715 | "unicode-ident", 716 | ] 717 | 718 | [[package]] 719 | name = "tracing" 720 | version = "0.1.40" 721 | source = "registry+https://github.com/rust-lang/crates.io-index" 722 | checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" 723 | dependencies = [ 724 | "pin-project-lite", 725 | "tracing-core", 726 | ] 727 | 728 | [[package]] 729 | name = "tracing-core" 730 | version = "0.1.32" 731 | source = "registry+https://github.com/rust-lang/crates.io-index" 732 | checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" 733 | 734 | [[package]] 735 | name = "unicode-ident" 736 | version = "1.0.12" 737 | source = "registry+https://github.com/rust-lang/crates.io-index" 738 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 739 | 740 | [[package]] 741 | name = "value-bag" 742 | version = "1.9.0" 743 | source = "registry+https://github.com/rust-lang/crates.io-index" 744 | checksum = "5a84c137d37ab0142f0f2ddfe332651fdbf252e7b7dbb4e67b6c1f1b2e925101" 745 | 746 | [[package]] 747 | name = "waker-fn" 748 | version = "1.2.0" 749 | source = "registry+https://github.com/rust-lang/crates.io-index" 750 | checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7" 751 | 752 | [[package]] 753 | name = "wasm-bindgen" 754 | version = "0.2.92" 755 | source = "registry+https://github.com/rust-lang/crates.io-index" 756 | checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" 757 | dependencies = [ 758 | "cfg-if 1.0.0", 759 | "wasm-bindgen-macro", 760 | ] 761 | 762 | [[package]] 763 | name = "wasm-bindgen-backend" 764 | version = "0.2.92" 765 | source = "registry+https://github.com/rust-lang/crates.io-index" 766 | checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" 767 | dependencies = [ 768 | "bumpalo", 769 | "log", 770 | "once_cell", 771 | "proc-macro2", 772 | "quote", 773 | "syn", 774 | "wasm-bindgen-shared", 775 | ] 776 | 777 | [[package]] 778 | name = "wasm-bindgen-futures" 779 | version = "0.4.42" 780 | source = "registry+https://github.com/rust-lang/crates.io-index" 781 | checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" 782 | dependencies = [ 783 | "cfg-if 1.0.0", 784 | "js-sys", 785 | "wasm-bindgen", 786 | "web-sys", 787 | ] 788 | 789 | [[package]] 790 | name = "wasm-bindgen-macro" 791 | version = "0.2.92" 792 | source = "registry+https://github.com/rust-lang/crates.io-index" 793 | checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" 794 | dependencies = [ 795 | "quote", 796 | "wasm-bindgen-macro-support", 797 | ] 798 | 799 | [[package]] 800 | name = "wasm-bindgen-macro-support" 801 | version = "0.2.92" 802 | source = "registry+https://github.com/rust-lang/crates.io-index" 803 | checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" 804 | dependencies = [ 805 | "proc-macro2", 806 | "quote", 807 | "syn", 808 | "wasm-bindgen-backend", 809 | "wasm-bindgen-shared", 810 | ] 811 | 812 | [[package]] 813 | name = "wasm-bindgen-shared" 814 | version = "0.2.92" 815 | source = "registry+https://github.com/rust-lang/crates.io-index" 816 | checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" 817 | 818 | [[package]] 819 | name = "web-sys" 820 | version = "0.3.69" 821 | source = "registry+https://github.com/rust-lang/crates.io-index" 822 | checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" 823 | dependencies = [ 824 | "js-sys", 825 | "wasm-bindgen", 826 | ] 827 | 828 | [[package]] 829 | name = "winapi" 830 | version = "0.2.8" 831 | source = "registry+https://github.com/rust-lang/crates.io-index" 832 | checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" 833 | 834 | [[package]] 835 | name = "winapi" 836 | version = "0.3.9" 837 | source = "registry+https://github.com/rust-lang/crates.io-index" 838 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 839 | dependencies = [ 840 | "winapi-i686-pc-windows-gnu", 841 | "winapi-x86_64-pc-windows-gnu", 842 | ] 843 | 844 | [[package]] 845 | name = "winapi-build" 846 | version = "0.1.1" 847 | source = "registry+https://github.com/rust-lang/crates.io-index" 848 | checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" 849 | 850 | [[package]] 851 | name = "winapi-i686-pc-windows-gnu" 852 | version = "0.4.0" 853 | source = "registry+https://github.com/rust-lang/crates.io-index" 854 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 855 | 856 | [[package]] 857 | name = "winapi-x86_64-pc-windows-gnu" 858 | version = "0.4.0" 859 | source = "registry+https://github.com/rust-lang/crates.io-index" 860 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 861 | 862 | [[package]] 863 | name = "windows-sys" 864 | version = "0.48.0" 865 | source = "registry+https://github.com/rust-lang/crates.io-index" 866 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 867 | dependencies = [ 868 | "windows-targets 0.48.5", 869 | ] 870 | 871 | [[package]] 872 | name = "windows-sys" 873 | version = "0.52.0" 874 | source = "registry+https://github.com/rust-lang/crates.io-index" 875 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 876 | dependencies = [ 877 | "windows-targets 0.52.5", 878 | ] 879 | 880 | [[package]] 881 | name = "windows-targets" 882 | version = "0.48.5" 883 | source = "registry+https://github.com/rust-lang/crates.io-index" 884 | checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 885 | dependencies = [ 886 | "windows_aarch64_gnullvm 0.48.5", 887 | "windows_aarch64_msvc 0.48.5", 888 | "windows_i686_gnu 0.48.5", 889 | "windows_i686_msvc 0.48.5", 890 | "windows_x86_64_gnu 0.48.5", 891 | "windows_x86_64_gnullvm 0.48.5", 892 | "windows_x86_64_msvc 0.48.5", 893 | ] 894 | 895 | [[package]] 896 | name = "windows-targets" 897 | version = "0.52.5" 898 | source = "registry+https://github.com/rust-lang/crates.io-index" 899 | checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" 900 | dependencies = [ 901 | "windows_aarch64_gnullvm 0.52.5", 902 | "windows_aarch64_msvc 0.52.5", 903 | "windows_i686_gnu 0.52.5", 904 | "windows_i686_gnullvm", 905 | "windows_i686_msvc 0.52.5", 906 | "windows_x86_64_gnu 0.52.5", 907 | "windows_x86_64_gnullvm 0.52.5", 908 | "windows_x86_64_msvc 0.52.5", 909 | ] 910 | 911 | [[package]] 912 | name = "windows_aarch64_gnullvm" 913 | version = "0.48.5" 914 | source = "registry+https://github.com/rust-lang/crates.io-index" 915 | checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 916 | 917 | [[package]] 918 | name = "windows_aarch64_gnullvm" 919 | version = "0.52.5" 920 | source = "registry+https://github.com/rust-lang/crates.io-index" 921 | checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" 922 | 923 | [[package]] 924 | name = "windows_aarch64_msvc" 925 | version = "0.48.5" 926 | source = "registry+https://github.com/rust-lang/crates.io-index" 927 | checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 928 | 929 | [[package]] 930 | name = "windows_aarch64_msvc" 931 | version = "0.52.5" 932 | source = "registry+https://github.com/rust-lang/crates.io-index" 933 | checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" 934 | 935 | [[package]] 936 | name = "windows_i686_gnu" 937 | version = "0.48.5" 938 | source = "registry+https://github.com/rust-lang/crates.io-index" 939 | checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 940 | 941 | [[package]] 942 | name = "windows_i686_gnu" 943 | version = "0.52.5" 944 | source = "registry+https://github.com/rust-lang/crates.io-index" 945 | checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" 946 | 947 | [[package]] 948 | name = "windows_i686_gnullvm" 949 | version = "0.52.5" 950 | source = "registry+https://github.com/rust-lang/crates.io-index" 951 | checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" 952 | 953 | [[package]] 954 | name = "windows_i686_msvc" 955 | version = "0.48.5" 956 | source = "registry+https://github.com/rust-lang/crates.io-index" 957 | checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 958 | 959 | [[package]] 960 | name = "windows_i686_msvc" 961 | version = "0.52.5" 962 | source = "registry+https://github.com/rust-lang/crates.io-index" 963 | checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" 964 | 965 | [[package]] 966 | name = "windows_x86_64_gnu" 967 | version = "0.48.5" 968 | source = "registry+https://github.com/rust-lang/crates.io-index" 969 | checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 970 | 971 | [[package]] 972 | name = "windows_x86_64_gnu" 973 | version = "0.52.5" 974 | source = "registry+https://github.com/rust-lang/crates.io-index" 975 | checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" 976 | 977 | [[package]] 978 | name = "windows_x86_64_gnullvm" 979 | version = "0.48.5" 980 | source = "registry+https://github.com/rust-lang/crates.io-index" 981 | checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 982 | 983 | [[package]] 984 | name = "windows_x86_64_gnullvm" 985 | version = "0.52.5" 986 | source = "registry+https://github.com/rust-lang/crates.io-index" 987 | checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" 988 | 989 | [[package]] 990 | name = "windows_x86_64_msvc" 991 | version = "0.48.5" 992 | source = "registry+https://github.com/rust-lang/crates.io-index" 993 | checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 994 | 995 | [[package]] 996 | name = "windows_x86_64_msvc" 997 | version = "0.52.5" 998 | source = "registry+https://github.com/rust-lang/crates.io-index" 999 | checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" 1000 | 1001 | [[package]] 1002 | name = "ws2_32-sys" 1003 | version = "0.2.1" 1004 | source = "registry+https://github.com/rust-lang/crates.io-index" 1005 | checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" 1006 | dependencies = [ 1007 | "winapi 0.2.8", 1008 | "winapi-build", 1009 | ] 1010 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------