Skip to content

Commit

Permalink
renamed api functions, updated android demos, updated iOS SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
Erkki Silvola committed Apr 12, 2019
1 parent 03135b0 commit a3ca724
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
Expand Down Expand Up @@ -44,16 +45,16 @@ public void blePowerStateChanged(boolean b) {
}

@Override
public void polarDeviceConnected(PolarDeviceInfo s) {
public void deviceConnected(PolarDeviceInfo s) {
}

@Override
public void polarDeviceConnecting(PolarDeviceInfo polarDeviceInfo) {
public void deviceConnecting(PolarDeviceInfo polarDeviceInfo) {

}

@Override
public void polarDeviceDisconnected(PolarDeviceInfo s) {
public void deviceDisconnected(PolarDeviceInfo s) {
}

@Override
Expand Down Expand Up @@ -82,7 +83,7 @@ public void hrFeatureReady(String s) {
}

@Override
public void fwInformationReceived(String s, String s1) {
public void disInformationReceived(String s, UUID u, String s1) {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.reactivestreams.Publisher;

import java.util.List;
import java.util.UUID;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
Expand Down Expand Up @@ -63,19 +64,19 @@ public void blePowerStateChanged(boolean b) {
}

@Override
public void polarDeviceConnected(PolarDeviceInfo s) {
public void deviceConnected(PolarDeviceInfo s) {
Log.d(TAG, "Device connected " + s.deviceId);
Toast.makeText(classContext, R.string.connected,
Toast.LENGTH_SHORT).show();
}

@Override
public void polarDeviceConnecting(PolarDeviceInfo polarDeviceInfo) {
public void deviceConnecting(PolarDeviceInfo polarDeviceInfo) {

}

@Override
public void polarDeviceDisconnected(PolarDeviceInfo s) {
public void deviceDisconnected(PolarDeviceInfo s) {
Log.d(TAG, "Device disconnected " + s);

}
Expand Down Expand Up @@ -112,10 +113,12 @@ public void hrFeatureReady(String s) {
}

@Override
public void fwInformationReceived(String s, String s1) {
String msg = "Firmware: " + s1.trim();
Log.d(TAG, "Firmware: " + s + " " + s1.trim());
textViewFW.append(msg + "\n");
public void disInformationReceived(String s, UUID u, String s1) {
if( u.equals(UUID.fromString("00002a28-0000-1000-8000-00805f9b34fb"))) {
String msg = "Firmware: " + s1.trim();
Log.d(TAG, "Firmware: " + s + " " + s1.trim());
textViewFW.append(msg + "\n");
}
}

@Override
Expand All @@ -138,7 +141,7 @@ public void polarFtpFeatureReady(String s) {
Log.d(TAG, "Polar FTP ready " + s);
}
});
api.connectToPolarDevice(DEVICE_ID);
api.connectToDevice(DEVICE_ID);

plotter = new Plotter(this, "ECG");
plotter.setListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.text.DecimalFormat;
import java.util.List;
import java.util.UUID;

import io.reactivex.disposables.Disposable;
import polar.com.sdk.api.PolarBleApi;
Expand Down Expand Up @@ -56,19 +57,19 @@ public void blePowerStateChanged(boolean b) {
}

@Override
public void polarDeviceConnected(PolarDeviceInfo s) {
public void deviceConnected(PolarDeviceInfo s) {
Log.d(TAG, "Device connected " + s.deviceId);
Toast.makeText(classContext, R.string.connected,
Toast.LENGTH_SHORT).show();
}

@Override
public void polarDeviceConnecting(PolarDeviceInfo polarDeviceInfo) {
public void deviceConnecting(PolarDeviceInfo polarDeviceInfo) {

}

@Override
public void polarDeviceDisconnected(PolarDeviceInfo s) {
public void deviceDisconnected(PolarDeviceInfo s) {
Log.d(TAG, "Device disconnected " + s);

}
Expand Down Expand Up @@ -104,10 +105,12 @@ public void hrFeatureReady(String s) {
}

@Override
public void fwInformationReceived(String s, String s1) {
String msg = "Firmware: " + s1.trim();
Log.d(TAG, "Firmware: " + s + " " + s1.trim());
textViewFW.append(msg + "\n");
public void disInformationReceived(String s, UUID u, String s1) {
if( u.equals(UUID.fromString("00002a28-0000-1000-8000-00805f9b34fb"))) {
String msg = "Firmware: " + s1.trim();
Log.d(TAG, "Firmware: " + s + " " + s1.trim());
textViewFW.append(msg + "\n");
}
}

@Override
Expand Down Expand Up @@ -139,7 +142,7 @@ public void polarFtpFeatureReady(String s) {
Log.d(TAG, "Polar FTP ready " + s);
}
});
api.connectToPolarDevice(DEVICE_ID);
api.connectToDevice(DEVICE_ID);

plotter = new TimePlotter(this, "HR/RR");
plotter.setListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import com.androidplot.xy.XYPlot;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
Expand Down Expand Up @@ -59,7 +61,7 @@ public void blePowerStateChanged(boolean b) {
}

@Override
public void polarDeviceConnected(PolarDeviceInfo s) {
public void deviceConnected(PolarDeviceInfo s) {
Log.d(TAG,"Device connected " + s);
deviceId = s.deviceId;
Toast.makeText(classContext, getString(R.string.connected) + " " + s.deviceId, Toast.LENGTH_SHORT).show();
Expand All @@ -73,12 +75,12 @@ public void polarDeviceConnected(PolarDeviceInfo s) {
}

@Override
public void polarDeviceConnecting(PolarDeviceInfo polarDeviceInfo) {
public void deviceConnecting(PolarDeviceInfo polarDeviceInfo) {

}

@Override
public void polarDeviceDisconnected(PolarDeviceInfo s) {
public void deviceDisconnected(PolarDeviceInfo s) {
Log.d(TAG,"Device disconnected " + s.deviceId);
}

Expand Down Expand Up @@ -113,7 +115,7 @@ public void hrFeatureReady(String s) {
}

@Override
public void fwInformationReceived(String s, String s1) {
public void disInformationReceived(String s, UUID u, String s1) {
}

@Override
Expand All @@ -132,7 +134,7 @@ public void polarFtpFeatureReady(String s) {
}
});

api.autoConnectToPolarDevice(-50, null).subscribe();
api.autoConnectToDevice(-50, "180D", null).subscribe();

plotter = new Plotter(this, "Exercise");
plotter.setListener(this);
Expand Down Expand Up @@ -171,7 +173,7 @@ public void run() throws Exception {
@Override
protected void onDestroy() {
super.onDestroy();
api.disconnectFromPolarDevice(deviceId);
api.disconnectFromDevice(deviceId);
}

//PlotterListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.Calendar;
import java.util.Date;
import java.util.UUID;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
Expand Down Expand Up @@ -88,19 +89,19 @@ public void blePowerStateChanged(boolean powered) {
}

@Override
public void polarDeviceConnected(PolarDeviceInfo polarDeviceInfo) {
public void deviceConnected(PolarDeviceInfo polarDeviceInfo) {
Log.d(TAG,"CONNECTED: " + polarDeviceInfo.deviceId);
DEVICE_ID = polarDeviceInfo.deviceId;
}

@Override
public void polarDeviceConnecting(PolarDeviceInfo polarDeviceInfo) {
public void deviceConnecting(PolarDeviceInfo polarDeviceInfo) {
Log.d(TAG,"CONNECTING: " + polarDeviceInfo.deviceId);
DEVICE_ID = polarDeviceInfo.deviceId;
}

@Override
public void polarDeviceDisconnected(PolarDeviceInfo polarDeviceInfo) {
public void deviceDisconnected(PolarDeviceInfo polarDeviceInfo) {
Log.d(TAG,"DISCONNECTED: " + polarDeviceInfo.deviceId);
ecgDisposable = null;
accDisposable = null;
Expand Down Expand Up @@ -145,8 +146,8 @@ public void hrFeatureReady(String identifier) {
}

@Override
public void fwInformationReceived(String identifier, String fwVersion) {
Log.d(TAG,"FW: " + fwVersion);
public void disInformationReceived(String identifier, UUID uuid, String value) {
Log.d(TAG,"uuid: " + uuid + " value: " + value);

}

Expand Down Expand Up @@ -278,14 +279,14 @@ public void run() throws Exception {
connect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
api.connectToPolarDevice(DEVICE_ID);
api.connectToDevice(DEVICE_ID);
}
});

disconnect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
api.disconnectFromPolarDevice(DEVICE_ID);
api.disconnectFromDevice(DEVICE_ID);
}
});

Expand All @@ -296,7 +297,7 @@ public void onClick(View view) {
autoConnectDisposable.dispose();
autoConnectDisposable = null;
}
autoConnectDisposable = api.autoConnectToPolarDevice(-50, null).subscribe(
autoConnectDisposable = api.autoConnectToDevice(-50, "180D", null).subscribe(
new Action() {
@Override
public void run() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = 96TQ43SDNE;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(PROJECT_DIR)/../",
Expand Down Expand Up @@ -371,7 +371,7 @@
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = 96TQ43SDNE;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(PROJECT_DIR)/../",
Expand Down
6 changes: 3 additions & 3 deletions examples/example-ios/polarBleSdkTestApp/ApiWrapperSwift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ import RxSwift

@objc func startAutoConnectToPolarDevice(_ rssi: Int, polarDeviceType: String?) {
stopAutoConnectToPolarDevice()
autoConnect = self.api.startAutoConnectToPolarDevice(rssi, polarDeviceType: polarDeviceType).subscribe()
autoConnect = self.api.startAutoConnectToDevice(rssi, service: nil, polarDeviceType: polarDeviceType).subscribe()
}

@objc func stopAutoConnectToPolarDevice() {
Expand All @@ -95,11 +95,11 @@ import RxSwift
}

@objc func connectToPolarDevice(_ identifier: String) {
self.api.connectToPolarDevice(identifier)
self.api.connectToDevice(identifier)
}

@objc func disconnectFromPolarDevice(_ identifier: String) {
self.api.disconnectFromPolarDevice(identifier)
self.api.disconnectFromDevice(identifier)
}

@objc func isFeatureReady(_ identifier: String, feature: Int) -> Bool {
Expand Down
15 changes: 8 additions & 7 deletions examples/example-ios/polarBleSdkTestApp/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ViewController: UIViewController,
api.powerStateObserver = self
api.deviceFeaturesObserver = self
api.logger = self
api.polarFilter(false)
NSLog("\(PolarBleApiDefaultImpl.versionInfo())")
}

Expand All @@ -40,7 +41,7 @@ class ViewController: UIViewController,

@IBAction func autoConnect(_ sender: Any) {
autoConnect?.dispose()
autoConnect = api.startAutoConnectToPolarDevice(-45, polarDeviceType: nil).subscribe{ e in
autoConnect = api.startAutoConnectToDevice(-55, service: nil, polarDeviceType: nil).subscribe{ e in
switch e {
case .completed:
NSLog("auto connect search complete")
Expand Down Expand Up @@ -69,11 +70,11 @@ class ViewController: UIViewController,
}

@IBAction func connectToDevice(_ sender: Any) {
api.connectToPolarDevice(deviceId)
api.connectToDevice(deviceId)
}

@IBAction func disconnectFromDevice(_ sender: Any) {
api.disconnectFromPolarDevice(deviceId)
api.disconnectFromDevice(deviceId)
}

@IBAction func accToggle(_ sender: Any) {
Expand Down Expand Up @@ -184,7 +185,7 @@ class ViewController: UIViewController,

@IBAction func searchToggle(_ sender: Any) {
if searchToggle == nil {
searchToggle = api.searchForPolarDevice().observeOn(MainScheduler.instance).subscribe{ e in
searchToggle = api.searchForDevice().observeOn(MainScheduler.instance).subscribe{ e in
switch e {
case .completed:
NSLog("search complete")
Expand Down Expand Up @@ -262,16 +263,16 @@ class ViewController: UIViewController,
}

// PolarBleApiObserver
func polarDeviceConnecting(_ polarDeviceInfo: PolarDeviceInfo) {
func deviceConnecting(_ polarDeviceInfo: PolarDeviceInfo) {
NSLog("DEVICE CONNECTING: \(polarDeviceInfo)")
}

func polarDeviceConnected(_ polarDeviceInfo: PolarDeviceInfo) {
func deviceConnected(_ polarDeviceInfo: PolarDeviceInfo) {
NSLog("DEVICE CONNECTED: \(polarDeviceInfo)")
deviceId = polarDeviceInfo.deviceId
}

func polarDeviceDisconnected(_ polarDeviceInfo: PolarDeviceInfo) {
func deviceDisconnected(_ polarDeviceInfo: PolarDeviceInfo) {
NSLog("DISCONNECTED: \(polarDeviceInfo)")
}

Expand Down

0 comments on commit a3ca724

Please sign in to comment.