nativeTest function

dynamic nativeTest()

Implementation

nativeTest () {
  slog('TEST: cwsPeripheralConnect ++++++');
  clingNative.cwsPeripheralConnect();

  for (int i = 0; i < 1; i++) {
    slog('TEST: start cwsLoadDeviceInfo now ++++++');
    clingNative.cwsLoadDeviceInfo();

    _testQueue();

    clingNative.cwsPeripheralProcess();

    slog('TEST: start cwsTimeSync now ++++++');
    clingNative.cwsSetGmtOffset(8 * 3600);
    clingNative.cwsTimeSync();

    slog('TEST: cwsSetLanguageType now ++++++');
    clingNative.cwsSetLanguageType(1);
    clingNative.cwsSetLanguageTypeDirectly();
    slog('TEST: get bondid ${clingNative.cwsGetBondAccountUserID()}');

    slog('TEST: cwsRequestForceAuth now ++++++');
    clingNative.cwsRequestForceAuth();

    slog('TEST: cwsLoadFileList now ++++++');
    clingNative.cwsLoadFileList();

    slog('TEST: cwsSendNewUserReminder now ++++++');
    for (int i = 0; i < 25; i++) {
      Pointer<PERIPHERAL_USER_REMINDER_CONTEXT> reminder = malloc<PERIPHERAL_USER_REMINDER_CONTEXT>();

      reminder.ref.hour = i;
      reminder.ref.minute = i * 5;
      reminder.ref.bRepeatDaily = 1;
      reminder.ref.weekday = 0x1f;
      _str2Array("name-$i", reminder.ref.name);
      clingNative.cwsSetNewUserReminder(reminder, i, 1);
      malloc.free(reminder);
    }
    clingNative.cwsSendNewUserReminder();
  }

  slog('TEST: cwsUpdateUserProfileCfg now ++++++');
  Pointer<PERIPHERAL_USER_PROFILE_DATA> userInfo = malloc<PERIPHERAL_USER_PROFILE_DATA>();
  userInfo.ref.height_in_cm = 180; /**< user height. */
  userInfo.ref.weight_in_kg = 99; /**< user weight */
  userInfo.ref.stride_length_in_cm = 100; /**< stride length, i.e., step length */
  userInfo.ref.stride_length_run_in_cm = 200; /**< running stride length */
  userInfo.ref.stepRateForRunLength = 4;
  userInfo.ref.units_type = 1; /** international or english unit **/
  userInfo.ref.nickname_len = 'abcde'.toNativeUtf8().length;
  userInfo.ref.nickname = 'abcde'.toNativeUtf8();
  userInfo.ref.clock_orientation = 1;
  userInfo.ref.sleep_alarm_day_of_week = 0x2f;
  userInfo.ref.bed_hr = 12;
  userInfo.ref.bed_min = 11;
  userInfo.ref.wakeup_hr = 10;
  userInfo.ref.wakeup_min = 10;
  userInfo.ref.screen_display_option = 0x0f;
  userInfo.ref.touch_virbration = 1;
  userInfo.ref.daily_goal = 20;
  userInfo.ref.training_display_option = 0x5;
  userInfo.ref.age = 24;
  userInfo.ref.sex = 1;
  userInfo.ref.stride_length_run_indoor_in_cm = 66;
  userInfo.ref.hr_alarm_rate = 80;
  userInfo.ref.pace_alarm_zone = 3;
  userInfo.ref.app_setting = 0x11;
  userInfo.ref.caloryDisplayType = 1;
  userInfo.ref.healthinfolevel = 3;
  userInfo.ref.stepAlarmEn = 1;
  userInfo.ref.stepAlarmVal = 20000;
  userInfo.ref.calAlarmEn = 1;
  userInfo.ref.calAlarmVal = 3000;
  userInfo.ref.stAlarmVal = 132;
  userInfo.ref.stMinAlarmVal = 123;

  clingNative.cwsUpdateUserProfileCfg(userInfo);
  clingNative.cwsSetUserProfileDirectly();
  malloc.free(userInfo);

  slog('TEST: cwsUpdateUserProfileCfg now ++++++');
  for (int i = 0; i < 5; i ++) {
    Pointer<PERIPHERAL_WEATHER_DATA> weather = malloc<PERIPHERAL_WEATHER_DATA>();
    weather.ref.aqi = i * 30;
    weather.ref.month = 1;
    weather.ref.day = i + 11;
    weather.ref.temperature_high = 10;
    weather.ref.temperature_low = -2;
    weather.ref.type = i % 4;

    clingNative.cwsUpdateWeatherForecast(weather, i);
    malloc.free(weather);
  }
  clingNative.cwsSendWeather();

  slog('TEST: cwsSetStreamingMode now ++++++');
  // clingNative.cwsEnableStreamingMode(1);
  clingNative.cwsSetStreamingMode(1);

  _testQueueActivity();

  // Future.delayed(const Duration(milliseconds: 300)).then((value) {
  //   clingNative.cwsClearUserReminders();
  //   clingNative.cwsSendNewUserReminder();
  //
  //   Future.delayed(const Duration(milliseconds: 300)).then((value) {
  //     clingNative.cwsClearUserReminders();
  //     clingNative.cwsSendNewUserReminder();
  //
  //     Future.delayed(const Duration(milliseconds: 300)).then((value) {
  //       clingNative.cwsClearUserReminders();
  //       clingNative.cwsSendNewUserReminder();
  //     });
  //   });
  // });

  _testQueue();
  clingNative.cwsCheckAuthorizationState();
  clingNative.cwsUnbindPeripheral();

  slog('TEST: Array in gps body now ++++++');
  Pointer<PERIPHERAL_GOGPS_BODY_V2> gpsV2 = malloc<PERIPHERAL_GOGPS_BODY_V2> ();
  gpsV2.ref.gpsData[0].heartrate = 88;
  slog('test array gps: ${gpsV2.ref.gpsData[0].heartrate}');
  malloc.free(gpsV2);

  slog('TEST: Array in pill reminder now ++++++');
  Pointer<PERIPHERAL_PILL_REMINDER_DATA> pill = malloc<PERIPHERAL_PILL_REMINDER_DATA>();
  pill.ref.pillReminder[0].epoch = 1111111111;
  pill.ref.pillReminder[0].reminderId = 1;
  slog('test array pill: ${pill.ref.pillReminder[0].epoch}');
  malloc.free(pill);

  // _testOta();
  // _testFileDownload();

  _testSleep();

  _testNotification();

  // clingNative.cwsPeripheralProcess();
}