Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Android Console: BLE fix for older devices (#1094)

Michael Rademaker08c8429e753e
diff --git a/console/android/ORLib/build.gradle b/console/android/ORLib/build.gradle
index 2a1f0d3a4..ab671ab16 100644
--- a/console/android/ORLib/build.gradle
+++ b/console/android/ORLib/build.gradle
@@ -46,6 +46,6 @@ dependencies {
implementation "com.google.android.gms:play-services-location:21.0.1"
implementation 'com.google.android.gms:play-services-vision:20.1.3'
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.13.1"
- implementation platform('com.google.firebase:firebase-bom:26.0.0')
+ implementation platform('com.google.firebase:firebase-bom:32.2.0')
implementation 'com.google.firebase:firebase-messaging-ktx'
}
diff --git a/console/android/ORLib/src/main/java/io/openremote/orlib/service/BleProvider.kt b/console/android/ORLib/src/main/java/io/openremote/orlib/service/BleProvider.kt
index aa5071762..d7f833a8f 100644
--- a/console/android/ORLib/src/main/java/io/openremote/orlib/service/BleProvider.kt
+++ b/console/android/ORLib/src/main/java/io/openremote/orlib/service/BleProvider.kt
@@ -59,7 +59,7 @@ class BleProvider(val context: Context) {
@SuppressLint("MissingPermission")
override fun onScanResult(callbackType: Int, result: android.bluetooth.le.ScanResult) {
super.onScanResult(callbackType, result)
- Log.i("BleProvider", "onScanResult: ${result.device.name} - ${result.device.address}")
+ Log.d("BleProvider", "onScanResult: ${result.device.name} - ${result.device.address}")
if (result.device != null && result.device.name != null) {
devices.add(result.device)
}
@@ -169,7 +169,7 @@ class BleProvider(val context: Context) {
readableDeviceIndex = 0
deviceCharacteristics.clear()
if (newState == BluetoothProfile.STATE_CONNECTED) {
- Log.i(
+ Log.d(
"BluetoothGattCallback",
"Successfully connected to $deviceAddress"
)
@@ -200,9 +200,9 @@ class BleProvider(val context: Context) {
override fun onServicesDiscovered(gatt: BluetoothGatt?, status: Int) {
with(gatt) {
this?.services?.forEach { service ->
- Log.i("BluetoothGattCallback", "Service: ${service.uuid}")
+ Log.d("BluetoothGattCallback", "Service: ${service.uuid}")
service.characteristics.forEach { characteristic ->
- Log.i(
+ Log.d(
"BluetoothGattCallback",
"Characteristic: ${characteristic.uuid}"
)
@@ -230,16 +230,16 @@ class BleProvider(val context: Context) {
}
}
- override fun onCharacteristicChanged(
- gatt: BluetoothGatt,
- characteristic: BluetoothGattCharacteristic,
- value: ByteArray
+ override fun onCharacteristicRead(
+ gatt: BluetoothGatt?,
+ characteristic: BluetoothGattCharacteristic?,
+ status: Int
) {
- super.onCharacteristicChanged(gatt, characteristic, value)
- Log.i(
- "BluetoothGattCallback",
- "Characteristic changed: ${characteristic.uuid} - ${String(value)}"
- )
+ characteristic?.let { readCharacteristic ->
+ handleCharacteristicStatus(gatt, readCharacteristic, status)
+ } ?: run {
+ Log.e("BluetoothGattCallback", "Characteristic was null!")
+ }
}
override fun onCharacteristicRead(
@@ -248,64 +248,90 @@ class BleProvider(val context: Context) {
value: ByteArray,
status: Int
) {
- with(characteristic) {
- when (status) {
- BluetoothGatt.GATT_SUCCESS -> {
- val deviceCharacteristic =
- deviceCharacteristics.find { it.characteristic.uuid == uuid }
- if (deviceCharacteristic != null) {
- deviceCharacteristic.value = String(value).substringBefore(
- '\u0000'
- )
- }
- Log.i(
- "BluetoothGattCallback",
- "Read characteristic $uuid:\n${String(value)} - ${value.contentToString()} - ${value.toHexString()}"
- )
- }
+ handleCharacteristicStatus(gatt, characteristic, status, value)
+ }
- BluetoothGatt.GATT_READ_NOT_PERMITTED -> {
- Log.e("BluetoothGattCallback", "Read not permitted for $uuid!")
- }
+ private fun handleCharacteristicStatus(
+ gatt: BluetoothGatt?,
+ readCharacteristic: BluetoothGattCharacteristic,
+ status: Int,
+ value: ByteArray? = null
+ ) {
+ when (status) {
+ BluetoothGatt.GATT_SUCCESS -> handleSuccess(
+ gatt,
+ readCharacteristic,
+ value ?: readCharacteristic.value
+ )
- else -> {
- Log.e(
- "BluetoothGattCallback",
- "Characteristic read failed for $uuid, error: $status"
- )
- }
- }
+ BluetoothGatt.GATT_READ_NOT_PERMITTED -> Log.e(
+ "BluetoothGattCallback",
+ "Read not permitted for ${readCharacteristic.uuid}!"
+ )
+
+ else -> Log.e(
+ "BluetoothGattCallback",
+ "Characteristic read failed for ${readCharacteristic.uuid}, error: $status"
+ )
+ }
+ }
+
+ private fun handleSuccess(
+ gatt: BluetoothGatt?,
+ readCharacteristic: BluetoothGattCharacteristic,
+ value: ByteArray
+ ) {
+ val deviceCharacteristic =
+ deviceCharacteristics.find { it.characteristic.uuid == readCharacteristic.uuid }
+ deviceCharacteristic?.also {
+ it.value = String(value).substringBefore('\u0000')
}
+ Log.d(
+ "BluetoothGattCallback",
+ "Read characteristic ${readCharacteristic.uuid}:\n${
+ String(
+ value
+ )
+ }"
+ )
+ handleDeviceIndex(gatt)
+ }
+
+ private fun handleDeviceIndex(gatt: BluetoothGatt?) {
if (readableDeviceIndex < deviceCharacteristics.size - 1) {
- gatt.readCharacteristic(deviceCharacteristics[++readableDeviceIndex].characteristic)
+ gatt?.readCharacteristic(deviceCharacteristics[++readableDeviceIndex].characteristic)
} else {
bleCallback.accept(
hashMapOf(
"action" to "CONNECT_TO_DEVICE",
"provider" to "ble",
"success" to true,
- "data" to hashMapOf(
- "attributes" to deviceCharacteristics.map {
- hashMapOf(
- "attributeId" to it.characteristic.uuid,
- "isReadable" to it.isReadable,
- "isWritable" to it.isWritable,
- "value" to it.value
- )
- }
- )
+ "data" to hashMapOf("attributes" to deviceCharacteristics.map {
+ createAttributeMap(
+ it
+ )
+ })
)
)
}
}
+ private fun createAttributeMap(deviceCharacteristic: BleAttribute) =
+ hashMapOf(
+ "attributeId" to deviceCharacteristic.characteristic.uuid,
+ "isReadable" to deviceCharacteristic.isReadable,
+ "isWritable" to deviceCharacteristic.isWritable,
+ "value" to deviceCharacteristic.value
+ )
+
+
override fun onCharacteristicWrite(
gatt: BluetoothGatt?,
characteristic: BluetoothGattCharacteristic?,
status: Int
) {
super.onCharacteristicWrite(gatt, characteristic, status)
- Log.i(
+ Log.d(
"BluetoothGattCallback",
"Write characteristic ${characteristic?.uuid}:\n${status}"
)
@@ -323,7 +349,7 @@ class BleProvider(val context: Context) {
}
override fun onMtuChanged(gatt: BluetoothGatt?, mtu: Int, status: Int) {
- Log.i(
+ Log.d(
"BluetoothGattCallback",
"ATT MTU changed to $mtu, success: ${status == BluetoothGatt.GATT_SUCCESS}"
)
@@ -413,6 +439,7 @@ class BleProvider(val context: Context) {
@SuppressLint("MissingPermission")
private fun scanLeDevice(bleCallback: BleCallback) {
+ devices.clear()
bluetoothAdapter.bluetoothLeScanner?.let { bluetoothLeScanner ->
if (!scanning) { // Stops scanning after a pre-defined scan period.
handler.postDelayed({
@@ -497,6 +524,3 @@ fun BluetoothGattCharacteristic.isWritableWithoutResponse(): Boolean =
fun BluetoothGattCharacteristic.containsProperty(property: Int): Boolean {
return properties and property != 0
}
-
-fun ByteArray.toHexString(): String =
- joinToString(separator = " ", prefix = "0x") { String.format("%02X", it) }
diff --git a/console/android/ORLib/src/main/java/io/openremote/orlib/service/ORFirebaseMessagingService.kt b/console/android/ORLib/src/main/java/io/openremote/orlib/service/ORFirebaseMessagingService.kt
index 044329995..3a8c72cd5 100644
--- a/console/android/ORLib/src/main/java/io/openremote/orlib/service/ORFirebaseMessagingService.kt
+++ b/console/android/ORLib/src/main/java/io/openremote/orlib/service/ORFirebaseMessagingService.kt
@@ -166,7 +166,7 @@ class ORFirebaseMessagingService : com.google.firebase.messaging.FirebaseMessagi
val pm = packageManager
val notificationIntent = pm.getLaunchIntentForPackage(packageName)
notificationIntent?.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
- val pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0)
+ val pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE)
val notificationBuilder = NotificationCompat.Builder(
this,
@@ -221,7 +221,7 @@ class ORFirebaseMessagingService : com.google.firebase.messaging.FirebaseMessagi
actionIntent.putExtra("openInBrowser", ORAlertAction.openInBrowser)
actionIntent.putExtra("data", ObjectMapper().writeValueAsString(ORAlertAction.data))
}
- return PendingIntent.getService(this, 0, actionIntent, PendingIntent.FLAG_ONE_SHOT)
+ return PendingIntent.getService(this, 0, actionIntent, PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE)
}
companion object {
diff --git a/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt b/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt
index 49afe1638..b8c600511 100644
--- a/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt
+++ b/console/android/ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt
@@ -4,8 +4,7 @@ import android.Manifest
import android.annotation.SuppressLint
import android.app.Activity
import android.app.DownloadManager
-import android.bluetooth.le.ScanCallback
-import android.bluetooth.le.ScanResult
+import android.app.NotificationManager
import android.content.*
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
@@ -13,6 +12,7 @@ import android.graphics.Bitmap
import android.net.ConnectivityManager
import android.net.Uri
import android.os.*
+import android.provider.Settings
import android.view.KeyEvent
import android.view.View
import android.webkit.*
@@ -21,6 +21,8 @@ import android.webkit.WebView.WebViewTransport
import android.widget.ProgressBar
import android.widget.Toast
import androidx.annotation.RequiresApi
+import androidx.appcompat.app.AlertDialog
+import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.preference.PreferenceManager
import com.fasterxml.jackson.core.JsonProcessingException
@@ -48,7 +50,9 @@ open class OrMainActivity : Activity() {
private val locationResponseCode = 555
private var locationCallback: GeolocationPermissions.Callback? = null;
- private var locationOrigin: String? = null;
+ private var locationOrigin: String? = null;
+
+ private val pushResponseCode = 556
private lateinit var binding: ActivityOrMainBinding
private lateinit var sharedPreferences: SharedPreferences
@@ -133,6 +137,7 @@ open class OrMainActivity : Activity() {
LOG.fine("Loading web view: $url")
loadUrl(url)
}
+
else -> {
var url = baseUrl
val intentUrl = intent.getStringExtra("appUrl")
@@ -197,7 +202,6 @@ open class OrMainActivity : Activity() {
}
-
@SuppressLint("SetJavaScriptEnabled")
fun initializeWebView() {
LOG.fine("Initializing web view")
@@ -317,7 +321,7 @@ open class OrMainActivity : Activity() {
origin: String?,
callback: GeolocationPermissions.Callback?
) {
- if(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
+ if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
callback?.invoke(origin, true, false)
} else {
locationCallback = callback
@@ -348,7 +352,10 @@ open class OrMainActivity : Activity() {
transport.webView = newWebView
resultMsg.sendToTarget()
newWebView.webViewClient = object : WebViewClient() {
- override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean {
+ override fun shouldOverrideUrlLoading(
+ view: WebView,
+ request: WebResourceRequest
+ ): Boolean {
val browserIntent = Intent(Intent.ACTION_VIEW)
browserIntent.data = request.url
startActivity(browserIntent)
@@ -414,7 +421,7 @@ open class OrMainActivity : Activity() {
|| failingUrl.endsWith("jpg")
|| failingUrl.endsWith("ico")
|| failingUrl.contains("locales")
- || failingUrl.contains( "consoleappconfig"))
+ || failingUrl.contains("consoleappconfig"))
) {
LOG.info("Ignoring error loading image resource")
return
@@ -436,11 +443,16 @@ open class OrMainActivity : Activity() {
val launchIntent = packageManager.getLaunchIntentForPackage(packageName)
if (launchIntent != null) {
launchIntent.putExtra(CLEAR_URL, baseUrl)
- launchIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
+ launchIntent.flags =
+ Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(launchIntent)
finish()
}
- Toast.makeText(applicationContext, "The main page couldn't be opened", Toast.LENGTH_LONG).show()
+ Toast.makeText(
+ applicationContext,
+ "The main page couldn't be opened",
+ Toast.LENGTH_LONG
+ ).show()
}
}
}
@@ -468,11 +480,25 @@ open class OrMainActivity : Activity() {
locationCallback?.invoke(locationOrigin, true, false)
}
} else if (requestCode == BleProvider.BLUETOOTH_PERMISSION_REQUEST_CODE || requestCode == BleProvider.ENABLE_BLUETOOTH_REQUEST_CODE) {
- bleProvider?.onRequestPermissionsResult(this, requestCode, object : BleProvider.BleCallback {
- override fun accept(responseData: Map<String, Any>) {
- notifyClient(responseData)
- }
- })
+ bleProvider?.onRequestPermissionsResult(
+ this,
+ requestCode,
+ object : BleProvider.BleCallback {
+ override fun accept(responseData: Map<String, Any>) {
+ notifyClient(responseData)
+ }
+ })
+ } else if (requestCode == pushResponseCode) {
+ if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ notifyClient(hashMapOf(
+ "action" to "PROVIDER_ENABLE",
+ "provider" to "push",
+ "hasPermission" to true,
+ "success" to true
+ ))
+ }
+ } else {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults)
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
}
@@ -511,6 +537,7 @@ open class OrMainActivity : Activity() {
Toast.LENGTH_LONG
).show()
}
+
"provider" -> {
data?.let {
val action = it.getString("action")
@@ -520,15 +547,19 @@ open class OrMainActivity : Activity() {
provider.equals("geofence", ignoreCase = true) -> {
handleGeofenceProviderMessage(it)
}
+
provider.equals("push", ignoreCase = true) -> {
handlePushProviderMessage(it)
}
+
provider.equals("storage", ignoreCase = true) -> {
handleStorageProviderMessage(it)
}
+
provider.equals("qr", ignoreCase = true) -> {
handleQrScannerProviderMessage(it)
}
+
provider.equals("ble", ignoreCase = true) -> {
handleBleProviderMessage(it)
}
@@ -550,6 +581,7 @@ open class OrMainActivity : Activity() {
val initData: Map<String, Any> = geofenceProvider!!.initialize()
notifyClient(initData)
}
+
action.equals("PROVIDER_ENABLE", ignoreCase = true) -> {
val consoleId = data.getString("consoleId")
(activity as OrMainActivity).consoleId = consoleId
@@ -560,6 +592,7 @@ open class OrMainActivity : Activity() {
}
})
}
+
action.equals("PROVIDER_DISABLE", ignoreCase = true) -> {
geofenceProvider?.disable()
val response: MutableMap<String, Any> = HashMap()
@@ -567,9 +600,11 @@ open class OrMainActivity : Activity() {
response["provider"] = "geofence"
notifyClient(response)
}
+
action.equals("GEOFENCE_REFRESH", ignoreCase = true) -> {
geofenceProvider?.refreshGeofences()
}
+
action.equals("GET_LOCATION", ignoreCase = true) -> {
geofenceProvider?.getLocation(
this@OrMainActivity,
@@ -593,18 +628,109 @@ open class OrMainActivity : Activity() {
response["provider"] = "push"
response["version"] = "fcm"
response["enabled"] = false
- response["disabled"] = sharedPreferences.contains(ORConstants.PUSH_PROVIDER_DISABLED_KEY)
+ response["disabled"] =
+ sharedPreferences.contains(ORConstants.PUSH_PROVIDER_DISABLED_KEY)
response["requiresPermission"] = false
response["hasPermission"] = true
response["success"] = true
notifyClient(response)
}
+
action.equals("PROVIDER_ENABLE", ignoreCase = true) -> {
val consoleId = data.getString("consoleId")
sharedPreferences.edit()
.putString(ORConstants.CONSOLE_ID_KEY, consoleId)
.remove(ORConstants.PUSH_PROVIDER_DISABLED_KEY)
.apply()
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ if (ContextCompat.checkSelfPermission(
+ this@OrMainActivity,
+ Manifest.permission.POST_NOTIFICATIONS
+ ) != PackageManager.PERMISSION_GRANTED
+ ) {
+ if (ActivityCompat.shouldShowRequestPermissionRationale(
+ this@OrMainActivity,
+ Manifest.permission.POST_NOTIFICATIONS
+ )
+ ) {
+ AlertDialog.Builder(this@OrMainActivity)
+ .setTitle(R.string.push_notification_alert_title)
+ .setMessage(R.string.push_notification_alert_message)
+ .setIcon(R.drawable.ic_notification)
+ .setCancelable(false)
+ .setPositiveButton(
+ R.string.yes
+ ) { dialog, which ->
+ requestPermissions(
+ arrayOf(Manifest.permission.POST_NOTIFICATIONS),
+ pushResponseCode
+ )
+ }
+ .setNegativeButton(
+ R.string.no
+ ) { dialog, which ->
+ sharedPreferences.edit()
+ .putBoolean(
+ ORConstants.PUSH_PROVIDER_DISABLED_KEY,
+ true
+ )
+ .apply()
+ notifyClient(
+ hashMapOf(
+ "action" to "PROVIDER_ENABLE",
+ "provider" to "push",
+ "hasPermission" to false,
+ "success" to true
+ )
+ )
+ }.show()
+ } else {
+ requestPermissions(
+ arrayOf(Manifest.permission.POST_NOTIFICATIONS),
+ pushResponseCode
+ )
+ }
+ } else {
+ val mgr =
+ [email protected](NOTIFICATION_SERVICE) as NotificationManager
+ if (!mgr.areNotificationsEnabled()) {
+ AlertDialog.Builder(this@OrMainActivity)
+ .setTitle(R.string.push_notification_alert_title)
+ .setMessage(R.string.push_notification_alert_message)
+ .setIcon(R.drawable.ic_notification)
+ .setCancelable(false)
+ .setPositiveButton(
+ R.string.yes
+ ) { dialog, which ->
+ val intent = Intent()
+ intent.action = Settings.ACTION_APP_NOTIFICATION_SETTINGS
+ intent.putExtra(
+ Settings.EXTRA_APP_PACKAGE,
+ )
+ startActivity(intent)
+ }
+ .setNegativeButton(
+ R.string.no
+ ) { dialog, which ->
+ sharedPreferences.edit()
+ .putBoolean(
+ ORConstants.PUSH_PROVIDER_DISABLED_KEY,
+ true
+ )
+ .apply()
+ notifyClient(
+ hashMapOf(
+ "action" to "PROVIDER_ENABLE",
+ "provider" to "push",
+ "hasPermission" to false,
+ "success" to true
+ )
+ )
+ }.show()
+ }
+ }
+ }
// TODO: Implement topic support
FirebaseMessaging.getInstance().token.addOnCompleteListener { task ->
val response: MutableMap<String, Any?> =
@@ -622,12 +748,14 @@ open class OrMainActivity : Activity() {
notifyClient(response)
}
}
+
action.equals("PROVIDER_DISABLE", ignoreCase = true) -> {
// Cannot disable push notifications
val response: MutableMap<String, Any?> = HashMap()
response["action"] = "PROVIDER_DISABLE"
response["provider"] = "push"
- sharedPreferences.edit().putBoolean(ORConstants.PUSH_PROVIDER_DISABLED_KEY, true).apply()
+ sharedPreferences.edit()
+ .putBoolean(ORConstants.PUSH_PROVIDER_DISABLED_KEY, true).apply()
notifyClient(response)
}
}
@@ -648,6 +776,7 @@ open class OrMainActivity : Activity() {
response["success"] = true
notifyClient(response)
}
+
action.equals("PROVIDER_ENABLE", ignoreCase = true) -> {
// Doesn't require enabling but just in case it gets called lets return a valid response
val response: MutableMap<String, Any> = HashMap()
@@ -657,6 +786,7 @@ open class OrMainActivity : Activity() {
response["success"] = true
notifyClient(response)
}
+
action.equals("STORE", ignoreCase = true) -> {
try {
val key = data.getString("key")
@@ -666,6 +796,7 @@ open class OrMainActivity : Activity() {
LOG.log(Level.SEVERE, "Failed to store data", e)
}
}
+
action.equals("RETRIEVE", ignoreCase = true) -> {
try {
val key = data.getString("key")
@@ -694,6 +825,7 @@ open class OrMainActivity : Activity() {
val initData: Map<String, Any> = qrScannerProvider!!.initialize()
notifyClient(initData)
}
+
action.equals("PROVIDER_ENABLE", ignoreCase = true) -> {
qrScannerProvider?.enable(object : QrScannerProvider.ScannerCallback {
@@ -702,10 +834,12 @@ open class OrMainActivity : Activity() {
}
})
}
+
action.equals("PROVIDER_DISABLE", ignoreCase = true) -> {
val response = qrScannerProvider?.disable()
notifyClient(response)
}
+
action.equals("SCAN_QR", ignoreCase = true) -> {
qrScannerProvider?.startScanner(this@OrMainActivity)
}
@@ -723,6 +857,7 @@ open class OrMainActivity : Activity() {
val initData: Map<String, Any> = bleProvider!!.initialize()
notifyClient(initData)
}
+
action.equals("PROVIDER_ENABLE", ignoreCase = true) -> {
bleProvider?.enable(object : BleProvider.BleCallback {
override fun accept(responseData: Map<String, Any>) {
@@ -730,17 +865,22 @@ open class OrMainActivity : Activity() {
}
})
}
+
action.equals("PROVIDER_DISABLE", ignoreCase = true) -> {
val response = bleProvider?.disable()
notifyClient(response)
}
+
action.equals("SCAN_BLE_DEVICES", ignoreCase = true) -> {
- bleProvider?.startBLEScan(this@OrMainActivity, object : BleProvider.BleCallback {
- override fun accept(responseData: Map<String, Any>) {
- notifyClient(responseData)
- }
- })
+ bleProvider?.startBLEScan(
+ this@OrMainActivity,
+ object : BleProvider.BleCallback {
+ override fun accept(responseData: Map<String, Any>) {
+ notifyClient(responseData)
+ }
+ })
}
+
action.equals("CONNECT_TO_DEVICE", ignoreCase = true) -> {
val address = data.getString("address")
bleProvider?.connectToDevice(address, object : BleProvider.BleCallback {
@@ -749,6 +889,7 @@ open class OrMainActivity : Activity() {
}
})
}
+
action.equals("SEND_TO_DEVICE", ignoreCase = true) -> {
val attributeId = data.getString("attributeId")
val value = data.get("value")
diff --git a/console/android/ORLib/src/main/res/values/strings.xml b/console/android/ORLib/src/main/res/values/strings.xml
index 2b483085a..a33ca52ef 100644
--- a/console/android/ORLib/src/main/res/values/strings.xml
+++ b/console/android/ORLib/src/main/res/values/strings.xml
@@ -17,6 +17,8 @@
<string name="download_completed">Download completed</string>
<string name="background_location_alert_title">Background location needed</string>
<string name="background_location_alert_body">In order to receive these notifications when the app is running in the background, background location access is needed.\nNo location history is stored, only the latest location is saved.\nDo you want to enabled it in the settings?</string>
+ <string name="push_notification_alert_title">Push notifications needed</string>
+ <string name="push_notification_alert_message">In order to receive these notifications, push notifications need to be enabled.\nDo you want to enabled it in the settings?</string>
<string name="camera_needed_alert_title">Camera access needed</string>
<string name="camera_needed_alert_body">In order to scan QR codes, access to the devices camera is needed.</string>
<string name="location_background_disabled_title">Background location disabled</string>
@@ -24,4 +26,4 @@
<string name="yes">Yes</string>
<string name="button_accept">Accept</string>
<string name="NOTIFICATION_CHANNEL_ID">OR</string>
-</resources>
\ No newline at end of file
+</resources>