Skip to content

Commit

Permalink
Merge pull request #143 from XYOracleNetwork/release
Browse files Browse the repository at this point in the history
Release - Minor refactor with updated core dependency
  • Loading branch information
Phillip Lorenzo authored Apr 22, 2020
2 parents 838aa77 + 346a78e commit 0abcbe6
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 36 deletions.
11 changes: 11 additions & 0 deletions .settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
A high-level SDK for interacting with the XYO network.
Including BLE, TCP/IP, Bound Witnessing, and Bridging. Use this instead of `sdk-core-kotlin` for integration with your app project.

> As you are developing on the SDK, be sure to keep an eye out for updates, as they may include core and ble updates
## Gradle Build

```gradle
compile 'network.xyo:sdk-xyo-android:3.1.31'
compile 'network.xyo:sdk-xyo-android:3.1.34'
```

## Maven Build
Expand All @@ -39,12 +41,33 @@ Including BLE, TCP/IP, Bound Witnessing, and Bridging. Use this instead of `sdk
<dependency>
<groupId>network.xyo</groupId>
<artifactId>sdk-xyo-android</artifactId>
<version>3.1.26</version>
<version>3.1.34</version>
<type>pom</type>
</dependency>
```

## Permissions and Set Up

When using Android Studio and an Android device to test BLE Client and Server be sure to enable permissions and add an initialization function in your `MainActivity`

`AndroidManifest.xml`

```xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
```

`MainActivity.kt`

```kotlin
GlobalScope.launch {
// place initialization function here for node build needed
// you can look at the sample app for code example
}
```

## Examples

