|
@@ -79,90 +79,16 @@ public class VinnnoVnoteSdk extends BaseSdk{
|
|
|
// onGlobalResultListener.onResult( new SearchResultUtils(StatusConstant.PARAMS_ERROR).toJSONObject() );
|
|
|
// return;
|
|
|
// }
|
|
|
- if(type == "twelveheart") {
|
|
|
- startSearchBT(type, SCAN_TIMEOUT, jsonObject -> {
|
|
|
- onGlobalResultListener.onResult(jsonObject);
|
|
|
- });
|
|
|
- }else {
|
|
|
- startSearch(type, SCAN_TIMEOUT, jsonObject -> {
|
|
|
- onGlobalResultListener.onResult(jsonObject);
|
|
|
- });
|
|
|
- }
|
|
|
- //停止搜索
|
|
|
- }else if( action.equals( RequestConstant.SEARCH_STOP ) ){
|
|
|
- //type 可以为空搜索全部支持的设备
|
|
|
-// if( StringUtils.isEmpty( type ) ){
|
|
|
-// onGlobalResultListener.onResult( new SearchResultUtils(StatusConstant.PARAMS_ERROR).toJSONObject() );
|
|
|
-// return;
|
|
|
-// }
|
|
|
- stopSearch();
|
|
|
- //断开设备
|
|
|
- }else if( action.equals( RequestConstant.BLE_DISCONNECT ) ){
|
|
|
- if( StringUtils.isEmpty( model ) ){
|
|
|
- onGlobalResultListener.onResult( new SearchResultUtils(StatusConstant.PARAMS_ERROR).toJSONObject() );
|
|
|
- return;
|
|
|
- }
|
|
|
- disConnectDevice( model );
|
|
|
- //是否连接
|
|
|
- }else if( action.equals( RequestConstant.BLE_IS_CONNECTED ) ){
|
|
|
- if( StringUtils.isEmpty( model ) ){
|
|
|
- onGlobalResultListener.onResult( new SearchResultUtils(StatusConstant.PARAMS_ERROR).toJSONObject() );
|
|
|
- return;
|
|
|
- }
|
|
|
- isConnected( model );
|
|
|
- }else{
|
|
|
- if( StringUtils.isEmpty( model ) ){
|
|
|
- onGlobalResultListener.onResult( new SearchResultUtils(StatusConstant.PARAMS_ERROR).toJSONObject() );
|
|
|
- return;
|
|
|
- }
|
|
|
- operation( action, model, params, jsonObject -> {
|
|
|
+ startSearch(type, SCAN_TIMEOUT, jsonObject -> {
|
|
|
onGlobalResultListener.onResult(jsonObject);
|
|
|
});
|
|
|
- }
|
|
|
- } catch (JSONException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 请求数据
|
|
|
- * @param params
|
|
|
- */
|
|
|
- public void requestBT (JSONObject params){
|
|
|
- //监听检查
|
|
|
- if( onGlobalResultListener == null ){
|
|
|
- onGlobalResultListener.onResult( new SearchResultUtils(StatusConstant.NO_REGISTER_INTERFACE).toJSONObject() );
|
|
|
- return;
|
|
|
- }
|
|
|
- //权限检查
|
|
|
- JSONObject checkRes = checkPermission();
|
|
|
- if( checkRes != null ){
|
|
|
- onGlobalResultListener.onResult( checkRes );
|
|
|
- return;
|
|
|
- }
|
|
|
- //操作
|
|
|
- try {
|
|
|
- String action = params.has("ACTION") ? params.getString("ACTION") : "";
|
|
|
- String model = params.has("MODEL") ? params.getString("MODEL") : "";
|
|
|
- //String mac = params.has("MAC") ? params.getString("MAC") : "";
|
|
|
- String type = params.has("TYPE") ? params.getString("TYPE") : "";
|
|
|
- int SCAN_TIMEOUT = params.has("SCAN_TIMEOUT") ? params.getInt("SCAN_TIMEOUT") : ScanTimeOut;
|
|
|
- if( StringUtils.isEmpty( action ) ){
|
|
|
- onGlobalResultListener.onResult( new SearchResultUtils(StatusConstant.PARAMS_ERROR).toJSONObject() );
|
|
|
- return;
|
|
|
- }
|
|
|
- //开始搜索
|
|
|
- if( action.equals(RequestConstant.SEARCH_START ) ){
|
|
|
- //type 可以为空搜索全部支持的设备
|
|
|
-// if( StringUtils.isEmpty( type ) ){
|
|
|
-// onGlobalResultListener.onResult( new SearchResultUtils(StatusConstant.PARAMS_ERROR).toJSONObject() );
|
|
|
-// return;
|
|
|
-// }
|
|
|
+ //停止搜索
|
|
|
+ }else if (action.equals(RequestConstant.SEARCH_START_BT )) {
|
|
|
startSearchBT(type, SCAN_TIMEOUT, jsonObject -> {
|
|
|
onGlobalResultListener.onResult(jsonObject);
|
|
|
});
|
|
|
- //停止搜索
|
|
|
- }else if( action.equals( RequestConstant.SEARCH_STOP ) ){
|
|
|
+ }
|
|
|
+ else if( action.equals( RequestConstant.SEARCH_STOP ) ){
|
|
|
//type 可以为空搜索全部支持的设备
|
|
|
// if( StringUtils.isEmpty( type ) ){
|
|
|
// onGlobalResultListener.onResult( new SearchResultUtils(StatusConstant.PARAMS_ERROR).toJSONObject() );
|
|
@@ -170,14 +96,14 @@ public class VinnnoVnoteSdk extends BaseSdk{
|
|
|
// }
|
|
|
stopSearch();
|
|
|
//断开设备
|
|
|
- }else if( action.equals( RequestConstant.BT_DISCONNECT ) ){
|
|
|
+ }else if( action.equals( RequestConstant.BLE_DISCONNECT ) ){
|
|
|
if( StringUtils.isEmpty( model ) ){
|
|
|
onGlobalResultListener.onResult( new SearchResultUtils(StatusConstant.PARAMS_ERROR).toJSONObject() );
|
|
|
return;
|
|
|
}
|
|
|
disConnectDevice( model );
|
|
|
//是否连接
|
|
|
- }else if( action.equals( RequestConstant.BT_IS_CONNECTED ) ){
|
|
|
+ }else if( action.equals( RequestConstant.BLE_IS_CONNECTED ) ){
|
|
|
if( StringUtils.isEmpty( model ) ){
|
|
|
onGlobalResultListener.onResult( new SearchResultUtils(StatusConstant.PARAMS_ERROR).toJSONObject() );
|
|
|
return;
|
|
@@ -188,7 +114,7 @@ public class VinnnoVnoteSdk extends BaseSdk{
|
|
|
onGlobalResultListener.onResult( new SearchResultUtils(StatusConstant.PARAMS_ERROR).toJSONObject() );
|
|
|
return;
|
|
|
}
|
|
|
- operationBT( action, model, params, jsonObject -> {
|
|
|
+ operation( action, model, params, jsonObject -> {
|
|
|
onGlobalResultListener.onResult(jsonObject);
|
|
|
});
|
|
|
}
|
|
@@ -197,4 +123,5 @@ public class VinnnoVnoteSdk extends BaseSdk{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|