Compare commits

..

No commits in common. "279b329a1e71c0c5f3336609ed1bc84a3810d374" and "13bf53e9643229a9eceb68002bebdf2bfb467c91" have entirely different histories.

49 changed files with 2161 additions and 307 deletions

View File

@ -1166,6 +1166,5 @@
"云存会员": "عضوية التخزين السحابي",
"服务,图像视频信息随心存!": "معلومات الخدمة والصور والفيديو في قلبك!",
"图像": "صورة",
"视频": "فيديو",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "حاليا ، لا تدعم الدولة تسجيل رمز التحقق من الهاتف المحمول ، يرجى استخدام عنوان بريدك الإلكتروني للتسجيل"
"视频": "فيديو"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Членство в Cloud Storage",
"服务,图像视频信息随心存!": "Информацията за обслужване, изображения и видео са във вашето сърце!",
"图像": "изображение",
"视频": "Видео",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "В момента страната не поддържа регистрация на код за потвърждение на мобилен телефон, моля, използвайте имейл адреса си, за да се регистрирате"
"视频": "Видео"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "ক্লাউড স্টোরেজ সদস্যতা",
"服务,图像视频信息随心存!": "পরিষেবা, চিত্র এবং ভিডিও তথ্য আপনার হৃদয়ে!",
"图像": "প্রতিচ্ছবি",
"视频": "ভিডিও",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "বর্তমানে, দেশটি মোবাইল ফোন যাচাইকরণ কোড নিবন্ধন সমর্থন করে না, নিবন্ধন করতে দয়া করে আপনার ইমেল ঠিকানা ব্যবহার করুন"
"视频": "ভিডিও"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Členství v cloudovém úložišti",
"服务,图像视频信息随心存!": "Servis, obrazové a video informace jsou na prvním místě!",
"图像": "obraz",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "V současné době země nepodporuje registraci ověřovacího kódu mobilního telefonu, k registraci použijte prosím svou e-mailovou adresu"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Medlemskab af Cloud Storage",
"服务,图像视频信息随心存!": "Service-, billed- og videoinformation er i dit hjerte!",
"图像": "billede",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "I øjeblikket understøtter landet ikke registrering af mobiltelefonbekræftelseskode, brug venligst din e-mailadresse til at tilmelde dig"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Cloud-Speicher-Mitgliedschaft",
"服务,图像视频信息随心存!": "Service-, Bild- und Videoinformationen liegen Ihnen am Herzen!",
"图像": "Bild",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Derzeit unterstützt das Land die Registrierung von Verifizierungscodes für Mobiltelefone nicht, bitte verwenden Sie Ihre E-Mail-Adresse, um sich zu registrieren"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Συνδρομή Cloud Storage",
"服务,图像视频信息随心存!": "Οι πληροφορίες εξυπηρέτησης, εικόνας και βίντεο είναι στην καρδιά σας!",
"图像": "εικόνα",
"视频": "Βίντεο",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Προς το παρόν, η χώρα δεν υποστηρίζει την εγγραφή κωδικού επαλήθευσης κινητού τηλεφώνου, χρησιμοποιήστε τη διεύθυνση email σας για να εγγραφείτε"
"视频": "Βίντεο"
}

View File

@ -1173,6 +1173,5 @@
"云存会员": "Cloud Storage Membership",
"服务,图像视频信息随心存!": "Service, image and video information are at your heart!",
"图像": "image",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Currently, the country does not support mobile phone verification code registration, please use your email address to register"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Membresía de almacenamiento en la nube",
"服务,图像视频信息随心存!": "¡La información de servicio, imagen y video está en su corazón!",
"图像": "imagen",
"视频": "Vídeo",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Actualmente, el país no admite el registro de códigos de verificación de teléfonos móviles, utilice su dirección de correo electrónico para registrarse"
"视频": "Vídeo"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Pilvesalvestuse liikmelisus",
"服务,图像视频信息随心存!": "Teenindus-, pildi- ja videoteave on teie südames!",
"图像": "Piltide",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Praegu ei toeta riik mobiiltelefoni kinnituskoodi registreerimist, palun kasutage registreerumiseks oma e-posti aadressi"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Pilvitallennustilan jäsenyys",
"服务,图像视频信息随心存!": "Palvelu-, kuva- ja videotiedot ovat sydämessäsi!",
"图像": "kuva",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Tällä hetkellä maa ei tue matkapuhelimen vahvistuskoodin rekisteröintiä, käytä rekisteröitymiseen sähköpostiosoitettasi"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Adhésion au stockage dans le cloud",
"服务,图像视频信息随心存!": "Le service, limage et les informations vidéo sont au cœur de vos préoccupations !",
"图像": "image",
"视频": "Vidéo",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Actuellement, le pays ne prend pas en charge lenregistrement du code de vérification du téléphone portable, veuillez utiliser votre adresse e-mail pour vous inscrire"
"视频": "Vidéo"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "חברות באחסון בענן",
"服务,图像视频信息随心存!": "מידע על שירות, תמונה ווידאו נמצאים בלב שלך!",
"图像": "תמונה",
"视频": "וידאו",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "נכון לעכשיו, המדינה אינה תומכת ברישום קוד אימות טלפון נייד, אנא השתמש בכתובת הדוא\"ל שלך כדי להירשם"
"视频": "וידאו"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "क्लाउड स्टोरेज सदस्यता",
"服务,图像视频信息随心存!": "सेवा, छवि और वीडियो जानकारी आपके दिल में हैं!",
"图像": "प्रतिबिंब",
"视频": "वीडियो",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "वर्तमान में, देश मोबाइल फोन सत्यापन कोड पंजीकरण का समर्थन नहीं करता है, कृपया पंजीकरण करने के लिए अपने ईमेल पते का उपयोग करें"
"视频": "वीडियो"
}

View File

@ -1168,6 +1168,5 @@
"云存会员": "雲存會員",
"服务,图像视频信息随心存!": "服務,圖像視頻資訊隨心存!",
"图像": "圖像",
"视频": "視頻",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "當前國家不支援手機驗證碼註冊,請使用郵箱進行註冊"
"视频": "視頻"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Članstvo u pohrani u oblaku",
"服务,图像视频信息随心存!": "Informacije o usluzi, slikama i videozapisima su vam u srcu!",
"图像": "slika",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Trenutno zemlja ne podržava registraciju koda za provjeru mobilnog telefona, za registraciju koristite svoju adresu e-pošte"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Felhőalapú tárolási tagság",
"服务,图像视频信息随心存!": "A szolgáltatás, a képi és videós információk a szívedben vannak!",
"图像": "kép",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Jelenleg az ország nem támogatja a mobiltelefonos ellenőrző kód regisztrációját, kérjük, használja e-mail címét a regisztrációhoz"
"视频": "Video"
}

View File

@ -1173,6 +1173,5 @@
"云存会员": "Cloud Storage Membership",
"服务,图像视频信息随心存!": "Ծառայությունը, պատկերը եւ վիդեո տեղեկատվությունը ձեր սրտում են:",
"图像": "Պատկերասրահ",
"视频": "Տեսանյութ",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Ներկայումս երկիրը չի աջակցում բջջային հեռախոսի ստուգման կոդի գրանցմանը, խնդրում ենք գրանցվելու համար օգտագործել ձեր էլ. փոստի հասցեն"
"视频": "Տեսանյութ"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Keanggotaan Cloud Storage",
"服务,图像视频信息随心存!": "Informasi layanan, gambar, dan video adalah inti Anda!",
"图像": "citra",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Saat ini, negara tersebut tidak mendukung pendaftaran kode verifikasi ponsel, silakan gunakan alamat email Anda untuk mendaftar"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Iscrizione al cloud storage",
"服务,图像视频信息随心存!": "Le informazioni sul servizio, le immagini e i video sono al tuo centro!",
"图像": "immagine",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Attualmente, il paese non supporta la registrazione del codice di verifica del telefono cellulare, si prega di utilizzare il proprio indirizzo e-mail per registrarsi"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "クラウドストレージメンバーシップ",
"服务,图像视频信息随心存!": "サービス、画像、ビデオ情報があなたの中心にあります!",
"图像": "画像",
"视频": "ビデオ",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "現在、この国は携帯電話の認証コード登録をサポートしていませんので、メールアドレスを使用して登録してください"
"视频": "ビデオ"
}

View File

