Skip to content

Commit

Permalink
Release-v2.9.0 package
Browse files Browse the repository at this point in the history
  • Loading branch information
SaravanKumarMS committed Jun 3, 2024
1 parent 1023f4f commit a4ccb65
Show file tree
Hide file tree
Showing 57 changed files with 2,721 additions and 389 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ EFR Connect includes many demos to test sample apps in the Silicon Labs GSDK qui
- **Wi-Fi Commissioning**: Commission a Wi-Fi device over BLE.
- **Bluetooth Electronic Shelf Labels (ESL)**: Adds and commissions ESL tags to the system network by scanning the tag's QR code with the mobile device's camera and provides the user a UI to view the list commissioned tags and control them.
- **Matter**: Commission and control of the Matter devices over Thread and Wi-Fi.
- **Wi-Fi OTA Firmware Update**: The Wi-Fi OTA firmware update demo demonstrates how to update the SiWx91x user application firmware over Wi-Fi connection, by downloading the image from the mobile phone.

## Development Features
EFR Connect helps developers create and troubleshoot Bluetooth applications running on Silicon Labs’ BLE hardware. Here’s a rundown of some example functionalities.
Expand Down
22 changes: 8 additions & 14 deletions mobile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ android {
compileSdk = 33
namespace = "com.siliconlabs.bledemo"


defaultConfig {
minSdk = 29
targetSdk = 33

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

packagingOptions { jniLibs { useLegacyPackaging = true } }

buildTypes {
release {
isMinifyEnabled = false
Expand Down Expand Up @@ -57,8 +58,8 @@ android {
create("blueGecko") {
dimension = versionDim
applicationId = "com.siliconlabs.bledemo"
versionCode = 48
versionName = "2.8.2"
versionCode = 49
versionName = "2.9.0"
}
}

Expand All @@ -73,14 +74,7 @@ android {

buildFeatures {
viewBinding = true

}

// packagingOptions {
// jniLibs {
// useLegacyPackaging = true
// }
// }
}

dependencies {
Expand Down Expand Up @@ -108,7 +102,8 @@ dependencies {
implementation("io.github.g00fy2.quickie:quickie-bundled:1.7.0")

implementation("com.google.android.flexbox:flexbox:3.0.0")
// implementation("com.github.PhilJay:MPAndroidChart:v3.0.3")
//MPAndroidChart is added as jar library file
//implementation("com.github.PhilJay:MPAndroidChart:v3.0.3")

// Navigation
implementation("androidx.navigation:navigation-fragment-ktx:2.5.3")
Expand All @@ -117,7 +112,6 @@ dependencies {

// Dependency injection
implementation("com.google.dagger:hilt-android:2.45")
implementation(files("libs/MPAndroidChart-v3.0.1.jar"))
kapt("com.google.dagger:hilt-android-compiler:2.45")

// View binding
Expand All @@ -129,7 +123,7 @@ dependencies {
// Parsing
implementation("com.google.code.gson:gson:2.10.1")
implementation("com.opencsv:opencsv:5.6")
implementation ("androidx.activity:activity:1.6.0-alpha05")
implementation("androidx.activity:activity:1.6.0-alpha05")

// Only used for Int.pow() method in a couple of places
implementation("com.google.guava:guava:29.0-android")
Expand All @@ -152,5 +146,5 @@ dependencies {
implementation("androidx.camera:camera-lifecycle:1.1.0")
implementation("androidx.camera:camera-view:1.1.0")
implementation("com.google.mlkit:barcode-scanning:17.0.2")
implementation ("com.daimajia.swipelayout:library:1.2.0@aar")
implementation("com.daimajia.swipelayout:library:1.2.0@aar")
}
10 changes: 7 additions & 3 deletions mobile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.NFC"/>
<uses-permission android:name="android.permission.NFC"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true" />
Expand All @@ -30,8 +33,9 @@
<application
android:name=".application.SiliconLabsDemoApplication"
android:allowBackup="false"
android:icon="@mipmap/efr_redesign_launcher"
android:label="@string/app_name_EFR_Connect"
android:icon="@mipmap/si_launcher_round"
android:requestLegacyExternalStorage="true"
android:label="@string/app_name_simplicity_Connect"
android:supportsRtl="true"
tools:replace="android:allowBackup"
android:enableOnBackInvokedCallback="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class BluetoothService : LocalService<BluetoothService>() {
ENVIRONMENT,
IOP_TEST,
ESL_DEMO,
MATTER_DEMO
MATTER_DEMO,
WIFI_OTA_UPDATE
}

interface ScanListener {
Expand Down Expand Up @@ -280,6 +281,7 @@ class BluetoothService : LocalService<BluetoothService>() {
addAction(ACTION_GATT_SERVER_REMOVE_NOTIFICATION)
}
registerReceiver(gattServerBroadcastReceiver, filter)

}

override fun onDestroy() {
Expand Down Expand Up @@ -659,10 +661,13 @@ class BluetoothService : LocalService<BluetoothService>() {

override fun onMtuChanged(gatt: BluetoothGatt, mtu: Int, status: Int) {
super.onMtuChanged(gatt, mtu, status)
Timber.d("onMtuChanged(): gatt device =${gatt.device.address}, mtu = $mtu")
addDeviceLog(GattOperationWithParameterLog(gatt, GattOperationLog.Type.MTU_CHANGED,
if (status == BluetoothGatt.GATT_SUCCESS) {
Timber.d("onMtuChanged(): gatt device =${gatt.device.address}, mtu = $mtu")
addDeviceLog(GattOperationWithParameterLog(gatt, GattOperationLog.Type.MTU_CHANGED,
status, "mtu = $mtu"))
extraGattCallback?.onMtuChanged(gatt, mtu, status)
extraGattCallback?.onMtuChanged(gatt, mtu, status)
}

}

override fun onPhyUpdate(gatt: BluetoothGatt, txPhy: Int, rxPhy: Int, status: Int) {
Expand Down Expand Up @@ -843,7 +848,7 @@ class BluetoothService : LocalService<BluetoothService>() {
createNotificationChannel()

val notification = Notification.Builder(this, CHANNEL_ID)
.setSmallIcon(R.mipmap.efr_redesign_launcher)
.setSmallIcon(R.mipmap.si_launcher)
.setContentTitle(getString(R.string.notification_title_device_has_connected, deviceName))
.setContentText(getString(R.string.notification_note_debug_connection))
.addAction(buildAction(getString(R.string.button_yes), getYesPendingIntent(device)))
Expand All @@ -869,7 +874,7 @@ class BluetoothService : LocalService<BluetoothService>() {

private fun buildAction(actionText: String, actionIntent: PendingIntent) : Notification.Action {
return Notification.Action.Builder(
R.mipmap.efr_redesign_launcher,
R.mipmap.si_launcher,
actionText,
actionIntent
).build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.siliconlabs.bledemo.utils
import android.annotation.SuppressLint
import android.bluetooth.BluetoothGatt
import android.bluetooth.BluetoothGattCharacteristic
import android.util.Log
import java.util.*
import java.util.concurrent.locks.Lock
import java.util.concurrent.locks.ReentrantLock
Expand Down Expand Up @@ -62,12 +63,13 @@ class GattQueue(private val gatt: BluetoothGatt?) {

private fun processNextCommand() {
var success = false
Log.i("GattQueue","processNextCommand")
val command = commands.poll()

if (command?.gatt != null && command.characteristic != null) {
val gatt = command.gatt
val characteristic = command.characteristic

Log.i("GattQueue","command.type "+command.type)
success = when (command.type) {
GattCommand.Type.READ -> gatt.readCharacteristic(characteristic)
GattCommand.Type.WRITE -> gatt.writeCharacteristic(characteristic)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.siliconlabs.bledemo.features.demo.matter_demo.adapters

import android.content.Context
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.content.ContextCompat
Expand Down Expand Up @@ -65,7 +64,7 @@ class MatterScannedResultAdapter(



holder.itemView.setOnClickListener {
holder.binding.textViewHeader.setOnClickListener {
runBlocking {
if (onClickListener != null) {
onClickListener!!.onClick(position, matterInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import kotlin.math.abs
@SuppressLint("MissingPermission")
class RangeTestActivity : BaseDemoActivity(), Controller {

private var lowerLimit: Int = 0
private var upperLimit: Int = 0
private var descriptor2906: BluetoothGattDescriptor? = null

private var activeDeviceId = 1

private var advertisementHandler: RangeTestAdvertisementHandler? = null
Expand Down Expand Up @@ -188,8 +192,8 @@ class RangeTestActivity : BaseDemoActivity(), Controller {
}
})
}.also {
it.show(supportFragmentManager, "select_device_dialog")
}
it.show(supportFragmentManager, "select_device_dialog")
}
} else {
showRangeTestFragment(presenter.getMode())
}
Expand Down Expand Up @@ -781,6 +785,10 @@ class RangeTestActivity : BaseDemoActivity(), Controller {
status: Int
) {
super.onCharacteristicRead(gatt, characteristic, status)
val descriptorUuid = UUID.fromString("00002906-0000-1000-8000-00805f9b34fb")
if (characteristic != null) {
descriptor2906 = characteristic.getDescriptor(descriptorUuid)
}

if (status != BluetoothGatt.GATT_SUCCESS) {
handleConnectionError()
Expand All @@ -794,11 +802,22 @@ class RangeTestActivity : BaseDemoActivity(), Controller {
if (gattCharacteristic != null) {
updatePresenter(gatt, characteristic, gattCharacteristic)

if (gattCharacteristic === GattCharacteristic.RangeTestTxPower || gattCharacteristic === GattCharacteristic.RangeTestPayload || gattCharacteristic === GattCharacteristic.RangeTestMaSize) {
if (gattCharacteristic === GattCharacteristic.RangeTestTxPower
|| gattCharacteristic === GattCharacteristic.RangeTestPayload
|| gattCharacteristic === GattCharacteristic.RangeTestMaSize
) {
val descriptors = characteristic.descriptors
if (descriptors.size > 1) {
queueReadDescriptor(gatt, characteristic, descriptors[descriptors.size - 1])
}
} else {
if (gattCharacteristic === GattCharacteristic.RangeTestChannel) {
val descriptors = characteristic.descriptors
if (descriptors.size > 1) {
descriptor2906?.let { queueReadDescriptor(gatt, characteristic, it) }
}

}
}
}
}
Expand All @@ -809,7 +828,22 @@ class RangeTestActivity : BaseDemoActivity(), Controller {
status: Int
) {
super.onDescriptorRead(gatt, descriptor, status)
if (descriptor?.uuid == UUID.fromString("00002906-0000-1000-8000-00805f9b34fb")) {
try {
val validRangeValue = descriptor.value
lowerLimit = (validRangeValue[1].toInt() and 0xFF) shl 8 or (validRangeValue[0].toInt() and 0xFF)
upperLimit = (validRangeValue[3].toInt() and 0xFF) shl 8 or (validRangeValue[2].toInt() and 0xFF)
RangeTestValues.setChannelsMinMax(lowerLimit, upperLimit)
val gattCharacteristic1 = GattCharacteristic.fromUuid(descriptor.characteristic.uuid)
gattCharacteristic1?.let {
updatePresenter(gatt, descriptor, it)
}

}catch (e:Exception)
{
e.stackTrace
}
}
if (status != BluetoothGatt.GATT_SUCCESS) {
handleConnectionError()
return
Expand Down Expand Up @@ -1213,7 +1247,7 @@ class RangeTestActivity : BaseDemoActivity(), Controller {
android.R.id.home -> {
service?.disconnectAllGatts()
gatt?.disconnect()
Handler(Looper.getMainLooper()).postDelayed({ onBackPressed() },500)
Handler(Looper.getMainLooper()).postDelayed({ onBackPressed() }, 500)
true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class RangeTestValues {
var PACKET_COUNT_LOOKUP: List<Int>
var ID_LOOKUP: List<Int>

private const val CHANNELS_MIN = 0
private const val CHANNELS_MAX = 19
private var CHANNELS_MIN = 0
private var CHANNELS_MAX = 0

private val PACKET_COUNTS = arrayOf(500, 1000, 2500, 5000, 10000, 25000, 50000)

Expand All @@ -39,5 +39,20 @@ class RangeTestValues {

ID_LOOKUP = Collections.unmodifiableList(idLookup)
}

fun setChannelsMinMax(min: Int, max: Int) {
CHANNELS_MIN = min
CHANNELS_MAX = max
updateChannelLookup()
}

private fun updateChannelLookup() {
val channelsLookupSize = CHANNELS_MAX - CHANNELS_MIN + 1
val channelsLookup: ArrayList<Int> = ArrayList(channelsLookupSize)
for (i in 0 until channelsLookupSize) {
channelsLookup.add(CHANNELS_MIN + i)
}
CHANNEL_LOOKUP = Collections.unmodifiableList(channelsLookup)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ class ThunderBoardDevice(device: BluetoothDevice) {
THUNDERBOARD_MODEL_SENSE -> Type.THUNDERBOARD_SENSE
THUNDERBOARD_MODEL_BLUE_V1,
THUNDERBOARD_MODEL_BLUE_V2 -> Type.THUNDERBOARD_BLUE

THUNDERBOARD_MODEL_DEV_KIT_V1,
THUNDERBOARD_MODEL_DEV_KIT_V2 -> Type.THUNDERBOARD_DEV_KIT
THUNDERBOARD_MODEL_DEV_KIT_V2,
THUNDERBOARD_MODEL_DEV_KIT_V3 -> Type.THUNDERBOARD_DEV_KIT

else -> Type.UNKNOWN
}

Expand All @@ -30,9 +33,9 @@ class ThunderBoardDevice(device: BluetoothDevice) {
UNKNOWN(0);

companion object {
fun fromInt(code: Int) : PowerSource {
fun fromInt(code: Int): PowerSource {
for (source in values()) {
if (source.value == code ) return source
if (source.value == code) return source
}
return UNKNOWN
}
Expand All @@ -52,6 +55,7 @@ class ThunderBoardDevice(device: BluetoothDevice) {
const val THUNDERBOARD_MODEL_BLUE_V2 = "BRD4184B"
const val THUNDERBOARD_MODEL_DEV_KIT_V1 = "BRD2601A"
const val THUNDERBOARD_MODEL_DEV_KIT_V2 = "BRD2601B"
const val THUNDERBOARD_MODEL_DEV_KIT_V3 = "BRD2608A"
}

}
Loading

0 comments on commit a4ccb65

Please sign in to comment.