fitpolo706 SDK
1.Import and use SDK
1.1 import module project fitpolosupport
1.2 settings.gradle document,quote fitpolosupport project:
include ‘:app’,’:fitpolosupport’
1.3 Edit the build.gradle file of the main project:
dependencies {
implementation fileTree(dir: ‘libs’, include: [‘*.jar’])
implementation project(path: ‘:fitpolosupport’)
}
1.4 Import sdk at project initialization
public class BaseApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// initialization
MokoSupport.getInstance().init(getApplicationContext());
}
}
2.Function Introduction
2.1 startScanDevice
@Description scanning device
public void startScanDevice(final MokoScanDeviceCallback callback) {}
MokoScanDeviceCallback:call back
@Description scan device call back
public interface ScanDeviceCallback {
@Description start scan
void onStartScan();
@Description scanned device
void onScanDevice(BleDevice device);
@Description end scan
void onStopScan();
}
public class BleDevice implements Serializable, Comparable<BleDevice> {
public String address;
public String name;
public int rssi;
public String verifyCode;
public byte[] scanRecord;
…
}
For example:
BleDevice{address=’DA:22:C3:C7:7D’, name=’FitpolpHR’, rssi=-38, verifyCode=’0C8D02′, scanRecord=[2,1,6,7…]}
2.2 createBluetoothGatt
@Description pair device
public void connDevice(Context context, String address, MokoConnStateCallback mokoConnStateCallback) {}
Enter the parameters:
@Description Front end display connection callback
public interface MokoConnStateCallback {
@Description connect successfully
void onConnectSuccess();
@Description disconnect
void onDisConnected();
@Description reconnect timeout
void onConnTimeout(int reConnCount);
}
2.3 setOpenReConnect
@Description setreconnect
public void setOpenReConnect(boolean openReConnect){}
2.4 sendOrder
@Description send order
public void sendOrder(OrderTask… orderTasks){}
Abstract class command, including command enumeration, command response callback, command response result;
public abstract class OrderTask {
public OrderType orderType;
public OrderEnum order;
public MokoOrderTaskCallback callback;
public OrderTaskResponse response;
}
public enum OrderType implements Serializable {
READ_CHARACTER(“READ_CHARACTER”, “0000ffb0-0000-1000-8000-00805f9b34fb”),
WRITE_CHARACTER(“WRITE_CHARACTER”, “0000ffb1-0000-1000-8000-00805f9b34fb”),
STEP_CHARACTER(“STEP_CHARACTER”, “0000ffb2-0000-1000-8000-00805f9b34fb”),
HEART_RATE_CHARACTER(“HEART_RATE_CHARACTER”, “0000ffb3-0000-1000-8000-00805f9b34fb”),
;
private String uuid;
private String name;
OrderType(String name, String uuid) {
this.name = name;
this.uuid = uuid;
}
public String getUuid() {
return uuid;
}
public String getName() {
return name;
}
}
2. OrderEnum
public enum OrderEnum implements Serializable {
READ_NOTIFY(“turn on read notify”, 0),
WRITE_NOTIFY(“turn on write notify”, 0)
STEP_NOTIFY(“turn on step counting notify”, 0),
HEART_RATE_NOTIFY(“turn on heart rate notify”, 0),
Z_READ_ALARMS(“read alarm”, 0x01),
Z_READ_SIT_ALERT(“read Sedentary reminder”, 0x04),
Z_READ_STEP_TARGET(“read step target”, 0x06),
Z_READ_UNIT_TYPE(“read unit type”, 0x07),
…
private String orderName;
private int orderHeader;
OrderEnum(String orderName, int orderHeader) {
this.orderName = orderName;
this.orderHeader = orderHeader;
}
public int getOrderHeader() {
return orderHeader;
}
public String getOrderName() {
return orderName;
}
}
3.MokoOrderTaskCallback
public interface MokoOrderTaskCallback {
// response success
void onOrderResult(OrderTaskResponse response);
// response timeout
void onOrderTimeout(OrderTaskResponse response);
// order executed complete
void onOrderFinish();
}
4. OrderTaskResponse
public class OrderTaskResponse implements Serializable {
public OrderEnum order;
public int responseType;
public byte[] responseValue;
}
OrderTask :
1.gain inner version No.
ZReadVersionTask
After returning the result, you can get the bracelet information as follows:
MokoSupport.versionCode;// gain firmware
MokoSupport.firmwareEnum;// gain firmware type
MokoSupport.canUpgrade;// whether could upgrade
2.set system time
ZWriteSystemTimeTask
3.set user information
ZWriteUserInfoTask
UserInfo Incoming users need to pass in user information
public class UserInfo {
public int weight;// weight
public int height;// height
public int age;// age
public int birthdayMonth;// birthday month
public int birthdayDay;// birthday date
public int gender;// Gender Male: 0; Female: 1
public int stepExtent;// step extent
}
4.gain user information
ZReadUserInfoTask
MokoSupport.getInstance().getUserInfo();
5.set alarm data
ZWriteAlarmsTask
List<BandAlarm> Incoming access to the alarm information
public class BandAlarm {
public String time;// time,formate:HH:mm
// state
// bit[7]:0:close;1:open;
// bit[6]:1:sunday
// bit[5]:1:saturday
// bit[4]:1:Friday
// bit[3]:1:Thursday
// bit[2]:1:Wednesday
// bit[1]:1:Tuesday
// bit[0]:1:Monday
// ex: every Sunday turn on:11000000; every Monday to Friday to trun on: 10011111;
public String state;
public int type;// type,0:take medicine;1:drink water;3:normaly;4:sleep ;5:take medicine;6: do sports
}
6.gain alarm datas
ZReadAlarmsTask
MokoSupport.getInstance().getAlarms();
7.set unit
ZWriteUnitTypeTask
Incoming entry unit system
unitType// 0: Chinese type;1:British type, Default Chinese type
8.gain unit type
ZReadUnitTypeTask
MokoSupport.getInstance().getUnitTypeBritish();
9.set display time format
ZWriteTimeFormatTask
Incoming entry should display time format
timeFormat;// 0:24;1:12, default 24-hour system
10.gain time display formate
ZReadTimeFormatTask
MokoSupport.getInstance().getTimeFormat();
11.set light up the screen by tap
ZWriteAutoLightenTask
incoming entry AutoLighten
public class AutoLighten {
public int autoLighten; // shake screen ,1: on;0: off;
public String startTime;// start time, formate:HH:mm;
public String endTime;// end time,formate:HH:mm; 8.set Sedentary reminder
}
12.gain light up the screen by tap
ZReadAutoLightenTask
MokoSupport.getInstance().getAutoLighten();
13.set sendentary reminder
ZWriteSitAlertTask
SitAlert incoing entry sedentary reminder information
public class SitAlert {
public int alertSwitch; // advise to sport,1: on;0: off;
public String startTime;// start time, formate:HH:mm;
public String endTime;// end time, formate:HH:mm;
}
14.gain sedentary reminder information
ZReadSitAlertTask
MokoSupport.getInstance().getSitAlert();
15.set last time display
ZWriteLastScreenTask
Incoming parameters need pass last time display
lastScreen;// 1: on;0: off
16.gain last time display
ZReadLastScreenTask
MokoSupport.getInstance().getLastScreen();
17.set heart rate meansure intervial
ZWriteHeartRateIntervalTask
Incoming parameters need pass heart rate intervial
heartRateInterval;// 0: off;1: 10mins;2: 20mins;3: 30mins
18.gain heart rate measure intrvial
ZReadHeartRateIntervalTask
MokoSupport.getInstance().getHeartRateInterval();
19.Set custom sortable features
ZWriteCustomSortScreenTask
Entering need to pass in the set of functions that can be displayed
ArrayList<Integer> shownScreen = new ArrayList<>();
shownScreen.add(0);//0:Activity
shownScreen.add(1);//1:Sport
shownScreen.add(2);//2:Stopwatch
shownScreen.add(3);//3:Timer
shownScreen.add(4);//4:Heart Rate
shownScreen.add(5);//5:Breath
shownScreen.add(6);//6:Sleep
shownScreen.add(7);//7:More
shownScreen.add(8);//8:Pairing code
The order of the values in the collection is the order in which the functions are displayed. The functions that do not need to be displayed are not added to the collection. For example:
ArrayList<Integer> shownScreen = new ArrayList<>();
shownScreen.add(0);//0:Activity
shownScreen.add(8);//8:Pairing code
shownScreen.add(1);//1:Sport
shownScreen.add(6);//6:Sleep
shownScreen.add(2);//2:Stopwatch
20.Get custom sortable features
ZReadCustomSortScreenTask
MokoSupport.getInstance().getCustomSortScreen();
21.set target steps
ZWriteStepTargetTask
incoming parameter need pass target steps
stepTarget;// value range 1~60000
22.gain target step
ZReadStepTargetTask
MokoSupport.getInstance().getStepTarget();
23.set watch face
ZWriteDialTask
incoming parameter need pass watch face
dial;// value range 1~3
24.gain watch face setting
ZReadDialTask
MokoSupport.getInstance().getDial();
25.set do not disturb
ZWriteNoDisturbTask
incoming parameter need pass do not disturb
public class NoDisturb {
public int noDisturb; // do not disturb,1: on;0: off;
public String startTime;// start time, formate:HH:mm;
public String endTime;// end time, formate:HH:mm;
}
26.Read not disturb
ZReadNoDisturbTask
MokoSupport.getInstance().getNodisturb();
27.Get unsynchronized step data
ZReadStepTask
incoming parameter need timestamp
lastSyncTime;// yyyy-MM-dd HH:mm
After returning the result, you can view the step data after the timestamp.
MokoSupport.getInstance().getDailySteps()
28.Get unsynchronized sleep record data
ZReadSleepGeneralTask
incoming parameter need timestamp
lastSyncTime;// yyyy-MM-dd HH:mm
After returning the result, you can view the sleep data after the timestamp.
MokoSupport.getInstance().getDailySleeps()
29.get unsymchronized heart rate datas
ZReadHeartRateTask
incoming parameter need timestamp
lastSyncTime;// yyyy-MM-dd HH:mm
After returning the result, you can view the heart rate after the timestamp.
MokoSupport.getInstance().getHeartRates()
30.turn steps change notification
ZOpenStepListenerTask
Can be received by the broadcast receiver when turned on
if (MokoConstants.ACTION_CURRENT_DATA.equals(action)) {
OrderEnum orderEnum = (OrderEnum) intent.getSerializableExtra(MokoConstants.EXTRA_KEY_CURRENT_DATA_TYPE);
switch (orderEnum) {
case Z_STEPS_CHANGES_LISTENER:
DailyStep dailyStep = MokoSupport.getInstance().getDailyStep();
LogModule.i(dailyStep.toString());
break;
}
}
31.gain Hardware parameter
ZReadParamsTask
Check the firmware parameters after returning the result
MokoSupport.getInstance().getProductBatch();// produce batch
MokoSupport.getInstance().getParams();// hardware parameter
public class FirmwareParams {
public String test; // bit0:flash, bit1:G sensor,bit2: hr measure;
public int reflectiveThreshold;// Reflective threshold, default1380;
public int reflectiveValue;// present reflective threshold
public int batchYear;// produce batch year
public int batchWeek;// produce batch week
public int speedUnit;// Bluetooth connection speed unit is 1.25ms
}
32.gain battery power
ZReadBatteryTask
check battery power after returning the result
MokoSupport.getInstance().getBatteryQuantity();
33.gain last time charge time
ZReadLastChargeTimeTask
MokoSupport.getInstance().getLastChargeTime();
34.set bracelet vibrate
ZWriteShakeTask
default vibrate twice, vibrate 1 second then stop 1 second
no response handle
35.set bracelet notification
ZWriteCommonMessageTask
isPhoneCall;
showText;// no more than 30 bytes
isOpen;// on/off notification
36.Set the bracelet to reset the data
ZWriteResetTask
37.set the bracelet to shut down
ZWriteCloseTask
38.find the mobilephone
ZWriteFindPhoneTask
When you need to use the search function on the bracelet, please send this command. After sending, click on the search for the phone on the bracelet and you will receive the command sent by the bracelet.
39.set bracelet language
ZWriteLanguageTask
Send this command to set the bracelet language to the system language
40.set date format
ZWriteDateFormatTask
Incoming entry date format
dateFormat;// 0:日/月,1:月/日
41.gain date format:zr
ZReadDateFormatTask
MokoSupport.getInstance().getDateFormat();
42.Set the vibration intensity of the bracelet
ZWriteShakeStrengthTask
Incoming vibration intensity
shakeStrength;// ranges:1~9
43.Get the vibration intensity of the bracelet
ZReadShakeStrengthTask
MokoSupport.getInstance().getShakeStrength();
44.Set the step interval
ZWriteStepIntervalTask
Default 30 minutes (1E)
45.Get the step interval
ZReadStepIntervalTask
MokoSupport.getInstance().getDailyDetailSteps();
46.Get exercise data
ZReadSportsTask
incoming parameter need timestamp
lastSyncTime;// yyyy-MM-dd HH:mm
MokoSupport.getInstance().getSportDatas();
47.Get sports heart rate
ZReadSportsHeartRateTask
incoming parameter need timestamp
lastSyncTime;// yyyy-MM-dd HH:mm
MokoSupport.getInstance().getSportsHeartRates();
2.5 sendDirectOrder
Send commands directly, this method can be used when the command does not need to answer, only supports the sending of a single command.
public void sendDirectOrder(OrderTask orderTask){}
2.6 isBluetoothOpen
Judge if Bluetooth is turned on
public boolean isBluetoothOpen(){}
2.7 isConnDevice
judge if the bracelet is connected with app
public boolean isConnDevice(Context context, String address){}
incominf parameter:address bracelet mac address
2.8 disConnectBle
disconnect the bracelet
public void disConnectBle(){}
3.Save Log to SD Card
public class LogModule {
private static final String TAG = “fitpoloDemoH706”;// file name
private static final String LOG_FOLDER = “fitpoloDemoH706”;// file folder name
…
}
LogModule.v(“log info”);
LogModule.d(“log info”);
LogModule.i(“log info”);
LogModule.w(“log info”);
LogModule.e(“log info”);
4.Upgrade
Register/anti-register listener
@Override
protected void onResume() {
super.onResume();
DfuServiceListenerHelper.registerProgressListener(this, mDfuProgressListener);
}
@Override
protected void onPause() {
super.onPause();
DfuServiceListenerHelper.unregisterProgressListener(this, mDfuProgressListener);
}
Turn on DFU, you need to pass the device Mac address and device name, firmware path, create DfuService
final DfuServiceInitiator starter = new DfuServiceInitiator(mDevice.address)
.setDeviceName(mDevice.name)
.setKeepBond(false)
.setDisableNotification(true);
starter.setZip(null, firmwarePath);
starter.start(this, DfuService.class);
Monitor upgrade status
onProgressChanged gain upgrade progess onError gain fail reason onDfuCompleted upgrade succeed
86-75523573370
4F, Building 2, Guanghui Technology Park, Mingqing Rd, Longhua, Shenzhen, China