Skip to content

Commit a472e1f

Browse files
committed
Starting updating to ST BLE Sensor V5.1.0
Signed-off-by: Luca Pezzoni <luca.pezzoni@st.com>
1 parent c0d7e2e commit a472e1f

197 files changed

Lines changed: 20149 additions & 495 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Application ST BLE Sensors
55

66
# Compilation
77

8-
Code compiled using gradle 8.1.1 and JDK 11
8+
Code compiled using gradle 8.2.1 and JDK jbr-17
99

1010
set on Gradle properties the Github Login name and SSO authentication
1111
Example:
@@ -16,24 +16,28 @@ GPR_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXX
1616
For using this application is necessary to downlaod the Android BlueST-SDK from:
1717
https://github.com/STMicroelectronics/BlueSTSDK_Android
1818

19-
tag BlueST-SDK_V1.0.0
19+
tag BlueST-SDK_V1.0.10
2020

2121
and follow the instruction for compiling and publish on local maven repository the 2 libraries necessary for this application:
2222
* st-blue-sdk
2323
* st-opus
2424

2525

2626

27-
## Install Bash4 on Mac
27+
brew install gnu-sed
2828

29-
brew install bash
29+
Set the PATH (first on Intel, second on Apple Silicon)
30+
PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
3031

31-
## Using the script for creating a new demo
32+
PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH"
3233

33-
brew install gnu-sed
34-
PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
35-
cd extra
36-
/usr/local/bin/bash ./createStDemoModule.sh binary_content xml "Binary Content"
34+
cd extra
35+
36+
Run the command (first on Intel, second on Apple Silicon)
37+
38+
/usr/local/bin/bash ./createStDemoModule.sh binary_content xml "Binary Content"
39+
40+
/opt/homebrew/bin/bash ./createStDemoModule.sh binary_content xml "Binary Content"
3741

3842
## License
3943

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ android {
2525
applicationId "com.st.bluems"
2626
minSdk rootProject.minSdk
2727
targetSdk rootProject.targetSdk
28-
versionCode 154
29-
versionName "5.0.0"
28+
versionCode 168
29+
versionName "5.1.0"
3030

3131
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3232
vectorDrawables {
@@ -120,5 +120,5 @@ dependencies {
120120

121121
// Debug
122122
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
123-
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
123+
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_reflect"
124124
}

app/src/main/AndroidManifest.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@
4747

4848
<category android:name="android.intent.category.LAUNCHER" />
4949
</intent-filter>
50+
51+
<intent-filter>
52+
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
53+
<action android:name="android.intent.action.VIEW" />
54+
<category android:name="android.intent.category.DEFAULT" />
55+
<category android:name="android.intent.category.BROWSABLE" />
56+
<!-- Accepts URIs that begin with "stapplication://connect” -->
57+
<data android:scheme="stapplication"
58+
android:host="connect" />
59+
</intent-filter>
60+
5061
</activity>
5162
</application>
5263

app/src/main/java/com/st/bluems/MainActivity.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package com.st.bluems
99

1010
import android.os.Bundle
11-
import android.util.Log
1211
import androidx.activity.viewModels
1312
import androidx.appcompat.app.AppCompatActivity
1413
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
@@ -28,11 +27,13 @@ import com.st.welcome.StWelcomeConfig
2827
import com.st.welcome.WelcomeFragmentDirections
2928
import com.st.welcome.model.WelcomePage
3029
import dagger.hilt.android.AndroidEntryPoint
30+
import java.nio.charset.StandardCharsets
3131

3232
@AndroidEntryPoint
3333
class MainActivity : AppCompatActivity() {
3434

3535
private val viewModel: MainViewModel by viewModels()
36+
private val nfcViewModel: NFCConnectionViewModel by viewModels()
3637
private lateinit var navController: NavController
3738

3839
override fun onCreate(savedInstanceState: Bundle?) {
@@ -52,6 +53,20 @@ class MainActivity : AppCompatActivity() {
5253
)
5354
}
5455

56+
//for using NFC deep Link node autoconnect
57+
val nfcIntent = intent
58+
val appLinkData = nfcIntent.data
59+
if (appLinkData != null) {
60+
61+
val sPairingPin: ByteArray? = appLinkData.getQueryParameter("Pin")?.toByteArray(
62+
StandardCharsets.UTF_8
63+
)
64+
nfcViewModel.setNFCPairingPin(sPairingPin)
65+
66+
val mNodeTag: String? = appLinkData.getQueryParameter("Add")
67+
nfcViewModel.setNFCNodeId(mNodeTag)
68+
}
69+
5570
viewModel.reportApplicationAnalytics(applicationContext)
5671

5772
installSplashScreen()
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.st.bluems
2+
3+
import android.util.Log
4+
import androidx.lifecycle.ViewModel
5+
import kotlinx.coroutines.flow.MutableStateFlow
6+
import kotlinx.coroutines.flow.asStateFlow
7+
8+
class NFCConnectionViewModel: ViewModel() {
9+
10+
private val _nfcNodeId = MutableStateFlow<String?>(null)
11+
val nfcNodeId = _nfcNodeId.asStateFlow()
12+
13+
private val _pairingPin= MutableStateFlow<ByteArray?>(null)
14+
val pairingPin = _pairingPin.asStateFlow()
15+
16+
17+
fun setNFCPairingPin(pin: ByteArray?) {
18+
_pairingPin.value = pin
19+
if(pin!=null) {
20+
Log.i("NFC", "NFC PairingPin = ${String(pin)}")
21+
}
22+
}
23+
24+
fun setNFCNodeId(nodeTag: String?) {
25+
_nfcNodeId.value = nodeTag
26+
if(nodeTag!=null) {
27+
Log.i("NFC", "NFC NodeId = $nodeTag")
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)