fetching 6 axis sensor data
This commit is contained in:
parent
355b6e5153
commit
d3d3b3b33c
@ -29,6 +29,7 @@ import com.minew.beaconplus.sdk.MTConnectionFeature;
|
|||||||
import com.minew.beaconplus.sdk.MTConnectionHandler;
|
import com.minew.beaconplus.sdk.MTConnectionHandler;
|
||||||
import com.minew.beaconplus.sdk.MTFrameHandler;
|
import com.minew.beaconplus.sdk.MTFrameHandler;
|
||||||
import com.minew.beaconplus.sdk.MTPeripheral;
|
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.ConnectState;
|
||||||
import com.minew.beaconplus.sdk.enums.FeatureSupported;
|
import com.minew.beaconplus.sdk.enums.FeatureSupported;
|
||||||
import com.minew.beaconplus.sdk.enums.FrameType;
|
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.UidFrame;
|
||||||
import com.minew.beaconplus.sdk.frames.UrlFrame;
|
import com.minew.beaconplus.sdk.frames.UrlFrame;
|
||||||
import com.minew.beaconplus.sdk.interfaces.MTCentralManagerListener;
|
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.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 com.minew.beaconplus.sdk.model.Trigger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -97,13 +103,10 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis
|
|||||||
|
|
||||||
sharedPreferences = getSharedPreferences(SHARED_PREF_NAME,MODE_PRIVATE);
|
sharedPreferences = getSharedPreferences(SHARED_PREF_NAME,MODE_PRIVATE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
initView();
|
initView();
|
||||||
initData();
|
initData();
|
||||||
initListener();
|
initListener();
|
||||||
|
|
||||||
|
|
||||||
tv_resetPass.setOnClickListener(new View.OnClickListener() {
|
tv_resetPass.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
@ -207,6 +210,9 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis
|
|||||||
mRecycle.setAdapter(mAdapter);
|
mRecycle.setAdapter(mAdapter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
long longtime = System.currentTimeMillis();
|
||||||
|
int time = (int) (longtime / 1000);
|
||||||
|
byte[] curTime = Tools.intToBytes(time);
|
||||||
|
|
||||||
private void initData() {
|
private void initData() {
|
||||||
mtPeripheral = MainActivity.mtPeripheral;
|
mtPeripheral = MainActivity.mtPeripheral;
|
||||||
@ -376,41 +382,64 @@ 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 as:(Firmware 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();
|
// Six-axis sensor data from the device
|
||||||
Log.d("slotAtitude", String.valueOf(slotAtitude));
|
|
||||||
// parameters can be modified:none,adv,txpower,adv/txpower
|
// Sensor data from the magnetometer on the device
|
||||||
FeatureSupported featureSupported = mtConnectionFeature.getFeatureSupported();
|
magnetometer();
|
||||||
Log.d("featureSupported", String.valueOf(featureSupported));
|
// From the atmospheric pressure sensor data on the device
|
||||||
// // frames supported(multiple)
|
atmosphesricPressure();
|
||||||
List<FrameType> supportedSlots = mtConnectionFeature.getSupportedSlots();
|
|
||||||
Log.d("supportedSlots", String.valueOf(supportedSlots));
|
|
||||||
// Txpower supported(multiple)
|
|
||||||
byte[] supportedTxpowers = mtConnectionFeature.getSupportedTxpowers();
|
|
||||||
Log.d("supportedTxpowers", String.valueOf(supportedTxpowers));
|
|
||||||
// trigger supported(multiple)
|
|
||||||
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));*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
private void initListener() {
|
||||||
ivBack.setOnClickListener(this);
|
ivBack.setOnClickListener(this);
|
||||||
tvSet.setOnClickListener(this);
|
tvSet.setOnClickListener(this);
|
||||||
@ -473,6 +502,7 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis
|
|||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
case R.id.tv_set:
|
case R.id.tv_set:
|
||||||
|
sensorData();
|
||||||
//saveTrigger();
|
//saveTrigger();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
5
app/src/main/res/drawable/mybutton.xml
Normal file
5
app/src/main/res/drawable/mybutton.xml
Normal 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…
x
Reference in New Issue
Block a user