├── sample
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── themes.xml
│ │ │ │ └── colors.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ │ └── no
│ │ │ │ └── nordicsemi
│ │ │ │ └── kotlin
│ │ │ │ └── ble
│ │ │ │ └── android
│ │ │ │ └── sample
│ │ │ │ ├── theme
│ │ │ │ └── Type.kt
│ │ │ │ ├── TestApplication.kt
│ │ │ │ └── util
│ │ │ │ └── CloseableCoroutineScope.kt
│ │ └── AndroidManifest.xml
│ └── native
│ │ └── java
│ │ └── no
│ │ └── nordicsemi
│ │ └── kotlin
│ │ └── ble
│ │ └── android
│ │ └── sample
│ │ └── di
│ │ └── SdkModule.kt
├── proguard-rules.pro
└── build.gradle.kts
├── test
├── consumer-rules.pro
├── src
│ ├── androidTest
│ │ └── java
│ │ │ └── no
│ │ │ └── nordicsemi
│ │ │ └── android
│ │ │ └── kotlin
│ │ │ └── ble
│ │ │ └── test
│ │ │ ├── utils
│ │ │ ├── TestAddressProvider.kt
│ │ │ └── BlinkySpecifications.kt
│ │ │ ├── BluetoothGattServiceFactoryTest.kt
│ │ │ ├── ReadFromDisconnectedDeviceTest.kt
│ │ │ ├── GetNotificationsStuckTest.kt
│ │ │ ├── SimultaneousRssiStuckTest.kt
│ │ │ └── DeadlockTwoDevices.kt
│ ├── test
│ │ └── java
│ │ │ └── no
│ │ │ └── nordicsemi
│ │ │ └── android
│ │ │ └── kotlin
│ │ │ └── ble
│ │ │ └── test
│ │ │ ├── BlinkySpecifications.kt
│ │ │ └── ApplicationScopeModule.kt
│ └── main
│ │ └── AndroidManifest.xml
└── proguard-rules.pro
├── client-mock
├── .gitignore
├── Module.md
└── src
│ └── main
│ └── java
│ └── no
│ └── nordicsemi
│ └── kotlin
│ └── ble
│ └── client
│ └── mock
│ └── DisconnectionReason.kt
├── core-mock
├── .gitignore
├── Module.md
└── src
│ └── main
│ └── java
│ └── no
│ └── nordicsemi
│ └── kotlin
│ └── ble
│ └── core
│ └── mock
│ └── MockEnvironment.kt
├── advertiser-core
├── .gitignore
└── Module.md
├── advertiser-android
├── .gitignore
├── Module.md
└── src
│ └── main
│ └── AndroidManifest.xml
├── advertiser-android-mock
├── .gitignore
└── Module.md
├── advertiser-core-android
├── .gitignore
└── Module.md
├── Gemfile
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
└── nordic.versions.toml
├── docs
└── html
│ ├── ui-kit
│ └── fonts
│ │ ├── inter-latin-400-italic.woff
│ │ ├── inter-latin-400-italic.woff2
│ │ ├── inter-latin-400-normal.woff
│ │ ├── inter-latin-400-normal.woff2
│ │ ├── inter-latin-600-normal.woff
│ │ ├── inter-latin-600-normal.woff2
│ │ ├── jetbrains-mono-latin-400-normal.woff
│ │ ├── jetbrains-mono-latin-600-normal.woff
│ │ ├── jetbrains-mono-latin-400-normal.woff2
│ │ └── jetbrains-mono-latin-600-normal.woff2
│ ├── images
│ ├── arrow-down.svg
│ ├── homepage.svg
│ ├── checkbox-off.svg
│ ├── copy-icon.svg
│ ├── placeholder.svg
│ ├── check.svg
│ ├── go-to-top-icon.svg
│ ├── checkbox-on.svg
│ ├── burger.svg
│ ├── cross.svg
│ ├── exception-class.svg
│ ├── enum.svg
│ ├── field-value.svg
│ ├── interface.svg
│ ├── field-variable.svg
│ ├── filter.svg
│ ├── success-icon.svg
│ ├── interface-kotlin.svg
│ ├── enum-kotlin.svg
│ ├── typealias-kotlin.svg
│ ├── anchor-copy-icon.svg
│ ├── theme-toggle.svg
│ ├── class.svg
│ ├── object.svg
│ ├── class-kotlin.svg
│ ├── function.svg
│ ├── abstract-class.svg
│ ├── annotation.svg
│ ├── abstract-class-kotlin.svg
│ └── annotation-kotlin.svg
│ ├── scripts
│ └── sourceset_dependencies.js
│ ├── styles
│ └── logo-styles.css
│ └── package-list
├── fastlane
├── Appfile
└── Fastfile
├── core-android-mock
├── Module.md
└── src
│ └── main
│ └── AndroidManifest.xml
├── core-android
├── Module.md
└── src
│ └── main
│ └── AndroidManifest.xml
├── core
├── Module.md
└── src
│ └── main
│ ├── java
│ └── no
│ │ └── nordicsemi
│ │ └── kotlin
│ │ └── ble
│ │ └── core
│ │ ├── GattConstants.kt
│ │ ├── exception
│ │ ├── GattException.kt
│ │ ├── ManagerClosedException.kt
│ │ └── BluetoothException.kt
│ │ ├── Peer.kt
│ │ ├── BondState.kt
│ │ ├── util
│ │ └── Distinct.kt
│ │ ├── AdvertisingDataDefinition.kt
│ │ ├── PeripheralType.kt
│ │ └── PhyInUse.kt
│ └── AndroidManifest.xml
├── client-android
├── Module.md
└── src
│ └── main
│ └── AndroidManifest.xml
├── client-core
├── Module.md
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── no
│ └── nordicsemi
│ └── kotlin
│ └── ble
│ └── client
│ └── exception
│ ├── BluetoothUnavailableException.kt
│ ├── ScanningException.kt
│ ├── PeripheralNotConnectedException.kt
│ ├── ValueDoesNotMatchException.kt
│ ├── OperationFailedException.kt
│ ├── InvalidAttributeException.kt
│ └── ConnectionFailedException.kt
├── client-android-mock
├── Module.md
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── no
│ └── nordicsemi
│ └── kotlin
│ └── ble
│ └── client
│ └── android
│ └── mock
│ └── MockCentralManager.kt
├── client-core-android
├── Module.md
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── no
│ └── nordicsemi
│ └── kotlin
│ └── ble
│ └── client
│ └── android
│ └── exception
│ ├── BondingFailedException.kt
│ └── PeripheralClosedException.kt
├── renovate.json
├── .github
└── workflows
│ └── deploy-to-nexus.yml
├── LICENSE
├── profile
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── no
│ └── nordicsemi
│ └── android
│ └── kotlin
│ └── ble
│ └── profile
│ ├── gls
│ └── data
│ │ ├── GlucoseMeasurementUnit.kt
│ │ ├── RequestStatus.kt
│ │ ├── GLSData.kt
│ │ ├── Tester.kt
│ │ ├── Meal.kt
│ │ ├── Carbohydrate.kt
│ │ ├── Health.kt
│ │ └── Medication.kt
│ ├── bps
│ └── data
│ │ ├── BloodPressureType.kt
│ │ ├── BloodPressureMeasurementData.kt
│ │ └── IntermediateCuffPressureData.kt
│ ├── hrs
│ ├── data
│ │ └── HRSData.kt
│ └── BodySensorLocationParser.kt
│ ├── prx
│ ├── PRXData.kt
│ ├── AlertLevelInputParser.kt
│ ├── AlarmLevel.kt
│ └── AlarmLevelParser.kt
│ ├── csc
│ └── data
│ │ ├── CSCDataSnapshot.kt
│ │ └── CSCData.kt
│ ├── hts
│ └── data
│ │ ├── HTSData.kt
│ │ └── TemperatureUnit.kt
│ ├── rscs
│ └── data
│ │ └── RSCSData.kt
│ ├── battery
│ └── BatteryLevelParser.kt
│ ├── cgm
│ └── data
│ │ ├── CGMRecord.kt
│ │ ├── CGMCalibrationStatus.kt
│ │ └── CGMErrorCode.kt
│ └── racp
│ └── RACPOpCode.kt
├── server-core
├── src
│ └── main
│ │ └── AndroidManifest.xml
└── build.gradle.kts
├── server-android
└── src
│ └── main
│ └── AndroidManifest.xml
├── server-android-mock
└── src
│ └── main
│ └── AndroidManifest.xml
└── server-core-android
├── src
└── main
│ ├── AndroidManifest.xml
│ └── java
│ └── no
│ └── nordicsemi
│ └── kotlin
│ └── ble
│ └── server
│ └── android
│ ├── PeripheralManager.kt
│ └── ConnectionEvent.kt
└── build.gradle.kts
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/test/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client-mock/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/core-mock/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/advertiser-core/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/advertiser-android/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/advertiser-android-mock/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/advertiser-core-android/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 |
3 | gem "fastlane"
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Sample
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/docs/html/ui-kit/fonts/inter-latin-400-italic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/docs/html/ui-kit/fonts/inter-latin-400-italic.woff
--------------------------------------------------------------------------------
/docs/html/ui-kit/fonts/inter-latin-400-italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/docs/html/ui-kit/fonts/inter-latin-400-italic.woff2
--------------------------------------------------------------------------------
/docs/html/ui-kit/fonts/inter-latin-400-normal.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/docs/html/ui-kit/fonts/inter-latin-400-normal.woff
--------------------------------------------------------------------------------
/docs/html/ui-kit/fonts/inter-latin-400-normal.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/docs/html/ui-kit/fonts/inter-latin-400-normal.woff2
--------------------------------------------------------------------------------
/docs/html/ui-kit/fonts/inter-latin-600-normal.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/docs/html/ui-kit/fonts/inter-latin-600-normal.woff
--------------------------------------------------------------------------------
/docs/html/ui-kit/fonts/inter-latin-600-normal.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/docs/html/ui-kit/fonts/inter-latin-600-normal.woff2
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/docs/html/ui-kit/fonts/jetbrains-mono-latin-400-normal.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/docs/html/ui-kit/fonts/jetbrains-mono-latin-400-normal.woff
--------------------------------------------------------------------------------
/docs/html/ui-kit/fonts/jetbrains-mono-latin-600-normal.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/docs/html/ui-kit/fonts/jetbrains-mono-latin-600-normal.woff
--------------------------------------------------------------------------------
/docs/html/ui-kit/fonts/jetbrains-mono-latin-400-normal.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/docs/html/ui-kit/fonts/jetbrains-mono-latin-400-normal.woff2
--------------------------------------------------------------------------------
/docs/html/ui-kit/fonts/jetbrains-mono-latin-600-normal.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NordicSemiconductor/Kotlin-BLE-Library/HEAD/docs/html/ui-kit/fonts/jetbrains-mono-latin-600-normal.woff2
--------------------------------------------------------------------------------
/sample/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/core-mock/Module.md:
--------------------------------------------------------------------------------
1 | # Module core-mock
2 |
3 | Core types for defining mock environments.
4 |
5 | # Package no.nordicsemi.kotlin.ble.core.mock
6 |
7 | This package contains classes for defining mock environments.
--------------------------------------------------------------------------------
/docs/html/images/arrow-down.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/fastlane/Appfile:
--------------------------------------------------------------------------------
1 | json_key_file("") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
2 | package_name("no.nordicsemi.android.kotlin.ble") # e.g. com.krausefx.app
3 |
--------------------------------------------------------------------------------
/docs/html/images/homepage.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/java/no/nordicsemi/kotlin/ble/android/sample/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package no.nordicsemi.kotlin.ble.android.sample.theme
2 |
3 | import androidx.compose.material3.Typography
4 |
5 | val AppTypography = Typography()
6 |
--------------------------------------------------------------------------------
/docs/html/images/checkbox-off.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/core-android-mock/Module.md:
--------------------------------------------------------------------------------
1 | # Module core-android-mock
2 |
3 | Types for customizing mock environment on Android.
4 |
5 | # Package no.nordicsemi.kotlin.ble.android.mock
6 |
7 | This package contains a class for defining mock environment on Android.
--------------------------------------------------------------------------------
/docs/html/images/copy-icon.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/docs/html/images/placeholder.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/test/src/androidTest/java/no/nordicsemi/android/kotlin/ble/test/utils/TestAddressProvider.kt:
--------------------------------------------------------------------------------
1 | package no.nordicsemi.android.kotlin.ble.test.utils
2 |
3 | object TestAddressProvider {
4 |
5 | val address = "F6:1B:1A:66:27:57"
6 | val auxiliaryAddress = "CA:CC:95:E9:72:2B"
7 | }
8 |
--------------------------------------------------------------------------------
/advertiser-android/Module.md:
--------------------------------------------------------------------------------
1 | # Module advertiser-android
2 |
3 | Android implementation for the Bluetooth Low Energy advertiser.
4 |
5 | # Package no.nordicsemi.kotlin.ble.advertiser.android
6 |
7 | This package contains a Factory method to create an Android implementation for the Bluetooth LE Advertiser.
--------------------------------------------------------------------------------
/core-android/Module.md:
--------------------------------------------------------------------------------
1 | # Module core-android
2 |
3 | Core types and interfaces for Bluetooth Low Energy clients and server implementations on Android.
4 |
5 | # Package no.nordicsemi.kotlin.ble.core.android
6 |
7 | Core types and interfaces for Bluetooth Low Energy clients and server implementations on Android.
--------------------------------------------------------------------------------
/docs/html/images/check.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/client-mock/Module.md:
--------------------------------------------------------------------------------
1 | # Module client-mock
2 |
3 | Common types and interfaces for mock Bluetooth Low Energy clients.
4 |
5 | This module is used by platform-specific mock implementations.
6 |
7 | # Package no.nordicsemi.kotlin.ble.client.mock
8 |
9 | Common types and interfaces for mock Bluetooth Low Energy clients.
--------------------------------------------------------------------------------
/docs/html/images/go-to-top-icon.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jul 03 17:34:01 CEST 2025
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
5 | networkTimeout=10000
6 | validateDistributionUrl=true
7 | zipStoreBase=GRADLE_USER_HOME
8 | zipStorePath=wrapper/dists
9 |
--------------------------------------------------------------------------------
/docs/html/images/checkbox-on.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/docs/html/images/burger.svg:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/docs/html/images/cross.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/advertiser-core-android/Module.md:
--------------------------------------------------------------------------------
1 | # Module advertiser-core-android
2 |
3 | Set of core classes providing the common functionality for Bluetooth Low Energy advertising on Android.
4 |
5 | # Package no.nordicsemi.kotlin.ble.advertiser.android
6 |
7 | This package contains the common Android implementation for the Bluetooth LE Advertiser functionality,
8 | used by the Android native and mock implementations.
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/advertiser-core/Module.md:
--------------------------------------------------------------------------------
1 | # Module advertiser-core
2 |
3 | Platform independent classes providing the core functionality for Bluetooth Low Energy advertising.
4 |
5 | # Package no.nordicsemi.kotlin.ble.advertiser
6 |
7 | This package contains the common interface for the Bluetooth LE Advertiser.
8 |
9 | # Package no.nordicsemi.kotlin.ble.advertiser.exception
10 |
11 | A package containing exceptions related to Bluetooth LE advertising operations.
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/core/Module.md:
--------------------------------------------------------------------------------
1 | # Module core
2 |
3 | Core types and interfaces for Bluetooth Low Energy clients and server implementations.
4 |
5 | # Package no.nordicsemi.kotlin.ble.core
6 |
7 | Core types and interfaces for Bluetooth Low Energy clients and server implementations.
8 |
9 | # Package no.nordicsemi.kotlin.ble.core.exception
10 |
11 | Generic Bluetooth Low Energy exceptions.
12 |
13 | # Package no.nordicsemi.kotlin.ble.core.util
14 |
15 | Utilities.
--------------------------------------------------------------------------------
/client-android/Module.md:
--------------------------------------------------------------------------------
1 | # Module client-android
2 |
3 | Android implementation for the Bluetooth Low Energy GATT client.
4 |
5 | This module provides the necessary classes and methods to interact with Bluetooth Low Energy (BLE)
6 | devices as a client on Android platforms, including scanning, connecting and exchanging data.
7 |
8 | # Package no.nordicsemi.kotlin.ble.client.android
9 |
10 | This package contains a Factory method to create an Android implementation for the Central Manager.
--------------------------------------------------------------------------------
/advertiser-android-mock/Module.md:
--------------------------------------------------------------------------------
1 | # Module advertiser-android-mock
2 |
3 | A mock implementation for the Bluetooth Low Energy advertiser on Android.
4 |
5 | This module provides a mock version of the Bluetooth LE advertiser, which can be used for testing
6 | purposes without requiring actual Bluetooth hardware.
7 |
8 | # Package no.nordicsemi.kotlin.ble.advertiser.android.mock
9 |
10 | This package contains a Factory method to create a mock Android implementation for the Bluetooth LE Advertiser.
--------------------------------------------------------------------------------
/docs/html/scripts/sourceset_dependencies.js:
--------------------------------------------------------------------------------
1 | sourceset_dependencies = '{":advertiser-android-mock/main":[],":client-core-android/main":[],":core-android/main":[],":client-mock/main":[],":core/main":[],":advertiser-android/debug":[],":advertiser-android/main":[],":advertiser-android/release":[],":core-android-mock/main":[],":advertiser-core-android/main":[],":client-core/main":[],":client-android/debug":[],":client-android/main":[],":client-android/release":[],":client-android-mock/main":[],":advertiser-core/main":[],":core-mock/main":[]}'
--------------------------------------------------------------------------------
/client-core/Module.md:
--------------------------------------------------------------------------------
1 | # Module client-core
2 |
3 | Common types and interfaces for Bluetooth Low Energy clients.
4 |
5 | This module is used by platform-specific implementations for native and mock environments.
6 |
7 | # Package no.nordicsemi.kotlin.ble.client
8 |
9 | Common types and interfaces for Bluetooth Low Energy clients.
10 |
11 | # Package no.nordicsemi.kotlin.ble.client.exception
12 |
13 | This package contains exceptions that can be thrown by the client when scanning or interacting with
14 | Bluetooth Low Energy devices.
--------------------------------------------------------------------------------
/docs/html/images/exception-class.svg:
--------------------------------------------------------------------------------
1 |
4 |
10 |
--------------------------------------------------------------------------------
/docs/html/images/enum.svg:
--------------------------------------------------------------------------------
1 |
4 |
10 |
--------------------------------------------------------------------------------
/docs/html/images/field-value.svg:
--------------------------------------------------------------------------------
1 |
4 |
5 |
11 |
--------------------------------------------------------------------------------
/docs/html/images/interface.svg:
--------------------------------------------------------------------------------
1 |
4 |
10 |
--------------------------------------------------------------------------------
/client-android-mock/Module.md:
--------------------------------------------------------------------------------
1 | # Module client-android-mock
2 |
3 | Android implementation for the Bluetooth Low Energy mock client.
4 |
5 | This module provides the necessary classes and methods to interact with mock Bluetooth Low Energy (BLE)
6 | devices as a client on Android platforms, including emulating scanning, connecting and exchanging data.
7 |
8 | Mock implementations are useful for testing purposes without requiring actual BLE hardware.
9 |
10 | # Package no.nordicsemi.kotlin.ble.client.android.mock
11 |
12 | This package contains a Factory method to create a mock Android implementation for the Central Manager.
--------------------------------------------------------------------------------
/docs/html/images/field-variable.svg:
--------------------------------------------------------------------------------
1 |
4 |
5 |
11 |
--------------------------------------------------------------------------------
/docs/html/images/filter.svg:
--------------------------------------------------------------------------------
1 |
9 |
--------------------------------------------------------------------------------
/gradle/nordic.versions.toml:
--------------------------------------------------------------------------------
1 | # Versions of Nordic libraries used in this project.
2 |
3 | # This is a subset of the Version Catalog available at https://github.com/NordicSemiconductor/Android-Version-Catalog
4 | # The version catalog can be updated independently of this project after the release of this library.
5 |
6 | [versions]
7 | nordic-log = "2.5.0"
8 | nordic-data = "0.5.0"
9 |
10 | [libraries]
11 | nordic-log = { group = "no.nordicsemi.android", name = "log", version.ref = "nordic-log" }
12 | nordic-log-timber = { group = "no.nordicsemi.android", name = "log-timber", version.ref = "nordic-log" }
13 | nordic-kotlin-data = { group = "no.nordicsemi.kotlin", name = "data", version.ref = "nordic-data" }
--------------------------------------------------------------------------------
/docs/html/images/success-icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/html/images/interface-kotlin.svg:
--------------------------------------------------------------------------------
1 |
4 |
5 |
14 |
--------------------------------------------------------------------------------
/test/src/test/java/no/nordicsemi/android/kotlin/ble/test/BlinkySpecifications.kt:
--------------------------------------------------------------------------------
1 | package no.nordicsemi.android.kotlin.ble.test
2 |
3 | import java.util.UUID
4 |
5 | object BlinkySpecifications {
6 | /** Nordic Blinky Service UUID. */
7 | val UUID_SERVICE_DEVICE: UUID = UUID.fromString("00001523-1212-efde-1523-785feabcd123")
8 |
9 | /** LED characteristic UUID. */
10 | val UUID_LED_CHAR: UUID = UUID.fromString("00001525-1212-efde-1523-785feabcd123")
11 |
12 | /** BUTTON characteristic UUID. */
13 | val UUID_BUTTON_CHAR: UUID = UUID.fromString("00001524-1212-efde-1523-785feabcd123")
14 |
15 | /** Notification descriptor UUID. */
16 | val NOTIFICATION_DESCRIPTOR = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb")
17 | }
18 |
--------------------------------------------------------------------------------
/client-core-android/Module.md:
--------------------------------------------------------------------------------
1 | # Module client-core-android
2 |
3 | Common Android types and interfaces for Bluetooth Low Energy clients.
4 |
5 | This module is used by by native and mock implementations on Android.
6 |
7 | # Package no.nordicsemi.kotlin.ble.client.android
8 |
9 | Common types and interfaces for Bluetooth Low Energy clients related to Android-specific API.
10 |
11 | # Package no.nordicsemi.kotlin.ble.client.android.exception
12 |
13 | This package contains exceptions that can be thrown by Android clients when scanning or interacting
14 | with Bluetooth Low Energy devices.
15 |
16 | # Package no.nordicsemi.kotlin.ble.client.android.preview
17 |
18 | Types that can be user for Previews in Android Jetpack Compose whenever a Peripheral instance is
19 | required.
--------------------------------------------------------------------------------
/docs/html/images/enum-kotlin.svg:
--------------------------------------------------------------------------------
1 |
4 |
5 |
14 |
--------------------------------------------------------------------------------
/test/src/androidTest/java/no/nordicsemi/android/kotlin/ble/test/utils/BlinkySpecifications.kt:
--------------------------------------------------------------------------------
1 | package no.nordicsemi.android.kotlin.ble.test.utils
2 |
3 | import java.util.UUID
4 |
5 | object BlinkySpecifications {
6 | /** Nordic Blinky Service UUID. */
7 | val UUID_SERVICE_DEVICE: UUID = UUID.fromString("00001523-1212-efde-1523-785feabcd123")
8 |
9 | /** LED characteristic UUID. */
10 | val UUID_LED_CHAR: UUID = UUID.fromString("00001525-1212-efde-1523-785feabcd123")
11 |
12 | /** BUTTON characteristic UUID. */
13 | val UUID_BUTTON_CHAR: UUID = UUID.fromString("00001524-1212-efde-1523-785feabcd123")
14 |
15 | /** Notification descriptor UUID. */
16 | val NOTIFICATION_DESCRIPTOR = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb")
17 | }
18 |
--------------------------------------------------------------------------------
/docs/html/images/typealias-kotlin.svg:
--------------------------------------------------------------------------------
1 |
4 |
5 |
14 |
--------------------------------------------------------------------------------
/docs/html/images/anchor-copy-icon.svg:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/test/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/fastlane/Fastfile:
--------------------------------------------------------------------------------
1 | # This file contains the fastlane.tools configuration
2 | # You can find the documentation at https://docs.fastlane.tools
3 | #
4 | # For a list of all available actions, check out
5 | #
6 | # https://docs.fastlane.tools/actions
7 | #
8 | # For a list of all available plugins, check out
9 | #
10 | # https://docs.fastlane.tools/plugins/available-plugins
11 | #
12 |
13 | # Uncomment the line if you want fastlane to automatically update itself
14 | # update_fastlane
15 |
16 | default_platform(:android)
17 |
18 | platform :android do
19 |
20 | desc "Deploy libraries to Nexus."
21 | lane :deployNexus do
22 | gradle(task: "publish")
23 | gradle(task: "releaseStagingRepositories")
24 | end
25 |
26 | desc "Generate docs."
27 | lane :generateDocs do
28 | gradle(task: "dokkaHtmlMultiModule")
29 | end
30 | end
31 |
--------------------------------------------------------------------------------
/docs/html/images/theme-toggle.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/docs/html/images/class.svg:
--------------------------------------------------------------------------------
1 |
4 |
10 |
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3 | "extends": [
4 | "config:recommended",
5 | "group:all",
6 | ":dependencyDashboard",
7 | "schedule:daily"
8 | ],
9 | "commitMessageExtra": "{{{currentValue}}} to {{#if isPinDigest}}{{{newDigestShort}}}{{else}}{{#if isMajor}}{{prettyNewMajor}}{{else}}{{#if isSingleVersion}}{{prettyNewVersion}}{{else}}{{#if newValue}}{{{newValue}}}{{else}}{{{newDigestShort}}}{{/if}}{{/if}}{{/if}}{{/if}}",
10 | "packageRules": [
11 | {
12 | "groupName": "kotlin",
13 | "matchPackageNames": [
14 | "/androidx.compose.compiler:compiler/",
15 | "/org.jetbrains.kotlin.*/",
16 | "/com.google.devtools.ksp/",
17 | "/androidx.compose.compiler/"
18 | ]
19 | },
20 | {
21 | "matchPackageNames": [
22 | "/androidx.hilt/"
23 | ],
24 | "enabled": false
25 | }
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/docs/html/images/object.svg:
--------------------------------------------------------------------------------
1 |
4 |
5 |
14 |
--------------------------------------------------------------------------------
/docs/html/images/class-kotlin.svg:
--------------------------------------------------------------------------------
1 |
4 |
5 |
14 |
--------------------------------------------------------------------------------
/docs/html/images/function.svg:
--------------------------------------------------------------------------------
1 |
4 |
10 |
--------------------------------------------------------------------------------
/docs/html/styles/logo-styles.css:
--------------------------------------------------------------------------------
1 | :root {
2 | /* Navigation bar */
3 | --dokka-logo-image-url: url(../images/logo-icon.svg);
4 | --dokka-logo-height: 120px;
5 | --dokka-logo-width: 120px;
6 |
7 | --color-background-nav: #00A9CE !important;
8 | --color-background-nav-dt: #333f48 !important;
9 |
10 | /* Selected menu */
11 | --color-key-blue: #00A9CE !important;
12 |
13 | /* Tabs */
14 | --active-section-color: #0077C8;
15 | --sidemenu-section-active-color: #0077C8;
16 | --active-tab-border-color: #0077C8;
17 | --hover-link-color: #0077C8;
18 |
19 | .toc--part[data-active]>.toc--row .toc--button:hover, .toc--part[data-active]>.toc--row .toc--link:hover {
20 | background-color: #2fb9df;
21 | }
22 | .sidebar {
23 | border-right: 1px solid rgba(39, 40, 44, .2);
24 | box-sizing: border-box;
25 | overflow: auto;
26 | width: var(--sidebar-width);
27 | background-color: #35414622;
28 | }
29 |
30 | }
31 |
32 | .theme-dark {
33 | --active-section-color: #00A9CE;
34 | --sidemenu-section-active-color: #00A9CE;
35 | --active-tab-border-color: #00A9CE;
36 | --hover-link-color: #00A9CE;
37 | }
38 |
--------------------------------------------------------------------------------
/docs/html/package-list:
--------------------------------------------------------------------------------
1 | $dokka.format:html-v1
2 | $dokka.linkExtension:html
3 |
4 | module:advertiser-android
5 | no.nordicsemi.kotlin.ble.advertiser.android
6 | module:advertiser-android-mock
7 | no.nordicsemi.kotlin.ble.advertiser.android.mock
8 | module:advertiser-core
9 | no.nordicsemi.kotlin.ble.advertiser
10 | no.nordicsemi.kotlin.ble.advertiser.exception
11 | module:advertiser-core-android
12 | no.nordicsemi.kotlin.ble.advertiser.android
13 | module:client-android
14 | no.nordicsemi.kotlin.ble.client.android
15 | module:client-android-mock
16 | no.nordicsemi.kotlin.ble.client.android.mock
17 | module:client-core
18 | no.nordicsemi.kotlin.ble.client
19 | no.nordicsemi.kotlin.ble.client.exception
20 | module:client-core-android
21 | no.nordicsemi.kotlin.ble.client.android
22 | no.nordicsemi.kotlin.ble.client.android.exception
23 | no.nordicsemi.kotlin.ble.client.android.preview
24 | module:client-mock
25 | no.nordicsemi.kotlin.ble.client.mock
26 | module:core
27 | no.nordicsemi.kotlin.ble.core
28 | no.nordicsemi.kotlin.ble.core.exception
29 | no.nordicsemi.kotlin.ble.core.util
30 | module:core-android
31 | no.nordicsemi.kotlin.ble.core.android
32 | module:core-android-mock
33 | no.nordicsemi.kotlin.ble.android.mock
34 | module:core-mock
35 | no.nordicsemi.kotlin.ble.core.mock
36 |
--------------------------------------------------------------------------------
/.github/workflows/deploy-to-nexus.yml:
--------------------------------------------------------------------------------
1 | name: Deploy to Nexus
2 | on:
3 | push:
4 | tags:
5 | - '*'
6 | workflow_dispatch:
7 | jobs:
8 | deployToNexus:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v6
12 | with:
13 | fetch-depth: 0
14 | - uses: actions/setup-java@v5
15 | with:
16 | distribution: 'jetbrains'
17 | java-version: '21'
18 | - shell: bash
19 | env:
20 | # The following env variables are used by gradle/publish-module.gradle
21 | GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
22 | GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
23 | # The following env variables are used by gradle/publish-root.gradle.kts
24 | OSSR_USERNAME: ${{ secrets.OSSR_USERNAME }}
25 | OSSR_PASSWORD: ${{ secrets.OSSR_PASSWORD }}
26 | SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
27 | # The script generates sec.gpg file that is required by gradle/publish-module.gradle
28 | # and starts :deployNexus lane using fastlane.
29 | run: |
30 | java --version
31 | echo "${{ secrets.GPG_FILE }}" > sec.gpg.asc
32 | gpg -d --passphrase "${{ secrets.GPG_FILE_PSWD }}" --batch sec.gpg.asc > sec.gpg
33 | fastlane deployNexus
34 |
--------------------------------------------------------------------------------
/sample/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.nordic.application.compose)
3 | alias(libs.plugins.nordic.hilt)
4 | }
5 |
6 | android {
7 | namespace = "no.nordicsemi.kotlin.ble.android.sample"
8 | defaultConfig {
9 | applicationId = "no.nordicsemi.kotlin.ble.android.sample"
10 | }
11 | androidResources {
12 | localeFilters += listOf("en")
13 | }
14 | flavorDimensions += listOf("mode")
15 | productFlavors {
16 | create("native") {
17 | isDefault = true
18 | dimension = "mode"
19 | }
20 | create("mock") {
21 | dimension = "mode"
22 | }
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation(project(":advertiser-android"))
28 | implementation(project(":advertiser-android-mock"))
29 | implementation(project(":client-android"))
30 | implementation(project(":client-android-mock"))
31 |
32 | implementation(libs.androidx.activity.compose)
33 | implementation(libs.androidx.navigation.compose)
34 | implementation(libs.androidx.hilt.navigation.compose)
35 | implementation(libs.androidx.lifecycle.runtime.compose)
36 | implementation(libs.androidx.compose.material.icons.core)
37 |
38 | // Binder SLF4J -> Timber
39 | implementation(libs.slf4j.timber)
40 | debugImplementation(libs.leakcanary)
41 | }
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
12 |
15 |
16 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/docs/html/images/abstract-class.svg:
--------------------------------------------------------------------------------
1 |
4 |
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2024, Nordic Semiconductor
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | 2. Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | 3. Neither the name of the copyright holder nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/test/src/androidTest/java/no/nordicsemi/android/kotlin/ble/test/BluetoothGattServiceFactoryTest.kt:
--------------------------------------------------------------------------------
1 | package no.nordicsemi.android.kotlin.ble.test
2 |
3 | import android.bluetooth.BluetoothGattCharacteristic
4 | import android.bluetooth.BluetoothGattDescriptor
5 | import androidx.test.ext.junit.runners.AndroidJUnit4
6 | import no.nordicsemi.android.kotlin.ble.core.data.BleGattPermission
7 | import no.nordicsemi.android.kotlin.ble.core.data.BleGattProperty
8 | import no.nordicsemi.android.kotlin.ble.server.main.service.BluetoothGattServiceFactory
9 | import no.nordicsemi.android.kotlin.ble.test.utils.BlinkySpecifications
10 | import org.junit.Test
11 | import org.junit.runner.RunWith
12 | import kotlin.test.assertEquals
13 |
14 | @RunWith(AndroidJUnit4::class)
15 | class BluetoothGattServiceFactoryTest {
16 |
17 | @Test
18 | fun whenCloneCharacteristicShouldAlsoCloneDescriptors() {
19 | val characteristic = BluetoothGattCharacteristic(
20 | BlinkySpecifications.UUID_BUTTON_CHAR,
21 | BleGattPermission.toInt(listOf(BleGattPermission.PERMISSION_READ)),
22 | BleGattProperty.toInt(listOf(BleGattProperty.PROPERTY_NOTIFY)),
23 | )
24 |
25 | val descriptor = BluetoothGattDescriptor(
26 | BlinkySpecifications.UUID_LED_CHAR,
27 | BleGattPermission.toInt(listOf(BleGattPermission.PERMISSION_READ)),
28 | )
29 |
30 | characteristic.addDescriptor(descriptor)
31 |
32 | val clone = BluetoothGattServiceFactory.cloneCharacteristic(characteristic)
33 |
34 | assertEquals(1, clone.descriptors.size)
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/client-core/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/profile/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/server-core/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/core-android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/server-android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/client-android-mock/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/client-core-android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/core-android-mock/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/server-android-mock/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/server-core-android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/docs/html/images/annotation.svg:
--------------------------------------------------------------------------------
1 |
4 |
10 |
--------------------------------------------------------------------------------
/test/src/androidTest/java/no/nordicsemi/android/kotlin/ble/test/ReadFromDisconnectedDeviceTest.kt:
--------------------------------------------------------------------------------
1 | package no.nordicsemi.android.kotlin.ble.test
2 |
3 | import androidx.test.ext.junit.runners.AndroidJUnit4
4 | import androidx.test.platform.app.InstrumentationRegistry
5 | import kotlinx.coroutines.CoroutineScope
6 | import kotlinx.coroutines.runBlocking
7 | import kotlinx.coroutines.test.UnconfinedTestDispatcher
8 | import kotlinx.coroutines.test.runTest
9 | import no.nordicsemi.android.kotlin.ble.client.main.callback.ClientBleGatt
10 | import no.nordicsemi.android.kotlin.ble.core.errors.DeviceDisconnectedException
11 | import no.nordicsemi.android.kotlin.ble.test.utils.BlinkySpecifications
12 | import no.nordicsemi.android.kotlin.ble.test.utils.TestAddressProvider
13 | import org.junit.Assert
14 | import org.junit.Test
15 | import org.junit.runner.RunWith
16 |
17 | @RunWith(AndroidJUnit4::class)
18 | class ReadFromDisconnectedDeviceTest {
19 |
20 | private val service = BlinkySpecifications.UUID_SERVICE_DEVICE
21 | private val char = BlinkySpecifications.UUID_LED_CHAR
22 |
23 | private val address = TestAddressProvider.address
24 |
25 | private val scope = CoroutineScope(UnconfinedTestDispatcher())
26 |
27 | @Test
28 | fun whenReadAfterDisconnectShouldThrow() = runTest {
29 | val context = InstrumentationRegistry.getInstrumentation().targetContext
30 | val gatt = ClientBleGatt.connect(context, address, scope)
31 | val services = gatt.discoverServices()
32 | val char = services.findService(service)?.findCharacteristic(char)
33 | gatt.disconnect() // Simulate a device disconnection
34 | Assert.assertThrows(DeviceDisconnectedException::class.java) {
35 | runBlocking {
36 | char?.read()!! //Issue: stuck here forever
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/test/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/docs/html/images/abstract-class-kotlin.svg:
--------------------------------------------------------------------------------
1 |
4 |
5 |
27 |
--------------------------------------------------------------------------------
/docs/html/images/annotation-kotlin.svg:
--------------------------------------------------------------------------------
1 |
4 |
5 |
14 |
--------------------------------------------------------------------------------
/core/src/main/java/no/nordicsemi/kotlin/ble/core/GattConstants.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.core
33 |
34 | /** The default ATT MTU size. */
35 | const val ATT_MTU_DEFAULT = 23
36 | /** The maximum ATT MTU size. */
37 | const val ATT_MTU_MAX = 517
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/gls/data/GlucoseMeasurementUnit.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.gls.data
33 |
34 | enum class GlucoseMeasurementUnit {
35 | UNIT_mol_L,
36 | UNIT_kg_L
37 | }
38 |
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/gls/data/RequestStatus.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.gls.data
33 |
34 | enum class RequestStatus {
35 | IDLE, PENDING, SUCCESS, ABORTED, FAILED, NOT_SUPPORTED
36 | }
37 |
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/bps/data/BloodPressureType.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.bps.data
33 |
34 | enum class BloodPressureType(internal val value: Int) {
35 | UNIT_MMHG(0),
36 | UNIT_KPA(1)
37 | }
38 |
--------------------------------------------------------------------------------
/core/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/test/src/androidTest/java/no/nordicsemi/android/kotlin/ble/test/GetNotificationsStuckTest.kt:
--------------------------------------------------------------------------------
1 | package no.nordicsemi.android.kotlin.ble.test
2 |
3 | import androidx.test.ext.junit.runners.AndroidJUnit4
4 | import androidx.test.platform.app.InstrumentationRegistry
5 | import kotlinx.coroutines.CoroutineScope
6 | import kotlinx.coroutines.flow.catch
7 | import kotlinx.coroutines.flow.first
8 | import kotlinx.coroutines.runBlocking
9 | import kotlinx.coroutines.test.UnconfinedTestDispatcher
10 | import kotlinx.coroutines.test.runTest
11 | import no.nordicsemi.android.kotlin.ble.client.main.callback.ClientBleGatt
12 | import no.nordicsemi.android.kotlin.ble.core.errors.DeviceDisconnectedException
13 | import no.nordicsemi.android.kotlin.ble.test.utils.BlinkySpecifications
14 | import no.nordicsemi.android.kotlin.ble.test.utils.TestAddressProvider
15 | import org.junit.Test
16 | import org.junit.Assert
17 | import org.junit.runner.RunWith
18 |
19 | @RunWith(AndroidJUnit4::class)
20 | class GetNotificationsStuckTest {
21 |
22 | private val service = BlinkySpecifications.UUID_SERVICE_DEVICE
23 | private val char = BlinkySpecifications.UUID_BUTTON_CHAR
24 |
25 | private val address = TestAddressProvider.address
26 |
27 | private val scope = CoroutineScope(UnconfinedTestDispatcher())
28 |
29 | @Test
30 | fun whenGetNotificationsAfterDisconnectShouldThrow() = runTest {
31 | val context = InstrumentationRegistry.getInstrumentation().targetContext
32 | val gatt = ClientBleGatt.connect(context, address, scope)
33 | val services = gatt.discoverServices()
34 | val not = services.findService(service)?.findCharacteristic(char)!!
35 | gatt.disconnect() // Simulate a device disconnection
36 | Assert.assertThrows(DeviceDisconnectedException::class.java) {
37 | runBlocking {
38 | not.getNotifications().first() //Issue: stuck here forever
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/client-core-android/src/main/java/no/nordicsemi/kotlin/ble/client/android/exception/BondingFailedException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.client.android.exception
33 |
34 | import no.nordicsemi.kotlin.ble.core.exception.BluetoothException
35 |
36 | class BondingFailedException: BluetoothException()
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/hrs/data/HRSData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.hrs.data
33 |
34 | data class HRSData(
35 | val heartRate: Int,
36 | val sensorContact: Boolean,
37 | val energyExpanded: Int?,
38 | val rrIntervals: List
39 | )
40 |
--------------------------------------------------------------------------------
/core/src/main/java/no/nordicsemi/kotlin/ble/core/exception/GattException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.core.exception
33 |
34 | /**
35 | * Base class for all GATT exceptions.
36 | */
37 | open class GattException: Exception {
38 | constructor(): super("GATT error")
39 | constructor(message: String): super(message)
40 | }
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/prx/PRXData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.prx
33 |
34 | data class PRXData(
35 | val localAlarmLevel: AlarmLevel = AlarmLevel.NONE,
36 | val isRemoteAlarm: Boolean = false,
37 | val linkLossAlarmLevel: AlarmLevel = AlarmLevel.HIGH
38 | )
39 |
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/gls/data/GLSData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.gls.data
33 |
34 | internal data class GLSData(
35 | val records: List = emptyList(),
36 | val batteryLevel: Int? = null,
37 | val requestStatus: RequestStatus = RequestStatus.IDLE
38 | )
39 |
--------------------------------------------------------------------------------
/core/src/main/java/no/nordicsemi/kotlin/ble/core/Peer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | @file:Suppress("unused")
33 |
34 | package no.nordicsemi.kotlin.ble.core
35 |
36 | /**
37 | * Class representing a Bluetooth LE peer device or a mock.
38 | *
39 | * @property identifier A platform-specific unique device identifier.
40 | */
41 | interface Peer {
42 | val identifier: ID
43 | }
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/csc/data/CSCDataSnapshot.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.csc.data
33 |
34 | internal data class CSCDataSnapshot(
35 | var wheelRevolutions: Long = -1,
36 | var wheelEventTime: Int = -1,
37 | var crankRevolutions: Long = -1,
38 | var crankEventTime: Int = -1
39 | )
40 |
--------------------------------------------------------------------------------
/test/src/androidTest/java/no/nordicsemi/android/kotlin/ble/test/SimultaneousRssiStuckTest.kt:
--------------------------------------------------------------------------------
1 | package no.nordicsemi.android.kotlin.ble.test
2 |
3 | import androidx.test.ext.junit.runners.AndroidJUnit4
4 | import androidx.test.platform.app.InstrumentationRegistry
5 | import kotlinx.coroutines.CoroutineScope
6 | import kotlinx.coroutines.launch
7 | import kotlinx.coroutines.sync.Mutex
8 | import kotlinx.coroutines.sync.withLock
9 | import kotlinx.coroutines.test.UnconfinedTestDispatcher
10 | import kotlinx.coroutines.test.runTest
11 | import no.nordicsemi.android.kotlin.ble.client.main.callback.ClientBleGatt
12 | import no.nordicsemi.android.kotlin.ble.test.utils.TestAddressProvider
13 | import org.junit.Test
14 | import org.junit.runner.RunWith
15 |
16 | @RunWith(AndroidJUnit4::class)
17 | class SimultaneousRssiStuckTest {
18 |
19 | private val address = TestAddressProvider.address
20 | private val address2 = TestAddressProvider.auxiliaryAddress
21 |
22 | private val scope = CoroutineScope(UnconfinedTestDispatcher())
23 |
24 | private val repeat = 5
25 |
26 | @Test
27 | fun whenReadRssiWithoutMutexShouldWork() = runTest {
28 | val context = InstrumentationRegistry.getInstrumentation().targetContext
29 | val gatt = ClientBleGatt.connect(context, address, scope)
30 | val gatt2 = ClientBleGatt.connect(context, address2, scope)
31 | val mutex = Mutex()
32 |
33 | // This one passes when using a mutex
34 | repeat(repeat) {
35 | val jobs = listOf(
36 | launch { mutex.withLock { gatt.readRssi() } },
37 | launch { mutex.withLock { gatt2.readRssi() } }
38 | )
39 | jobs.forEach { it.join() }
40 | }
41 |
42 | //Issue: This one gets stuck when no mutex is used
43 | repeat(repeat) {
44 | val jobs = listOf(
45 | launch { gatt.readRssi() },
46 | launch { gatt2.readRssi() }
47 | )
48 | jobs.forEach { it.join() }
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/hts/data/HTSData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.hts.data
33 |
34 | import java.util.Calendar
35 |
36 | data class HTSData(
37 | val temperature: Float = 0f,
38 | val unit: TemperatureUnit = TemperatureUnit.CELSIUS,
39 | val timestamp: Calendar? = null,
40 | val type: Int? = null
41 | )
42 |
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/prx/AlertLevelInputParser.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.prx
33 |
34 | import no.nordicsemi.android.common.core.DataByteArray
35 |
36 | object AlertLevelInputParser {
37 |
38 | fun parse(alarmLevel: AlarmLevel): DataByteArray {
39 | return DataByteArray.from(alarmLevel.value)
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/rscs/data/RSCSData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.rscs.data
33 |
34 | data class RSCSData(
35 | val running: Boolean = false,
36 | val instantaneousSpeed: Float = 1.0f,
37 | val instantaneousCadence: Int = 0,
38 | val strideLength: Int? = null,
39 | val totalDistance: Long? = null
40 | )
41 |
--------------------------------------------------------------------------------
/core/src/main/java/no/nordicsemi/kotlin/ble/core/exception/ManagerClosedException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | @file:Suppress("unused")
33 |
34 | package no.nordicsemi.kotlin.ble.core.exception
35 |
36 | import no.nordicsemi.kotlin.ble.core.Manager
37 |
38 | /**
39 | * Thrown when an operation is requested on a [Manager] that has been closed.
40 | */
41 | class ManagerClosedException: IllegalStateException("Manager is closed")
--------------------------------------------------------------------------------
/client-core/src/main/java/no/nordicsemi/kotlin/ble/client/exception/BluetoothUnavailableException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.client.exception
33 |
34 | import no.nordicsemi.kotlin.ble.core.exception.BluetoothException
35 |
36 | /**
37 | * Thrown when Bluetooth is disabled or unavailable on the device.
38 | */
39 | class BluetoothUnavailableException: BluetoothException("Bluetooth is disabled or unavailable")
--------------------------------------------------------------------------------
/client-core/src/main/java/no/nordicsemi/kotlin/ble/client/exception/ScanningException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.client.exception
33 |
34 | import no.nordicsemi.kotlin.ble.core.exception.BluetoothException
35 |
36 | /**
37 | * Base class for scanning exceptions.
38 | */
39 | open class ScanningException: BluetoothException {
40 | constructor(): super("Scanning failed")
41 | constructor(message: String): super(message)
42 | }
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/hts/data/TemperatureUnit.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.hts.data
33 |
34 | enum class TemperatureUnit(private val value: Int) {
35 | CELSIUS(0),
36 | FAHRENHEIT(1);
37 |
38 | companion object {
39 | fun create(value: Int): TemperatureUnit? {
40 | return values().firstOrNull { it.value == value }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/csc/data/CSCData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.csc.data
33 |
34 | data class CSCData(
35 | val scanDevices: Boolean = false,
36 | val speed: Float = 0f,
37 | val cadence: Float = 0f,
38 | val distance: Float = 0f,
39 | val totalDistance: Float = 0f,
40 | val gearRatio: Float = 0f,
41 | val wheelSize: WheelSize = WheelSizes.default
42 | )
43 |
--------------------------------------------------------------------------------
/sample/src/main/java/no/nordicsemi/kotlin/ble/android/sample/TestApplication.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.android.sample
33 |
34 | import android.app.Application
35 | import dagger.hilt.android.HiltAndroidApp
36 | import timber.log.Timber
37 |
38 | @HiltAndroidApp
39 | class TestApplication : Application() {
40 |
41 | override fun onCreate() {
42 | super.onCreate()
43 |
44 | Timber.plant(Timber.DebugTree())
45 | }
46 | }
--------------------------------------------------------------------------------
/client-core/src/main/java/no/nordicsemi/kotlin/ble/client/exception/PeripheralNotConnectedException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | @file:Suppress("unused")
33 |
34 | package no.nordicsemi.kotlin.ble.client.exception
35 |
36 | import no.nordicsemi.kotlin.ble.core.exception.GattException
37 |
38 | /**
39 | * Thrown when the peripheral is not connected, or has disconnected during the operation.
40 | */
41 | class PeripheralNotConnectedException: GattException("Peripheral is not connected")
--------------------------------------------------------------------------------
/core/src/main/java/no/nordicsemi/kotlin/ble/core/BondState.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | @file:Suppress("unused")
33 |
34 | package no.nordicsemi.kotlin.ble.core
35 |
36 | /**
37 | * Defines available bonding states.
38 | */
39 | enum class BondState {
40 | /** Device is not bonded and bonding process has not been initiated. */
41 | NONE,
42 | /** Device is not bonded, but bonding process has been initiated. */
43 | BONDING,
44 | /** Device is bonded. */
45 | BONDED
46 | }
47 |
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/battery/BatteryLevelParser.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.battery
33 |
34 | import no.nordicsemi.kotlin.data.IntFormat
35 | import no.nordicsemi.kotlin.data.getInt
36 |
37 | object BatteryLevelParser {
38 |
39 | fun parse(bytes: ByteArray): Int? {
40 | if (bytes.size == 1) {
41 | return bytes.getInt(0, IntFormat.UINT8)
42 | }
43 | return null
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/cgm/data/CGMRecord.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.cgm.data
33 |
34 | import android.os.Parcelable
35 | import kotlinx.parcelize.Parcelize
36 |
37 | @Parcelize
38 | data class CGMRecord(
39 | val glucoseConcentration: Float,
40 | val trend: Float?,
41 | val quality: Float?,
42 | val status: CGMStatus?,
43 | val timeOffset: Int,
44 | val crcPresent: Boolean
45 | ) : Parcelable
46 |
--------------------------------------------------------------------------------
/advertiser-android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/cgm/data/CGMCalibrationStatus.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.cgm.data
33 |
34 | class CGMCalibrationStatus(val value: Int) {
35 | val rejected: Boolean
36 | val dataOutOfRange: Boolean
37 | val processPending: Boolean
38 |
39 | init {
40 | rejected = value and 0x01 != 0
41 | dataOutOfRange = value and 0x02 != 0
42 | processPending = value and 0x04 != 0
43 | }
44 | }
--------------------------------------------------------------------------------
/client-core/src/main/java/no/nordicsemi/kotlin/ble/client/exception/ValueDoesNotMatchException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.client.exception
33 |
34 | import no.nordicsemi.kotlin.ble.core.exception.GattException
35 |
36 | /**
37 | * Thrown when the value reported by the remote device does not match the value sent
38 | * using *Reliable Write* or *Long Write* operation.
39 | */
40 | class ValueDoesNotMatchException:
41 | GattException("The received value does not match the value sent")
--------------------------------------------------------------------------------
/core/src/main/java/no/nordicsemi/kotlin/ble/core/exception/BluetoothException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.core.exception
33 |
34 | /**
35 | * Base class for all Bluetooth exceptions.
36 | */
37 | open class BluetoothException: IllegalStateException {
38 | constructor(): super()
39 | constructor(message: String): super(message)
40 | constructor(throwable: Throwable): super(throwable)
41 | constructor(message: String, throwable: Throwable): super(message, throwable)
42 | }
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/bps/data/BloodPressureMeasurementData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.bps.data
33 |
34 | import java.util.Calendar
35 |
36 | data class BloodPressureMeasurementData(
37 | val systolic: Float,
38 | val diastolic: Float,
39 | val meanArterialPressure: Float,
40 | val unit: BloodPressureType,
41 | val pulseRate: Float?,
42 | val userID: Int?,
43 | val status: BPMStatus?,
44 | val calendar: Calendar?
45 | )
46 |
--------------------------------------------------------------------------------
/client-core/src/main/java/no/nordicsemi/kotlin/ble/client/exception/OperationFailedException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.client.exception
33 |
34 | import no.nordicsemi.kotlin.ble.core.OperationStatus
35 | import no.nordicsemi.kotlin.ble.core.exception.GattException
36 |
37 | /**
38 | * Thrown when the GATT operation failed.
39 | *
40 | * @property reason The reason of the failure.
41 | */
42 | data class OperationFailedException(
43 | val reason: OperationStatus
44 | ): GattException("Operation failed: $reason")
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/hrs/BodySensorLocationParser.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.hrs
33 |
34 | import no.nordicsemi.android.common.core.DataByteArray
35 | import no.nordicsemi.android.common.core.IntFormat
36 |
37 | object BodySensorLocationParser {
38 |
39 | fun parse(data: DataByteArray): Int? {
40 |
41 | if (data.size < 1) {
42 | return null
43 | }
44 |
45 | return data.getIntValue(IntFormat.FORMAT_UINT8, 0)
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/sample/src/native/java/no/nordicsemi/kotlin/ble/android/sample/di/SdkModule.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.android.sample.di
33 |
34 | import android.os.Build
35 | import dagger.Module
36 | import dagger.Provides
37 | import dagger.hilt.InstallIn
38 | import dagger.hilt.components.SingletonComponent
39 | import javax.inject.Named
40 |
41 | @Module
42 | @InstallIn(SingletonComponent::class)
43 | class SdkModule {
44 |
45 | @Provides
46 | @Named("sdkVersion")
47 | fun provideSdkVersion() = Build.VERSION.SDK_INT
48 |
49 | }
--------------------------------------------------------------------------------
/client-android-mock/src/main/java/no/nordicsemi/kotlin/ble/client/android/mock/MockCentralManager.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.client.android.mock
33 |
34 | import no.nordicsemi.kotlin.ble.client.android.CentralManager
35 | import no.nordicsemi.kotlin.ble.client.mock.SimulationProvider
36 |
37 | /**
38 | * A mock central manager implementation for Android that can mock a real Central Manager.
39 | *
40 | * Use [simulatePeripherals] to set up mock peripherals.
41 | */
42 | interface MockCentralManager: CentralManager, SimulationProvider
--------------------------------------------------------------------------------
/client-android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/client-core/src/main/java/no/nordicsemi/kotlin/ble/client/exception/InvalidAttributeException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.client.exception
33 |
34 | import no.nordicsemi.kotlin.ble.core.exception.BluetoothException
35 |
36 | /**
37 | * Thrown when the attribute has been invalidated and cannot be used anymore.
38 | *
39 | * An attribute may be invalidated when the device has disconnected, the services
40 | * of the device have changed.
41 | */
42 | class InvalidAttributeException: BluetoothException("The attribute has been invalidated and cannot be used anymore")
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/prx/AlarmLevel.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.prx
33 |
34 | enum class AlarmLevel(internal val value: Byte) {
35 | NONE(0x00),
36 | MEDIUM(0x01),
37 | HIGH(0x02);
38 |
39 | companion object {
40 | internal fun create(value: Int): AlarmLevel {
41 | return AlarmLevel.values().firstOrNull { it.value.toInt() == value }
42 | ?: throw IllegalArgumentException("Cannot find AlarmLevel for provided value: $value")
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/client-core-android/src/main/java/no/nordicsemi/kotlin/ble/client/android/exception/PeripheralClosedException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.client.android.exception
33 |
34 | import no.nordicsemi.kotlin.ble.core.exception.BluetoothException
35 | import no.nordicsemi.kotlin.ble.client.android.Peripheral
36 |
37 | /**
38 | * Thrown when the peripheral wasn't connected or has been closed.
39 | *
40 | * This exception is thrown from [Peripheral.refreshCache] when the underlying GATT
41 | * object is null.
42 | */
43 | class PeripheralClosedException: BluetoothException()
--------------------------------------------------------------------------------
/core/src/main/java/no/nordicsemi/kotlin/ble/core/util/Distinct.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | @file:Suppress("unused")
33 |
34 | package no.nordicsemi.kotlin.ble.core.util
35 |
36 | import kotlinx.coroutines.flow.Flow
37 | import kotlinx.coroutines.flow.flow
38 | import no.nordicsemi.kotlin.ble.core.Peer
39 |
40 | /**
41 | * Returns a flow that emits only distinct peers.
42 | */
43 | fun > Flow.distinct(): Flow = flow {
44 | val set = mutableSetOf()
45 | collect { value ->
46 | if (set.add(value.identifier)) {
47 | emit(value)
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/gls/data/Tester.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.gls.data
33 |
34 | enum class Tester(internal val value: Int) {
35 | RESERVED(0),
36 | SELF(1),
37 | HEALTH_CARE_PROFESSIONAL(2),
38 | LAB_TEST(3),
39 | NOT_AVAILABLE(15);
40 |
41 | companion object {
42 | fun create(value: Int): Tester {
43 | return values().firstOrNull { it.value == value }
44 | ?: throw IllegalArgumentException("Cannot create Tester for value $value")
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/gls/data/Meal.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.gls.data
33 |
34 | enum class Meal(internal val value: Int) {
35 | RESERVED(0),
36 | PREPRANDIAL(1),
37 | POSTPRANDIAL(2),
38 | FASTING(3),
39 | CASUAL(4),
40 | BEDTIME(5);
41 |
42 | companion object {
43 | fun create(value: Int): Meal {
44 | return values().firstOrNull { it.value == value }
45 | ?: throw IllegalArgumentException("Cannot create Meal for value $value")
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/prx/AlarmLevelParser.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.prx
33 |
34 | import no.nordicsemi.android.common.core.DataByteArray
35 | import no.nordicsemi.android.common.core.IntFormat
36 |
37 | object AlarmLevelParser {
38 |
39 | fun parse(bytes: DataByteArray): AlarmLevel? {
40 | if (bytes.size == 1) {
41 | val level: Int = bytes.getIntValue(IntFormat.FORMAT_UINT8, 0) ?: return null
42 | return AlarmLevel.create(level)
43 | }
44 | return null
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/sample/src/main/java/no/nordicsemi/kotlin/ble/android/sample/util/CloseableCoroutineScope.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.android.sample.util
33 |
34 | import dagger.hilt.android.lifecycle.RetainedLifecycle
35 | import kotlinx.coroutines.CoroutineScope
36 | import kotlinx.coroutines.cancel
37 | import kotlin.coroutines.CoroutineContext
38 |
39 | class CloseableCoroutineScope(context: CoroutineContext) : CoroutineScope, RetainedLifecycle.OnClearedListener {
40 | override val coroutineContext: CoroutineContext = context
41 |
42 | override fun onCleared() {
43 | coroutineContext.cancel()
44 | }
45 | }
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/bps/data/IntermediateCuffPressureData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.bps.data
33 |
34 | import androidx.annotation.FloatRange
35 | import androidx.annotation.IntRange
36 | import java.util.Calendar
37 |
38 | data class IntermediateCuffPressureData(
39 | @FloatRange(from = 0.0) val cuffPressure: Float,
40 | val unit: BloodPressureType,
41 | @FloatRange(from = 0.0) val pulseRate: Float? = null,
42 | @IntRange(from = 0, to = 255) val userID: Int? = null,
43 | val status: BPMStatus? = null,
44 | val calendar: Calendar? = null
45 | )
--------------------------------------------------------------------------------
/test/src/androidTest/java/no/nordicsemi/android/kotlin/ble/test/DeadlockTwoDevices.kt:
--------------------------------------------------------------------------------
1 | package no.nordicsemi.android.kotlin.ble.test
2 |
3 | import androidx.test.ext.junit.runners.AndroidJUnit4
4 | import androidx.test.platform.app.InstrumentationRegistry
5 | import kotlinx.coroutines.CoroutineScope
6 | import kotlinx.coroutines.launch
7 | import kotlinx.coroutines.runBlocking
8 | import kotlinx.coroutines.test.UnconfinedTestDispatcher
9 | import no.nordicsemi.android.kotlin.ble.client.main.callback.ClientBleGatt
10 | import no.nordicsemi.android.kotlin.ble.core.data.BleGattConnectOptions
11 | import no.nordicsemi.android.kotlin.ble.core.data.BleGattConnectionPriority
12 | import no.nordicsemi.android.kotlin.ble.test.utils.BlinkySpecifications
13 | import no.nordicsemi.android.kotlin.ble.test.utils.TestAddressProvider
14 | import org.junit.Test
15 | import org.junit.runner.RunWith
16 |
17 | @RunWith(AndroidJUnit4::class)
18 | class DeadlockTwoDevices {
19 |
20 | private val address = TestAddressProvider.address
21 | private val address2 = TestAddressProvider.auxiliaryAddress
22 |
23 | private val scope = CoroutineScope(UnconfinedTestDispatcher())
24 |
25 | private val testCount = 10
26 |
27 | @Test
28 | fun deadLockTwoDevices() = runBlocking {
29 | val j1 = scope.launch {
30 | repeat(testCount) {
31 | val c1 = ClientBleGatt.connect(InstrumentationRegistry.getInstrumentation().targetContext, address, scope)
32 | if (!c1.isConnected) {
33 | return@launch
34 | }
35 | // c1.requestMtu(23)
36 | c1.requestConnectionPriority(BleGattConnectionPriority.LOW_POWER)
37 | c1.disconnect()
38 | }
39 | }
40 |
41 | val j2 = scope.launch {
42 | repeat(testCount) {
43 | val c2 = ClientBleGatt.connect(InstrumentationRegistry.getInstrumentation().targetContext, address2, scope)
44 | if (!c2.isConnected) {
45 | return@launch
46 | }
47 | // c2.requestMtu(23)
48 | c2.requestConnectionPriority(BleGattConnectionPriority.LOW_POWER)
49 | c2.disconnect()
50 | }
51 | }
52 |
53 | j1.join()
54 | j2.join()
55 | }
56 | }
--------------------------------------------------------------------------------
/core/src/main/java/no/nordicsemi/kotlin/ble/core/AdvertisingDataDefinition.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | @file:Suppress("unused")
33 |
34 | package no.nordicsemi.kotlin.ble.core
35 |
36 | import kotlin.uuid.ExperimentalUuidApi
37 | import kotlin.uuid.Uuid
38 |
39 | /**
40 | * Advertising data packet container for Bluetooth LE advertising.
41 | *
42 | * This represents the data to be advertised in the Advertising Data as well as the Scan Response
43 | * data.
44 | *
45 | * @param serviceUuids A list of service UUID to advertise.
46 | */
47 | @OptIn(ExperimentalUuidApi::class)
48 | open class AdvertisingDataDefinition(
49 | val serviceUuids: List? = null,
50 | )
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/gls/data/Carbohydrate.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.gls.data
33 |
34 | enum class Carbohydrate(internal val value: Int) {
35 | RESERVED(0),
36 | BREAKFAST(1),
37 | LUNCH(2),
38 | DINNER(3),
39 | SNACK(4),
40 | DRINK(5),
41 | SUPPER(6),
42 | BRUNCH(7);
43 |
44 | companion object {
45 | fun create(value: Int): Carbohydrate {
46 | return values().firstOrNull { it.value == value }
47 | ?: throw IllegalArgumentException("Cannot create Carbohydrate for value $value")
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/client-core/src/main/java/no/nordicsemi/kotlin/ble/client/exception/ConnectionFailedException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | @file:Suppress("unused", "MemberVisibilityCanBePrivate")
33 |
34 | package no.nordicsemi.kotlin.ble.client.exception
35 |
36 | import no.nordicsemi.kotlin.ble.core.ConnectionState
37 | import no.nordicsemi.kotlin.ble.core.exception.GattException
38 |
39 | /**
40 | * Thrown when the connection to the peripheral has failed.
41 | *
42 | * @property reason The reason why the connection attempt failed.
43 | */
44 | class ConnectionFailedException(
45 | val reason: ConnectionState.Disconnected.Reason
46 | ): GattException("Connection failed, reason: $reason")
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/cgm/data/CGMErrorCode.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.cgm.data
33 |
34 | enum class CGMErrorCode(val value: Int) {
35 | CGM_ERROR_OP_CODE_NOT_SUPPORTED(2),
36 | CGM_ERROR_INVALID_OPERAND(3),
37 | CGM_ERROR_PROCEDURE_NOT_COMPLETED(4),
38 | CGM_ERROR_PARAMETER_OUT_OF_RANGE(5);
39 |
40 | companion object {
41 | fun create(value: Int): CGMErrorCode {
42 | return values().firstOrNull { it.value == value }
43 | ?: throw IllegalArgumentException("Cannot create error code for value: $value")
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/gls/data/Health.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.gls.data
33 |
34 | enum class Health(internal val value: Int) {
35 | RESERVED(0),
36 | MINOR_HEALTH_ISSUES(1),
37 | MAJOR_HEALTH_ISSUES(2),
38 | DURING_MENSES(3),
39 | UNDER_STRESS(4),
40 | NO_HEALTH_ISSUES(5),
41 | NOT_AVAILABLE(15);
42 |
43 | companion object {
44 | fun create(value: Int): Health {
45 | return values().firstOrNull { it.value == value }
46 | ?: throw IllegalArgumentException("Cannot create Health for value $value")
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/client-mock/src/main/java/no/nordicsemi/kotlin/ble/client/mock/DisconnectionReason.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | @file:Suppress("unused")
33 |
34 | package no.nordicsemi.kotlin.ble.client.mock
35 |
36 | sealed class DisconnectionReason {
37 |
38 | /**
39 | * The disconnection was initiated by the mock peripheral.
40 | */
41 | data object TerminateLocalHost: DisconnectionReason()
42 |
43 | /**
44 | * The disconnection was initiated by the client.
45 | */
46 | data object TerminatePeerUser: DisconnectionReason()
47 |
48 | /**
49 | * The disconnection occurred due to a timeout.
50 | */
51 | data object Timeout: DisconnectionReason()
52 | }
--------------------------------------------------------------------------------
/core/src/main/java/no/nordicsemi/kotlin/ble/core/PeripheralType.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | @file:Suppress("unused")
33 |
34 | package no.nordicsemi.kotlin.ble.core
35 |
36 | /**
37 | * The Bluetooth device type of the remote device.
38 | */
39 | enum class PeripheralType {
40 | /**
41 | * The peripheral is a Classic - BR/EDR devices.
42 | */
43 | CLASSIC,
44 |
45 | /**
46 | * The peripheral is a Low-Energy-only device.
47 | */
48 | LE,
49 |
50 | /**
51 | * The peripheral supports both Classic and Low-Energy (BR/EDR/LE).
52 | */
53 | DUAL,
54 |
55 | /**
56 | * The peripheral type is unknown.
57 | */
58 | UNKNOWN
59 | }
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/racp/RACPOpCode.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.racp
33 |
34 | enum class RACPOpCode(internal val value: Int) {
35 | RACP_OP_CODE_REPORT_STORED_RECORDS(1),
36 | RACP_OP_CODE_DELETE_STORED_RECORDS(2),
37 | RACP_OP_CODE_ABORT_OPERATION(3),
38 | RACP_OP_CODE_REPORT_NUMBER_OF_RECORDS(4);
39 |
40 | companion object {
41 | fun create(value: Int): RACPOpCode {
42 | return values().firstOrNull { it.value == value }
43 | ?: throw IllegalArgumentException("Cannot create RACP op code for value: $value")
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/profile/src/main/java/no/nordicsemi/android/kotlin/ble/profile/gls/data/Medication.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.profile.gls.data
33 |
34 | enum class Medication(internal val value: Int) {
35 | RESERVED(0),
36 | RAPID_ACTING_INSULIN(1),
37 | SHORT_ACTING_INSULIN(2),
38 | INTERMEDIATE_ACTING_INSULIN(3),
39 | LONG_ACTING_INSULIN(4),
40 | PRE_MIXED_INSULIN(5);
41 |
42 | companion object {
43 | fun create(value: Int): Medication {
44 | return values().firstOrNull { it.value == value }
45 | ?: throw IllegalArgumentException("Cannot create Medication for value $value")
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/core/src/main/java/no/nordicsemi/kotlin/ble/core/PhyInUse.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | @file:Suppress("unused")
33 |
34 | package no.nordicsemi.kotlin.ble.core
35 |
36 | /**
37 | * A class that holds the PHYs in use for a connection.
38 | *
39 | * @property txPhy The transmitter PHY in use.
40 | * @property rxPhy The receiver PHY in use.
41 | */
42 | data class PhyInUse(
43 | val txPhy: Phy,
44 | val rxPhy: Phy,
45 | ) {
46 | companion object {
47 | /**
48 | * A constant for legacy LE 1M PHY.
49 | */
50 | val PHY_LE_1M = PhyInUse(Phy.PHY_LE_1M, Phy.PHY_LE_1M)
51 | }
52 |
53 | override fun toString(): String {
54 | return "TX PHY=$txPhy, RX PHY=$rxPhy"
55 | }
56 | }
--------------------------------------------------------------------------------
/test/src/test/java/no/nordicsemi/android/kotlin/ble/test/ApplicationScopeModule.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.android.kotlin.ble.test
33 |
34 | import dagger.Module
35 | import dagger.Provides
36 | import dagger.hilt.InstallIn
37 | import dagger.hilt.components.SingletonComponent
38 | import kotlinx.coroutines.CoroutineScope
39 | import kotlinx.coroutines.SupervisorJob
40 | import kotlinx.coroutines.test.UnconfinedTestDispatcher
41 |
42 | @Module
43 | @InstallIn(SingletonComponent::class)
44 | class ApplicationScopeModule {
45 |
46 | @Provides
47 | internal fun provideServerDevice(): CoroutineScope {
48 | return CoroutineScope(SupervisorJob() + UnconfinedTestDispatcher())
49 | }
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/core-mock/src/main/java/no/nordicsemi/kotlin/ble/core/mock/MockEnvironment.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | package no.nordicsemi.kotlin.ble.core.mock
33 |
34 | /**
35 | * A mock environment that can be used to test the behavior of the Central Manager.
36 | *
37 | * @property deviceName The device local device name.
38 | * @property isBluetoothSupported Whether Bluetooth is supported on the device.
39 | * @property isBluetoothEnabled Whether Bluetooth is enabled.
40 | * @property reportsConnectionParameters Whether the environment reports connection parameters.
41 | */
42 | open class MockEnvironment(
43 | var deviceName: String,
44 | val isBluetoothSupported: Boolean,
45 | val isBluetoothEnabled: Boolean,
46 | val reportsConnectionParameters: Boolean
47 | )
--------------------------------------------------------------------------------
/server-core-android/src/main/java/no/nordicsemi/kotlin/ble/server/android/PeripheralManager.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | @file:Suppress("MemberVisibilityCanBePrivate", "unused")
33 |
34 | package no.nordicsemi.kotlin.ble.server.android
35 |
36 | import kotlinx.coroutines.flow.Flow
37 | import no.nordicsemi.kotlin.ble.server.PeripheralManager
38 |
39 | /**
40 | * A Android Peripheral Manager extends the [PeripheralManager] interface with additional
41 | * Android-specific features.
42 | */
43 | interface PeripheralManager: PeripheralManager {
44 |
45 | /**
46 | * Returns a cold flow of connection events.
47 | *
48 | * Every time a device connects or disconnects, a new event will be emitted.
49 | */
50 | val connectionEvents: Flow
51 | }
52 |
--------------------------------------------------------------------------------
/server-core/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | plugins {
33 | alias(libs.plugins.nordic.kotlin.jvm)
34 | alias(libs.plugins.nordic.nexus.jvm)
35 | }
36 |
37 | group = "no.nordicsemi.kotlin.ble"
38 |
39 | nordicNexusPublishing {
40 | POM_ARTIFACT_ID = "server-core"
41 | POM_NAME = "Nordic Kotlin BLE library"
42 | POM_DESCRIPTION = "Nordic Kotlin BLE library"
43 | POM_URL = "https://github.com/NordicSemiconductor/Kotlin-BLE-Library"
44 | POM_SCM_URL = "https://github.com/NordicSemiconductor/Kotlin-BLE-Library"
45 | POM_SCM_CONNECTION = "scm:git@github.com:NordicSemiconductor/Kotlin-BLE-Library.git"
46 | POM_SCM_DEV_CONNECTION = "scm:git@github.com:NordicSemiconductor/Kotlin-BLE-Library.git"
47 | }
48 |
49 | dependencies {
50 | api(project(":core"))
51 | }
52 |
--------------------------------------------------------------------------------
/server-core-android/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | plugins {
33 | alias(libs.plugins.nordic.kotlin.jvm)
34 | alias(libs.plugins.nordic.nexus.jvm)
35 | }
36 |
37 | group = "no.nordicsemi.kotlin.ble"
38 |
39 | nordicNexusPublishing {
40 | POM_ARTIFACT_ID = "server-core-android"
41 | POM_NAME = "Nordic Kotlin BLE library"
42 | POM_DESCRIPTION = "Nordic Kotlin BLE library"
43 | POM_URL = "https://github.com/NordicSemiconductor/Kotlin-BLE-Library"
44 | POM_SCM_URL = "https://github.com/NordicSemiconductor/Kotlin-BLE-Library"
45 | POM_SCM_CONNECTION = "scm:git@github.com:NordicSemiconductor/Kotlin-BLE-Library.git"
46 | POM_SCM_DEV_CONNECTION = "scm:git@github.com:NordicSemiconductor/Kotlin-BLE-Library.git"
47 | }
48 |
49 | dependencies {
50 | api(project(":server-core"))
51 | }
52 |
--------------------------------------------------------------------------------
/server-core-android/src/main/java/no/nordicsemi/kotlin/ble/server/android/ConnectionEvent.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are
6 | * permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice, this list of
9 | * conditions and the following disclaimer.
10 | *
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 | * of conditions and the following disclaimer in the documentation and/or other materials
13 | * provided with the distribution.
14 | *
15 | * 3. Neither the name of the copyright holder nor the names of its contributors may be
16 | * used to endorse or promote products derived from this software without specific prior
17 | * written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | @file:Suppress("unused")
33 |
34 | package no.nordicsemi.kotlin.ble.server.android
35 |
36 | /**
37 | * An event indicating a connection event.
38 | */
39 | sealed class ConnectionEvent (
40 | val device: Central
41 | )
42 |
43 | /**
44 | * An event indicating that a device has connected to the local GATT server.
45 | *
46 | * @param device The central device that has connected.
47 | */
48 | class ConnectionEstablished(device: Central): ConnectionEvent(device)
49 |
50 | /**
51 | * An event indicating that a device has disconnected from the local GATT server.
52 | *
53 | * @param device The central device that has disconnected.
54 | */
55 | class ConnectionLost(device: Central): ConnectionEvent(device)
--------------------------------------------------------------------------------