@ -1173,6 +1173,5 @@
"云存会员": "Cloud Storage წევრობა",
"服务,图像视频信息随心存!": "მომსახურება, სურათი და ვიდეო ინფორმაცია თქვენს გულშია!",
"图像": "სურათი",
"视频": "ვიდეო",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "ამჟამად, ქვეყანა არ უჭერს მხარს მობილური ტელეფონის დამადასტურებელი კოდის რეგისტრაციას, გთხოვთ გამოიყენოთ თქვენი ელექტრონული ფოსტის მისამართი რეგისტრაციისთვის"
"视频": "ვიდეო"
}

View File

@ -1178,6 +1178,5 @@
"云存会员": "云存会员",
"服务,图像视频信息随心存!": "服务,图像视频信息随心存!",
"图像": "图像",
"视频": "视频",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "当前国家不支持手机验证码注册,请使用邮箱进行注册"
"视频": "视频"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Бұлтты сақтауға мүшелік",
"服务,图像视频信息随心存!": "Қызмет, бейне және бейне ақпарат сіздің жүрегіңізде жатыр!",
"图像": "кескіні",
"视频": "Бейне",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Қазіргі уақытта елде ұялы телефонды растау кодын тіркеуді қолдамайды, тіркелу үшін электрондық пошта мекенжайыңызды пайдаланыңыз"
"视频": "Бейне"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "클라우드 스토리지 멤버십",
"服务,图像视频信息随心存!": "서비스, 이미지 및 비디오 정보가 당신의 중심에 있습니다!",
"图像": "이미지",
"视频": "비디오",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "현재 해당 국가는 휴대폰 인증코드 등록을 지원하지 않으니 이메일 주소를 사용하여 등록하세요."
"视频": "비디오"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Debesies saugyklos narystė",
"服务,图像视频信息随心存!": "Aptarnavimas, vaizdas ir video informacija yra jūsų širdis!",
"图像": "vaizdas",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Šiuo metu šalis nepalaiko mobiliojo telefono patvirtinimo kodo registracijos, registruodamiesi naudokite savo el. pašto adresą"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Keahlian Storan Awan",
"服务,图像视频信息随心存!": "Maklumat perkhidmatan, imej dan video adalah di hati anda!",
"图像": "Imej",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Pada masa ini, negara ini tidak menyokong pendaftaran kod pengesahan telefon bimbit, sila gunakan alamat e-mel anda untuk mendaftar"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Lidmaatschap voor cloudopslag",
"服务,图像视频信息随心存!": "Service-, beeld- en video-informatie staan bij u centraal!",
"图像": "beeld",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Momenteel ondersteunt het land de registratie van de verificatiecode voor mobiele telefoons niet, gebruik uw e-mailadres om u te registreren"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Członkostwo w usłudze Cloud Storage",
"服务,图像视频信息随心存!": "Informacje o serwisie, obrazie i wideo są w Twoim sercu!",
"图像": "obraz",
"视频": "Wideo",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Obecnie kraj nie obsługuje rejestracji kodem weryfikacyjnym telefonu komórkowego, użyj swojego adresu e-mail, aby się zarejestrować"
"视频": "Wideo"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Associação de armazenamento em nuvem",
"服务,图像视频信息随心存!": "Informações de serviço, imagem e vídeo estão no seu coração!",
"图像": "imagem",
"视频": "Vídeo",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Atualmente, o país não suporta o registro do código de verificação do telefone celular, use seu endereço de e-mail para se registrar"
"视频": "Vídeo"
}

View File

@ -1172,6 +1172,5 @@
"云存会员": "Associação de armazenamento em nuvem",
"服务,图像视频信息随心存!": "Informações de serviço, imagem e vídeo estão no seu coração!",
"图像": "imagem",
"视频": "Vídeo",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Atualmente, o país não suporta o registro do código de verificação do telefone celular, use seu endereço de e-mail para se registrar"
"视频": "Vídeo"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Abonament de stocare în cloud",
"服务,图像视频信息随心存!": "Serviciile, imaginile și informațiile video sunt în centrul dumneavoastră!",
"图像": "imagine",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "În prezent, țara nu acceptă înregistrarea codului de verificare a telefonului mobil, vă rugăm să utilizați adresa de e-mail pentru a vă înregistra"
"视频": "Video"
}

View File

@ -1171,6 +1171,5 @@
"云存会员": "Членство в облачном хранилище",
"服务,图像视频信息随心存!": "Сервисная, имиджевая и видеоинформация в Вашем сердце!",
"图像": "образ",
"视频": "Видео",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "В настоящее время страна не поддерживает регистрацию кода верификации мобильного телефона, пожалуйста, используйте свой адрес электронной почты для регистрации"
"视频": "Видео"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Členstvo v cloudovom úložisku",
"服务,图像视频信息随心存!": "Informácie o službách, obrázkoch a videách sú vo vašom srdci!",
"图像": "obraz",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "V súčasnosti krajina nepodporuje registráciu overovacieho kódu mobilného telefónu, na registráciu použite svoju e-mailovú adresu"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Чланство у облаку за складиштење",
"服务,图像视频信息随心存!": "Сервис , слике и видео информације су у вашем срцу!",
"图像": "Слика",
"视频": "Пријава",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Тренутно , земља не подржава регистрацију кода за верификацију мобилног телефона, молимо вас да користите своју адресу е-поште за регистрацију"
"视频": "Пријава"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Medlemskap i molnlagring",
"服务,图像视频信息随心存!": "Service, bild- och videoinformation finns i ditt hjärta!",
"图像": "bild",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "För närvarande stöder landet inte registrering av verifieringskoder för mobiltelefoner, använd din e-postadress för att registrera dig"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "สมาชิกที่เก็บข้อมูลบนคลาวด์",
"服务,图像视频信息随心存!": "ข้อมูลบริการ รูปภาพ และวิดีโออยู่ที่หัวใจของคุณ!",
"图像": "ภาพ",
"视频": "วีดิทัศน์",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "ปัจจุบันประเทศไม่รองรับการลงทะเบียนรหัสยืนยันโทรศัพท์มือถือ โปรดใช้ที่อยู่อีเมลของคุณในการลงทะเบียน"
"视频": "วีดิทัศน์"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Bulut Depolama Üyeliği",
"服务,图像视频信息随心存!": "Servis, görüntü ve video bilgileri kalbinizde!",
"图像": "resim",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Şu anda ülke cep telefonu doğrulama kodu kaydını desteklememektedir, lütfen kaydolmak için e-posta adresinizi kullanın"
"视频": "Video"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "雲存會員",
"服务,图像视频信息随心存!": "服務,圖像視頻資訊隨心存!",
"图像": "圖像",
"视频": "視頻",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "當前國家不支援手機驗證碼註冊,請使用郵箱進行註冊"
"视频": "視頻"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Членство в хмарних сховищах",
"服务,图像视频信息随心存!": "Сервіс, зображення та відео інформація у вашому серці!",
"图像": "образ",
"视频": "Відео",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Наразі країна не підтримує реєстрацію коду підтвердження на мобільному телефоні, будь ласка, використовуйте свою адресу електронної пошти для реєстрації"
"视频": "Відео"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Cloud Storage Membership",
"服务,图像视频信息随心存!": "خدمت، تصویر اور ویڈیو کی معلومات آپ کے دل میں ہیں!",
"图像": "روپ",
"视频": "ویڈیو",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "فی الحال، ملک موبائل فون کی توثیقی کوڈ رجسٹریشن کی حمایت نہیں کرتا ہے، براہ کرم رجسٹر کرنے کے لئے اپنا ای میل ایڈریس استعمال کریں"
"视频": "ویڈیو"
}

View File

@ -1167,6 +1167,5 @@
"云存会员": "Tư cách thành viên lưu trữ đám mây",
"服务,图像视频信息随心存!": "Thông tin dịch vụ, hình ảnh và video là trọng tâm của bạn!",
"图像": "ảnh",
"视频": "Video",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "Hiện tại, quốc gia này không hỗ trợ đăng ký mã xác minh điện thoại di động, vui lòng sử dụng địa chỉ email của bạn để đăng ký"
"视频": "Video"
}

View File

@ -1179,6 +1179,5 @@
"云存会员": "云存会员",
"服务,图像视频信息随心存!": "服务,图像视频信息随心存!",
"图像": "图像",
"视频": "视频",
"当前国家不支持手机验证码注册,请使用邮箱进行注册": "当前国家不支持手机验证码注册,请使用邮箱进行注册"
"视频": "视频"
}

