package Ġio . particle . mesh . setup . flow . context Ċ Ċ import Ġandroidx . annotation . Worker Thread Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġio . particle . android . sdk . cloud . Particle Cloud Ċ import Ġio . particle . android . sdk . cloud . Particle Device . Particle DeviceType Ċ import Ġio . particle . android . sdk . cloud . models . Particle Sim Ċ import Ġio . particle . mesh . common . android . li ved ata . cast And Post Ċ import Ġio . particle . mesh . common . android . li ved ata . cast AndSet On MainThread Ċ import Ġio . particle . mesh . common . logged Ċ import Ġio . particle . mesh . setup . Barcode Data . Complete Barcode Data Ċ import Ġio . particle . mesh . setup . connection . Protocol Trans ceiver Ċ import Ġio . particle . mesh . setup . flow . Gen 3 Connectivity Type Ċ import Ġio . particle . mesh . setup . to Connectivity Type Ċ import Ġio . particle . mesh . setup . to DeviceType Ċ import Ġmu . Kotlin Logging ĊĊ Ċ // ĠTO OD : Ġreplace Ġthis Ġwith Ġsealed Ġclasses , Ġone Ġfor Ġeach Ġrole Ċ enum Ġclass ĠDevice Role Ġ{ ĊĠĠĠ ĠSET UP _ TARGET , ĊĠĠĠ ĠCOMM IS SION ER Ċ } ĊĊ Ċ class ĠSetup Device ( ĊĠĠĠ Ġdevice Role : ĠDevice Role , ĊĠĠĠ Ġval Ġbarcode : ĠLive Data < Complete Barcode Data ?> Ġ= ĠMutable LiveData (), ĊĠĠĠ Ġval Ġtrans ceiver LD : ĠLive Data < Protocol Trans ceiver ?> Ġ= ĠMutable LiveData (), ĊĠĠĠ Ġval Ġis Device Connected To Cloud LD : ĠLive Data < Boolean ?> Ġ= ĠMutable LiveData (), ĊĠĠĠ Ġval Ġis Cl a imed LD : ĠLive Data < Boolean ?> Ġ= ĠMutable LiveData (), ĊĠĠĠ Ġval Ġis Sim Activated LD : ĠLive Data < Boolean ?> Ġ= ĠMutable LiveData () Ċ ) Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġlog Ġ= ĠKotlin Logging . logger Ġ{} ĊĊĠĠĠ Ġvar Ġdevice Role : ĠDevice Role Ġby Ġlog . logged ( device Role ) ĊĠĠĠ Ġvar ĠdeviceId : ĠString ? Ġby Ġlog . logged () ĊĠĠĠ Ġvar Ġconnectivity Type : ĠGen 3 Connectivity Type ? Ġby Ġlog . logged () ĊĠĠĠ Ġvar Ġdevice Type : ĠParticle DeviceType ? Ġby Ġlog . logged () ĊĠĠĠ Ġvar Ġhas Latest Firmware Ġby Ġlog . logged ( false ) ĊĠĠĠ Ġvar ĠshouldBe Cl a imed : ĠBoolean ? Ġby Ġlog . logged () ĊĠĠĠ Ġvar Ġcurrent Device Name : ĠString ? Ġby Ġlog . logged () ĊĠĠĠ Ġvar Ġic cid : ĠString ? Ġby Ġlog . logged () ĊĠĠĠ Ġvar Ġsim : ĠParticle Sim ? Ġby Ġlog . logged () ĊĠĠĠ Ġvar Ġdata Used In MB : ĠFloat ? Ġby Ġlog . logged () ĊĠĠĠ Ġvar Ġownership Checked For Switch ing To Control Panel : ĠBoolean Ġby Ġlog . logged ( false ) ĊĠĠĠ Ġvar Ġn yan Signal ing Stopped : ĠBoolean Ġby Ġlog . logged ( false ) ĊĊĠĠĠ Ġ@ Worker Thread ĊĠĠĠ Ġfun Ġupdate Barcode ( barcode Data : ĠComplete Barcode Data ?, Ġcloud : ĠParticle Cloud ) Ġ{ ĊĠĠĠĠĠĠĠ Ġlog . info Ġ{ Ġ" update Barcode () Ġfor Ġ$ device Role : Ġ$ barcode Data " Ġ} ĊĊĠĠĠĠĠĠĠ Ġif Ġ( barcode Data Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdevice Type Ġ= Ġnull ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconnectivity Type Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdevice Type Ġ= Ġbarcode Data . to DeviceType ( cloud ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconnectivity Type Ġ= Ġdevice Type !!. to Connectivity Type () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġ// Ġupdate Ġthis Ġlast Ġto Ġguarantee Ġthat Ġdevice Type Ġand Ġconnectivity Type Ġare Ġset Ġby Ġthe Ġtime ĊĠĠĠĠĠĠĠ Ġ// Ġthe Ġbarcode Ġis Ġupdated ĊĠĠĠĠĠĠĠ Ġbarcode . cast And Post ( barcode Data ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġupdate Device Trans ceiver ( trans ceiver : ĠProtocol Trans ceiver ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġlog . info Ġ{ Ġ" update Device Trans ceiver () Ġfor Ġ$ device Role : Ġ$ trans ceiver " Ġ} ĊĠĠĠĠĠĠĠ Ġtrans ceiver LD . cast AndSet On MainThread ( trans ceiver ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġupdate Is Cl a imed ( is Cl a imed : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġlog . info Ġ{ Ġ" update Is Cl a imed () Ġfor Ġ$ device Role : Ġ$ is Cl a imed " Ġ} ĊĠĠĠĠĠĠĠ Ġis Cl a imed LD . cast And Post ( is Cl a imed ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġupdate Device Connected To Cloud LD ( isConnected : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġlog . info Ġ{ Ġ" update Device Connected To Cloud LD () Ġfor Ġ$ device Role : Ġ$ isConnected " Ġ} ĊĠĠĠĠĠĠĠ Ġis Device Connected To Cloud LD . cast And Post ( isConnected ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġupdate Is Sim Activated ( is Activated : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġlog . info Ġ{ Ġ" update Is Sim Activated () Ġfor Ġ$ device Role : Ġ$ is Activated " Ġ} ĊĠĠĠĠĠĠĠ Ġis Sim Activated LD . cast And Post ( is Activated ) ĊĠĠĠ Ġ} Ċ Ċ } Ċ