Copy this code to test. Look below for specific usage.
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
classpath 'com.android.tools.build:gradle:3.6.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.71"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"
// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
7 changes: 4 additions & 3 deletions xyo-android-library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ task printVersion {
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
ndkVersion "21.0.6113669"

versionProps['VERSION_PATCH'] = patch.toString()
versionProps.store(versionPropsFile.newWriter(), null)
Expand Down Expand Up @@ -150,13 +151,13 @@ ktlint {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.61"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.72"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'network.xyo:sdk-base-android:2.1.288'
implementation 'network.xyo:sdk-ble-android:3.1.1144'
implementation 'network.xyo:sdk-core-kotlin:3.0.42'
implementation 'network.xyo:sdk-ble-android:3.1.1145'
implementation 'network.xyo:sdk-core-kotlin:3.0.44'
implementation 'com.snappydb:snappydb-lib:0.5.2'
api 'org.bouncycastle:bcpkix-jdk15on:1.64'
}
Expand Down
41 changes: 31 additions & 10 deletions xyo-android-library/src/main/java/network/xyo/sdk/XyoBleClient.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@file:Suppress("SpellCheckingInspection")

package network.xyo.sdk
import android.content.Context
import android.util.Log
import java.util.*
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -42,51 +45,67 @@ class XyoBleClient(

var lastBoundWitnessTime = Date().time - minBWTimeGap // ten seconds ago

var scanner: XYSmartScanModern
private var scanner: XYSmartScanModern

private val boundWitnessMutex = Mutex()

override var scan: Boolean
get() { return scanner.started() }
get() {
// val tag = "TAG "
// Log.i(tag, "Does this scan??")
return scanner.started()
}
set(value) {
GlobalScope.launch {
if (value && !scanner.started()) {
val tag = "TAG "
Log.i(tag, "Does this trigger a start??")
scanner.start()
Log.i(tag, "Is this scanner working?? $scanner")
} else if (!value && scanner.started()) {
val tag = "TAG "
Log.i(tag, "Does this trigger a stop??")
scanner.stop()
}
}
}

private val scannerListener = object : XYSmartScan.Listener() {
// override fun onStart
override fun entered(device: XYBluetoothDevice) {
val tag = "TAG "
super.entered(device)
deviceCount++
if (device is XyoBluetoothClient) {
log.info("Xyo Device Entered: ${device.id}")
xyoDeviceCount++
}
Log.i(tag,"Xyo Device Entered: ${device.id}")
xyoDeviceCount++
}

override fun exited(device: XYBluetoothDevice) {
val tag = "TAG "
super.exited(device)
deviceCount--
if (device is XyoBluetoothClient) {
log.info("Xyo Device Exited: ${device.id}")
xyoDeviceCount--
}
Log.i(tag, "Xyo Device Exited: ${device.id}")
xyoDeviceCount--
}
override fun detected(device: XYBluetoothDevice) {
val tag = "TAG "
super.detected(device)
Log.i(tag, "do we even get a device here? $device")
Log.i(tag, "are we detecting anything??")
if (this@XyoBleClient.autoBoundWitness) {
Log.i(tag, "hello ?? $autoBoundWitness")
if (Date().time - lastBoundWitnessTime > minBWTimeGap) {
Log.i(tag, "hello again ???")
(device as? XyoBluetoothClient)?.let { client ->
Log.i(tag, "Hello again again???")
device.rssi?.let { rssi ->
Log.i(tag, "Hello wtf 3???")
if (rssi < minimumRssi) {
log.info("Rssi too low: $rssi")
return
}
(client as? XyoBridgeX)?.let {
Log.i(tag, "Hello one more time???")
if (!supportBridgeX) {
log.info("BridgeX not Supported: $rssi")
return
Expand All @@ -111,6 +130,8 @@ class XyoBleClient(

suspend fun tryBoundWitnessWithDevice(device: XyoBluetoothClient) {
if (boundWitnessMutex.tryLock()) {
val tag = "TAG "
Log.i(tag, "is there a bound witness attempt here?")
boundWitnessStarted(device)

var errorMessage: String? = null
Expand Down
4 changes: 2 additions & 2 deletions xyo-android-library/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Fri Apr 10 00:51:29 UTC 2020
VERSION_PATCH=33
#Wed Apr 22 22:10:21 UTC 2020
VERSION_PATCH=34
34 changes: 23 additions & 11 deletions xyo-android-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ apply plugin: 'maven-publish'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
ndkVersion "21.0.6113669"
defaultConfig {
applicationId "network.xyo.sdk.sample"
minSdkVersion 21
Expand All @@ -20,6 +21,13 @@ android {
targetCompatibility = 1.8
}

lintOptions {
htmlReport false
abortOnError true
warningsAsErrors true
disable "HardwareIds", "MissingPermission"
}

kotlinOptions {
jvmTarget = "1.8"
}
Expand All @@ -33,23 +41,27 @@ android {
debuggable true
}
}

configurations {
all {
exclude group: 'org.json', module: 'json'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.61"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.72"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.1.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
implementation 'network.xyo:sdk-base-android:2.1.288'
implementation 'network.xyo:sdk-ble-android:3.1.1144'
implementation 'network.xyo:sdk-core-kotlin:3.0.42'
implementation 'network.xyo:sdk-ble-android:3.1.1145'
implementation 'network.xyo:sdk-core-kotlin:3.0.44'
implementation project(':xyo-android-library')
}
4 changes: 2 additions & 2 deletions xyo-android-sample/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Nov 22 08:51:11 PST 2019
#Mon Apr 13 13:11:06 PDT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Empty file modified xyo-android-sample/gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package network.xyo.sdk.sample
import android.content.Context
import android.content.pm.PackageManager
import android.location.LocationManager
import android.util.Log
import android.os.Bundle
import com.google.android.material.bottomnavigation.BottomNavigationView
import androidx.appcompat.app.AppCompatActivity
Expand All @@ -27,11 +28,11 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
GlobalScope.launch {
initializeXyoSimpleWithGps()
// initializeXyoSimpleWithGps()
//initializeXyoSimple()
//initializeXyoBleClientOnly()
// initializeXyoBleClientOnly()
//initializeXyoBleServerOnly()
//initializeXyoBleOnly()
initializeXyoBleOnly()
ui {
setContentView(R.layout.activity_main)
val navView: BottomNavigationView = findViewById(R.id.nav_view)
Expand Down Expand Up @@ -85,11 +86,14 @@ class MainActivity : AppCompatActivity() {

private suspend fun initializeXyoBleClientOnly() {
val builder = XyoNodeBuilder()
val tag = "TAG: "
node = builder.build(this)
(node.networks["ble"] as? XyoBleNetwork)?.let { network ->
Log.i(tag, "Ble? Hello? ")
network.client.autoBridge = true
network.client.autoBoundWitness = true
network.client.scan = true
Log.i(tag, "Client Scan? $network.client.scan ")
network.server.autoBridge = false
network.server.listen = false
}
Expand Down

0 comments on commit 0abcbe6

Please sign in to comment.