View File

@ -16,7 +16,8 @@ import 'io_type.dart';
import 'reciver_data.dart';
//
typedef ConnectStateCallBack = Function(BluetoothConnectionState connectionState);
typedef ConnectStateCallBack = Function(
BluetoothConnectionState connectionState);
typedef ScanDevicesCallBack = Function(List<ScanResult>);
class BlueManage {
@ -61,7 +62,8 @@ class BlueManage {
ScanResult? scanResult;
//
BluetoothConnectionState? bluetoothConnectionState = BluetoothConnectionState.disconnected;
BluetoothConnectionState? bluetoothConnectionState =
BluetoothConnectionState.disconnected;
BluetoothAdapterState? _adapterState = BluetoothAdapterState.on;
StreamSubscription<BluetoothAdapterState>? _adapterStateStateSubscription;
@ -101,7 +103,7 @@ class BlueManage {
//
_mtuSubscription?.cancel();
_mtuSubscription = null;
_mtuSubscription = bluetoothConnectDevice!.mtu.listen((int value) {
_mtuSize = value - 3;
AppLog.log('设备MTU变化 - 原始值:$value 计算后MTU:$_mtuSize 设备:${bluetoothConnectDevice?.remoteId.str}');
@ -109,7 +111,8 @@ class BlueManage {
}
void _initAdapterStateStateSubscription() {
_adapterStateStateSubscription ??= FlutterBluePlus.adapterState.listen((BluetoothAdapterState state) {
_adapterStateStateSubscription ??=
FlutterBluePlus.adapterState.listen((BluetoothAdapterState state) {
AppLog.log('蓝牙状态:$state');
_adapterState = state;
});
@ -119,15 +122,18 @@ class BlueManage {
_connectionStateSubscription?.cancel();
_connectionStateSubscription = null;
_connectionStateSubscription =
bluetoothConnectDevice!.connectionState.listen((BluetoothConnectionState state) async {
_connectionStateSubscription = bluetoothConnectDevice!.connectionState
.listen((BluetoothConnectionState state) async {
bluetoothConnectionState = state;
AppLog.log('蓝牙连接回调状态:$state');
});
}
void _initSendStreamSubscription() {
_sendStreamSubscription ??= EventBusManager().eventBus!.on<EventSendModel>().listen((EventSendModel model) {
_sendStreamSubscription ??= EventBusManager()
.eventBus!
.on<EventSendModel>()
.listen((EventSendModel model) {
AppLog.log('eventBus接收发送数据:${model}');
if (model.sendChannel == DataChannel.ble) {
FlutterBluePlus.isSupported.then((bool isAvailable) async {
@ -152,7 +158,8 @@ class BlueManage {
}
///
Future<void> startScanSingle(String deviceName, int timeout, ScanDevicesCallBack scanDevicesCallBack) async {
Future<void> startScanSingle(String deviceName, int timeout,
ScanDevicesCallBack scanDevicesCallBack) async {
final DateTime start = DateTime.now();
FlutterBluePlus.isSupported.then((bool isAvailable) async {
if (isAvailable) {
@ -160,7 +167,9 @@ class BlueManage {
if (_adapterState == BluetoothAdapterState.on) {
try {
BuglyTool.uploadException(
message: '开始指定设备名称的扫描蓝牙设备', detail: '调用方法是:startScanSingle 指定设备名称是:$deviceName', upload: false);
message: '开始指定设备名称的扫描蓝牙设备',
detail: '调用方法是:startScanSingle 指定设备名称是:$deviceName',
upload: false);
//android 3
final int divisor = Platform.isAndroid ? 3 : 1;
FlutterBluePlus.startScan(
@ -172,9 +181,12 @@ class BlueManage {
final StreamSubscription<List<ScanResult>> subscription =
FlutterBluePlus.scanResults.listen((List<ScanResult> results) {
final bool isExit = results.any((ScanResult element) =>
(element.device.platformName == deviceName) || (element.advertisementData.advName == deviceName));
final int milliseconds = DateTime.now().millisecondsSinceEpoch - start.millisecondsSinceEpoch;
AppLog.log('扫描到的设备数:${results.length} 是否查找到 $isExit 以查找$milliseconds毫秒');
(element.device.platformName == deviceName) ||
(element.advertisementData.advName == deviceName));
final int milliseconds = DateTime.now().millisecondsSinceEpoch -
start.millisecondsSinceEpoch;
AppLog.log(
'扫描到的设备数:${results.length} 是否查找到 $isExit 以查找$milliseconds毫秒');
BuglyTool.uploadException(
message: '指定设备名称的扫描蓝牙设备 监听扫描结果',
detail:
@ -190,15 +202,20 @@ class BlueManage {
}
final isMatch = _isMatch(
scanResult.advertisementData.serviceUuids.map((e) => e.uuid).toList(),
scanResult.advertisementData.serviceUuids
.map((e) => e.uuid)
.toList(),
isSingle: true,
);
if (isMatch && (scanResult.rssi >= -100)) {
// id相同的元素
final int knownDeviceIndex = scanDevices.indexWhere((ScanResult d) =>
(d.device.platformName == scanResult.device.platformName) ||
(d.advertisementData.advName == scanResult.advertisementData.advName));
final int knownDeviceIndex = scanDevices.indexWhere(
(ScanResult d) =>
(d.device.platformName ==
scanResult.device.platformName) ||
(d.advertisementData.advName ==
scanResult.advertisementData.advName));
// -1
if (knownDeviceIndex >= 0) {
scanDevices[knownDeviceIndex] = scanResult;
@ -207,7 +224,8 @@ class BlueManage {
}
BuglyTool.uploadException(
message: '遍历扫描到的结果跟缓存的结果对比,如果有最新的就更新缓存',
detail: 'startScanSingle deviceName:$deviceName 查询到的结果scanResult:$scanResult',
detail:
'startScanSingle deviceName:$deviceName 查询到的结果scanResult:$scanResult',
upload: false);
}
}
@ -216,7 +234,9 @@ class BlueManage {
}
}, onError: (e) {
BuglyTool.uploadException(
message: '指定设备名称的扫描蓝牙设备 监听扫描结果失败', detail: '打印失败问题 e${e.toString()}', upload: false);
message: '指定设备名称的扫描蓝牙设备 监听扫描结果失败',
detail: '打印失败问题 e${e.toString()}',
upload: false);
AppLog.log('扫描失败:$e');
});
FlutterBluePlus.cancelWhenScanComplete(subscription);
@ -225,7 +245,9 @@ class BlueManage {
subscription.cancel();
} catch (e) {
BuglyTool.uploadException(
message: '指定设备名称的扫描蓝牙设备 内部逻辑整形失败', detail: 'tartScanSingle内部逻辑整形失败 e:${e.toString()}', upload: false);
message: '指定设备名称的扫描蓝牙设备 内部逻辑整形失败',
detail: 'tartScanSingle内部逻辑整形失败 e:${e.toString()}',
upload: false);
AppLog.log('扫描失败');
}
} else {
@ -242,11 +264,12 @@ class BlueManage {
}
///
Future<void> startScan(int timeout, DeviceType deviceType, ScanDevicesCallBack scanDevicesCallBack,
Future<void> startScan(int timeout, DeviceType deviceType,
ScanDevicesCallBack scanDevicesCallBack,
{List<Guid>? idList}) async {
FlutterBluePlus.isSupported.then((bool isAvailable) async {
if (isAvailable) {
AppLog.log('startScan 蓝牙状态 系统蓝牙状态:$_adapterState 蓝牙连接状态:$bluetoothConnectionState');
// AppLog.log('startScan 蓝牙状态 系统蓝牙状态:$_adapterState 蓝牙连接状态:$bluetoothConnectionState');
if (_adapterState == BluetoothAdapterState.on) {
try {
FlutterBluePlus.startScan(timeout: Duration(seconds: timeout));
@ -255,23 +278,28 @@ class BlueManage {
scanDevices.clear();
for (final ScanResult scanResult in results) {
if (scanResult.advertisementData.serviceUuids.isNotEmpty) {
AppLog.log(
'扫描到的设备:${scanResult.advertisementData.serviceUuids[0].toString()}====${scanResult.advertisementData.advName}');
// AppLog.log(
// '扫描到的设备:${scanResult.advertisementData.serviceUuids[0].toString()}====${scanResult.advertisementData.advName}');
} else {
continue;
}
final isMatch = _isMatch(
scanResult.advertisementData.serviceUuids.map((e) => e.uuid).toList(),
scanResult.advertisementData.serviceUuids
.map((e) => e.uuid)
.toList(),
deviceType: deviceType,
isSingle: false,
);
//
if (isMatch && (scanResult.rssi >= -100)) {
// id相同的元素
final int knownDeviceIndex = scanDevices.indexWhere((ScanResult d) =>
(d.device.platformName == scanResult.device.platformName) ||
(d.advertisementData.advName == scanResult.advertisementData.advName));
final int knownDeviceIndex = scanDevices.indexWhere(
(ScanResult d) =>
(d.device.platformName ==
scanResult.device.platformName) ||
(d.advertisementData.advName ==
scanResult.advertisementData.advName));
// -1
if (knownDeviceIndex >= 0) {
scanDevices[knownDeviceIndex] = scanResult;
@ -305,8 +333,10 @@ class BlueManage {
}
/// uuid
bool _isMatch(List<String> serviceUuids, {DeviceType deviceType = DeviceType.blue, required bool isSingle}) {
final List<String> prefixes = getDeviceType(deviceType).map((e) => e.toLowerCase()).toList();
bool _isMatch(List<String> serviceUuids,
{DeviceType deviceType = DeviceType.blue, required bool isSingle}) {
final List<String> prefixes =
getDeviceType(deviceType).map((e) => e.toLowerCase()).toList();
for (String uuid in serviceUuids) {
final String cleanUuid = uuid.toLowerCase();
if (cleanUuid.length == 8) {
@ -337,7 +367,8 @@ class BlueManage {
} else {
// UUID的第31321
if (cleanUuid.length >= 32) {
String pairStatus = cleanUuid.substring(30, 32); // 31321
String pairStatus =
cleanUuid.substring(30, 32); // 31321
// 00=01=
if (pairStatus == '00') {
return true; // true
@ -355,11 +386,12 @@ class BlueManage {
//
bool hasNewEvent = (byte1 == 1);
//
if (!isPaired) {
return true; // true
if (isPaired) {
return true; // false
} else {
return false; // false
return false; // true
}
}
// 01trueuuid
@ -376,7 +408,8 @@ class BlueManage {
} else {
// UUID的第31321
if (cleanUuid.length >= 32) {
String pairStatus = cleanUuid.substring(30, 32); // 31321
String pairStatus =
cleanUuid.substring(30, 32); // 31321
// 00=01=
if (pairStatus == '00') {
return true; // true
@ -395,10 +428,8 @@ class BlueManage {
/// List senderData,
Future<void> blueSendData(
String deviceName,
ConnectStateCallBack stateCallBack, {
bool isAddEquipment = false,
}) async {
String deviceName, ConnectStateCallBack stateCallBack,
{bool isAddEquipment = false}) async {
FlutterBluePlus.isSupported.then((bool isAvailable) async {
if (isAvailable) {
// AppLog.log('蓝牙状态 系统蓝牙状态:$_adapterState 蓝牙连接状态:$bluetoothConnectionState');
@ -407,16 +438,12 @@ class BlueManage {
if (bluetoothConnectionState != BluetoothConnectionState.connected) {
BuglyTool.uploadException(
message: '点击按钮 蓝牙未连接 下一步扫描连接蓝牙',
detail: 'blueSendData 蓝牙连接状态 bluetoothConnectionState$bluetoothConnectionState deviceName:$deviceName',
detail:
'blueSendData 蓝牙连接状态 bluetoothConnectionState$bluetoothConnectionState deviceName:$deviceName',
upload: false);
//
_connect(
deviceName,
(BluetoothConnectionState state) {
stateCallBack(bluetoothConnectionState!);
},
isAddEquipment: isAddEquipment,
);
_connect(deviceName, (BluetoothConnectionState state) {
stateCallBack(bluetoothConnectionState!);
}, isAddEquipment: isAddEquipment);
} else {
BuglyTool.uploadException(
message: '点击按钮 蓝牙已经连接 下一步扫描连接蓝牙',
@ -428,7 +455,8 @@ class BlueManage {
} else {
BuglyTool.uploadException(
message: '点击按钮 蓝牙未打开',
detail: 'blueSendData 蓝牙未打开--_adapterState:${BluetoothAdapterState.on} deviceName:$deviceName',
detail:
'blueSendData 蓝牙未打开--_adapterState:${BluetoothAdapterState.on} deviceName:$deviceName',
upload: false);
try {
stateCallBack(BluetoothConnectionState.disconnected);
@ -437,13 +465,16 @@ class BlueManage {
AppLog.log('蓝牙打开失败');
BuglyTool.uploadException(
message: '点击按钮 蓝牙未打开 然后蓝牙打开失败',
detail: 'blueSendData 蓝牙打开失败--_adapterState:${BluetoothAdapterState.on} deviceName:$deviceName',
detail:
'blueSendData 蓝牙打开失败--_adapterState:${BluetoothAdapterState.on} deviceName:$deviceName',
upload: false);
}
}
} else {
BuglyTool.uploadException(
message: '点击按钮 蓝牙状态不可用', detail: 'blueSendData 蓝牙状态不可用--isAvailable:$isAvailable', upload: false);
message: '点击按钮 蓝牙状态不可用',
detail: 'blueSendData 蓝牙状态不可用--isAvailable:$isAvailable',
upload: false);
stateCallBack(BluetoothConnectionState.disconnected);
AppLog.log('开始扫描 蓝牙不可用,不能进行蓝牙操作');
}
@ -451,7 +482,8 @@ class BlueManage {
}
///
Future<void> _connect(String deviceName, ConnectStateCallBack connectStateCallBack,
Future<void> _connect(
String deviceName, ConnectStateCallBack connectStateCallBack,
{bool isAddEquipment = false}) async {
connectDeviceName = deviceName;
//
@ -459,12 +491,16 @@ class BlueManage {
// true是有缓存设备
final bool isExistDevice = isExistScanDevices(connectDeviceName);
//
final bool isCurrentDevice = CommonDataManage().currentKeyInfo.lockName == deviceName;
final bool isCurrentDevice =
CommonDataManage().currentKeyInfo.lockName == deviceName;
// mac地址
final String? mac = CommonDataManage().currentKeyInfo.mac;
AppLog.log('开始连接 是否存在缓存:$isExistDevice 是否是当前设备:$isCurrentDevice mac$mac');
if (GetPlatform.isAndroid && !isExistDevice && isCurrentDevice && mac != null) {
if (GetPlatform.isAndroid &&
!isExistDevice &&
isCurrentDevice &&
mac != null) {
// mac地址不为空
BuglyTool.uploadException(
message: '开始连接 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空 上传记录当前方法是_connect',
@ -476,17 +512,22 @@ class BlueManage {
try {
if (!needScanSingle) {
BuglyTool.uploadException(
message: '开始连接 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空 上传记录当前方法是_connect',
message:
'开始连接 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空 上传记录当前方法是_connect',
detail: '调用方法doNotSearchBLE直接连接,needScanSingle$needScanSingle',
upload: false);
await doNotSearchBLE(mac, connectStateCallBack, isAddEquipment: isAddEquipment);
await doNotSearchBLE(mac, connectStateCallBack,
isAddEquipment: isAddEquipment);
} else {
BuglyTool.uploadException(
message: '开始连接 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空 上传记录当前方法是_connect',
detail: '调用方法startScanSingle执行扫描函数,needScanSingle$needScanSingle',
message:
'开始连接 当是安卓设备 且不存在缓存设备 且是当前设备 且mac地址不为空 上传记录当前方法是_connect',
detail:
'调用方法startScanSingle执行扫描函数,needScanSingle$needScanSingle',
upload: false);
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) {
_connectDevice(scanDevices, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment);
_connectDevice(scanDevices, deviceName, connectStateCallBack,
isAddEquipment: isAddEquipment);
});
}
} catch (e) {
@ -495,7 +536,8 @@ class BlueManage {
detail: '调用方法doNotSearchBLE发生异常执行扫描函数 startScanSingle异常信息$e',
upload: false);
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) {
_connectDevice(scanDevices, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment);
_connectDevice(scanDevices, deviceName, connectStateCallBack,
isAddEquipment: isAddEquipment);
});
}
//
@ -512,13 +554,16 @@ class BlueManage {
} else if (isAddEquipment == false && isExistDevice == false) {
// 使
BuglyTool.uploadException(
message: '取消缓存直接使用,存在配对场景设备信息会更变 然后开始指定设备名称的扫描蓝牙设备 上传记录当前方法是_connect',
detail: '符合条件(isAddEquipment == false && isExistDevice == false) 下一步调用startScanSingle',
message:
'取消缓存直接使用,存在配对场景设备信息会更变 然后开始指定设备名称的扫描蓝牙设备 上传记录当前方法是_connect',
detail:
'符合条件(isAddEquipment == false && isExistDevice == false) 下一步调用startScanSingle',
upload: false);
// AppLog.log('无存在设备需要扫描 deviceName:$deviceName isAddEquipment:$isAddEquipment');
startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) {
_connectDevice(scanDevices, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment);
_connectDevice(scanDevices, deviceName, connectStateCallBack,
isAddEquipment: isAddEquipment);
});
} else {
BuglyTool.uploadException(
@ -527,14 +572,16 @@ class BlueManage {
'走这个方法是有缓存或者添加设备的时候以及不符合(GetPlatform.isAndroid && !isExistDevice && isCurrentDevice && mac != null) deviceName:$deviceName 直接调用_connectDevice',
upload: false);
// AppLog.log('安卓或者iOS 存在设备不需要扫描 deviceName:$deviceName isAddEquipment:$isAddEquipment');
_connectDevice(devicesList, deviceName, connectStateCallBack, isAddEquipment: isAddEquipment);
_connectDevice(devicesList, deviceName, connectStateCallBack,
isAddEquipment: isAddEquipment);
}
}
//
bool isExistScanDevices(String connectDeviceName) {
final bool isExistDevice = scanDevices.any((ScanResult element) =>
element.device.platformName == connectDeviceName || element.advertisementData.advName == connectDeviceName);
element.device.platformName == connectDeviceName ||
element.advertisementData.advName == connectDeviceName);
return isExistDevice;
}
@ -548,15 +595,17 @@ class BlueManage {
//
// AppLog.log("devicesList:$devicesList");
final int knownDeviceIndex = devicesList.indexWhere(
(ScanResult d) => (d.device.platformName == deviceName) || (d.advertisementData.advName == deviceName));
final int knownDeviceIndex = devicesList.indexWhere((ScanResult d) =>
(d.device.platformName == deviceName) ||
(d.advertisementData.advName == deviceName));
ScanResult? scanResult; //使
if (knownDeviceIndex >= 0) {
//
connectDeviceMacAddress = devicesList[knownDeviceIndex].advertisementData.advName.isNotEmpty
? devicesList[knownDeviceIndex].advertisementData.advName
: devicesList[knownDeviceIndex].device.platformName;
connectDeviceMacAddress =
devicesList[knownDeviceIndex].advertisementData.advName.isNotEmpty
? devicesList[knownDeviceIndex].advertisementData.advName
: devicesList[knownDeviceIndex].device.platformName;
bluetoothConnectDevice = devicesList[knownDeviceIndex].device;
scanResult = devicesList[knownDeviceIndex];
@ -567,8 +616,10 @@ class BlueManage {
}
if (scanResult == null || connectDeviceMacAddress.isEmpty) {
BuglyTool.uploadException(
message: '扫描结果scanResult == null || connectDeviceMacAddress.isEmpty不往下执行 return 上传记录当前方法是_connectDevice',
detail: 'scanResult:$scanResult connectDeviceMacAddress$connectDeviceMacAddress',
message:
'扫描结果scanResult == null || connectDeviceMacAddress.isEmpty不往下执行 return 上传记录当前方法是_connectDevice',
detail:
'scanResult:$scanResult connectDeviceMacAddress$connectDeviceMacAddress',
upload: false);
return;
}
@ -602,7 +653,8 @@ class BlueManage {
BuglyTool.uploadException(
message: '提示该锁已被重置, 回调断开连接, 清除缓存上传记录当前方法是_connectDevice',
detail: 'isReconnect:$isReconnect serviceUuids:${scanResult.advertisementData.serviceUuids[0].toString()}',
detail:
'isReconnect:$isReconnect serviceUuids:${scanResult.advertisementData.serviceUuids[0].toString()}',
upload: false);
}
return;
@ -634,7 +686,8 @@ class BlueManage {
BuglyTool.uploadException(
message: '提示该锁已被重置, 回调断开连接, 清除缓存上传记录当前方法是_connectDevice',
detail: 'isReconnect:$isReconnect serviceUuids:${scanResult.advertisementData.serviceUuids[0].toString()}',
detail:
'isReconnect:$isReconnect serviceUuids:${scanResult.advertisementData.serviceUuids[0].toString()}',
upload: false);
}
return;
@ -651,11 +704,13 @@ class BlueManage {
}
//
Future<void> doNotSearchBLE(String masAdds, ConnectStateCallBack connectStateCallBack,
Future<void> doNotSearchBLE(
String masAdds, ConnectStateCallBack connectStateCallBack,
{bool isAddEquipment = false}) async {
await FlutterBluePlus.stopScan();
if (bluetoothConnectDevice == null || bluetoothConnectDevice?.remoteId.str != masAdds) {
if (bluetoothConnectDevice == null ||
bluetoothConnectDevice?.remoteId.str != masAdds) {
bluetoothConnectDevice = BluetoothDevice.fromId(masAdds);
_initGetMtuSubscription();
_initListenConnectionState();
@ -666,24 +721,25 @@ class BlueManage {
} else {
BuglyTool.uploadException(
message: '直接给蓝牙设备写入 上传记录当前方法是doNotSearchBLE',
detail: '直接给蓝牙设备写入 用传入的bluetoothConnectDevice${bluetoothConnectDevice.toString()}连接 masAdds:$masAdds',
detail:
'直接给蓝牙设备写入 用传入的bluetoothConnectDevice${bluetoothConnectDevice.toString()}连接 masAdds:$masAdds',
upload: false);
}
//
await bluetoothDeviceConnect(bluetoothConnectDevice!, connectStateCallBack, isAddEquipment: isAddEquipment);
await bluetoothDeviceConnect(bluetoothConnectDevice!, connectStateCallBack,
isAddEquipment: isAddEquipment);
}
//
Future<void> bluetoothDeviceConnect(BluetoothDevice bluetoothConnectDevice, ConnectStateCallBack connectStateCallBack,
Future<void> bluetoothDeviceConnect(BluetoothDevice bluetoothConnectDevice,
ConnectStateCallBack connectStateCallBack,
{bool isAddEquipment = false}) async {
//
const int maxAttempts = 3;
int attempt = 0;
while (attempt < maxAttempts) {
try {
await bluetoothConnectDevice.connect(
timeout: 5.seconds,
);
await bluetoothConnectDevice.connect(timeout: 5.seconds);
break; // If the connection is successful, break the loop
} catch (e) {
AppLog.log('连接失败 重连了: $e');
@ -698,7 +754,8 @@ class BlueManage {
AppLog.log('$maxAttempts次后尝试连接失败');
BuglyTool.uploadException(
message: '连接三次超时断开连接 回调断开连接 上传记录当前方法是bluetoothDeviceConnect',
detail: 'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} $maxAttempts次后尝试连接失败',
detail:
'bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} $maxAttempts次后尝试连接失败',
upload: false);
needScanSingle = true;
connectStateCallBack(BluetoothConnectionState.disconnected);
@ -707,18 +764,22 @@ class BlueManage {
if (bluetoothConnectionState == BluetoothConnectionState.connected) {
try {
needScanSingle = false;
final List<BluetoothService> services = await bluetoothConnectDevice.discoverServices();
final List<BluetoothService> services =
await bluetoothConnectDevice.discoverServices();
//
for (final BluetoothService service in services) {
if (service.uuid == _serviceIdConnect) {
for (final BluetoothCharacteristic characteristic in service.characteristics) {
if (characteristic.characteristicUuid == _characteristicIdSubscription) {
for (final BluetoothCharacteristic characteristic
in service.characteristics) {
if (characteristic.characteristicUuid ==
_characteristicIdSubscription) {
_subScribeToCharacteristic(characteristic);
bluetoothConnectionState = BluetoothConnectionState.connected;
connectStateCallBack(bluetoothConnectionState!);
BuglyTool.uploadException(
message: '订阅成功 上传记录当前方法是bluetoothDeviceConnect',
detail: '发现服务,连接成功,订阅数据 bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} ',
detail:
'发现服务,连接成功,订阅数据 bluetoothDeviceConnect:${bluetoothConnectDevice.toString()} ',
upload: false);
} else {
BuglyTool.uploadException(
@ -740,18 +801,22 @@ class BlueManage {
needScanSingle = true;
bluetoothConnectionState = BluetoothConnectionState.disconnected;
connectStateCallBack(bluetoothConnectionState!);
AppLog.log('发现设备时失败 e:$e bluetoothConnectionState:$bluetoothConnectionState');
AppLog.log(
'发现设备时失败 e:$e bluetoothConnectionState:$bluetoothConnectionState');
BuglyTool.uploadException(
message: '发现服务时失败',
detail: '发现服务时报错原因e$e bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
detail:
'发现服务时报错原因e$e bluetoothDeviceConnect:${bluetoothConnectDevice.toString()}',
upload: false);
rethrow;
}
}
}
Future<void> _subScribeToCharacteristic(BluetoothCharacteristic characteristic) async {
final StreamSubscription<List<int>> subscription = characteristic.onValueReceived.listen((List<int> data) {
Future<void> _subScribeToCharacteristic(
BluetoothCharacteristic characteristic) async {
final StreamSubscription<List<int>> subscription =
characteristic.onValueReceived.listen((List<int> data) {
AppLog.log('订阅获取的数据: $data ');
if (data == lastTimeData || data.isEmpty) {
return;
@ -799,7 +864,10 @@ class BlueManage {
return false;
}
//239, 1, 238, 2,
if ((data[0] == 0xEF) && (data[1] == 0x01) && (data[2] == 0xEE) && (data[3] == 0x02)) {
if ((data[0] == 0xEF) &&
(data[1] == 0x01) &&
(data[2] == 0xEE) &&
(data[3] == 0x02)) {
return true;
} else {
return false;
@ -808,10 +876,12 @@ class BlueManage {
///
Future<void> writeCharacteristicWithResponse(List<int> value) async {
final List<BluetoothService> services = await bluetoothConnectDevice!.discoverServices();
final List<BluetoothService> services =
await bluetoothConnectDevice!.discoverServices();
for (final BluetoothService service in services) {
if (service.uuid == _serviceIdConnect) {
for (final BluetoothCharacteristic characteristic in service.characteristics) {
for (final BluetoothCharacteristic characteristic
in service.characteristics) {
if (characteristic.characteristicUuid == _characteristicIdWrite) {
try {
//
@ -830,22 +900,27 @@ class BlueManage {
while (!packetSent && retryCount < maxRetries) {
try {
if (characteristic.properties.writeWithoutResponse) {
await characteristic.write(subData[i], withoutResponse: true);
await characteristic.write(subData[i],
withoutResponse: true);
} else if (characteristic.properties.write) {
await characteristic.write(subData[i]);
} else {
//
throw Exception('This characteristic does not support writing.');
throw Exception(
'This characteristic does not support writing.');
}
//
packetSent = true;
} catch (e) {
if (e.toString().contains('UNKNOWN_GATT_ERROR (133)') && retryCount < maxRetries - 1) {
if (e.toString().contains('UNKNOWN_GATT_ERROR (133)') &&
retryCount < maxRetries - 1) {
// GATT错误133
retryCount++;
AppLog.log('蓝牙写入失败(GATT 133),数据包 ${i + 1}/${subData.length} 正在重试 $retryCount/$maxRetries...');
await Future.delayed(Duration(milliseconds: retryDelayMs));
AppLog.log(
'蓝牙写入失败(GATT 133),数据包 ${i + 1}/${subData.length} 正在重试 $retryCount/$maxRetries...');
await Future.delayed(
Duration(milliseconds: retryDelayMs));
continue;
} else {
//
@ -856,7 +931,8 @@ class BlueManage {
}
if (!packetSent) {
throw Exception('蓝牙写入失败,数据包 ${i + 1}/${subData.length} 已达到最大重试次数');
throw Exception(
'蓝牙写入失败,数据包 ${i + 1}/${subData.length} 已达到最大重试次数');
}
}
@ -888,19 +964,21 @@ class BlueManage {
Future<void> disconnect() async {
try {
connectDeviceMacAddress = '';
// MTU监听
_mtuSubscription?.cancel();
_mtuSubscription = null;
_mtuSize = 20; // MTU为默认值
if (bluetoothConnectionState == BluetoothConnectionState.connected) {
AppLog.log('请求断开蓝牙连接');
//
await bluetoothConnectDevice!.disconnect(timeout: 1);
await bluetoothConnectDevice!.disconnect(timeout: 3);
AppLog.log('断开连接成功');
}
} on Exception catch (e, _) {
AppLog.log('断开连接失败: $e');
} finally {
bluetoothConnectionState = BluetoothConnectionState.disconnected;
}
}
@ -928,7 +1006,7 @@ class BlueManage {
_mtuSubscription?.cancel();
_adapterStateStateSubscription?.cancel();
_connectionStateSubscription?.cancel();
//
_mtuSize = 20;
connectDeviceName = '';

View File

@ -165,7 +165,6 @@ class LockDetailLogic extends BaseGetXController {
}
_handleSynchronizeUploadLockData();
break;
case 0x06:
//
@ -929,31 +928,28 @@ class LockDetailLogic extends BaseGetXController {
}
void _handleGetLockPasswordData() {
BlueManage().blueSendData(
BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
final List<String>? token = await Storage.getStringList(saveBlueToken);
final List<int> getTokenList = changeStringListToIntList(token!);
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
final List<String>? token = await Storage.getStringList(saveBlueToken);
final List<int> getTokenList = changeStringListToIntList(token!);
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
IoSenderManage.updataLockPasswordListCommand(
lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(),
page: state.uploadPasswordPage,
countReq: state.countReq,
token: getTokenList,
needAuthor: 1,
signKey: signKeyDataList,
privateKey: getPrivateKeyList);
}
},
);
IoSenderManage.updataLockPasswordListCommand(
lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(),
page: state.uploadPasswordPage,
countReq: state.countReq,
token: getTokenList,
needAuthor: 1,
signKey: signKeyDataList,
privateKey: getPrivateKeyList);
}
});
}
//
@ -967,7 +963,7 @@ class LockDetailLogic extends BaseGetXController {
// 10
state.uploadPasswordPage = state.uploadPasswordPage + 1;
final List<int> token = reply.data.sublist(3, 7);
showEasyLoading();
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -1071,6 +1067,7 @@ class LockDetailLogic extends BaseGetXController {
final List<int> token = reply.data.sublist(3, 7);
showEasyLoading();
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -1174,6 +1171,7 @@ class LockDetailLogic extends BaseGetXController {
final List<int> token = reply.data.sublist(3, 7);
showEasyLoading();
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -1327,6 +1325,7 @@ class LockDetailLogic extends BaseGetXController {
final List<int> token = reply.data.sublist(3, 7);
showEasyLoading();
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -1403,6 +1402,7 @@ class LockDetailLogic extends BaseGetXController {
final List<int> token = reply.data.sublist(3, 7);
showEasyLoading();
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -1479,6 +1479,7 @@ class LockDetailLogic extends BaseGetXController {
final List<int> token = reply.data.sublist(3, 7);
showEasyLoading();
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
@ -1502,8 +1503,6 @@ class LockDetailLogic extends BaseGetXController {
} else {
state.indexCount.value = state.indexCount.value + 1;
_lockDataUpload(uploadType: 2, recordType: 7, records: state.uploadRemoteControlDataList);
AppLog.log('需要执行断开操作');
BlueManage().disconnect();
}
break;
case 0x06:

View File

@ -45,7 +45,8 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
@override
void onInit() async {
super.onInit();
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
_replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
if (reply is VoicePackageConfigureReply) {
//
_handlerStartVoicePackageConfigure(reply);
@ -71,7 +72,8 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
final vendor = state.lockSetInfoData.value.lockBasicInfo?.vendor;
final model = state.lockSetInfoData.value.lockBasicInfo?.model;
final PassthroughListResponse entity = await ApiRepository.to.getPassthroughList(data: {
final PassthroughListResponse entity =
await ApiRepository.to.getPassthroughList(data: {
'vendor': vendor!,
'model': model!,
});
@ -108,15 +110,18 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
final passthroughItem = PassthroughItem(
lang: element.lang,
timbres: element.timbres,
langText: ExtensionLanguageType.fromLocale(locales[indexOf]).lanTitle,
langText:
ExtensionLanguageType.fromLocale(locales[indexOf]).lanTitle,
name: element.name,
);
state.languages.add(passthroughItem);
}
});
state.languages.refresh();
final lang = state.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre?.lang;
final timbre = state.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre?.timbre;
final lang = state
.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre?.lang;
final timbre = state
.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre?.timbre;
// for 访
for (int i = 0; i < state.languages.length; i++) {
final language = state.languages[i]; //
@ -151,7 +156,8 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
// APP层的语言
Locale? currentLocale = Get.locale; //
if (currentLocale != null) {
final indexWhere = state.languages.indexWhere((element) => element.lang == currentLocale.toString());
final indexWhere = state.languages
.indexWhere((element) => element.lang == currentLocale.toString());
state.selectPassthroughListIndex.value = indexWhere;
}
}
@ -186,11 +192,15 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
});
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
final List<String>? signKey =
await Storage.getStringList(saveBlueSignKey);
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
final String uid = await Storage.getUid() ?? '';
final String md5Str = md5.convert(data).toString().toUpperCase();
@ -209,7 +219,8 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
privateKey: getPrivateKeyList)
.packageData(),
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
}
@ -222,14 +233,16 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
});
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
BlueManage().writeCharacteristicWithResponse(
GetDeviceModelCommand(
lockID: BlueManage().connectDeviceName,
).packageData(),
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
showBlueConnetctToast();
@ -238,7 +251,8 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
}
//
void _handlerStartVoicePackageConfigure(VoicePackageConfigureReply reply) async {
void _handlerStartVoicePackageConfigure(
VoicePackageConfigureReply reply) async {
final int status = reply.data[6];
switch (status) {
case 0x00:
@ -266,7 +280,8 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
if (state.data == null) return;
state.voiceSubcontractingIndex = 0;
state.voiceSubcontractingCount =
(state.data!.length + state.voiceSubcontractingSize - 1) ~/ state.voiceSubcontractingSize;
(state.data!.length + state.voiceSubcontractingSize - 1) ~/
state.voiceSubcontractingSize;
state.progress.value = 0.0; //
_sendNextPackage();
}
@ -317,7 +332,8 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
Uint8List packageData = state.data!.sublist(start, end);
//
state.progress.value = (state.voiceSubcontractingIndex + 1) / state.voiceSubcontractingCount;
state.progress.value =
(state.voiceSubcontractingIndex + 1) / state.voiceSubcontractingCount;
EasyLoading.showProgress(state.progress.value,
status: '正在发送数据 ${(state.progress.value * 100).toStringAsFixed(0)}%');
await _sendLanguageFileBleMessage(
@ -326,7 +342,8 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
);
}
_sendLanguageFileBleMessage({required int index, required Uint8List data}) async {
_sendLanguageFileBleMessage(
{required int index, required Uint8List data}) async {
await BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
@ -337,15 +354,17 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
data: data,
).packageData(),
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
// showBlueConnetctToast();
showBlueConnetctToast();
}
});
}
void _handlerVoicePackageConfigureProcess(VoicePackageConfigureProcessReply reply) {
void _handlerVoicePackageConfigureProcess(
VoicePackageConfigureProcessReply reply) {
//
_sendTimeoutTimer?.cancel();
_isTimeout = false; //
@ -412,7 +431,8 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
});
}
Future<void> _executeLogic(VoicePackageConfigureConfirmationReply reply) async {
Future<void> _executeLogic(
VoicePackageConfigureConfirmationReply reply) async {
await _handlerVoicePackageConfigureConfirmation(reply);
}
@ -420,12 +440,9 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
VoicePackageConfigureConfirmationReply reply,
) async {
showEasyLoading();
showBlueConnetctToastTimer(
action: () {
dismissEasyLoading();
},
isShowBlueConnetctToast: false,
);
showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
});
final LoginEntity entity = await ApiRepository.to.settingCurrentVoiceTimbre(
data: {
'lang': state.tempLangStr.value,
@ -435,8 +452,10 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
);
if (entity.errorCode!.codeIsSuccessful) {
showSuccess('设置成功'.tr, something: () async {
state.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre?.lang = state.tempLangStr.value;
state.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre?.timbre = state.tempTimbreStr.value;
state.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre?.lang =
state.tempLangStr.value;
state.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre
?.timbre = state.tempTimbreStr.value;
await BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
@ -447,10 +466,11 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
languageCode: state.tempLangStr.value,
).packageData(),
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
// showBlueConnetctToast();
showBlueConnetctToast();
}
});
await Future.delayed(Duration(seconds: 1));
@ -471,7 +491,8 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
}
}
void handleLockCurrentVoicePacketResult(ReadLockCurrentVoicePacketReply reply) {
void handleLockCurrentVoicePacketResult(
ReadLockCurrentVoicePacketReply reply) {
final int status = reply.data[2];
switch (status) {
case 0x00:
@ -480,21 +501,25 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
const int languageCodeStartIndex = 3;
const int languageCodeLength = 20;
const int languageCodeEndIndex = languageCodeStartIndex + languageCodeLength; // 23
const int languageCodeEndIndex =
languageCodeStartIndex + languageCodeLength; // 23
if (reply.data.length < languageCodeEndIndex) {
throw Exception(
'Reply data is too short to contain LanguageCode. Expected at least $languageCodeEndIndex bytes, got ${reply.data.length}');
}
List<int> languageCodeBytes = reply.data.sublist(languageCodeStartIndex, languageCodeEndIndex);
List<int> languageCodeBytes =
reply.data.sublist(languageCodeStartIndex, languageCodeEndIndex);
String languageCode = String.fromCharCodes(languageCodeBytes);
languageCode = languageCode.trim(); //
languageCode = languageCode.replaceAll('\u0000', ''); // (null bytes)
languageCode =
languageCode.replaceAll('\u0000', ''); // (null bytes)
if (languageCode != null && languageCode != '') {
final indexWhere = state.languages.indexWhere((element) => element.lang == languageCode);
final indexWhere = state.languages
.indexWhere((element) => element.lang == languageCode);
if (indexWhere != -1) {
print('锁板上的语言是:$languageCode,下标是:$indexWhere');
state.selectPassthroughListIndex.value = indexWhere;
@ -516,11 +541,9 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
void readLockLanguage() async {
showEasyLoading();
showBlueConnetctToastTimer(
isShowBlueConnetctToast: false,
action: () {
dismissEasyLoading();
});
showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
});
await BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
@ -529,10 +552,11 @@ class SpeechLanguageSettingsLogic extends BaseGetXController {
lockID: BlueManage().connectDeviceName,
).packageData(),
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
// showBlueConnetctToast();
showBlueConnetctToast();
}
});
}

View File

@ -43,7 +43,8 @@ class LockVoiceSettingLogic extends BaseGetXController {
@override
void onInit() async {
super.onInit();
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
_replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
if (reply is VoicePackageConfigureReply) {
//
_handlerStartVoicePackageConfigure(reply);
@ -77,14 +78,12 @@ class LockVoiceSettingLogic extends BaseGetXController {
});
}
Future<void> _executeLogic(VoicePackageConfigureConfirmationReply reply) async {
Future<void> _executeLogic(
VoicePackageConfigureConfirmationReply reply) async {
showEasyLoading();
showBlueConnetctToastTimer(
action: () {
dismissEasyLoading();
},
isShowBlueConnetctToast: false,
);
showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
});
final LoginEntity entity = await ApiRepository.to.settingCurrentVoiceTimbre(
data: {
'lang': state.tempLangStr.value,
@ -94,8 +93,10 @@ class LockVoiceSettingLogic extends BaseGetXController {
);
if (entity.errorCode!.codeIsSuccessful) {
showSuccess('设置成功'.tr, something: () async {
state.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre?.lang = state.tempLangStr.value;
state.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre?.timbre = state.tempTimbreStr.value;
state.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre?.lang =
state.tempLangStr.value;
state.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre
?.timbre = state.tempTimbreStr.value;
await BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
@ -106,14 +107,16 @@ class LockVoiceSettingLogic extends BaseGetXController {
languageCode: state.tempLangStr.value,
).packageData(),
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
// showBlueConnetctToast();
showBlueConnetctToast();
}
});
await Future.delayed(Duration(seconds: 1));
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
eventBus
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
Get.offAllNamed(Routers.starLockMain);
});
}
@ -142,7 +145,8 @@ class LockVoiceSettingLogic extends BaseGetXController {
// APP层的语言
Locale? currentLocale = Get.locale; //
if (currentLocale != null) {
final indexWhere = state.languages.indexWhere((element) => element.lang == currentLocale.toString());
final indexWhere = state.languages
.indexWhere((element) => element.lang == currentLocale.toString());
state.selectPassthroughListIndex.value = indexWhere;
}
}
@ -172,11 +176,15 @@ class LockVoiceSettingLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
});
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
final List<String>? signKey =
await Storage.getStringList(saveBlueSignKey);
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
final String uid = await Storage.getUid() ?? '';
final String md5Str = md5.convert(data).toString().toUpperCase();
@ -195,7 +203,8 @@ class LockVoiceSettingLogic extends BaseGetXController {
privateKey: getPrivateKeyList)
.packageData(),
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
@ -207,7 +216,8 @@ class LockVoiceSettingLogic extends BaseGetXController {
});
}
void _handlerVoicePackageConfigureProcess(VoicePackageConfigureProcessReply reply) {
void _handlerVoicePackageConfigureProcess(
VoicePackageConfigureProcessReply reply) {
//
_sendTimeoutTimer?.cancel();
_isTimeout = false; //
@ -225,7 +235,8 @@ class LockVoiceSettingLogic extends BaseGetXController {
}
//
void _handlerStartVoicePackageConfigure(VoicePackageConfigureReply reply) async {
void _handlerStartVoicePackageConfigure(
VoicePackageConfigureReply reply) async {
final int status = reply.data[6];
switch (status) {
case 0x00:
@ -254,7 +265,8 @@ class LockVoiceSettingLogic extends BaseGetXController {
final vendor = state.lockSetInfoData.value.lockBasicInfo?.vendor;
final model = state.lockSetInfoData.value.lockBasicInfo?.model;
final PassthroughListResponse entity = await ApiRepository.to.getPassthroughList(data: {
final PassthroughListResponse entity =
await ApiRepository.to.getPassthroughList(data: {
'vendor': vendor!,
'model': model!,
});
@ -290,7 +302,8 @@ class LockVoiceSettingLogic extends BaseGetXController {
final passthroughItem = PassthroughItem(
lang: element.lang,
timbres: element.timbres,
langText: ExtensionLanguageType.fromLocale(locales[indexOf]).lanTitle,
langText:
ExtensionLanguageType.fromLocale(locales[indexOf]).lanTitle,
name: element.name,
);
@ -298,8 +311,10 @@ class LockVoiceSettingLogic extends BaseGetXController {
}
});
state.languages.refresh();
final lang = state.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre?.lang;
final timbre = state.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre?.timbre;
final lang = state
.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre?.lang;
final timbre = state
.lockSetInfoData.value.lockSettingInfo?.currentVoiceTimbre?.timbre;
state.languages.value.forEach((element) {
final timbres = element.timbres;
timbres.forEach((item) {
@ -320,7 +335,8 @@ class LockVoiceSettingLogic extends BaseGetXController {
if (state.data == null) return;
state.voiceSubcontractingIndex = 0;
state.voiceSubcontractingCount =
(state.data!.length + state.voiceSubcontractingSize - 1) ~/ state.voiceSubcontractingSize;
(state.data!.length + state.voiceSubcontractingSize - 1) ~/
state.voiceSubcontractingSize;
state.progress.value = 0.0; //
_sendNextPackage();
}
@ -364,7 +380,8 @@ class LockVoiceSettingLogic extends BaseGetXController {
Uint8List packageData = state.data!.sublist(start, end);
//
state.progress.value = (state.voiceSubcontractingIndex + 1) / state.voiceSubcontractingCount;
state.progress.value =
(state.voiceSubcontractingIndex + 1) / state.voiceSubcontractingCount;
EasyLoading.showProgress(state.progress.value,
status: '正在发送数据 ${(state.progress.value * 100).toStringAsFixed(0)}%');
_sendLanguageFileBleMessage(
@ -374,7 +391,8 @@ class LockVoiceSettingLogic extends BaseGetXController {
}
_sendLanguageFileBleMessage({required int index, required Uint8List data}) {
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
BlueManage().writeCharacteristicWithResponse(
VoicePackageConfigureProcess(
@ -383,7 +401,8 @@ class LockVoiceSettingLogic extends BaseGetXController {
data: data,
).packageData(),
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
// showBlueConnetctToast();
@ -426,12 +445,9 @@ class LockVoiceSettingLogic extends BaseGetXController {
void readLockLanguage() async {
showEasyLoading();
showBlueConnetctToastTimer(
action: () {
dismissEasyLoading();
},
isShowBlueConnetctToast: false,
);
showBlueConnetctToastTimer(action: () {
dismissEasyLoading();
});
await BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
@ -440,15 +456,17 @@ class LockVoiceSettingLogic extends BaseGetXController {
lockID: BlueManage().connectDeviceName,
).packageData(),
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
} else if (deviceConnectionState ==
BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
// showBlueConnetctToast();
showBlueConnetctToast();
}
});
}
void handleLockCurrentVoicePacketResult(ReadLockCurrentVoicePacketReply reply) {
void handleLockCurrentVoicePacketResult(
ReadLockCurrentVoicePacketReply reply) {
final int status = reply.data[2];
switch (status) {
case 0x00:
@ -457,24 +475,28 @@ class LockVoiceSettingLogic extends BaseGetXController {
const int languageCodeStartIndex = 3;
const int languageCodeLength = 20;
const int languageCodeEndIndex = languageCodeStartIndex + languageCodeLength; // 23
const int languageCodeEndIndex =
languageCodeStartIndex + languageCodeLength; // 23
if (reply.data.length < languageCodeEndIndex) {
throw Exception(
'Reply data is too short to contain LanguageCode. Expected at least $languageCodeEndIndex bytes, got ${reply.data.length}');
}
List<int> languageCodeBytes = reply.data.sublist(languageCodeStartIndex, languageCodeEndIndex);
List<int> languageCodeBytes =
reply.data.sublist(languageCodeStartIndex, languageCodeEndIndex);
String languageCode = String.fromCharCodes(languageCodeBytes);
languageCode = languageCode.trim(); //
languageCode = languageCode.replaceAll('\u0000', ''); // (null bytes)
languageCode =
languageCode.replaceAll('\u0000', ''); // (null bytes)
print('LanguageCode: $languageCode'); // : zh_CN, en_US
if (languageCode != null && languageCode != '') {
final indexWhere = state.languages.indexWhere((element) => element.lang == languageCode);
final indexWhere = state.languages
.indexWhere((element) => element.lang == languageCode);
if (indexWhere != -1) {
print('锁板上的语言是:$languageCode,下标是:$indexWhere');
state.selectPassthroughListIndex.value = indexWhere;

1775
pubspec.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@ -176,12 +176,12 @@ dependencies:
url_launcher: ^6.1.10
#蓝牙
# flutter_reactive_ble: ^5.1.1
flutter_blue_plus: 1.33.0
flutter_blue_plus: 1.32.7
#
event_bus: ^2.0.0
#菊花
flutter_easyloading: 3.0.5
flutter_spinkit: 5.2.1
flutter_easyloading: 3.0.4
#图形验证码
# aj_captcha_flutter: ^0.0.1
asn1lib: ^1.6.5
@ -218,7 +218,7 @@ dependencies:
jpush_flutter:
git:
url: git@code.star-lock.cn:StarlockTeam/jpush_flutter.git
url: git@code-internal.star-lock.cn:StarlockTeam/jpush_flutter.git
ref: 656df9ee91b1ec8b96aa1208a6b0df27a4516067
#视频播放器
@ -235,7 +235,6 @@ dependencies:
# ffmpeg_kit_flutter: 5.1.0-LTS
fast_gbk: ^1.0.0
flutter_pcm_sound: ^1.1.0
intl: ^0.18.0
# flutter_audio_capture: <1.1.5
@ -247,7 +246,7 @@ dependencies:
#侧滑删除
flutter_slidable: ^3.0.1
# audio_service: ^0.18.12
app_settings: ^6.1.1
app_settings: ^5.1.1
flutter_local_notifications: ^17.0.0
fluwx: 4.5.5
system_settings: ^2.0.0