Browse Source

fetching 6 axis sensor data

master
Krish 1 year ago
parent
commit
d3d3b3b33c
2 changed files with 71 additions and 36 deletions
  1. +66
    -36
      app/src/main/java/com/example/beacondemo/Activity/DetailActivity.java
  2. +5
    -0
      app/src/main/res/drawable/mybutton.xml

+ 66
- 36
app/src/main/java/com/example/beacondemo/Activity/DetailActivity.java View File

@ -29,6 +29,7 @@ import com.minew.beaconplus.sdk.MTConnectionFeature;
import com.minew.beaconplus.sdk.MTConnectionHandler;
import com.minew.beaconplus.sdk.MTFrameHandler;
import com.minew.beaconplus.sdk.MTPeripheral;
import com.minew.beaconplus.sdk.Utils.Tools;
import com.minew.beaconplus.sdk.enums.ConnectState;
import com.minew.beaconplus.sdk.enums.FeatureSupported;
import com.minew.beaconplus.sdk.enums.FrameType;
@ -52,7 +53,12 @@ import com.minew.beaconplus.sdk.frames.TvocFrame;
import com.minew.beaconplus.sdk.frames.UidFrame;
import com.minew.beaconplus.sdk.frames.UrlFrame;
import com.minew.beaconplus.sdk.interfaces.MTCentralManagerListener;
import com.minew.beaconplus.sdk.interfaces.MTSensorOperateCallback;
import com.minew.beaconplus.sdk.interfaces.SetTriggerListener;
import com.minew.beaconplus.sdk.model.SensorAPModel;
import com.minew.beaconplus.sdk.model.SensorHTModel;
import com.minew.beaconplus.sdk.model.SensorMAGModel;
import com.minew.beaconplus.sdk.model.SensorSixAxisModel;
import com.minew.beaconplus.sdk.model.Trigger;
import java.util.ArrayList;
@ -97,13 +103,10 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis
sharedPreferences = getSharedPreferences(SHARED_PREF_NAME,MODE_PRIVATE);
initView();
initData();
initListener();
tv_resetPass.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -207,6 +210,9 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis
mRecycle.setAdapter(mAdapter);
}
long longtime = System.currentTimeMillis();
int time = (int) (longtime / 1000);
byte[] curTime = Tools.intToBytes(time);
private void initData() {
mtPeripheral = MainActivity.mtPeripheral;
@ -376,40 +382,63 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis
}
});
/*MTConnectionHandler mtConnectionHandler = mtPeripheral.mMTConnectionHandler;
ConnectState connectState = mtConnectionHandler.getConnectState();
// password require or not. None, Require
PasswordState passwordState = mMTConnectionHandler.getPasswordState();
// device info, such asFirmware Version 0.9.1;
HashMap<String, String> systeminfos = (HashMap<String, String>) mMTConnectionHandler.systeminfos;
String manufacturer = systeminfos.get(SyncStateContract.Constants.manufacturer);
String modlenumber = systeminfos.get(Constants.modlenumber);
String macAddress = systeminfos.get(Constants.serialnumber);
String hardware = systeminfos.get(Constants.hardware);
String firmware = systeminfos.get(Constants.firmware);
String software = systeminfos.get(Constants.software);*/
// device features
/*MTConnectionFeature mtConnectionFeature = mMTConnectionHandler.mTConnectionFeature;
// atitude of slot(s),
int slotAtitude = mtConnectionFeature.getSlotAtitude();
Log.d("slotAtitude", String.valueOf(slotAtitude));
// parameters can be modifiednoneadv,txpower,adv/txpower
FeatureSupported featureSupported = mtConnectionFeature.getFeatureSupported();
Log.d("featureSupported", String.valueOf(featureSupported));
// // frames supportedmultiple
List<FrameType> supportedSlots = mtConnectionFeature.getSupportedSlots();
Log.d("supportedSlots", String.valueOf(supportedSlots));
// Txpower supportedmultiple
byte[] supportedTxpowers = mtConnectionFeature.getSupportedTxpowers();
Log.d("supportedTxpowers", String.valueOf(supportedTxpowers));
// trigger supportedmultiple
ArrayList<TriggerType> supportTriggers = (ArrayList<TriggerType>) mtConnectionFeature.supportTriggers;
Log.d("supportTriggers", String.valueOf(supportTriggers));
// Version of firmware;
Version version = mtConnectionFeature.getVersion();
Log.d("version", String.valueOf(version));*/
// Six-axis sensor data from the device
// Sensor data from the magnetometer on the device
magnetometer();
// From the atmospheric pressure sensor data on the device
atmosphesricPressure();
}
public void sensorData(){
mMTConnectionHandler.getMtSensorHandler().readLSMHistory(Tools.intToBytes(time),
(MTSensorOperateCallback<SensorSixAxisModel>) sensorSixAxisModel -> {
int date = sensorSixAxisModel.getDate();// Unix timestamp of this data
System.out.println("Date: " + date);
double A_XAxis = sensorSixAxisModel.getA_XAxis();
double A_YAxis = sensorSixAxisModel.getA_YAxis();
double A_ZAxis = sensorSixAxisModel.getA_ZAxis();
double D_XAxis = sensorSixAxisModel.getD_XAxis();
double D_YAxis = sensorSixAxisModel.getD_YAxis();
double D_ZAxis = sensorSixAxisModel.getD_ZAxis();
System.out.println("Six axis sensor data: " + A_XAxis + " " + A_YAxis + " " + A_ZAxis + " " + D_XAxis + " " + D_YAxis + " " + D_ZAxis);
});
}
public void magnetometer(){
mMTConnectionHandler.getMtSensorHandler().readLISHistory(Tools.intToBytes(time),
new MTSensorOperateCallback<SensorMAGModel>() {
@Override
public void onResult(SensorMAGModel sensorMAGModel) {
int date = sensorMAGModel.getDate();// Unix timestamp of this data
double A_XAxis = sensorMAGModel.getXAxis();
double A_YAxis = sensorMAGModel.getYAxis();
double A_ZAxis = sensorMAGModel.getZAxis();
System.out.println("Data from magnetometer: " + A_XAxis + " " + A_YAxis + " " + A_ZAxis) ;
}
});
}
public void atmosphesricPressure(){
mMTConnectionHandler.getMtSensorHandler().readDPSHistory(Tools.intToBytes(time),
new MTSensorOperateCallback<SensorAPModel>() {
@Override
public void onResult(SensorAPModel sensorAPModel) {
int date = sensorAPModel.getDate();// Unix timestamp of this data
double pressure = sensorAPModel.getPressure();
System.out.println("Pressure: " +pressure) ;
}
});
}
private void initListener() {
ivBack.setOnClickListener(this);
@ -473,6 +502,7 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis
finish();
break;
case R.id.tv_set:
sensorData();
//saveTrigger();
break;
default:


+ 5
- 0
app/src/main/res/drawable/mybutton.xml View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="40dp"/>
<solid android:color="#58857e"></solid>
</shape>

Loading…
Cancel
Save