clingwinsdk 0.0.1 clingwinsdk: ^0.0.1 copied to clipboard
Cling sdk for flutter on windows.
example/lib/main.dart
import 'dart:io';
import 'dart:ui';
import 'package:clingwinsdk/cling_device.dart';
import 'package:clingwinsdk/wearablesdk/model/cling_cmd.dart';
import 'package:clingwinsdk/wearablesdk/native_if.dart';
import 'package:clingwinsdk/wearablesdk/native_test.dart';
import 'package:clingwinsdk_example/event_model.dart';
import 'package:clingwinsdk_example/scan_regist.dart';
import 'package:clingwinsdk_example/test.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:clingwinsdk/cling_ble_manager.dart';
import 'kml_utils.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isMacOS) {
// NativeIf.initNativeSdk('HCa3f4b08b799e28af', '7978e5e9477d07dd5d7dc79fd1bc00d7', 'BxctUCjDgKG7gqX4+GDXWIpU3u75oakJjE8nj+neeXc=');
// NativeIf.initNativeSdk('HCa3f4b08b799e28af', '7978e5e9477d07dd5d7dc79fd1bc00d7', 'AHLglDS9wVK3RNGietLVmWeCHfM0XnXeBCEAIh0ETyU=');
NativeIf.initNativeSdk(
'hc4b39eae99ea03f2',
'56752d796a1369ffea6b8eb5c47c7e27',
'EtuuqvAWwYdHZ8CH1+c+f9sIY3yFN9xky6YCG4D6A1oT05r79Qg8SXUQysk0O/Xs');
// NativeIf.initNativeSdk('hc61ae700d3a77de5', '9ba1635dc020258644b8a9d0df54b05c', 'ftqrg8ZFeFtaFDfnNTtGQPr1s5pOCokfJQQxn8kkTrnFmCoL5H+BXMSJmu9wjmzR');
nativeTest();
testKml();
} else {
await ClingBleManager.initialize(
'hc4b39eae99ea03f2', '56752d796a1369ffea6b8eb5c47c7e27');
}
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
onGenerateRoute: (settings) {
if (settings.name == 'test') {
return MaterialPageRoute(builder: (context) {
return const ScanRegistTest();
});
}
},
home: const Scaffold(
body: HomeWidget(),
),
);
}
}
class HomeWidget extends StatefulWidget {
const HomeWidget({super.key});
@override
State<HomeWidget> createState() => _HomeWidgetState();
}
class _HomeWidgetState extends State<HomeWidget> with HLTest {
List<EventModel> get _events => [
EventModel(
name: '测试',
event: () {
Navigator.of(context).pushNamed('test');
},
pass: true),
EventModel(name: '搜索', event: testble, pass: true),
EventModel(
name: 'disconnectt',
event: () {
ClingBleManager.disconnect();
},
pass: true),
EventModel(name: '设备信息', event: CLCmdDeviceInfo.load, pass: true),
// EventModel(name: '设置设备信息', event: setDeviceInfo, pass: true),
EventModel(name: '同步时间', event: CLCmdTimeSync.sync, pass: true),
EventModel(
name: '激活',
event: () {
ClingBleManager.registerDevice(1976, 1);
},
pass: true),
EventModel(
name: '反激活', event: ClingBleManager.deRegisterDevice, pass: true),
EventModel(
name: '设备Config',
event: () {
final data = CLCmdDeviceConfig(
PPGDayIntervalMilliSec: 60000, //ppg白天时间间隔
PPGNightIntervalMilliSec: 60000, //ppg晚上时间间隔
SkinTempDayIntervalMilliSec: 60000, //白天肤温间隔
SkinTempNightIntervalMilliSec: 60000, //晚上肤温间隔
bUIScreenActivateWristFlip: false, //翻腕亮屏
bUIScreenActivatePressHold1s: true, //1s点亮屏幕
bUIScreenActivatePressHold3s: false, //3s点亮屏幕
bUIScreenTapping: true, //轻拍屏幕
bUINavigationTapping: true, //
bUINavigationWristShaking: true,
bReminderOffWeekends: true,
idleAlertTimeInMinutes: 30, //久坐提醒时间间隔
idleAlertTimeStart: 9, //久坐提醒开始时间
idleAlertTimeEnd: 20, //久坐提醒终止时间
screenOnTimeGeneral: 10, //屏幕关闭时长【2-15】
screenOnTimeHeartRate: 25, //心率监测关闭时长【15-60】,default=25
sleepSensitivity: 1, //睡眠灵敏度0-低,1-中,2-高
stepSensitivity: 2, //记步灵敏度2-低,1-中,0-高
vocSampleRate: 0, //voc手环采样率
alcoholSensitivity: 2, //酒精监测灵敏度2-低,1-种,0-高,特定手环使用
cityname: 'shanghai',
hrbroadcast: 1, //心率广播开关,1开,0关
touchEnable: true, //触摸开关
autoBPEnable: false, //自动血压
autoBOEnable: false, //自动血氧开关
);
data.send();
},
pass: true),
EventModel(
name: '设置语言',
event: () {
CLCmdLanguage.setLanguage(1);
},
pass: true),
EventModel(
name: '设置用户信息',
event: () {
final data = CLCmdUserProfile(
height_in_cm: 176,
weight_in_kg: 65,
stride_length_in_cm: 86,
stride_length_run_in_cm: 110,
stepRateForRunLength: 2,
units_type: 0,
nickname: '张三',
clock_orientation: 1,
sleep_alarm_day_of_week: 1 | (0x7f + 1),
bed_hr: 15,
bed_min: 46,
wakeup_hr: 15,
wakeup_min: 48,
screen_display_option: 1,
touch_virbration: 1,
daily_goal: 8,
training_display_option: 1,
age: 28,
sex: 1,
stride_length_run_indoor_in_cm: 100,
hr_alarm_rate: 2,
pace_alarm_zone: 20,
app_setting: 1,
caloryDisplayType: 1,
healthinfolevel: 1,
stepAlarmEn: 1,
stepAlarmVal: 1,
calAlarmEn: 1,
calAlarmVal: 1,
stAlarmVal: 1,
stMinAlarmVal: 1);
data.send();
},
pass: true),
// EventModel(
// name: 'daytotal信息',
// event: () {
// clingNative.cwsLoadDailyActivityTotal();
// },
// pass: false),
EventModel(
name: '设置天气',
event: () {
//最多设置五天,0晴天,1多云,2下雨,3下雪
for (var i = 0; i < 4; i++) {
final data = CLCmdWeatherData(
month: 1,
day: 17 + i,
type: 3,
temperature_low: i + 30,
temperature_high: 50 + i,
aqi: 16 + i);
data.add(i);
}
CLCmdWeatherData.setup();
},
pass: true),
EventModel(
name: '设置闹钟',
event: () {
final data = CLCmdUserReminder(
hour: 14,
minute: 45,
name: 'test alarm',
weekday: 1,
bRepeatDaily: 1);
data.send(0, 0);
},
pass: true),
EventModel(
name: '更新闹钟',
event: () {
final data = CLCmdUserReminder(
hour: 15,
minute: 0,
name: 'test alarm update',
weekday: 1,
bRepeatDaily: 1);
data.send(0, 1);
},
pass: true),
EventModel(
name: '删除闹钟',
event: () {
CLCmdUserReminder.delete();
},
pass: true),
EventModel(
name: '设置服药提醒',
event: () {
final data = CLCmdPillReminder(
reminderId: 1,
hour: 15,
minute: 25,
name: 'haiqing',
weekday: 0x7f,
bRepeatDaily: true,
url: 'https://test.com');
data.send(0, 0);
},
pass: true),
EventModel(
name: '更新服药提醒',
event: () {
final data = CLCmdPillReminder(
reminderId: 1,
hour: 15,
minute: 20,
name: 'hiles',
weekday: 1,
bRepeatDaily: true,
url: 'https://test.com');
data.send(0, 1);
},
pass: true),
EventModel(
name: '删除服药提醒',
event: () {
CLCmdPillReminder.delete();
},
pass: true),
EventModel(
name: '分钟数据',
event: () {
CLCmdStreamingData.loadMinuteData();
},
pass: true),
EventModel(
name: 'SmartNotiSNS',
event: () {
CLCmdSmartNotification.send(CLCmdSmartNotificationType.modeNew,
CLCmdSmartNotificationType.idSns, 1,
strTitle: '锦秀申江',
strContent: "hello hiles");
// testClingNotification(CLCmdSmartNotificationType.modeNew, CLCmdSmartNotificationType.idSns, 1, strTitle:'sns test', strContent:"content smart notification test");
},
pass: true),
EventModel(
name: 'SmartNotiInCall',
event: () {
CLCmdSmartNotification.send(CLCmdSmartNotificationType.modeNew,
CLCmdSmartNotificationType.idIncomingCall, 1,
strTitle: '18797817942', strContent: "test");
// testClingNotification(CLCmdSmartNotificationType.modeNew, CLCmdSmartNotificationType.idIncomingCall, 1, strTitle:'17315673444', strContent:"incall test");
},
pass: true),
EventModel(
name: 'Del InCall',
event: () {
CLCmdSmartNotification.send(CLCmdSmartNotificationType.modeDelete,
CLCmdSmartNotificationType.idIncomingCall, 1);
// testClingNotification(CLCmdSmartNotificationType.modeDelete, CLCmdSmartNotificationType.idIncomingCall, 1);
},
pass: true),
...items(),
// EventModel(
// name: 'GPS Arrow',
// event: () {
// final data = CLCmdArrowData(arrow_dir: 1, arrow_bgcolor: 0xFFFF00, arrow_color: 0xFF0000, shine_freq: 10, shine_interval: 1, shine_during: 60, shine_enable: true);
// clingNative.cwsUpdateArrowData(data.toPonter());
// data.free();
// },
// pass: false),
];
@override
void initState() {
super.initState();
initPlatformState();
// testble();
configTestEvent();
// ResourceLoader.loadClockFace().then((value) {
// print(value);
// });
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
if (!mounted) return;
setState(() {});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: GridView.builder(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 8,
mainAxisSpacing: 12,
crossAxisSpacing: 12,
childAspectRatio: 2.4),
itemBuilder: (context, index) {
final item = _events[index];
return InkWell(
onTap: () {
item.event();
},
child: Container(
color: item.pass
? const Color.fromARGB(100, 171, 236, 173)
: const Color.fromARGB(100, 220, 223, 223),
alignment: Alignment.center,
child: Text(item.name,
style: const TextStyle(
fontSize: 16, fontWeight: FontWeight.bold))));
},
itemCount: _events.length),
);
}
void testble() {
ClingBleManager.scan(ClingDeviceType.ge,
seconds: 15,
connectDevice:
const String.fromEnvironment('d', defaultValue: 'A9CF'))
.listen((devices) {
// print(devices);
}, onError: (e) {
print(e);
});
}
}