setEpoch method

Future<SetEpochResponse> setEpoch(
  1. String address, {
  2. int io = 0,
  3. int timeout = kScenarioCmdTimeout,
})

Will set the Epoch time stored on the device at address

Implementation

Future<SetEpochResponse> setEpoch(String address, {int io = 0, int timeout = kScenarioCmdTimeout}) async {
  _checkValidAddress(address);
  final r = Random();
  final correlation = int.parse(address, radix: 16) + r.nextInt(1 << 15);
  final now = DateTime.now();
  final epoch = now.millisecondsSinceEpoch ~/ 1000;
  return SetEpochResponse.fromJson(await _sendRequest(
    'set_epoch',
    params: <String, dynamic>{
      'node_address': address,
      'request': {
        'command': 'set epoch',
        'correlation': correlation,
        'io': io,
        'time_zone': 0, // for now, unused
        'epoch': epoch,
      },
      'timeout': timeout * 2,
    },
  ));
}