|
|
|
|
//
|
|
|
|
|
// BLEBaseBl.m
|
|
|
|
|
// BluetoothDemo
|
|
|
|
|
//
|
|
|
|
|
// Created by mac on 17/3/13.
|
|
|
|
|
// Copyright © 2017年 . All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "BLEBaseBlFireBoltt.h"
|
|
|
|
|
#import "BluetoothFireBoltt.h"
|
|
|
|
|
#import "L2DataParseFireBoltt.h"
|
|
|
|
|
#import "BLEConstFireBoltt.h"
|
|
|
|
|
#import "BLETools.h"
|
|
|
|
|
#import <JL_BLEKit/JL_BLEKit.h>
|
|
|
|
|
#import <JLDialUnit/JLDialUnit.h>
|
|
|
|
|
#import "JL_RunSDK.h"
|
|
|
|
|
#import "NSString+SelectString.h"
|
|
|
|
|
#import <SVProgressHUD/SVProgressHUD.h>
|
|
|
|
|
|
|
|
|
|
#define LOne_Version 0 //L1层版本
|
|
|
|
|
#define LTwo_Version 0 //L2层版本
|
|
|
|
|
#define LOne_Length 5 //L2层无Value是的总长度
|
|
|
|
|
#define Identification 0xCB //识别标志
|
|
|
|
|
|
|
|
|
|
@interface BLEBaseBlFireBoltt() <BluetoothDataSource>
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, strong)BluetoothFireBoltt *blueTooth;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation BLEBaseBlFireBoltt
|
|
|
|
|
|
|
|
|
|
+ (nullable instancetype)shareInstance
|
|
|
|
|
{
|
|
|
|
|
static BLEBaseBlFireBoltt *share = nil;
|
|
|
|
|
static dispatch_once_t oneToken;
|
|
|
|
|
dispatch_once(&oneToken, ^{
|
|
|
|
|
share = [[self alloc] init];
|
|
|
|
|
});
|
|
|
|
|
return share;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (instancetype)init
|
|
|
|
|
{
|
|
|
|
|
if (self = [super init]) {
|
|
|
|
|
self.blueTooth = [BluetoothFireBoltt shareInstance];
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
查找设备
|
|
|
|
|
*/
|
|
|
|
|
- (void)findDeviceWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd {
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
设置时间
|
|
|
|
|
*/
|
|
|
|
|
- (void)setIngTimeWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd {
|
|
|
|
|
NSData *value = [[NSData alloc] init];
|
|
|
|
|
// 手环设置时间最后拼接一个12/24小时制,hasAMPM NO:24小时 YES:12小时
|
|
|
|
|
NSString *formatStringForHours = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 locale:[NSLocale currentLocale]];
|
|
|
|
|
NSRange containsA = [formatStringForHours rangeOfString:@"a"];
|
|
|
|
|
BOOL hasAMPM = containsA.location != NSNotFound;
|
|
|
|
|
NSMutableData *data = [NSMutableData dataWithData:[BluetoothToolFireBoltt getTimeDataWithTime:@[[NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]]] cmdType:BleCMD_setIngTime]];
|
|
|
|
|
[data appendBytes:&(hasAMPM) length:1];
|
|
|
|
|
value = data;
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:value];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
绑定请求
|
|
|
|
|
*/
|
|
|
|
|
- (void)bindingDeviceWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd {
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
同步联系人
|
|
|
|
|
*/
|
|
|
|
|
- (void)syncContactWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
contentArr:(NSArray *)contentArr
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
NSMutableData *bookData = [NSMutableData new];
|
|
|
|
|
for (NSString *book in contentArr)
|
|
|
|
|
{
|
|
|
|
|
NSArray *array = [book componentsSeparatedByString:@"\n"];
|
|
|
|
|
NSString *name = [NSString stringWithFormat:@"%@",array[0]];
|
|
|
|
|
NSString *phone = [NSString stringWithFormat:@"%@",array[1]];
|
|
|
|
|
|
|
|
|
|
phone = [phone stringByReplacingOccurrencesOfString:@" " withString:@""];
|
|
|
|
|
phone = [phone stringByReplacingOccurrencesOfString:@"+86" withString:@""];
|
|
|
|
|
|
|
|
|
|
NSData *namedata = [name dataUsingEncoding:NSUTF16LittleEndianStringEncoding];
|
|
|
|
|
NSData *phonedata = [phone dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
NSLog(@"data-->%@",namedata);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned long len = [namedata length];
|
|
|
|
|
[bookData appendBytes:&len length:1];
|
|
|
|
|
[bookData appendData:namedata];
|
|
|
|
|
|
|
|
|
|
unsigned long len1 = [phonedata length];
|
|
|
|
|
[bookData appendBytes:&len1 length:1];
|
|
|
|
|
[bookData appendData:phonedata];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:bookData];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
二维码推送
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param payType 收款码类型 1:zfb收款码,2:微信收款码,3:Paypal收款码,4.个人微信码
|
|
|
|
|
@param qrCodeImg 二维码字符串
|
|
|
|
|
*/
|
|
|
|
|
- (void)qrCodePushWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
PayType:(NSInteger)payType
|
|
|
|
|
qrCodeImg:(UIImage *)qrCodeImg
|
|
|
|
|
{
|
|
|
|
|
NSString *qrcodeStr = [self readQRCodeFromImage:qrCodeImg];
|
|
|
|
|
if (qrcodeStr.length > 0)
|
|
|
|
|
{
|
|
|
|
|
NSMutableData *imgData = [NSMutableData new];
|
|
|
|
|
NSData *ImgData = [qrcodeStr dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
unsigned long imgLen = [ImgData length];
|
|
|
|
|
|
|
|
|
|
[imgData appendBytes:&payType length:1];
|
|
|
|
|
[imgData appendBytes:&imgLen length:2];
|
|
|
|
|
[imgData appendData:ImgData];
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:imgData];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
手表WIFI
|
|
|
|
|
*/
|
|
|
|
|
- (void)watchWifiWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd {
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
协助输入开始
|
|
|
|
|
*/
|
|
|
|
|
- (void)inputStartWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd {
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
发送协助输入
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param content 输入的内容
|
|
|
|
|
*/
|
|
|
|
|
- (void)inputSendWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
content:(NSString *)content {
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[content dataUsingEncoding:NSUTF8StringEncoding]];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
发送剪切板数据
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param content 剪切板内容
|
|
|
|
|
*/
|
|
|
|
|
- (void)shearPlateWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
content:(NSString *)content {
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[content dataUsingEncoding:NSUTF8StringEncoding]];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
协助输入结束
|
|
|
|
|
*/
|
|
|
|
|
- (void)inputEndWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd {
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
表盘推送
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param dialType 表盘类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)dialPushWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
dialType:(NSInteger)dialType {
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[[NSString stringWithFormat:@"%ld",dialType] dataUsingEncoding:NSUTF8StringEncoding]];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
紧急拨号
|
|
|
|
|
|
|
|
|
|
使用#分割手机号
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param urgentNumber 紧急拨号的号码
|
|
|
|
|
*/
|
|
|
|
|
- (void)urgentDialWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
urgentNumber:(NSString *)urgentNumber {
|
|
|
|
|
|
|
|
|
|
//NSString *urgentStr = @"13480905523^13554564776";
|
|
|
|
|
NSData *data = [urgentNumber dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:data];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
同步健康数据(key 0xA0)
|
|
|
|
|
|
|
|
|
|
@param type 1:睡眠,2:心率,3:计步,4:运动模式 (手环使用,72平台传0同步所有) 5:血压 6:血氧
|
|
|
|
|
@param timeArr 时间戳数组(三个时间),传空则为获取所有
|
|
|
|
|
*/
|
|
|
|
|
- (void)syncHealthWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
Type:(NSInteger)type
|
|
|
|
|
timeArr:(NSArray *)timeArr {
|
|
|
|
|
NSMutableData *value = [[NSMutableData alloc] init];
|
|
|
|
|
[value appendBytes:&type length:1];
|
|
|
|
|
[value appendData:timeArr.count ? [BluetoothToolFireBoltt getTimeDataWithTime:timeArr cmdType:cmd] : 0];
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:value];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
同步表盘数据
|
|
|
|
|
*/
|
|
|
|
|
- (void)syncDialPushFB
|
|
|
|
|
{
|
|
|
|
|
BleCMD_FireBoltt cmd = BleCMD_dialRequest;
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
WIFI需要密码
|
|
|
|
|
*/
|
|
|
|
|
- (void)wifiPassWordWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
SSID:(NSString *)SSID
|
|
|
|
|
PassWord:(NSString *)passWord {
|
|
|
|
|
|
|
|
|
|
NSData *SSIDData = [SSID dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
NSData *passWordData = [passWord dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
NSData *divisionData = [@"|" dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
NSMutableData *value = [[NSMutableData alloc] init];
|
|
|
|
|
[value appendData:SSIDData];
|
|
|
|
|
[value appendData:divisionData];
|
|
|
|
|
[value appendData:passWordData];
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:value];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
已保存的WIFI
|
|
|
|
|
*/
|
|
|
|
|
- (void)wifiLinkWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
NetworkId:(NSString *)networkId {
|
|
|
|
|
|
|
|
|
|
NSData *value = [networkId dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:value];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
WIFI无需密码
|
|
|
|
|
*/
|
|
|
|
|
- (void)wifiNoPassWordWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
SSID:(NSString *)SSID {
|
|
|
|
|
|
|
|
|
|
NSData *value = [SSID dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:value];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 固件升级启动
|
|
|
|
|
|
|
|
|
|
@param updateData 固件升级包数据
|
|
|
|
|
*/
|
|
|
|
|
- (void)firmwareUpdateWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
UpdateData:(NSData *)updateData {
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:updateData];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
获取设备固件版本信息
|
|
|
|
|
*/
|
|
|
|
|
- (void)firmwareVersionWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd {
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
闹钟设置
|
|
|
|
|
|
|
|
|
|
@param alarmClockArr 闹钟数组(时间戳字符串&&周期字符串)
|
|
|
|
|
*/
|
|
|
|
|
- (void)setAlarmClockWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
AlarmClockArr:(NSArray *)alarmClockArr {
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[BluetoothToolFireBoltt getAlarmClockDataWithArr:alarmClockArr]];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
用户信息设置
|
|
|
|
|
|
|
|
|
|
@param gender 性别
|
|
|
|
|
@param age 年龄
|
|
|
|
|
@param height 身高
|
|
|
|
|
@param weight 体重
|
|
|
|
|
@param goal 运动目标
|
|
|
|
|
*/
|
|
|
|
|
- (void)setUserInfoWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
gender:(NSString *)gender
|
|
|
|
|
age:(NSString *)age
|
|
|
|
|
height:(NSString *)height
|
|
|
|
|
weight:(NSString *)weight
|
|
|
|
|
Goal:(NSString *)goal
|
|
|
|
|
BMI:(NSString *)BMI
|
|
|
|
|
{
|
|
|
|
|
// 拼接成八个字节的数据
|
|
|
|
|
NSInteger goals = [goal integerValue];
|
|
|
|
|
Byte buffer[9];
|
|
|
|
|
buffer[0] = (Byte)[gender integerValue];
|
|
|
|
|
buffer[1] = (Byte)[age integerValue];
|
|
|
|
|
buffer[2] = (Byte)[height integerValue];
|
|
|
|
|
buffer[3] = (Byte)[weight integerValue];
|
|
|
|
|
buffer[4] = (Byte)(goals);
|
|
|
|
|
buffer[5] = (Byte)(goals >> 8);
|
|
|
|
|
buffer[6] = (Byte)(goals >> 16);
|
|
|
|
|
buffer[7] = 0;
|
|
|
|
|
buffer[8] = (Byte)[BMI integerValue];
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:9]];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
防丢设置
|
|
|
|
|
|
|
|
|
|
@param ONOFF 0:关闭 1:开启
|
|
|
|
|
*/
|
|
|
|
|
- (void)setTheLostWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
ONOFF:(BOOL)ONOFF {
|
|
|
|
|
|
|
|
|
|
Byte buffer[2];
|
|
|
|
|
buffer[0] = 1;
|
|
|
|
|
buffer[1] = ONOFF;
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:2]];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
久坐设置
|
|
|
|
|
|
|
|
|
|
@param ONOFF 0:关闭 1:开启
|
|
|
|
|
@param StartTime 开始时间
|
|
|
|
|
@param endTime 结束时间
|
|
|
|
|
@param cycle 周期
|
|
|
|
|
@param sittingTime 久坐时间
|
|
|
|
|
@param sittingThreshold 久坐阈值
|
|
|
|
|
*/
|
|
|
|
|
- (void)setSedentaryWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
ONOFF:(BOOL)ONOFF
|
|
|
|
|
StartTime:(NSString *)StartTime
|
|
|
|
|
EndTime:(NSString *)endTime
|
|
|
|
|
Cycle:(NSString *)cycle
|
|
|
|
|
SittingTime:(NSString *)sittingTime
|
|
|
|
|
SittingThreshold:(NSString *)sittingThreshold {
|
|
|
|
|
|
|
|
|
|
Byte buffer[8];
|
|
|
|
|
buffer[0] = ONOFF;
|
|
|
|
|
buffer[1] = StartTime.intValue;
|
|
|
|
|
buffer[2] = endTime.intValue;
|
|
|
|
|
// 周期
|
|
|
|
|
const char *cycleStr = [cycle cStringUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
// 二进制字符串转成整数
|
|
|
|
|
int cycleValue = 0;
|
|
|
|
|
for (int j = 0; j < 7; j ++) {
|
|
|
|
|
if (cycleStr[j] == '1') {
|
|
|
|
|
cycleValue += 1 * pow(2, j);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
buffer[3] = cycleValue;
|
|
|
|
|
buffer[4] = [sittingTime intValue];
|
|
|
|
|
buffer[5] = ([sittingTime intValue] >> 8);
|
|
|
|
|
buffer[6] = ([sittingThreshold intValue] & 0xff);
|
|
|
|
|
buffer[7] = [sittingThreshold intValue] >> 8;
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:8]];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
自动睡眠设置 (暂不使用)
|
|
|
|
|
|
|
|
|
|
@param ONOFF 0:关闭 1:开启
|
|
|
|
|
*/
|
|
|
|
|
- (void)setSleepWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
ONOFF:(BOOL)ONOFF {
|
|
|
|
|
|
|
|
|
|
Byte buffer[1];
|
|
|
|
|
buffer[0] = ONOFF;
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:1]];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
系统用户设置(key 0x27)
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)setSystemUserWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd {
|
|
|
|
|
// 1. 0:中文 1:英文 2.俄罗斯语 3.西班牙语 4.德国 5.意大利 6.法国 7.葡萄牙 8.波兰语 9.荷兰 10.希腊 11.土耳其 12.罗马尼亚 13.日语 14.繁体(目前只支持M6) 15.希伯来语 16.丹麦语 17.塞尔维亚语 18:其他
|
|
|
|
|
// 2. 0:24小时制 1: 12小时制 3. 单位秒,范围0-255
|
|
|
|
|
Byte buffer[4];
|
|
|
|
|
NSString *language = [BLETools getCurrentLanguage];
|
|
|
|
|
if ([language hasPrefix:@"zh"]) {
|
|
|
|
|
buffer[0] = 0;
|
|
|
|
|
// 单独处理有繁体的手环设备
|
|
|
|
|
if ([language hasPrefix:@"zh-Hant"]) {
|
|
|
|
|
buffer[0] = 14;
|
|
|
|
|
}
|
|
|
|
|
}else if ([language hasPrefix:@"en"]) {
|
|
|
|
|
buffer[0] = 1;
|
|
|
|
|
}else if ([language hasPrefix:@"ru"]) {
|
|
|
|
|
buffer[0] = 2;
|
|
|
|
|
}else if ([language hasPrefix:@"es"]) {
|
|
|
|
|
buffer[0] = 3;
|
|
|
|
|
}else if ([language hasPrefix:@"de"]) {
|
|
|
|
|
buffer[0] = 4;
|
|
|
|
|
}else if ([language hasPrefix:@"it"]) {
|
|
|
|
|
buffer[0] = 5;
|
|
|
|
|
}else if ([language hasPrefix:@"fr"]) {
|
|
|
|
|
buffer[0] = 6;
|
|
|
|
|
}else if ([language hasPrefix:@"pt"]) {
|
|
|
|
|
buffer[0] = 7;
|
|
|
|
|
}else if ([language hasPrefix:@"pl"]) {
|
|
|
|
|
buffer[0] = 8;
|
|
|
|
|
}else if ([language hasPrefix:@"nl"]) {
|
|
|
|
|
buffer[0] = 9;
|
|
|
|
|
}else if ([language hasPrefix:@"el"]) {
|
|
|
|
|
buffer[0] = 10;
|
|
|
|
|
}else if ([language hasPrefix:@"tr"]) {
|
|
|
|
|
buffer[0] = 11;
|
|
|
|
|
}else if ([language hasPrefix:@"ro"]) {
|
|
|
|
|
buffer[0] = 12;
|
|
|
|
|
}else if ([language hasPrefix:@"ja"]) {
|
|
|
|
|
buffer[0] = 13;
|
|
|
|
|
}else if ([language hasPrefix:@"he"]) {
|
|
|
|
|
buffer[0] = 15;
|
|
|
|
|
}else if ([language hasPrefix:@"da"]) {
|
|
|
|
|
buffer[0] = 16;
|
|
|
|
|
}else if ([language hasPrefix:@"sr"]) {
|
|
|
|
|
buffer[0] = 17;
|
|
|
|
|
}else {
|
|
|
|
|
buffer[0] = 18;
|
|
|
|
|
}
|
|
|
|
|
// 手环设置时间最后拼接一个12/24小时制,hasAMPM NO:24小时 YES:12小时
|
|
|
|
|
NSString *formatStringForHours = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 locale:[NSLocale currentLocale]];
|
|
|
|
|
NSRange containsA = [formatStringForHours rangeOfString:@"a"];
|
|
|
|
|
BOOL hasAMPM = containsA.location != NSNotFound;
|
|
|
|
|
buffer[1] = hasAMPM;
|
|
|
|
|
buffer[2] = 0;
|
|
|
|
|
buffer[3] = 1;
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:4]];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
喝水提醒设置(key 0x28)
|
|
|
|
|
|
|
|
|
|
@param ONOFF 喝水使能 0:关 1:开
|
|
|
|
|
@param startTime 开始时间 小时+分钟
|
|
|
|
|
@param endTime 结束时间 小时+分钟
|
|
|
|
|
@param cycle 周期
|
|
|
|
|
@param interval 喝水间隔设置 分钟
|
|
|
|
|
*/
|
|
|
|
|
- (void)setDrinkRemindWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
DrinkONOFF:(BOOL)ONOFF
|
|
|
|
|
StartTime:(NSString *)startTime
|
|
|
|
|
EndTime:(NSString *)endTime
|
|
|
|
|
Cycle:(NSString *)cycle
|
|
|
|
|
Interval:(NSString *)interval {
|
|
|
|
|
|
|
|
|
|
Byte buffer[8];
|
|
|
|
|
buffer[0] = ONOFF;
|
|
|
|
|
// 开始&&结束时间
|
|
|
|
|
NSArray *startArr = [startTime componentsSeparatedByString:@":"];
|
|
|
|
|
NSArray *endArr = [endTime componentsSeparatedByString:@":"];
|
|
|
|
|
buffer[1] = [startArr[0] intValue];
|
|
|
|
|
buffer[2] = [startArr[1] intValue];
|
|
|
|
|
buffer[3] = [endArr[0] intValue];
|
|
|
|
|
buffer[4] = [endArr[1] intValue];
|
|
|
|
|
// 周期
|
|
|
|
|
const char *cycleStr = [cycle cStringUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
// 二进制字符串转成整数
|
|
|
|
|
int cycleValue = 0;
|
|
|
|
|
for (int j = 0; j < 7; j ++) {
|
|
|
|
|
|
|
|
|
|
if (cycleStr[j] == '1') {
|
|
|
|
|
|
|
|
|
|
cycleValue += 1 * pow(2, j);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
buffer[5] = cycleValue;
|
|
|
|
|
buffer[6] = [interval intValue] & 0xff;
|
|
|
|
|
buffer[7] = [interval intValue] >> 8;
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:8]];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
设备电量请求
|
|
|
|
|
*/
|
|
|
|
|
- (void)requestBatteryWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd {
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
解除绑定请求(key 0x42)
|
|
|
|
|
*/
|
|
|
|
|
- (void)unbundledDeviceWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd {
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
拍照开关(key 0x46) ->手环使用
|
|
|
|
|
|
|
|
|
|
@param ONOFF 0:相机已关闭 1:相机已打开
|
|
|
|
|
*/
|
|
|
|
|
- (void)cameraSwitchWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
ONOFF:(BOOL)ONOFF {
|
|
|
|
|
|
|
|
|
|
Byte buffer[1];
|
|
|
|
|
buffer[0] = ONOFF;
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:1]];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
横竖显示(key 0x49)
|
|
|
|
|
|
|
|
|
|
@param isVertical 0:横屏1:竖屏
|
|
|
|
|
*/
|
|
|
|
|
- (void)relationDisplayWithBleCmdTypeFB:(BleCMD_FireBoltt )cmd
|
|
|
|
|
IsVertical:(BOOL)isVertical {
|
|
|
|
|
|
|
|
|
|
Byte buffer[1];
|
|
|
|
|
buffer[0] = isVertical;
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:1]];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
抬手亮屏显示(key 0x4A)
|
|
|
|
|
|
|
|
|
|
@param hand 0:左手 1:右手
|
|
|
|
|
@param raise 0:抬手亮屏关闭 1:抬手亮屏开启
|
|
|
|
|
@param flip 0:翻腕亮屏关闭 1:翻腕亮屏开启
|
|
|
|
|
*/
|
|
|
|
|
- (void)gesturesControlWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
Hand:(NSInteger)hand
|
|
|
|
|
Raise:(BOOL)raise
|
|
|
|
|
Flip:(BOOL)flip {
|
|
|
|
|
|
|
|
|
|
Byte buffer[3];
|
|
|
|
|
buffer[0] = hand;
|
|
|
|
|
buffer[1] = raise;
|
|
|
|
|
buffer[2] = flip;
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:3]];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
勿扰模式(key 0x2A)
|
|
|
|
|
|
|
|
|
|
@param ONOFF 勿扰使能 1: 开启 0: 关闭
|
|
|
|
|
@param startTime 开始时间
|
|
|
|
|
@param endTime 结束时间
|
|
|
|
|
*/
|
|
|
|
|
- (void)notDisturbWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
ONOFF:(BOOL)ONOFF
|
|
|
|
|
StartTime:(NSString *)startTime
|
|
|
|
|
EndTime:(NSString *)endTime {
|
|
|
|
|
|
|
|
|
|
Byte buffer[5];
|
|
|
|
|
buffer[0] = ONOFF;
|
|
|
|
|
|
|
|
|
|
// 开始&&结束时间
|
|
|
|
|
NSArray *startArr = [startTime componentsSeparatedByString:@":"];
|
|
|
|
|
NSArray *endArr = [endTime componentsSeparatedByString:@":"];
|
|
|
|
|
buffer[1] = [startArr[0] intValue];
|
|
|
|
|
buffer[2] = [startArr[1] intValue];
|
|
|
|
|
buffer[3] = [endArr[0] intValue];
|
|
|
|
|
buffer[4] = [endArr[1] intValue];
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:5]];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
提醒模式(key 0x2B)
|
|
|
|
|
|
|
|
|
|
@param remindType 提醒方式 1:亮屏 2:震动 3:亮屏+震动
|
|
|
|
|
*/
|
|
|
|
|
- (void)remindModelWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
RemindType:(NSInteger)remindType {
|
|
|
|
|
|
|
|
|
|
Byte buffer[1];
|
|
|
|
|
buffer[0] = remindType;
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:1]];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
同步实时数据(key 0xB0)
|
|
|
|
|
|
|
|
|
|
@param syncType 1:睡眠 2:心率 3:计步 4:运动模式 5:血压 6: 心电 7:血氧 8:体温
|
|
|
|
|
*/
|
|
|
|
|
- (void)realTimesyncWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
SyncType:(NSInteger)syncType {
|
|
|
|
|
Byte buffer[1];
|
|
|
|
|
buffer[0] = syncType;
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:1]];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
读取手环设置请求(key 0x2D)
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)readBraceletSetWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd {
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
读取手环配置请求(key 0x2E)
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)readProfileWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd {
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
运动目标设置
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param targetSteps 运动目标步数
|
|
|
|
|
@param sportMode 运动模式 0:计步 1:跑步 2:骑行 3:爬山
|
|
|
|
|
*/
|
|
|
|
|
- (void)setSportTargetWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
TargetSteps:(NSInteger)targetSteps
|
|
|
|
|
SportMode:(NSInteger)sportMode {
|
|
|
|
|
|
|
|
|
|
NSMutableData *value = [[NSMutableData alloc] init];
|
|
|
|
|
[value appendBytes:&targetSteps length:3];
|
|
|
|
|
[value appendBytes:&sportMode length:1];
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:value];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
设置推送
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param value 推送值
|
|
|
|
|
*/
|
|
|
|
|
- (void)setPushWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
value:(NSInteger)value {
|
|
|
|
|
NSData *data = [NSData dataWithBytes:&value length:2];
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:data];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
心率检测设置
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param ONOFF 开关
|
|
|
|
|
@param startTime 开始时间
|
|
|
|
|
@param endTime 结束时间
|
|
|
|
|
@param interval 间隔时间
|
|
|
|
|
*/
|
|
|
|
|
- (void)setHeartRateCheckWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
RateONOFF:(BOOL)ONOFF
|
|
|
|
|
StartTime:(NSString *)startTime
|
|
|
|
|
EndTime:(NSString *)endTime
|
|
|
|
|
Interval:(NSString *)interval {
|
|
|
|
|
// 开始&&结束时间
|
|
|
|
|
NSArray *startArr = [startTime componentsSeparatedByString:@":"];
|
|
|
|
|
NSArray *endArr = [endTime componentsSeparatedByString:@":"];
|
|
|
|
|
Byte buffer[6];
|
|
|
|
|
buffer[0] = ONOFF;
|
|
|
|
|
buffer[1] = [startArr[0] intValue];
|
|
|
|
|
buffer[2] = [startArr[1] intValue];
|
|
|
|
|
buffer[3] = [endArr[0] intValue];
|
|
|
|
|
buffer[4] = [endArr[1] intValue];
|
|
|
|
|
buffer[5] = [interval intValue];
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:6]];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 天气推送(最多三天,当天、明天、后天)
|
|
|
|
|
/// @param cmd 命令类型
|
|
|
|
|
/// @param weathers 天气数组{lowTemperature: Strting, highTemperature: Strting, currenTemperature: Strting, weatherType: Int}
|
|
|
|
|
- (void)setWeatherPushWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
Weathers:(NSArray *)weathers {
|
|
|
|
|
NSInteger length = 4 * weathers.count;
|
|
|
|
|
Byte buffer[length];
|
|
|
|
|
for (int i = 0; i < weathers.count; i ++) {
|
|
|
|
|
NSDictionary *dict = weathers[i];
|
|
|
|
|
buffer[0 + i * 4] = [dict[@"lowTemperature"] intValue];
|
|
|
|
|
buffer[1 + i * 4] = [dict[@"highTemperature"] intValue];
|
|
|
|
|
buffer[2 + i * 4] = [dict[@"weatherType"] intValue];
|
|
|
|
|
buffer[3 + i * 4] = [dict[@"currenTemperature"] intValue];
|
|
|
|
|
}
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:length]];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
推送两天的天气
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param lowTemperature 低温1
|
|
|
|
|
@param highTemperature 高温1
|
|
|
|
|
@param weatherType 天气类型1
|
|
|
|
|
@param lowTemperature2 低温2
|
|
|
|
|
@param highTemperature2 高温2
|
|
|
|
|
@param weatherType2 天气类型2
|
|
|
|
|
*/
|
|
|
|
|
- (void)setWeather2PushWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
LowTemperature:(NSString *)lowTemperature
|
|
|
|
|
HighTemperature:(NSString *)highTemperature
|
|
|
|
|
WeatherType:(NSInteger)weatherType
|
|
|
|
|
LowTemperature2:(NSString *)lowTemperature2
|
|
|
|
|
HighTemperature2:(NSString *)highTemperature2
|
|
|
|
|
WeatherType2:(NSInteger)weatherType2
|
|
|
|
|
{
|
|
|
|
|
Byte buffer[6];
|
|
|
|
|
buffer[0] = [lowTemperature intValue];
|
|
|
|
|
buffer[1] = [highTemperature intValue];
|
|
|
|
|
buffer[2] = weatherType;
|
|
|
|
|
buffer[3] = [lowTemperature2 intValue];
|
|
|
|
|
buffer[4] = [highTemperature2 intValue];
|
|
|
|
|
buffer[5] = weatherType2;
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:6]];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
气象指数推送
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型0
|
|
|
|
|
@param UV 紫外线
|
|
|
|
|
@param pressure 气压
|
|
|
|
|
@param altitude 海拔
|
|
|
|
|
*/
|
|
|
|
|
- (void)weatherIndexWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
UV:(NSString *)UV
|
|
|
|
|
Pressure:(NSString *)pressure
|
|
|
|
|
Altitude:(NSString *)altitude {
|
|
|
|
|
Byte buffer[5];
|
|
|
|
|
buffer[0] = [UV intValue];
|
|
|
|
|
buffer[1] = [pressure intValue] & 0xff;
|
|
|
|
|
buffer[2] = [pressure intValue] >> 8;
|
|
|
|
|
buffer[3] = [altitude intValue] & 0xff;
|
|
|
|
|
buffer[4] = [altitude intValue] >> 8;
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:5]];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
恢复出厂设置
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)restoreFactoryWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd {
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
单位设置
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型 (key 0x01)
|
|
|
|
|
@param measure 度量单位 (0:公制 1:英制)
|
|
|
|
|
@param temperature 温度 (0: 摄氏度 1:华氏摄氏度)
|
|
|
|
|
*/
|
|
|
|
|
- (void)unitSettingWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
measure:(NSInteger)measure
|
|
|
|
|
temperature:(NSInteger)temperature {
|
|
|
|
|
Byte buffer[2];
|
|
|
|
|
buffer[0] = measure;
|
|
|
|
|
buffer[1] = temperature;
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:2]];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
呼吸设置
|
|
|
|
|
*/
|
|
|
|
|
- (void)breatheWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd withTime:(int)time {
|
|
|
|
|
Byte buffer[1]; buffer[0] = time;
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:1]];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
GPS信号强度同步到设备
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param dialType 信号强度
|
|
|
|
|
*/
|
|
|
|
|
- (void)GPSSignalStrengthWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
dialType:(NSInteger)dialType {
|
|
|
|
|
Byte buffer[1]; buffer[0] = dialType;
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:1]];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
准备启动Esim服务
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)startEsimWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd {
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
结束Esim服务
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)endEsimWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd {
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
获取设备EID
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)getDeviceEidWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd {
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
获取设备IMEI号
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)getDeviceIMEIWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd {
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
获取手表的profile列表
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)getProfileListWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd {
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:0];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
开启profile
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)enableProfileWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd iccid:(NSString *)iccid {
|
|
|
|
|
NSData *data = [BLETools convertHexStrToData: iccid];
|
|
|
|
|
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:data];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
禁用profile
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)disableProfileWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd iccid:(NSString *)iccid{
|
|
|
|
|
NSData *data = [BLETools convertHexStrToData: iccid];
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:data];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
删除profile
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)deleteProfileWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd iccid:(NSString *)iccid{
|
|
|
|
|
NSData *data = [BLETools convertHexStrToData: iccid];
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:data];
|
|
|
|
|
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
发送数据到设备
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param message sdk出来的数据
|
|
|
|
|
*/
|
|
|
|
|
- (void)sendMessageWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
message:(NSString *)message {
|
|
|
|
|
NSData *data = [BLETools convertHexStrToData: message];
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value: data];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 发送FLASH数据命令
|
|
|
|
|
/// @param cmd 命令类型
|
|
|
|
|
/// @param data 数据
|
|
|
|
|
- (void)falshSendWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
total:(NSInteger)total
|
|
|
|
|
curren:(NSInteger)curren
|
|
|
|
|
lenght:(NSInteger)lenght
|
|
|
|
|
data:(NSData *)data {
|
|
|
|
|
NSInteger crc = 0xff;
|
|
|
|
|
for (int i = 0; i < data.length; i++) {
|
|
|
|
|
crc^= ((Byte*)([data bytes]))[i] & 0xFF;
|
|
|
|
|
for (int j = 0; j < 8; j++) {
|
|
|
|
|
if((crc & 1) !=0){
|
|
|
|
|
crc >>=1;
|
|
|
|
|
crc^=0xB8;
|
|
|
|
|
}else{
|
|
|
|
|
crc>>=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
NSMutableData *value = [NSMutableData dataWithBytes:&total length:2];
|
|
|
|
|
[value appendData:[NSData dataWithBytes:¤ length:2]];
|
|
|
|
|
[value appendData:[NSData dataWithBytes:&lenght length:2]];
|
|
|
|
|
[value appendData:[NSData dataWithBytes:&crc length:2]];
|
|
|
|
|
[value appendData:data];
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value: value];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 推送表盘
|
|
|
|
|
/// @param cmd 命令类型
|
|
|
|
|
/// @param number 第几个表盘
|
|
|
|
|
/// @param type 0:删除表盘 1:增加表盘 2:更新表盘
|
|
|
|
|
/// @param fileLenght 文件大小
|
|
|
|
|
- (void)newDialPushWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
number:(NSInteger)number
|
|
|
|
|
type:(NSInteger)type
|
|
|
|
|
fileLenght:(NSInteger)fileLenght {
|
|
|
|
|
Byte buffer[2];
|
|
|
|
|
buffer[0] = number;
|
|
|
|
|
buffer[1] = type;
|
|
|
|
|
NSMutableData *data = [NSMutableData dataWithBytes:buffer length:2];
|
|
|
|
|
[data appendData:[NSData dataWithBytes:&fileLenght length:4]];
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value: data];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
体温检测设置
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param ONOFF 开关
|
|
|
|
|
@param startTime 开始时间
|
|
|
|
|
@param endTime 结束时间
|
|
|
|
|
@param interval 间隔时间
|
|
|
|
|
*/
|
|
|
|
|
- (void)setTemperatureCheckWithBleCmdTypeFB:(BleCMD_FireBoltt)cmd
|
|
|
|
|
RateONOFF:(BOOL)ONOFF
|
|
|
|
|
StartTime:(NSString *)startTime
|
|
|
|
|
EndTime:(NSString *)endTime
|
|
|
|
|
Interval:(NSString *)interval {
|
|
|
|
|
// 开始&&结束时间
|
|
|
|
|
NSArray *startArr = [startTime componentsSeparatedByString:@":"];
|
|
|
|
|
NSArray *endArr = [endTime componentsSeparatedByString:@":"];
|
|
|
|
|
Byte buffer[6];
|
|
|
|
|
buffer[0] = ONOFF;
|
|
|
|
|
buffer[1] = [startArr[0] intValue];
|
|
|
|
|
buffer[2] = [startArr[1] intValue];
|
|
|
|
|
buffer[3] = [endArr[0] intValue];
|
|
|
|
|
buffer[4] = [endArr[1] intValue];
|
|
|
|
|
buffer[5] = [interval intValue];
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:6]];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
根据类型获取对应数据
|
|
|
|
|
|
|
|
|
|
@param cmd 蓝牙指令类型
|
|
|
|
|
*/
|
|
|
|
|
- (NSDictionary *)dataFromCmd:(BleCMD_FireBoltt)cmd {
|
|
|
|
|
|
|
|
|
|
NSInteger bleCMDBranch;//小分类
|
|
|
|
|
NSInteger bleCMDMain;//常识性的注释 大分类
|
|
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
|
case BleCMD_setIngTime: // 时间设置 0X20
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0X20;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_bindingDevice: // 绑定请求 0X44
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0X44;
|
|
|
|
|
bleCMDMain = 0X04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_cameraSwitch: // 拍照开关 0X46
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0X46;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case BleCMD_cameraOFF: // 拍照退出 0X48
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0X48;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_syncContact: // 同步联系人 0X4B
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0X4C;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// case BleCMD_watchWifi: // 手表WIFI 0X4C
|
|
|
|
|
// {
|
|
|
|
|
//
|
|
|
|
|
// bleCMDBranch = 0x4c;
|
|
|
|
|
// bleCMDMain = 0x04;
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_inputStart: // 协助输入开始 0X4D
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x4d;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_inputSend: // 发送协助输入 0X16
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x16;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_shearPlate: // 发送剪切板数据 0X17
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x17;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_inputEnd: // 协助输入结束 0X18
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x18;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_dialPush: // 表盘推送 0X4E
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x4E;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_urgentDial: // 紧急拨号 0X15
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x15;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_findDevice: // 查找设备 0X50
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0x50;
|
|
|
|
|
bleCMDMain = 0x05;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_syncHealth: // 同步健康数据指令 0xA0
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0xA0;
|
|
|
|
|
bleCMDMain = 0x0A;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case BleCMD_sportStateToDevice: //!< 运动状态同步到设备 0xB3
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0xB3;
|
|
|
|
|
bleCMDMain = 0x0A;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case BleCMD_GPSSignalStrength: //!< GPS信号强度同步到设备 0xB5
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0xB5;
|
|
|
|
|
bleCMDMain = 0x0A;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case BleCMD_wifiPassWord: // WIFI需要密码 0x1A
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x1A;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_wifiLink: // 已保存的WIFI 0X1B
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x1B;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_wifiNoPassWord: // WIFI无需密码 0X1C
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x1C;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_firmwareUpdate: // 固件升级 0x10
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x10;
|
|
|
|
|
bleCMDMain = 0x01;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_firmwareVersion: // 固件版本信息 0x12
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x12;
|
|
|
|
|
bleCMDMain = 0x01;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_setAlarmClock: // 闹钟设置 0x21
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x21;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_setUserInfo: // 用户信息设置 0x23
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x23;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_setTheLost: // 防丢设置 0x24
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x24;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_setSedentary: // 久坐设置 0x25
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x25;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_setSleep: // 自动睡眠设置 0x26
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x26;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_setSystemUser: // 系统用户设置 0x27
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x27;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_setDrinkRemind: // 喝水提醒设置 0x28
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x28;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_requestBattery: // 设备电量请求 0x40
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x40;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_unbundledDevice: // 解除绑定命令 0x42
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x42;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_relationDisplay: // 横竖显示 0x49
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x49;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_gesturesControl: // 抬手亮屏 0x4A
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x4A;
|
|
|
|
|
bleCMDMain = 0x04;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_remindSwitch: // 提醒开关 0x60
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x60;
|
|
|
|
|
bleCMDMain = 0x06;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_notDisturb: // 勿扰模式 0x2A
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x2A;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_remindModel: // 提醒模式 0x2B
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0x2B;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_realTimesync:
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bleCMDBranch = 0xB0;
|
|
|
|
|
bleCMDMain = 0x0A;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_setPush: // 推送设置 0x29
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0x29;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_readBraceletSet: // 读取手环设置请求 0x2D
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0x2D;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_readProfile: // 读取手环配置请求 0x2E
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0x2E;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_setSportTarget: // 设置运动目标(手环使用)
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0x22;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_heartRateCheck: // 心率检测
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0x2C;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_FireBoltt_weatherPush: // 天气推送
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0x30;
|
|
|
|
|
bleCMDMain = 0x03;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_qrCodePush: // 二维码推送
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0xE0;
|
|
|
|
|
bleCMDMain = 0x0E;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_restoreFactory: // 恢复出厂
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0xC7;
|
|
|
|
|
bleCMDMain = 0x0C;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_weatherIndex: // 气象指数推送
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0xE1;
|
|
|
|
|
bleCMDMain = 0x0E;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_unitSetting: //单位设置
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0x01;
|
|
|
|
|
bleCMDMain = 0x02;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_braceletPialPush: // 手环表盘推送
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0xE2;
|
|
|
|
|
bleCMDMain = 0x0E;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_dialRequest: // 表盘请求 0X4F
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0X4F;
|
|
|
|
|
bleCMDMain = 0X04;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_breathe: //!< 呼吸设置 0x30
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0X30;
|
|
|
|
|
bleCMDMain = 0X02;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_falshSend:
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0X03;
|
|
|
|
|
bleCMDMain = 0X14;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_newDialPush:
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0X05;
|
|
|
|
|
bleCMDMain = 0X16;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BleCMD_temperatureCheck:
|
|
|
|
|
{
|
|
|
|
|
bleCMDBranch = 0X35;
|
|
|
|
|
bleCMDMain = 0X02;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
// 查找设备 0X50
|
|
|
|
|
bleCMDBranch = 0x50;
|
|
|
|
|
bleCMDMain = 0x05;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return @{@"bleCMDBranch":@(bleCMDBranch),@"bleCMDMain":@(bleCMDMain)};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark ------------新协议 组建命令
|
|
|
|
|
|
|
|
|
|
- (BlueToothItemFireBoltt *)getCmd:(BleCMD_FireBoltt)cmd value:(NSData *)buffer {
|
|
|
|
|
|
|
|
|
|
// 序号
|
|
|
|
|
NSInteger sid = [self getSendCmdID];
|
|
|
|
|
|
|
|
|
|
// 命令类型 && key
|
|
|
|
|
NSDictionary *dict = [self dataFromCmd:cmd];
|
|
|
|
|
NSInteger command = [dict[@"bleCMDMain"] integerValue];
|
|
|
|
|
NSInteger key = [dict[@"bleCMDBranch"] integerValue];
|
|
|
|
|
|
|
|
|
|
// 1.CRC计算
|
|
|
|
|
Byte cmdKeybyte[5];
|
|
|
|
|
cmdKeybyte[0] = command;
|
|
|
|
|
cmdKeybyte[1] = LTwo_Version;
|
|
|
|
|
cmdKeybyte[2] = key;
|
|
|
|
|
cmdKeybyte[3] = (Byte)(buffer.length >> 8);
|
|
|
|
|
cmdKeybyte[4] = (Byte)(buffer.length & 0xff);
|
|
|
|
|
|
|
|
|
|
// L2层数据构建
|
|
|
|
|
NSMutableData *contentData = [NSMutableData new];
|
|
|
|
|
[contentData appendBytes:cmdKeybyte length:5];
|
|
|
|
|
[contentData appendData:buffer];
|
|
|
|
|
|
|
|
|
|
// 8位CRC计算
|
|
|
|
|
int crc = 0xff;
|
|
|
|
|
for (int i = 0; i < contentData.length; i++) {
|
|
|
|
|
crc^= ((Byte*)([contentData bytes]))[i] & 0xFF;
|
|
|
|
|
for (int j = 0; j < 8; j++) {
|
|
|
|
|
if((crc & 1) !=0){
|
|
|
|
|
crc >>=1;
|
|
|
|
|
crc^=0xB8;
|
|
|
|
|
}else{
|
|
|
|
|
crc>>=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//2.包头L1 (8bytes)
|
|
|
|
|
Byte byte[8];
|
|
|
|
|
byte[0] = Identification;//识别标志
|
|
|
|
|
byte[1] = [BluetoothToolFireBoltt stitchWithErr:1 Ack:0 Vision:0];
|
|
|
|
|
byte[2] = (Byte)(contentData.length >> 8);//取高八位
|
|
|
|
|
byte[3] = (Byte)(contentData.length & 0xff);//取低八位
|
|
|
|
|
byte[4] = (Byte)(crc >> 8);//CRC 高八位
|
|
|
|
|
byte[5] = (Byte)(crc & 0xff);//CRC 低八位
|
|
|
|
|
byte[6] = (Byte)(sid >> 8);//序列号 高八位
|
|
|
|
|
byte[7] = (Byte)(sid & 0xff);//序列号 低八位
|
|
|
|
|
|
|
|
|
|
// 3.L2数据(5bytes+buffer) + L1
|
|
|
|
|
NSMutableData *data = [[NSMutableData alloc] initWithBytes:byte length:8];
|
|
|
|
|
[data appendData:contentData];
|
|
|
|
|
|
|
|
|
|
// 4.构建请求体
|
|
|
|
|
return [[BlueToothItemFireBoltt alloc] initWithbyteBuffer:data
|
|
|
|
|
sid:sid
|
|
|
|
|
cmd:cmd
|
|
|
|
|
dataSource:self];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
序号
|
|
|
|
|
*/
|
|
|
|
|
- (NSInteger)getSendCmdID {
|
|
|
|
|
static NSInteger nSendCmdID = 0;
|
|
|
|
|
nSendCmdID ++;
|
|
|
|
|
return nSendCmdID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - BluetoothDelegate
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
蓝牙指令成功回调
|
|
|
|
|
|
|
|
|
|
@param manager 蓝牙管理器
|
|
|
|
|
@param sid 请求需要
|
|
|
|
|
@param data 返回数据
|
|
|
|
|
@param cmdId 请求类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)bluetoothManager:(BluetoothFireBoltt *)manager
|
|
|
|
|
sequenceID:(NSInteger)sid
|
|
|
|
|
didCompleteWithData:(id)data
|
|
|
|
|
cmdId:(BleCMD_FireBoltt)cmdId {
|
|
|
|
|
|
|
|
|
|
// 解析数据
|
|
|
|
|
// <ba30001c 1c800000 00000000 00000000 00000000 00070072 00000700 71000007 00730000>
|
|
|
|
|
// 完整数据收到解析处理
|
|
|
|
|
//NSLog(@"我是接收到的完整数据 -------%@",data);
|
|
|
|
|
|
|
|
|
|
NSDictionary *dict = [L2DataParseFireBoltt L2_ParseData:data type:cmdId];
|
|
|
|
|
|
|
|
|
|
if (IsDelegate(self.delegate, finishedHandle:data:cmd:)) {
|
|
|
|
|
|
|
|
|
|
[self.delegate finishedHandle:self data:dict cmd:cmdId];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
蓝牙指令失败回调
|
|
|
|
|
|
|
|
|
|
@param manager 蓝牙管理器
|
|
|
|
|
@param sid 请求需要
|
|
|
|
|
@param data 返回数据
|
|
|
|
|
@param cmdId 请求类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)bluetoothManager:(BluetoothFireBoltt *)manager
|
|
|
|
|
sequenceID:(NSInteger)sid
|
|
|
|
|
didErrorWithData:(id)data
|
|
|
|
|
cmdId:(BleCMD_FireBoltt)cmdId {
|
|
|
|
|
|
|
|
|
|
if (IsDelegate(self.delegate, failedHandle:data:cmd:)) {
|
|
|
|
|
|
|
|
|
|
[self.delegate failedHandle:self data:data cmd:cmdId];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
蓝牙指令超时回调
|
|
|
|
|
|
|
|
|
|
@param manager 蓝牙管理器
|
|
|
|
|
@param sid 请求需要
|
|
|
|
|
@param data 返回数据
|
|
|
|
|
@param cmdId 请求类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)bluetoothManager:(BluetoothFireBoltt *)manager
|
|
|
|
|
sequenceID:(NSInteger)sid
|
|
|
|
|
didTimeOutWithData:(id)data
|
|
|
|
|
cmdId:(BleCMD_FireBoltt)cmdId {
|
|
|
|
|
|
|
|
|
|
if (IsDelegate(self.delegate, timeOutHandle:data:cmd:)) {
|
|
|
|
|
|
|
|
|
|
[self.delegate timeOutHandle:self data:data cmd:cmdId];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
表盘发送完成
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param pushType 推送类型
|
|
|
|
|
*/
|
|
|
|
|
- (void)braceletDialPushComplete:(BleCMD_FireBoltt)cmd
|
|
|
|
|
pushType:(NSInteger)pushType{
|
|
|
|
|
Byte buffer[1];
|
|
|
|
|
buffer[0] = pushType;
|
|
|
|
|
NSData *completeData = [NSData dataWithBytes:buffer length:1];
|
|
|
|
|
[self braceletPialPush:cmd valuesData:completeData];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
发送表盘数据内容
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param pushType 推送类型
|
|
|
|
|
@param Offset 偏移
|
|
|
|
|
@param keep 保留
|
|
|
|
|
@param DialPushData 图的数据
|
|
|
|
|
*/
|
|
|
|
|
- (void)braceletDialPushData:(BleCMD_FireBoltt)cmd
|
|
|
|
|
pushType:(NSInteger)pushType
|
|
|
|
|
offset:(NSInteger)Offset
|
|
|
|
|
keep:(NSInteger)keep
|
|
|
|
|
dialPushData:(NSData *)DialPushData{
|
|
|
|
|
Byte buffer[6];
|
|
|
|
|
buffer[0] = pushType;
|
|
|
|
|
buffer[1] = (Offset >> 24) & 0xff;
|
|
|
|
|
buffer[2] = (Offset >> 16) & 0xff;
|
|
|
|
|
buffer[3] = (Offset >> 8) & 0xff;
|
|
|
|
|
buffer[4] = Offset & 0xff;
|
|
|
|
|
buffer[5] = keep & 0xff;
|
|
|
|
|
NSMutableData *sendDialData = [NSMutableData dataWithBytes:buffer length:6];
|
|
|
|
|
[sendDialData appendData:DialPushData];
|
|
|
|
|
[self braceletPialPush:cmd valuesData:[NSData dataWithData:sendDialData]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
手机推送表盘的信息
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param pushType 推送类型
|
|
|
|
|
@param dialID 表盘ID
|
|
|
|
|
@param fileSize 文件大小
|
|
|
|
|
*/
|
|
|
|
|
- (void)braceletDialPush:(BleCMD_FireBoltt)cmd
|
|
|
|
|
pushType:(NSInteger)pushType
|
|
|
|
|
dialID:(NSInteger)dialID
|
|
|
|
|
fileSize:(NSInteger)fileSize{
|
|
|
|
|
Byte buffer[9];
|
|
|
|
|
buffer[0] = pushType;
|
|
|
|
|
buffer[1] = (dialID >> 24) & 0xff;
|
|
|
|
|
buffer[2] = (dialID >> 16) & 0xff;
|
|
|
|
|
buffer[3] = (dialID >> 8) & 0xff;
|
|
|
|
|
buffer[4] = dialID & 0xff;
|
|
|
|
|
buffer[5] = (fileSize >> 24) & 0xff;
|
|
|
|
|
buffer[6] = (fileSize >> 16) & 0xff;
|
|
|
|
|
buffer[7] = (fileSize >> 8) & 0xff;
|
|
|
|
|
buffer[8] = fileSize & 0xff;
|
|
|
|
|
|
|
|
|
|
NSData *dialData = [NSData dataWithBytes:buffer length:9];
|
|
|
|
|
[self braceletPialPush:cmd valuesData:dialData];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
发送表盘命令
|
|
|
|
|
|
|
|
|
|
@param cmd 命令类型
|
|
|
|
|
@param valuesData 表盘数据
|
|
|
|
|
*/
|
|
|
|
|
- (void)braceletPialPush:(BleCMD_FireBoltt)cmd
|
|
|
|
|
valuesData:(NSData * )valuesData {
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:valuesData];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
运动状态同步到设备 0xB3
|
|
|
|
|
*/
|
|
|
|
|
- (void)sportStateToDeviceWithBleCmdType:(BleCMD_FireBoltt)cmd isOn:(int)on sportType:(int)sportType {
|
|
|
|
|
Byte buffer[2]; buffer[0] = on; buffer[1] = sportType;
|
|
|
|
|
BlueToothItemFireBoltt *item = [self getCmd:cmd value:[NSData dataWithBytes:buffer length:2]];
|
|
|
|
|
[self.blueTooth writeWithBleItem:item];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// 二维码识别
|
|
|
|
|
/// - Parameter qrcodeImage: 二维码图片
|
|
|
|
|
- (NSString *)readQRCodeFromImage:(UIImage *)qrcodeImage
|
|
|
|
|
{
|
|
|
|
|
//if (qrcodeImage)
|
|
|
|
|
{
|
|
|
|
|
//1. 初始化扫描仪,设置设别类型和识别质量
|
|
|
|
|
CIDetector*detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{ CIDetectorAccuracy : CIDetectorAccuracyHigh }];
|
|
|
|
|
//2. 扫描获取的特征组
|
|
|
|
|
NSArray *features = [detector featuresInImage:[CIImage imageWithCGImage:qrcodeImage.CGImage]];
|
|
|
|
|
//3. 获取扫描结果
|
|
|
|
|
CIQRCodeFeature *feature = [features objectAtIndex:0];
|
|
|
|
|
NSString *scannedResult = feature.messageString;
|
|
|
|
|
NSLog(@"扫描到的结果 %@",scannedResult);
|
|
|
|
|
return scannedResult;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 杰里表盘推送
|
|
|
|
|
- (void)newJerryDialPush:(NSString *)path urlName:(NSString *)urlName fileData:(NSData *)fileData
|
|
|
|
|
{
|
|
|
|
|
NSString *fileName = [NSString stringWithFormat:@"/%@",[self stringIntercepting:urlName]];
|
|
|
|
|
[JL_Tools removePath:path];
|
|
|
|
|
|
|
|
|
|
NSString *binPath = [JL_Tools createOn:NSDocumentDirectory MiddlePath:@"" File:[self stringIntercepting:urlName]];
|
|
|
|
|
[JL_Tools writeData:fileData fillFile:binPath];
|
|
|
|
|
NSData *pathData = [NSData dataWithContentsOfFile:binPath];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NSString *fileName = [NSString stringWithFormat:@"/%@",[binPath lastPathComponent]];
|
|
|
|
|
NSLog(@"-->添加自定义表盘的路径:%@",binPath);
|
|
|
|
|
NSLog(@"-->添加自定义表盘的大小:%lld",(long long)pathData.length);
|
|
|
|
|
|
|
|
|
|
[DialManager listFile:^(DialOperateType type, NSArray * _Nullable array) {
|
|
|
|
|
if (type == DialOperateTypeSuccess && array.count > 0)
|
|
|
|
|
{
|
|
|
|
|
if ([array containsObject:[self stringIntercepting:urlName]])
|
|
|
|
|
{
|
|
|
|
|
[DialManager deleteFile:[NSString stringWithFormat:@"/%@",[self stringIntercepting:urlName]] Result:^(DialOperateType type, float progress) {
|
|
|
|
|
if (type == DialOperateTypeSuccess)
|
|
|
|
|
{
|
|
|
|
|
[self JerryDialPush:fileName pathData:pathData];
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
[self JerryDialPush:fileName pathData:pathData];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
- (void)JerryDialPush:(NSString *)fileName pathData:(NSData *)pathData
|
|
|
|
|
{
|
|
|
|
|
[DialManager repaceFile:fileName Content:pathData Result:^(DialOperateType type, float progress) {
|
|
|
|
|
if (type == DialOperateTypeNoSpace) {
|
|
|
|
|
NSLog(@"空间不足");
|
|
|
|
|
// [SVProgressHUD dismiss];
|
|
|
|
|
// [SVProgressHUD showErrorWithStatus:@"空间不足"];
|
|
|
|
|
[DialManager listFile:^(DialOperateType type, NSArray * _Nullable array) {
|
|
|
|
|
if (type == DialOperateTypeSuccess && array.count > 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *str = [NSString stringWithFormat:@"/%@",array[array.count-1]];
|
|
|
|
|
[DialManager deleteFile:str Result:^(DialOperateType type, float progress) {
|
|
|
|
|
if (type == DialOperateTypeSuccess)
|
|
|
|
|
[self JerryDialPush:fileName pathData:pathData];
|
|
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
if (type == DialOperateTypeFail) {
|
|
|
|
|
NSLog(@"添加失败");
|
|
|
|
|
[SVProgressHUD dismiss];
|
|
|
|
|
[SVProgressHUD showErrorWithStatus:@"推送失败"];
|
|
|
|
|
}
|
|
|
|
|
if (type == DialOperateTypeDoing) {
|
|
|
|
|
[SVProgressHUD showWithStatus:[NSString stringWithFormat:@"%@:%.1f%%",NSLocalizedString(@"推送中", nil),progress*100.0f]];
|
|
|
|
|
}
|
|
|
|
|
if (type == DialOperateTypeSuccess) {
|
|
|
|
|
NSLog(@"添加完成");
|
|
|
|
|
[SVProgressHUD show];
|
|
|
|
|
//[SVProgressHUD showInfoWithStatus:@"添加完成"];
|
|
|
|
|
/*--- 更新缓存 ---*/
|
|
|
|
|
[self activeCustomWatch:fileName];//设置自定义表盘
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)activeCustomWatch:(NSString *)fileName
|
|
|
|
|
{
|
|
|
|
|
[[BluetoothFireBoltt shareInstance].mAssist.mCmdManager.mFlashManager cmdWatchFlashPath:fileName Flag:JL_DialSettingActivateCustomDial
|
|
|
|
|
Result:^(uint8_t flag, uint32_t size,
|
|
|
|
|
NSString * _Nullable path,
|
|
|
|
|
NSString * _Nullable describe) {
|
|
|
|
|
[JL_Tools mainTask:^{
|
|
|
|
|
[SVProgressHUD showInfoWithStatus:NSLocalizedString((flag != 0) ? @"设置失败" : @"设置成功", nil)];
|
|
|
|
|
if (flag == 0)
|
|
|
|
|
{
|
|
|
|
|
[[BluetoothFireBoltt shareInstance].mAssist.mCmdManager.mFlashManager cmdWatchFlashPath:fileName Flag:JL_DialSettingSetDial Result:^(uint8_t flag, uint32_t size, NSString * _Nullable path, NSString * _Nullable describe) {
|
|
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (NSString *)stringIntercepting:(NSString *)filePath
|
|
|
|
|
{
|
|
|
|
|
NSString *fileName = [NSString stringWithFormat:@"%@",[[NSFileManager defaultManager] displayNameAtPath:filePath]];
|
|
|
|
|
// if ([fileName hasSuffix:@".bin"])
|
|
|
|
|
// {
|
|
|
|
|
// fileName = [fileName stringByReplacingOccurrencesOfString:@".bin" withString:@""];
|
|
|
|
|
// }
|
|
|
|
|
if ([fileName containsString:@"_"])
|
|
|
|
|
{
|
|
|
|
|
if ([fileName hasSuffix:@".bin"])
|
|
|
|
|
fileName = [fileName selcteStringWithSelectSatrt:@"_" selecteEnd:@".bin"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [fileName uppercaseString];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@end
|