2017-03-22 16:16:10 -07:00
|
|
|
import { Injectable } from '@angular/core';
|
2017-04-27 00:36:12 -04:00
|
|
|
import { Plugin, Cordova, CordovaCheck, IonicNativePlugin } from '@ionic-native/core';
|
2017-03-22 16:16:10 -07:00
|
|
|
import { Observable } from 'rxjs/Observable';
|
|
|
|
|
2017-05-14 00:55:16 -04:00
|
|
|
declare const cordova: any;
|
2017-03-22 16:16:10 -07:00
|
|
|
|
|
|
|
/**
|
2017-03-22 19:16:38 -04:00
|
|
|
* @name Jins Meme
|
2017-03-22 16:16:10 -07:00
|
|
|
* @description
|
|
|
|
* Implementation of the JINS MEME SDK
|
|
|
|
*
|
|
|
|
* @usage
|
2017-04-30 20:36:22 +02:00
|
|
|
* ```typescript
|
2017-03-22 16:16:10 -07:00
|
|
|
* import { JinsMeme } from '@ionic-native/jins-meme';
|
2017-03-22 19:16:38 -04:00
|
|
|
*
|
2017-03-22 16:16:10 -07:00
|
|
|
* constructor(private jinsMeme: JinsMeme) { }
|
2017-03-22 19:16:38 -04:00
|
|
|
*
|
2017-03-22 16:16:10 -07:00
|
|
|
* ...
|
2017-03-22 19:16:38 -04:00
|
|
|
*
|
2017-03-29 17:56:35 -05:00
|
|
|
* this.jinsMeme.setAppClientID(appClientId: string, clientSecret: string).then(
|
|
|
|
* // Bluetooth should be enabled and the JINS MEME powered on (blinking blue light)
|
|
|
|
* this.jinsMeme.startScan().subscribe((meme_addr) => {
|
|
|
|
* this.jinsMeme.connect(meme_addr).subscribe((connectResult) => {
|
|
|
|
* this.memeService.startDataReport().subscribe((dataReport) => {
|
|
|
|
* console.log(dataReport);
|
|
|
|
* });
|
|
|
|
* });
|
|
|
|
* });
|
|
|
|
* .catch(console.log('jinsMeme.setAppClientID authentication error'));
|
2017-03-22 16:16:10 -07:00
|
|
|
*
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
@Plugin({
|
|
|
|
pluginName: 'Jins Meme',
|
|
|
|
plugin: 'JinsMemeSDK-Plugin-Cordova',
|
|
|
|
pluginRef: 'cordova.plugins.JinsMemePlugin',
|
2017-03-28 08:24:04 -04:00
|
|
|
repo: 'https://github.com/jins-meme/JinsMemeSDK-Plugin-Cordova',
|
|
|
|
platforms: ['Android', 'iOS']
|
2017-03-22 16:16:10 -07:00
|
|
|
})
|
|
|
|
@Injectable()
|
2017-04-27 00:36:12 -04:00
|
|
|
export class JinsMeme extends IonicNativePlugin {
|
2017-03-22 16:16:10 -07:00
|
|
|
/**
|
|
|
|
* Authentication and authorization of App and SDK.
|
2017-03-29 17:56:35 -05:00
|
|
|
* Must call this method first.
|
|
|
|
* Sign up for an app ID (and get an app/client secret) at developers.jins.com
|
2017-03-22 16:16:10 -07:00
|
|
|
*
|
|
|
|
*@param {string} setAppClientID
|
|
|
|
*@param {string} clientSecret
|
|
|
|
*@returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
setAppClientID(appClientId: string, clientSecret: string): Promise<any> { return; }
|
|
|
|
/**
|
|
|
|
* Starts scanning for JINS MEME.
|
|
|
|
* @returns {Observable<any>}
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
observable: true,
|
|
|
|
clearFunction: 'stopScan',
|
|
|
|
clearWithArgs: true
|
|
|
|
})
|
|
|
|
startScan(): Observable<any> { return; }
|
|
|
|
/**
|
|
|
|
* Stops scanning JINS MEME.
|
|
|
|
* @returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
stopScan(): Promise<any> { return; }
|
|
|
|
/**
|
|
|
|
* Establishes connection to JINS MEME.
|
|
|
|
* @param {string} target
|
|
|
|
* @returns {Observable<any>}
|
|
|
|
*/
|
|
|
|
@CordovaCheck({
|
|
|
|
observable: true
|
|
|
|
})
|
|
|
|
connect(target: string): Observable<any> {
|
2017-04-30 20:36:22 +02:00
|
|
|
return new Observable<any>((observer: any) => {
|
|
|
|
let data = cordova.plugins.JinsMemePlugin.connect(target, observer.next.bind(observer), observer.complete.bind(observer), observer.error.bind(observer));
|
|
|
|
return () => console.log(data);
|
|
|
|
});
|
|
|
|
}
|
2017-03-22 16:16:10 -07:00
|
|
|
/**
|
|
|
|
* Set auto connection mode.
|
|
|
|
*@param {Boolean} flag
|
|
|
|
*@returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
setAutoConnect(flag: boolean): Promise<any> { return; }
|
|
|
|
/**
|
|
|
|
* Returns whether a connection to JINS MEME has been established.
|
|
|
|
*@returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
isConnected(): Promise<any> { return; }
|
|
|
|
/**
|
|
|
|
* Disconnects from JINS MEME.
|
|
|
|
*@returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
disconnect(): Promise<any> { return; }
|
|
|
|
/**
|
|
|
|
* Starts receiving realtime data.
|
|
|
|
* @returns {Observable<any>}
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
observable: true,
|
|
|
|
clearFunction: 'stopDataReport',
|
|
|
|
clearWithArgs: true
|
|
|
|
})
|
|
|
|
startDataReport(): Observable<any> { return; }
|
2017-04-30 20:36:22 +02:00
|
|
|
/**
|
|
|
|
* Stops receiving data.
|
|
|
|
*@returns {Promise<any>}
|
|
|
|
*/
|
2017-03-22 16:16:10 -07:00
|
|
|
@Cordova()
|
|
|
|
stopDataReport(): Promise<any> { return; }
|
|
|
|
/**
|
|
|
|
* Returns SDK version.
|
|
|
|
*
|
|
|
|
*@returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
getSDKVersion(): Promise<any> { return; }
|
|
|
|
/**
|
|
|
|
* Returns JINS MEME connected with other apps.
|
|
|
|
*@returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
getConnectedByOthers(): Promise<any> { return; }
|
|
|
|
/**
|
|
|
|
* Returns calibration status
|
|
|
|
*@returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
isCalibrated(): Promise<any> { return; }
|
|
|
|
/**
|
|
|
|
* Returns device type.
|
|
|
|
*@returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
getConnectedDeviceType(): Promise<any> { return; }
|
|
|
|
/**
|
|
|
|
* Returns hardware version.
|
|
|
|
*@returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
getConnectedDeviceSubType(): Promise<any> { return; }
|
|
|
|
/**
|
|
|
|
* Returns FW Version.
|
|
|
|
*@returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
getFWVersion(): Promise<any> { return; }
|
|
|
|
/**
|
|
|
|
* Returns HW Version.
|
|
|
|
*@returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
getHWVersion(): Promise<any> { return; }
|
|
|
|
/**
|
|
|
|
* Returns response about whether data was received or not.
|
|
|
|
*@returns {Promise<any>}
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
isDataReceiving(): Promise<any> { return; }
|
|
|
|
}
|