@@ -35,10 +35,16 @@ dependencies { | |||
implementation 'androidx.appcompat:appcompat:1.1.0' | |||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | |||
testImplementation 'junit:junit:4.12' | |||
implementation 'com.github.elinkthings:AILinkSDKRepositoryAndroid:1.8.0'//蓝牙核心库 | |||
implementation 'com.github.elinkthings:AILinkSDKRepositoryAndroid:1.8.2'//蓝牙核心库 | |||
implementation 'com.github.elinkthings:AILinkSDKOtaLibraryAndroid:1.0.3'//OTA库,需要依赖核心库 | |||
implementation 'com.github.elinkthings:AILinkSDKParsingLibraryAndroid:1.5.7'//解析库,需要依赖核心库 | |||
implementation 'com.github.elinkthings:AILinkSDKParsingLibraryAndroid:1.6.1'//解析库,需要依赖核心库 | |||
implementation 'androidx.recyclerview:recyclerview:1.1.0' | |||
implementation 'com.jakewharton:butterknife:10.2.0' | |||
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0' | |||
api 'com.squareup.retrofit2:converter-gson:2.5.0' | |||
} | |||
@@ -64,6 +64,8 @@ | |||
<activity android:name=".BroadcastBloodOxygenActivity" /> | |||
<activity android:name=".SmartMaskActivity" /> | |||
<activity android:name=".ToothBrushWifiBleActivity" /> | |||
<activity android:name=".HeightWeightScaleActivity" /> | |||
<activity android:name=".RopeSkippingActivity" /> | |||
<service android:name="com.pingwang.bluetoothlib.server.ELinkBleServer"/> | |||
</application> |
@@ -60,7 +60,6 @@ public class HeightWeightScaleActivity extends BleBaseActivity implements OnCall | |||
if (bleDevice != null) { | |||
HeightBodyFatBleData.init(bleDevice); | |||
HeightBodyFatBleData.getInstance().setOnHeightBodyFatDataCallback(this); | |||
HeightBodyFatBleData.getInstance().setOnHeightBodyFatDataCallback(this); | |||
} | |||
} | |||
@@ -116,7 +115,9 @@ public class HeightWeightScaleActivity extends BleBaseActivity implements OnCall | |||
@Override | |||
public void onScanning(BleValueBean data) { | |||
if (data.getMac().equalsIgnoreCase(mAddress)){ | |||
connectBle(data.getMac()); | |||
} | |||
} | |||
@@ -135,6 +136,7 @@ public class HeightWeightScaleActivity extends BleBaseActivity implements OnCall | |||
if (mac.equals(mAddress)) { | |||
logList.add(0, "连接已经断开"); | |||
listAdapter.notifyDataSetChanged(); | |||
startScanBle(0); | |||
} | |||
@@ -147,7 +149,11 @@ public class HeightWeightScaleActivity extends BleBaseActivity implements OnCall | |||
@Override | |||
public void onServicesDiscovered(String mac) { | |||
BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||
if (bleDevice != null) { | |||
HeightBodyFatBleData.init(bleDevice); | |||
HeightBodyFatBleData.getInstance().setOnHeightBodyFatDataCallback(this); | |||
} | |||
} | |||
@@ -118,6 +118,7 @@ public class MainActivity extends BleAppBaseActivity { | |||
mList.add(findViewById(R.id.btn_food_temp)); | |||
mList.add(findViewById(R.id.btn_temp_humidity)); | |||
mList.add(findViewById(R.id.btn_share_condom)); | |||
mList.add(findViewById(R.id.btn_rope_skip)); | |||
for (View view : mList) { | |||
view.setOnClickListener(listener); | |||
} | |||
@@ -286,6 +287,9 @@ public class MainActivity extends BleAppBaseActivity { | |||
case R.id.btn_temp_humidity: | |||
type= BleDeviceConfig.TEMP_Humidity; | |||
break; | |||
case R.id.btn_rope_skip: | |||
type=BleDeviceConfig.ROPE_SKIPPING; | |||
break; | |||
} | |||
startActivity(type); |
@@ -0,0 +1,238 @@ | |||
package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||
import android.os.Bundle; | |||
import android.view.View; | |||
import android.widget.ArrayAdapter; | |||
import android.widget.ListView; | |||
import androidx.annotation.Nullable; | |||
import com.google.gson.Gson; | |||
import com.pingwang.bluetoothlib.device.BleDevice; | |||
import com.pingwang.bluetoothlib.listener.OnCallbackBle; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | |||
import cn.net.aicare.modulelibrary.module.RopeSkipping.OnRopeSkipCallBack; | |||
import cn.net.aicare.modulelibrary.module.RopeSkipping.RopeSkipRecord; | |||
import cn.net.aicare.modulelibrary.module.RopeSkipping.RopeSkippingBleData; | |||
public class RopeSkippingActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, OnRopeSkipCallBack { | |||
private List<String> logList; | |||
private ArrayAdapter mArrayAdapter; | |||
private ListView listviw; | |||
private String mAddress; | |||
private boolean isPauseLog = false; | |||
@Override | |||
public void onServiceSuccess() { | |||
mBluetoothService.setOnCallback(this); | |||
logList.add("绑定服务成功"); | |||
if (mBluetoothService != null) { | |||
mBluetoothService.setOnCallback(this); | |||
BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||
if (bleDevice != null) { | |||
RopeSkippingBleData.init(bleDevice); | |||
RopeSkippingBleData.getInstance().setOnRopeSkipCallBack(this); | |||
} | |||
} | |||
} | |||
@Override | |||
public void onServiceErr() { | |||
if (mArrayAdapter != null && logList != null) { | |||
refreshLog("绑定服务失败"); | |||
} | |||
} | |||
@Override | |||
public void unbindServices() { | |||
if (mArrayAdapter != null && logList != null) { | |||
refreshLog("解除绑定服务"); | |||
} | |||
} | |||
@Override | |||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
mAddress = getIntent().getStringExtra("mac"); | |||
setContentView(R.layout.activity_rope_skipping); | |||
listviw = findViewById(R.id.listview); | |||
findViewById(R.id.btn_syn_time).setOnClickListener(this); | |||
findViewById(R.id.btn_free_jump).setOnClickListener(this); | |||
findViewById(R.id.btn_time_jump).setOnClickListener(this); | |||
findViewById(R.id.btn_num_jump).setOnClickListener(this); | |||
findViewById(R.id.btn_stop_free_jump).setOnClickListener(this); | |||
findViewById(R.id.btn_stop_time_jump).setOnClickListener(this); | |||
findViewById(R.id.btn_stop_num_jump).setOnClickListener(this); | |||
findViewById(R.id.btn_get_history).setOnClickListener(this); | |||
findViewById(R.id.btn_clear_log).setOnClickListener(this); | |||
findViewById(R.id.btn_default_timer).setOnClickListener(this); | |||
findViewById(R.id.btn_default_num).setOnClickListener(this); | |||
findViewById(R.id.btn_bind).setOnClickListener(this); | |||
logList = new ArrayList<>(); | |||
mArrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, logList); | |||
listviw.setAdapter(mArrayAdapter); | |||
} | |||
@Override | |||
public void onClick(View v) { | |||
if (v.getId() == R.id.btn_syn_time) { | |||
if (RopeSkippingBleData.getInstance() != null) { | |||
RopeSkippingBleData.getInstance().synTime(System.currentTimeMillis()); | |||
} | |||
refreshLog("同步时间搓"); | |||
} else if (v.getId() == R.id.btn_free_jump) { | |||
if (RopeSkippingBleData.getInstance() != null) { | |||
RopeSkippingBleData.getInstance().startOrStopMode(1, 1); | |||
} | |||
refreshLog("启动自由跳绳"); | |||
} else if (v.getId() == R.id.btn_time_jump) { | |||
if (RopeSkippingBleData.getInstance() != null) { | |||
RopeSkippingBleData.getInstance().startOrStopMode(2, 1); | |||
} | |||
refreshLog("启动倒计时跳绳"); | |||
} else if (v.getId() == R.id.btn_num_jump) { | |||
if (RopeSkippingBleData.getInstance() != null) { | |||
RopeSkippingBleData.getInstance().startOrStopMode(3, 1); | |||
} | |||
refreshLog("启动倒计数跳绳绳"); | |||
} else if (v.getId() == R.id.btn_clear_log) { | |||
if (!isPauseLog) { | |||
isPauseLog = true; | |||
} else { | |||
isPauseLog = false; | |||
} | |||
} else if (v.getId() == R.id.btn_stop_free_jump) { | |||
if (RopeSkippingBleData.getInstance() != null) { | |||
RopeSkippingBleData.getInstance().startOrStopMode(1, 0); | |||
} | |||
refreshLog("结束自由跳绳"); | |||
} else if (v.getId() == R.id.btn_stop_time_jump) { | |||
if (RopeSkippingBleData.getInstance() != null) { | |||
RopeSkippingBleData.getInstance().startOrStopMode(2, 0); | |||
} | |||
refreshLog("结束倒计时跳绳"); | |||
} else if (v.getId() == R.id.btn_stop_num_jump) { | |||
if (RopeSkippingBleData.getInstance() != null) { | |||
RopeSkippingBleData.getInstance().startOrStopMode(3, 0); | |||
} | |||
refreshLog("结束倒计数跳绳绳"); | |||
} else if (v.getId() == R.id.btn_default_num) { | |||
if (RopeSkippingBleData.getInstance() != null) { | |||
RopeSkippingBleData.getInstance().setCountDownNum(50); | |||
} | |||
refreshLog("默认倒计数100"); | |||
} else if (v.getId() == R.id.btn_default_timer) { | |||
if (RopeSkippingBleData.getInstance() != null) { | |||
RopeSkippingBleData.getInstance().setTimerNum(120); | |||
} | |||
refreshLog("默认倒计时60"); | |||
} else if (v.getId() == R.id.btn_get_history) { | |||
if (RopeSkippingBleData.getInstance() != null) { | |||
RopeSkippingBleData.getInstance().offlineHistory(1); | |||
} | |||
refreshLog("获取离线记录"); | |||
} else if (v.getId() == R.id.btn_bind) { | |||
if (RopeSkippingBleData.getInstance() != null) { | |||
RopeSkippingBleData.getInstance().questBind(); | |||
} | |||
refreshLog("请按确认按钮"); | |||
} | |||
} | |||
private void refreshLog(String content) { | |||
if (!isPauseLog) { | |||
logList.add(content); | |||
mArrayAdapter.notifyDataSetChanged(); | |||
} | |||
} | |||
@Override | |||
public void onFinish(RopeSkipRecord ropeSkipBean) { | |||
refreshLog("跳绳结束" + "\n" + ropeSkipBean.toString() + " \n绊绳=" + new Gson().toJson(ropeSkipBean.getStopDetail())); | |||
} | |||
@Override | |||
public void onBattery(int battery) { | |||
} | |||
@Override | |||
public void onCurrentData(int status, int mode, int defaultValue, int currentJumpNum, int currentJumpTime, int batter) { | |||
refreshLog("实时数据 \n" + "状态: " + status + " ( 0:准备 1:进行中 2:完成) \n" + "模式: " | |||
+ mode + " (1:自由 2:倒计时 3:倒计数) \n" | |||
+ "默认值: " + defaultValue + " 电量 " + batter + "\n 当前个数: " + currentJumpNum + " 时间 " + currentJumpTime); | |||
} | |||
@Override | |||
public void onResultTimerAndCountDownNum(int mode, int timer) { | |||
if (mode == 2) { | |||
refreshLog("设置默认时间:" + timer); | |||
} else if (mode == 3) { | |||
refreshLog("设置默认个数:" + timer); | |||
} | |||
} | |||
@Override | |||
public void onResultStatus(int mode, int result) { | |||
refreshLog("模式: " + mode + " (1:自由 2:倒计时 3:倒计数)" + "结果: " + result + "0:成功 1:失败 2:不支持"); | |||
} | |||
@Override | |||
public void onBindResult(int result) { | |||
refreshLog("确认绑定结果: " + result + " 0 : 成功 1 :失败 2 不支持"); | |||
} | |||
@Override | |||
public void onFinishOffHistory(List<RopeSkipRecord> list) { | |||
if (list == null) { | |||
refreshLog("没有离线记录"); | |||
} else { | |||
refreshLog("离线记录:\n" + new Gson().toJson(list)); | |||
} | |||
} | |||
@Override | |||
public void finish() { | |||
super.finish(); | |||
if (mBluetoothService != null) | |||
mBluetoothService.disconnectAll(); | |||
} | |||
} |
@@ -410,6 +410,11 @@ public class ShowBleActivity extends AppCompatActivity implements OnCallbackBle, | |||
case BleDeviceConfig.TEMP_Humidity: | |||
intent.setClass(ShowBleActivity.this, TempHumidityActivity.class); | |||
break; | |||
case BleDeviceConfig.ROPE_SKIPPING: | |||
intent.setClass(ShowBleActivity.this, RopeSkippingActivity.class); | |||
break; | |||
// case BleDeviceConfig.BLD_WEIGHT: | |||
// intent.setClass(ShowBleActivity.this, BLDWeightScaleBle.class); | |||
// break; |
@@ -221,7 +221,7 @@ public class ToothBrushWifiBleActivity extends BleBaseActivity implements View.O | |||
mMHandler.sendEmptyMessage(ConnectWifi); | |||
} | |||
} | |||
if (type == CmdConfig.DISORCONNECTWIFI) { | |||
if (type == CmdConfig.DISCONNECT_WIFI) { | |||
mList.add(0, "发起连接 " + status); | |||
mMHandler.sendEmptyMessage(ToRefreUi); | |||
} |
@@ -124,11 +124,13 @@ public class TransmissionActivity extends BleBaseActivity implements View.OnClic | |||
} | |||
@Override | |||
public void showdata(String data) { | |||
public void showdata(String data, int type) { | |||
mlogList.add(0, "收 payload数据"+ TimeUtils.getTime()+data); | |||
mMHandler.sendEmptyMessage(ToRefreUi); | |||
} | |||
@Override | |||
public void onSupportUnit(List<SupportUnitBean> list) { | |||
@@ -446,11 +446,31 @@ public class WeightScaleBleActivity extends BleBaseActivity implements View.OnCl | |||
} | |||
@Override | |||
public void onSetPortStatus(int status) { | |||
} | |||
@Override | |||
public void onSetIpUrlStatus(int status) { | |||
} | |||
@Override | |||
public void onIpData(String ip) { | |||
} | |||
@Override | |||
public void onPortData(int port) { | |||
} | |||
@Override | |||
public void onUrlData(String url) { | |||
} | |||
@Override | |||
public void onClick(View v) { |
@@ -52,28 +52,15 @@ public class WeightScaleWifiBleActivity extends BleBaseActivity implements View. | |||
private MHandler mMHandler; | |||
private EditText mEditText; | |||
private RadioButton kg, jing, stlb, lb; | |||
private byte[] testIp = new byte[]{0x74, | |||
0x65, 0x73, 0x74, 0x2e, | |||
0x61, 0x69, 0x6c, 0x69, | |||
0x6e, 0x6b, 0x2e, 0x72, | |||
0x65, 0x76, 0x69, 0x63, | |||
0x65, 0x2e, 0x61, 0x69, | |||
0x63, 0x61, 0x72, 0x65, | |||
0x2e, 0x6e, 0x65, 0x74, | |||
0x2e, 0x63, 0x6e}; | |||
private byte[] productIp = new byte[]{ | |||
0x61, 0x69, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, | |||
0x69, 0x6f, 0x74, 0x2e, 0x61, 0x69, 0x63, | |||
0x61, 0x72, 0x65, 0x2e, 0x6e, 0x65, 0x74, | |||
0x2e, 0x63, 0x6e}; | |||
private byte[] IpUrl = new byte[]{ | |||
0x2f, 0x64, 0x65, 0x76, 0x69, | |||
0x76, 0x63, 0x64, 0x2f, 0x73, | |||
0x65, 0x72, 0x76, 0x64, 0x72, | |||
0x52, 0x65, 0x64, 0x69, 0x72, | |||
0x65, 0x63, 0x74, 0x2f}; | |||
private EditText et_ip, et_url, et_port; | |||
private byte[] testIp = new byte[]{0x74, 0x65, 0x73, 0x74, 0x2e, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x72, 0x65, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x61, 0x69, 0x63, 0x61, 0x72, 0x65, 0x2e, | |||
0x6e, 0x65, 0x74, 0x2e, 0x63, 0x6e}; | |||
private byte[] productIp = new byte[]{0x61, 0x69, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x69, 0x6f, 0x74, 0x2e, 0x61, 0x69, 0x63, 0x61, 0x72, 0x65, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x63, 0x6e}; | |||
private byte[] IpUrl = new byte[]{0x2f, 0x64, 0x65, 0x76, 0x69, 0x76, 0x63, 0x64, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x64, 0x72, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x2f}; | |||
private boolean isTest = false; | |||
@Override | |||
@@ -91,6 +78,13 @@ public class WeightScaleWifiBleActivity extends BleBaseActivity implements View. | |||
findViewById(R.id.setedmac).setOnClickListener(this); | |||
findViewById(R.id.ota).setOnClickListener(this); | |||
findViewById(R.id.surroundings).setOnClickListener(this); | |||
findViewById(R.id.check_ip).setOnClickListener(this); | |||
findViewById(R.id.check_port).setOnClickListener(this); | |||
findViewById(R.id.check_url).setOnClickListener(this); | |||
et_ip = findViewById(R.id.et_ip); | |||
et_port = findViewById(R.id.et_port); | |||
et_url = findViewById(R.id.et_url); | |||
mEditText = findViewById(R.id.select_wifi_et); | |||
kg = findViewById(R.id.kg); | |||
jing = findViewById(R.id.jin); | |||
@@ -137,6 +131,7 @@ public class WeightScaleWifiBleActivity extends BleBaseActivity implements View. | |||
} | |||
}); | |||
} | |||
@@ -460,7 +455,7 @@ public class WeightScaleWifiBleActivity extends BleBaseActivity implements View. | |||
*/ | |||
@Override | |||
public void OnSetWifiNameOrPwdOrConnectCallback(int type, int status) { | |||
if (type == BodyFatDataUtil.SET_WIFI_MAC) { | |||
if (type == CmdConfig.SET_WIFI_MAC) { | |||
mList.add(0, "获取到设置的mac地址状态 " + status); | |||
if (status == BodyFatDataUtil.STATUS_SUCCESS) { | |||
issetMac = true; | |||
@@ -469,14 +464,14 @@ public class WeightScaleWifiBleActivity extends BleBaseActivity implements View. | |||
} | |||
} | |||
if (type == BodyFatDataUtil.SET_WIFI_PAW) { | |||
if (type == CmdConfig.SET_WIFI_PAW) { | |||
mList.add(0, "获取到设置的密码状态 " + status); | |||
if (status == BodyFatDataUtil.STATUS_SUCCESS && issetMac) { | |||
mMHandler.sendEmptyMessage(ConnectWifi); | |||
} | |||
} | |||
if (type == BodyFatDataUtil.DIS_OR_CON_WIFI) { | |||
if (type == CmdConfig.DIS_OR_CON_WIFI) { | |||
mList.add(0, "发起连接 " + status); | |||
mMHandler.sendEmptyMessage(ToRefreUi); | |||
} | |||
@@ -504,15 +499,24 @@ public class WeightScaleWifiBleActivity extends BleBaseActivity implements View. | |||
@Override | |||
public void onSetIpStatus(int status) { | |||
// if (status == 0) { | |||
// if (isTest) { | |||
// mList.add(0, "设置环境IP为生产环境成功"); | |||
// mList.add(0, "设置环境路径为生产环境"); | |||
// } else { | |||
// mList.add(0, "设置环境IP为测试环境成功"); | |||
// mList.add(0, "设置环境路径为测试环境"); | |||
// } | |||
// setIpUrl(IpUrl); | |||
// } else { | |||
// mList.add(0, "设置环境IP失败"); | |||
// } | |||
// listAdapter.notifyDataSetChanged(); | |||
if (status == 0) { | |||
if (isTest) { | |||
mList.add(0, "设置环境IP为生产环境成功"); | |||
mList.add(0, "设置环境路径为生产环境"); | |||
} else { | |||
mList.add(0, "设置环境IP为测试环境成功"); | |||
mList.add(0, "设置环境路径为测试环境"); | |||
} | |||
setIpUrl(IpUrl); | |||
mList.add(0, "设置环境IP成功"); | |||
int port = Integer.parseInt(et_port.getText().toString()); | |||
mList.add(0, "设置环境端口为:" + port); | |||
setPort(port); | |||
} else { | |||
mList.add(0, "设置环境IP失败"); | |||
} | |||
@@ -520,23 +524,60 @@ public class WeightScaleWifiBleActivity extends BleBaseActivity implements View. | |||
} | |||
@Override | |||
public void onSetIpUrlStatus(int status) { | |||
public void onSetPortStatus(int status) { | |||
if (status == 0) { | |||
if (isTest) { | |||
mList.add(0, "设置环境路径为生产环境成功"); | |||
isTest = false; | |||
} else { | |||
mList.add(0, "设置环境路径为测试环境成功"); | |||
isTest = true; | |||
mList.add(0, "设置环境端口成功"); | |||
String ipUrlStr = et_url.getText().toString(); | |||
mList.add(0, "设置环境url为:" + ipUrlStr); | |||
setIpUrl(convertToASCII(ipUrlStr)); | |||
} else { | |||
mList.add(0, "设置环境端口失败"); | |||
} | |||
listAdapter.notifyDataSetChanged(); | |||
} | |||
} | |||
@Override | |||
public void onSetIpUrlStatus(int status) { | |||
// if (status == 0) { | |||
// if (isTest) { | |||
// mList.add(0, "设置环境路径为生产环境成功"); | |||
// isTest = false; | |||
// | |||
// } else { | |||
// mList.add(0, "设置环境路径为测试环境成功"); | |||
// isTest = true; | |||
// | |||
// } | |||
// } else { | |||
// mList.add(0, "设置环境路径失败"); | |||
// } | |||
// listAdapter.notifyDataSetChanged(); | |||
if (status == 0) { | |||
mList.add(0, "设置环境url成功"); | |||
} else { | |||
mList.add(0, "设置环境路径失败"); | |||
mList.add(0, "设置环境url失败"); | |||
} | |||
listAdapter.notifyDataSetChanged(); | |||
} | |||
@Override | |||
public void onIpData(String ip) { | |||
mList.add(0, "环境ip:" + ip); | |||
listAdapter.notifyDataSetChanged(); | |||
} | |||
@Override | |||
public void onPortData(int port) { | |||
mList.add(0, "环境端口:" + port); | |||
listAdapter.notifyDataSetChanged(); | |||
} | |||
@Override | |||
public void onUrlData(String url) { | |||
mList.add(0, "环境url:" + url); | |||
listAdapter.notifyDataSetChanged(); | |||
} | |||
@Override | |||
public void onClick(View v) { | |||
int id = v.getId(); | |||
@@ -563,7 +604,7 @@ public class WeightScaleWifiBleActivity extends BleBaseActivity implements View. | |||
@Override | |||
public void tvSucceedListener(View v, String data) { | |||
bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().setWifiMac(wifimacMap.get(selectWifi))); | |||
if (data.equals("") || data.length() > 8) { | |||
if (data.equals("") || data.length() >= 8) { | |||
setPaw(data); | |||
} else { | |||
Toast.makeText(WeightScaleWifiBleActivity.this, "密码格式不对", Toast.LENGTH_SHORT).show(); | |||
@@ -600,25 +641,41 @@ public class WeightScaleWifiBleActivity extends BleBaseActivity implements View. | |||
showFileChooser(); | |||
break; | |||
case R.id.surroundings: | |||
if (isTest) { | |||
setIp(productIp); | |||
mList.add(0, "设置环境IP为生产环境"); | |||
} else { | |||
setIp(testIp); | |||
mList.add(0, "设置环境IP为测试环境"); | |||
} | |||
String ipStr = et_ip.getText().toString(); | |||
setIp(convertToASCII(ipStr)); | |||
mList.add(0, "设置环境IP为:" + ipStr); | |||
listAdapter.notifyDataSetChanged(); | |||
break; | |||
case R.id.check_ip: | |||
mList.add(0, "查看环境ip"); | |||
listAdapter.notifyDataSetChanged(); | |||
bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().checkIp()); | |||
break; | |||
case R.id.check_port: | |||
mList.add(0, "查看环境端口"); | |||
listAdapter.notifyDataSetChanged(); | |||
bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().checkPort()); | |||
break; | |||
case R.id.check_url: | |||
mList.add(0, "查看环境url"); | |||
listAdapter.notifyDataSetChanged(); | |||
bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().checkUrl()); | |||
break; | |||
} | |||
} | |||
private byte[] convertToASCII(String string) { | |||
char[] ch = string.toCharArray(); | |||
byte[] tmp = new byte[ch.length]; | |||
for (int i = 0; i < ch.length; i++) { | |||
tmp[i] = (byte) Integer.valueOf(ch[i]).intValue(); | |||
} | |||
return tmp; | |||
} | |||
private void setIp(byte[] ips) { | |||
if (ips.length <= 14) | |||
@@ -646,6 +703,10 @@ public class WeightScaleWifiBleActivity extends BleBaseActivity implements View. | |||
} | |||
private void setPort(int port) { | |||
bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().environmentPort(port)); | |||
} | |||
private void setIpUrl(byte[] setIpUrl) { | |||
if (setIpUrl.length <= 14) | |||
bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().environmentUrl(0, setIpUrl)); | |||
@@ -760,17 +821,24 @@ public class WeightScaleWifiBleActivity extends BleBaseActivity implements View. | |||
listAdapter.notifyDataSetChanged(); | |||
} | |||
private int mOldProgress = -1; | |||
@Override | |||
public void onOtaProgress(float progress, int currentCount, int maxCount) { | |||
mList.add(0, "otaProgress:"+progress); | |||
listAdapter.notifyDataSetChanged(); | |||
if (mOldProgress != progress) { | |||
mOldProgress = (int) progress; | |||
mList.add(0, "otaProgress:" + progress); | |||
listAdapter.notifyDataSetChanged(); | |||
} | |||
} | |||
}); | |||
} else { | |||
} | |||
} | |||
private static final int FILE_SELECT_CODE = 0x1002; | |||
private void showFileChooser() { | |||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); | |||
intent.setType("*/*"); | |||
@@ -782,5 +850,4 @@ public class WeightScaleWifiBleActivity extends BleBaseActivity implements View. | |||
Toast.makeText(this, "Please install a File Manager.", Toast.LENGTH_SHORT).show(); | |||
} | |||
} | |||
} |
@@ -157,6 +157,12 @@ public class BleDeviceConfig { | |||
public final static int SHARE_CONDOM = 0x1007; | |||
/** | |||
* 跳绳 | |||
*/ | |||
public final static int ROPE_SKIPPING = 0x002f; | |||
/** | |||
* 身高体脂秤 | |||
*/ |
@@ -313,6 +313,11 @@ | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="共享套套机" /> | |||
<Button | |||
android:id="@+id/btn_rope_skip" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="跳绳" /> | |||
</LinearLayout> | |||
@@ -0,0 +1,113 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:focusable="true" | |||
android:focusableInTouchMode="true" | |||
android:orientation="vertical"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
> | |||
<Button | |||
android:id="@+id/btn_syn_time" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="同步时间搓" /> | |||
<Button | |||
android:id="@+id/btn_free_jump" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="启动自由跳" /> | |||
<Button | |||
android:id="@+id/btn_time_jump" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="启动倒时跳" /> | |||
<Button | |||
android:id="@+id/btn_num_jump" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="启动倒数跳" /> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
> | |||
<Button | |||
android:id="@+id/btn_stop_free_jump" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="停止自由跳" /> | |||
<Button | |||
android:id="@+id/btn_stop_time_jump" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="停止倒时跳" /> | |||
<Button | |||
android:id="@+id/btn_stop_num_jump" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="停止倒数跳" /> | |||
<Button | |||
android:id="@+id/btn_default_num" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="默认100个" /> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
> | |||
<Button | |||
android:id="@+id/btn_default_timer" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="默认60秒" /> | |||
<Button | |||
android:id="@+id/btn_get_history" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="获取历史记录" /> | |||
<Button | |||
android:id="@+id/btn_clear_log" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="暂停刷新" /> | |||
<Button | |||
android:id="@+id/btn_bind" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="确认绑定" /> | |||
</LinearLayout> | |||
<ListView | |||
android:id="@+id/listview" | |||
android:layout_width="match_parent" | |||
android:layout_height="0dp" | |||
android:layout_weight="2.5" | |||
android:padding="10dp" | |||
android:stackFromBottom="true" | |||
android:transcriptMode="alwaysScroll"> | |||
</ListView> | |||
</LinearLayout> |
@@ -1,147 +1,233 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<RelativeLayout | |||
xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:orientation="vertical"> | |||
<Button | |||
android:id="@+id/wifistatus" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="查看wifi状态" /> | |||
<Button | |||
android:id="@+id/scan_wifi" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginStart="12dp" | |||
android:layout_toEndOf="@+id/wifistatus" | |||
android:text="搜索wifi热点" /> | |||
<Button | |||
android:id="@+id/sn" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/scan_wifi" | |||
android:layout_marginTop="8dp" | |||
android:text="查看设备did号" /> | |||
<EditText | |||
android:id="@+id/select_wifi_et" | |||
android:layout_width="90dp" | |||
android:layout_height="wrap_content" | |||
android:layout_marginStart="22dp" | |||
android:layout_toEndOf="@+id/scan_wifi" | |||
android:hint="选择wifi序号" | |||
android:inputType="number" | |||
android:textSize="14dp" /> | |||
<Button | |||
android:id="@+id/connect_wifi" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/select_wifi_et" | |||
android:layout_marginStart="13dp" | |||
android:layout_marginTop="11dp" | |||
android:layout_toEndOf="@+id/disconnect" | |||
android:text="发起连接" /> | |||
<Button | |||
android:id="@+id/disconnect" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/scan_wifi" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:layout_toEndOf="@+id/sn" | |||
android:text="断开连接" /> | |||
<Button | |||
android:id="@+id/setedmac" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/sn" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:text="获取希望设置的MAC" /> | |||
<Button | |||
android:id="@+id/setedpaw" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/sn" | |||
android:layout_toEndOf="@id/setedmac" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:text="获取希望设置的密码" /> | |||
<Button | |||
android:id="@+id/setedname" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/setedmac" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:text="获取当前连接wifi名称" /> | |||
<Button | |||
android:id="@+id/ota" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/setedmac" | |||
android:layout_toEndOf="@+id/setedname" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:text="ota" /> | |||
<Button | |||
android:id="@+id/surroundings" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/setedmac" | |||
android:layout_toEndOf="@+id/ota" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:text="切换环境" /> | |||
<RadioGroup | |||
android:id="@+id/unit" | |||
android:layout_below="@+id/setedname" | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:orientation="vertical"> | |||
<ScrollView | |||
android:layout_width="match_parent" | |||
android:orientation="horizontal" | |||
android:layout_height="wrap_content"> | |||
<RadioButton | |||
android:id="@+id/kg" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="1" | |||
android:text="kg"/> | |||
<RadioButton | |||
android:id="@+id/jin" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="1" | |||
android:text="斤"/> | |||
<RadioButton | |||
android:id="@+id/st_lb" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="1" | |||
android:text="st:lb"/> | |||
<RadioButton | |||
android:id="@+id/lb" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="1" | |||
android:text="lb"/> | |||
</RadioGroup> | |||
android:layout_height="0dp" | |||
android:layout_weight="1.6"> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:orientation="vertical"> | |||
<Button | |||
android:id="@+id/wifistatus" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="查看wifi状态" /> | |||
<Button | |||
android:id="@+id/scan_wifi" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginStart="12dp" | |||
android:layout_toEndOf="@+id/wifistatus" | |||
android:text="搜索wifi热点" /> | |||
<Button | |||
android:id="@+id/sn" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/scan_wifi" | |||
android:layout_marginTop="8dp" | |||
android:text="查看设备did号" /> | |||
<EditText | |||
android:id="@+id/select_wifi_et" | |||
android:layout_width="90dp" | |||
android:layout_height="wrap_content" | |||
android:layout_marginStart="22dp" | |||
android:layout_toEndOf="@+id/scan_wifi" | |||
android:hint="选择wifi序号" | |||
android:inputType="number" | |||
android:textSize="14dp" /> | |||
<Button | |||
android:id="@+id/connect_wifi" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/select_wifi_et" | |||
android:layout_marginStart="13dp" | |||
android:layout_marginTop="11dp" | |||
android:layout_toEndOf="@+id/disconnect" | |||
android:text="发起连接" /> | |||
<Button | |||
android:id="@+id/disconnect" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/scan_wifi" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:layout_toEndOf="@+id/sn" | |||
android:text="断开连接" /> | |||
<Button | |||
android:id="@+id/setedmac" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/sn" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:text="获取希望设置的MAC" /> | |||
<Button | |||
android:id="@+id/setedpaw" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/sn" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:layout_toEndOf="@id/setedmac" | |||
android:text="获取希望设置的密码" /> | |||
<Button | |||
android:id="@+id/setedname" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/setedmac" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:text="获取当前连接wifi名称" /> | |||
<Button | |||
android:id="@+id/ota" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/setedmac" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:layout_toEndOf="@+id/setedname" | |||
android:text="ota" /> | |||
<EditText | |||
android:id="@+id/et_ip" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@id/setedname" | |||
android:layout_marginStart="10dp" | |||
android:layout_marginEnd="10dp" | |||
android:inputType="text" | |||
android:maxLines="1" | |||
android:text="47.113.114.70" /> | |||
<EditText | |||
android:id="@+id/et_port" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@id/et_ip" | |||
android:layout_marginStart="10dp" | |||
android:layout_marginEnd="10dp" | |||
android:inputType="number" | |||
android:maxLines="1" | |||
android:text="8092" /> | |||
<EditText | |||
android:id="@+id/et_url" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@id/et_port" | |||
android:layout_marginStart="10dp" | |||
android:layout_marginEnd="10dp" | |||
android:inputType="text" | |||
android:maxLines="1" | |||
android:text="/index/" /> | |||
<Button | |||
android:id="@+id/surroundings" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/et_url" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:text="切换环境" /> | |||
<Button | |||
android:id="@+id/check_ip" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@id/et_url" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:layout_toEndOf="@id/surroundings" | |||
android:text="查看ip" /> | |||
<Button | |||
android:id="@+id/check_port" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@id/et_url" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:layout_toEndOf="@id/check_ip" | |||
android:text="查看端口" /> | |||
<Button | |||
android:id="@+id/check_url" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@id/et_url" | |||
android:layout_marginStart="9dp" | |||
android:layout_marginTop="5dp" | |||
android:layout_toEndOf="@id/check_port" | |||
android:text="查看url" /> | |||
<RadioGroup | |||
android:id="@+id/unit" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_below="@+id/check_ip" | |||
android:orientation="horizontal"> | |||
<RadioButton | |||
android:id="@+id/kg" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="1" | |||
android:text="kg" /> | |||
<RadioButton | |||
android:id="@+id/jin" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="1" | |||
android:text="斤" /> | |||
<RadioButton | |||
android:id="@+id/st_lb" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="1" | |||
android:text="st:lb" /> | |||
<RadioButton | |||
android:id="@+id/lb" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="1" | |||
android:text="lb" /> | |||
</RadioGroup> | |||
</RelativeLayout> | |||
</ScrollView> | |||
<ListView | |||
android:id="@+id/log_list" | |||
android:layout_marginTop="20dp" | |||
android:layout_below="@id/unit" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
android:layout_height="0dp" | |||
android:layout_below="@id/unit" | |||
android:layout_marginTop="20dp" | |||
android:layout_weight="1"> | |||
</ListView> | |||
</RelativeLayout> | |||
</LinearLayout> |