/* Ċ Ġ* ĠCopyright ĠÂ© Ġ 2 0 2 0 ĠN HS X . ĠAll Ġrights Ġreserved . Ċ Ġ*/ Ċ Ċ package Ġuk . n hs . n hs x . sonar . android . app . ble Ċ Ċ import Ġandroid . bluetooth . le . Ad vertise Callback Ċ import Ġandroid . bluetooth . le . Ad vertise Data Ċ import Ġandroid . bluetooth . le . Ad vertise Settings Ċ import Ġandroid . bluetooth . le . Bluetooth Le Ad vert iser Ċ import Ġandroid . os . Parcel Uuid Ċ import Ġtim ber . log . Tim ber Ċ import Ġjavax . inject . Inject Ċ import Ġjavax . inject . Singleton Ċ Ċ @ Singleton Ċ class ĠAd vertise Ġ@ Inject Ġconstructor ( private Ġval Ġbluetooth Le Ad vert iser : ĠBluetooth Le Ad vert iser ) Ġ{ ĊĠĠĠ Ġprivate Ġval Ġad vertise Data : ĠAd vertise Data Ġ= ĊĠĠĠĠĠĠĠ ĠAd vertise Data . Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Service Uuid ( Parcel Uuid ( SON AR _ SERVICE _ UUID )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Include Device Name ( false ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Include Tx Power Level ( true ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠ Ġprivate Ġval Ġad vertise Settings : ĠAd vertise Settings Ġ= ĊĠĠĠĠĠĠĠ ĠAd vertise Settings . Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Ad vertise Mode ( Ad vertise Settings . AD VER TI SE _ MODE _ LOW _ POWER ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Connect able ( true ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. setTimeout ( 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Tx Power Level ( Ad vertise Settings . AD VER TI SE _ TX _ POWER _ MEDIUM ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠ Ġprivate Ġval Ġadvertising Callback Ġ= ĠAd vertising Callback () ĊĊĠĠĠ Ġfun Ġstart () Ġ{ ĊĠĠĠĠĠĠĠ ĠTim ber . d (" Bluetooth Le Ad vert iser Ġstart Ad vertising ") ĊĠĠĠĠĠĠĠ Ġbluetooth Le Ad vert iser . start Ad vertising ( ad vertise Settings , Ġad vertise Data , Ġadvertising Callback ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġstop () Ġ{ ĊĠĠĠĠĠĠĠ ĠTim ber . d (" Bluetooth Le Ad vert iser Ġstop Ad vertising ") ĊĠĠĠĠĠĠĠ Ġbluetooth Le Ad vert iser . stop Ad vertising ( ad vertising Callback ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ private Ġclass ĠAd vertising Callback Ġ: ĠAd vertise Callback () Ġ{ ĊĠĠĠ Ġoverride Ġfun ĠonStart Success ( settings In Effect : ĠAd vertise Settings ?) Ġ{ ĊĠĠĠĠĠĠĠ ĠTim ber . i (" Bluetooth Le Ad vert iser ĠStarted Ġadvertising Ġwith Ġsettings Ġ$ settings In Effect ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonStart Failure ( errorCode : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ ĠTim ber . e (" Bluetooth Le Ad vert iser ĠFailed Ġto Ġstart Ġwith Ġerror Ġcode Ġ$ errorCode ") ĊĠĠĠ Ġ} Ċ } Ċ