Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native-ble-plx 라이브러리 변경 필요 #28

Open
1 of 2 tasks
seh9306 opened this issue Nov 9, 2018 · 2 comments
Open
1 of 2 tasks

react-native-ble-plx 라이브러리 변경 필요 #28

seh9306 opened this issue Nov 9, 2018 · 2 comments

Comments

@seh9306
Copy link
Collaborator

seh9306 commented Nov 9, 2018

  • 라이브러리를 이용하여 값을 수신할 경우현재 Base64 인코딩과 데이터 수신 방식 변경 방법 찾기

  • 최종적 어플리케이션 개발에 적용시키기

@seh9306
Copy link
Collaborator Author

seh9306 commented Nov 9, 2018

react-native-ble-plx
com.polidea.reactnativeble.wrapper.Characteristic.java

public WritableMap toJSObject(byte[] value)

js.putString(Metadata.VALUE, value != null ? Base64Converter.encode(value) : null);

위 코드를

if(value!= null || value.length > 2){
int i = 0;
if(value[1] < 0){
i = value[1]*-1+(128+value[1])*2;
}else {
i = value[1];
}
String temp = new Integer(i).toString();
js.putString(Metadata.VALUE, temp);
}

로 변경

최종 개발 후

@seh9306
Copy link
Collaborator Author

seh9306 commented Nov 11, 2018

com.polidea.reactnativeble.wrapper.Characteristic.java

Metadata에

String BPM = "bpm";

추가한다.

public WritableMap toJSObject(byte[] value)

js.putString(Metadata.VALUE, value != null ? Base64Converter.encode(value) : null);
if(value!= null || value.length == 2){
int i = 0;
if(value[1] < 0){
i = 256+value[1];
}else {
i = value[1];
}
String temp = new Integer(i).toString();
js.putString(Metadata.BPM, temp);
}

변경하지 않고 추가한다. BleError가 발생할 수 있기 때문에 오버라이드 혹은 메소드를 새로 생성하고

BleModule.java 파일의 1287 line에

jsResult.pushMap(characteristic.toJSObject(bytes));

jsResult.pushMap(characteristic.toJSObjectBPM(bytes));

이나

jsResult.pushMap(characteristic.toJSObject(bytes, 0));

같이 변경한다.

Characteristic.js 파일에

bpm : String

추가

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant