Skip to content

Commit

Permalink
开放接收参数
Browse files Browse the repository at this point in the history
  • Loading branch information
lxj-helloworld committed Aug 28, 2019
1 parent 59e2a46 commit 8914213
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ private void sendData() {
byte[] frame = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04};
DataSendBuffer.DATA_SEND_BUFFER.setDatasSendArr(frame);
HelpUtils.currentChannel = channelLoRa;

send();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ private void showError(String errorInfo){
}

private void parseBytes(byte[] bytes){

byte[] receiveBytes = dataRecieveBuffer.addItem (bytes);
Log.d(TAG,"in parseBytes receiveBytes = " + MethodsHelp.METHODS_HELP.byteToHexString(receiveBytes,receiveBytes.length));
Map map = new HashMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public enum HelpUtils {
//最大发送次数
public static final int maxWriteCount = 5;
//最大读取次数
public static final int maxReadCount = 40;
public static int maxReadCount = 20;
//收到报文后,连续收不到多少次后停止
public static final int maxSerialCount = 2;

//串口最小通信间隔 单位毫秒
public static final int minSerialInterval = 100;
public static int minSerialInterval = 100;
//每次发送接收时的最大字节个数
public static final int normalByteSize = 1024;
//当前通道
Expand All @@ -43,7 +43,8 @@ public enum HelpUtils {
public static final int channelNFC = 5;
//载波通道
public static final int channelZb = 6;

//LoRa音频通道
public static final int channelLoRaAudio = 7;

//标识当前传输的报文类型
public static int protocolType = 0;
Expand All @@ -60,4 +61,29 @@ public enum HelpUtils {
public static final int TYPE_NFC = 4;
//是否允许一直接收数据
public static boolean canReceiving = false;


public static int getMaxReadCount() {
return maxReadCount;
}

public static void setMaxReadCount(int maxReadCount) {
HelpUtils.maxReadCount = maxReadCount;
}

public static int getMinSerialInterval() {
return minSerialInterval;
}

public static void setMinSerialInterval(int minSerialInterval) {
HelpUtils.minSerialInterval = minSerialInterval;
}

public static int getMaxWriteCount() {
return maxWriteCount;
}

public static int getMaxSerialCount() {
return maxSerialCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static com.example.xiaojin20135.comlib.help.HelpUtils.channel485;
import static com.example.xiaojin20135.comlib.help.HelpUtils.channelFirared;
import static com.example.xiaojin20135.comlib.help.HelpUtils.channelLoRa;
import static com.example.xiaojin20135.comlib.help.HelpUtils.channelLoRaAudio;
import static com.example.xiaojin20135.comlib.help.HelpUtils.channelManage;
import static com.example.xiaojin20135.comlib.help.HelpUtils.channelNFC;
import static com.example.xiaojin20135.comlib.help.HelpUtils.channelNetPort;
Expand Down Expand Up @@ -114,9 +115,12 @@ public void subscribe (ObservableEmitter<Integer> emitter) throws Exception {
}else if(HelpUtils.currentChannel == channelLoRa){
datasLen = JniMethods.LoraWrite(toSendArr,toSendArr.length);
Log.d (TAG,"LoRa通道 发送 dataLen = " + datasLen);
}else if(HelpUtils.currentChannel == channelLoRaAudio){
datasLen = JniMethods.AudioWrite(toSendArr,toSendArr.length);
Log.d (TAG,"LoRa音频通道 发送 dataLen = " + datasLen);
}
}
Thread.sleep (1);
Thread.sleep (0);
}catch (InterruptedException e){
if(!emitter.isDisposed ()){
emitter.onError (e);
Expand Down Expand Up @@ -180,6 +184,10 @@ public void subscribe (ObservableEmitter<byte[]> emitter) throws Exception {
datas = new byte[255];
length = JniMethods.LoraRead(datas,255);
Log.d (TAG,"LoRa通道 接收 length = " + length);
}else if(HelpUtils.currentChannel == channelLoRaAudio){
datas = new byte[255];
length = JniMethods.AudioRead(datas,255);
Log.d (TAG,"LoRa音频通道 接收 length = " + length);
}
if(length > 0){
Log.d(TAG,"当前已收到的报文长度 currentLen = " + currentLen);
Expand Down Expand Up @@ -257,6 +265,10 @@ public void subscribe (ObservableEmitter<byte[]> emitter) throws Exception {
datas = new byte[255];
length = JniMethods.LoraRead(datas,255);
Log.d (TAG,"LoRa通道 接收 length = " + length);
}else if(HelpUtils.currentChannel == channelLoRa){
datas = new byte[255];
length = JniMethods.LoraRead(datas,255);
Log.d (TAG,"LoRa通道 接收 length = " + length);
}
if(length > 0){
Log.d(TAG,"本次收到 = " + MethodsHelp.METHODS_HELP.byteToHexString(datas,length));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ public static void initPort(File device) throws SecurityException, IOException {
public static native int LoraWrite(byte[] bytesArr,int len);


public static native int AudioRead(byte[] bytesArr,int len);
public static native int AudioWrite(byte[] bytesArr,int len);


//设置中心频率
public static native int LoRaSetFrequency(int freq);
//设置扩频因子
Expand Down

0 comments on commit 8914213

Please sign in to comment.