Exemplo n.º 1
0
        /// <summary>
        /// Get Descriptors for a Logbook entry
        /// </summary>
        /// <param name="logId">Logbook entry to get</param>
        public async Task <BaseResult> GetLogbookDescriptorsAsync(int logId)
        {
            string datapath = String.Format(LOGBOOK_DATA, logId);
            var    op       = new ApiCallAsync <BaseResult>(this, MdsOp.GET, datapath);

            return(await op.CallAsync());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get LedState for an LED
        /// </summary>
        /// <param name="ledIndex">Number of the Led</param>
        public async Task <LedState> GetLedStateAsync(int ledIndex = 0)
        {
            string datapath = String.Format(LED_PATH, ledIndex);
            var    op       = new ApiCallAsync <LedState>(this, MdsOp.GET, datapath);

            return(await op.CallAsync());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get data from a Logbook entry as Json by accessing the suunto://MDS/Logbook/{serial}>/ByID/{ID}/Data REST endpoint.
        /// This MDS Logbook proxy service takes care of paging and also data-json conversion.
        /// </summary>
        /// <param name="logId">Number of the entry to get</param>
        public async Task <string> GetLogbookDataJsonAsync(int logId)
        {
            string datapath = String.Format(MDS_LOGBOOK_DATA_PATH, logId);
            var    op       = new ApiCallAsync <string>(this, MdsOp.GET, datapath, null, MDS_LOGBOOK_PREFIX);

            return(await op.CallAsync());
        }
Exemplo n.º 4
0
 /// <summary>
 /// Set state of the Datalogger
 /// </summary>
 /// <param name="start">Set true to start the datalogger, false to stop</param>
 public async Task SetLoggerStatusAsync(bool start)
 {
     string LOG_ON  = "{\"newState\":3}";
     string LOG_OFF = "{\"newState\":2}";
     var    op      = new ApiCallAsync(this, MdsOp.PUT, DATALOGGER_STATE_PATH, start ? LOG_ON : LOG_OFF);
     await op.CallAsync();
 }
Exemplo n.º 5
0
        public async Task SetLoggerConfigAsync(string deviceName, DataLoggerConfig dataLoggerConfig)
        {
            string jsonConfig = Newtonsoft.Json.JsonConvert.SerializeObject(dataLoggerConfig);

            var op = new ApiCallAsync(deviceName, MdsOp.PUT, DATALOGGER_CONFIG_PATH, jsonConfig);
            await op.CallAsync().ConfigureAwait(false);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Set configuration for the Datalogger
        /// </summary>
        /// <param name="dataLoggerConfig">Configuration to apply to the DataLogger. Config is an array of structs containing paths to the subscription of data to log.
        /// For example:
        /// DataLoggerConfig.DataEntry[] entries = { new DataLoggerConfig.DataEntry("/Meas/IMU9/52") };
        /// DataLoggerConfig config = new DataLoggerConfig(new DataLoggerConfig.Config(new DataLoggerConfig.DataEntries(entries)));
        /// </param>
        public async Task SetLoggerConfigAsync(DataLoggerConfig dataLoggerConfig)
        {
            string jsonConfig = Newtonsoft.Json.JsonConvert.SerializeObject(dataLoggerConfig);

            var op = new ApiCallAsync(this, MdsOp.PUT, DATALOGGER_CONFIG_PATH, jsonConfig);
            await op.CallAsync();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Get data from a Logbook entry
        /// </summary>
        /// <param name="deviceName">Name of the device, e.g. Movesense 174430000051</param>
        /// <param name="logId">Number of the entry to get</param>
        public async Task <string> GetLogbookDataAsync(string deviceName, int logId)
        {
            string datapath = String.Format(LOGBOOK_DATA_PATH, logId);
            var    op       = new ApiCallAsync <string>(deviceName, MdsOp.GET, datapath);

            return(await op.CallAsync());
        }
Exemplo n.º 8
0
 public async Task SetLoggerStatusAsync(string deviceName, bool start)
 {
     string LOG_ON  = "{\"newState\":3}";
     string LOG_OFF = "{\"newState\":2}";
     var    op      = new ApiCallAsync(deviceName, MdsOp.PUT, DATALOGGER_STATE_PATH, start ? LOG_ON : LOG_OFF);
     await op.CallAsync().ConfigureAwait(false);
 }
Exemplo n.º 9
0
        public async Task <LedState> GetLedStateAsync(string deviceName, int ledIndex = 0)
        {
            string datapath = String.Format(LED_PATH, ledIndex);
            var    op       = new ApiCallAsync <LedState>(deviceName, MdsOp.GET, datapath);

            return(await op.CallAsync().ConfigureAwait(false));
        }
Exemplo n.º 10
0
        public async Task <BaseResult> GetLogbookDescriptorsAsync(string deviceName, int logId)
        {
            string datapath = String.Format(LOGBOOK_DATA, logId);
            var    op       = new ApiCallAsync <BaseResult>(deviceName, MdsOp.GET, datapath);

            return(await op.CallAsync().ConfigureAwait(false));
        }
Exemplo n.º 11
0
        public async Task <string> GetLogbookDataJsonAsync(string deviceName, int logId)
        {
            string datapath = String.Format(MDS_LOGBOOK_DATA_PATH, logId);
            var    op       = new ApiCallAsync <string>(deviceName, MdsOp.GET, datapath, null, MDS_LOGBOOK_PREFIX);

            return(await op.CallAsync().ConfigureAwait(false));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Get data from a Logbook entry
        /// </summary>
        /// <param name="logId">Number of the entry to get</param>
        public async Task <string> GetLogbookDataAsync(int logId)
        {
            string datapath = String.Format(LOGBOOK_DATA_PATH, logId);
            var    op       = new ApiCallAsync <string>(this, MdsOp.GET, datapath);

            return(await op.CallAsync().ConfigureAwait(false));
        }
Exemplo n.º 13
0
 /// <summary>
 /// Sets state of an LED
 /// </summary>
 /// <param name="ledIndex">Index of the Led - use 0 for standard Movesense sensor</param>
 /// <param name="ledOn">Set on or off</param>
 /// <param name="ledColor">[optional]value from LedColor enumeration - default is LedColor.Red</param>
 public async Task SetLedStateAsync(int ledIndex, bool ledOn, LedColor ledColor = LedColor.Red)
 {
     string datapath     = String.Format(LED_PATH, ledIndex);
     string led_On_Body  = $"{{ \"LedState\": {{ \"IsOn\": true, \"LedColor\": {(int)ledColor}}} }}";
     string led_Off_Body = @"{ ""LedState"": { ""IsOn"": false, ""LedColor"": 0} }";
     var    op           = new ApiCallAsync <LedState>(this, MdsOp.PUT, datapath, ledOn ? led_On_Body : led_Off_Body);
     await op.CallAsync();
 }
Exemplo n.º 14
0
        /// <summary>
        /// Set clock time on the device to sync with the time on the phone, as number of microseconds since epoch 1.1.1970 (UTC).
        /// </summary>
        /// <param name="deviceName">Name of the device, e.g. Movesense 174430000051</param>
        public async Task SetTimeAsync(string deviceName)
        {
            long   timems = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds;
            string time   = $"{{\"value\":{timems * 1000}}}";

            Debug.WriteLine($"INFO SetTime TIME {time}");
            var op = new ApiCallAsync <TimeResult>(deviceName, MdsOp.POST, TIME_PATH, time);
            await op.CallAsync();
        }
Exemplo n.º 15
0
        /// <summary>
        /// Set clock time on the device to sync with the time on the phone, as number of microseconds since epoch 1.1.1970 (UTC).
        /// </summary>
        public async Task SetTimeAsync()
        {
            long   timems      = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds;
            string requestBody = $"{{\"value\":{timems * 1000}}}";

            Debug.WriteLine($"INFO SetTimeAsync TIME {requestBody}");
            var op = new ApiCallAsync <TimeResult>(this, MdsOp.PUT, TIME_PATH, requestBody);
            await op.CallAsync();
        }
Exemplo n.º 16
0
        /// <summary>
        /// Set configuration for the Datalogger - ONLY sets IMU9
        /// </summary>
        /// <param name="freq">Sampling rate, e.g. 26 for 26Hz</param>
        public async Task SetupLoggerAsync(int freq = 26)
        {
            DataLoggerConfig.DataEntry[] entries =
            {
                new DataLoggerConfig.DataEntry("/Meas/IMU9/" + freq)
            };

            DataLoggerConfig config     = new DataLoggerConfig(new DataLoggerConfig.Config(new DataLoggerConfig.DataEntries(entries)));
            string           jsonConfig = Newtonsoft.Json.JsonConvert.SerializeObject(config);

            var op = new ApiCallAsync(this, MdsOp.PUT, DATALOGGER_CONFIG_PATH, jsonConfig);
            await op.CallAsync();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Get info on the app running on the device
        /// </summary>
        public async Task <AppInfo> GetAppInfoAsync()
        {
            var op = new ApiCallAsync <AppInfo>(this, MdsOp.GET, APP_INFO_PATH);

            return(await op.CallAsync());
        }
Exemplo n.º 18
0
        /// <summary>
        /// Gets current time in number of microseconds since epoch 1.1.1970 (UTC).
        /// If not explicitly set, contains number of seconds since reset.
        /// </summary>
        public async Task <TimeResult> GetTimeAsync()
        {
            var op = new ApiCallAsync <TimeResult>(this, MdsOp.GET, TIME_PATH);

            return(await op.CallAsync());
        }
Exemplo n.º 19
0
        /// <summary>
        /// Get details of Logbook entries by accessing the suunto://MDS/Logbook/{serial}>/Entries" REST endpoint.
        /// This MDS Logbook proxy service takes care of paging and also data-json conversion.
        /// </summary>
        public async Task <LogEntriesMDSResult> GetLogEntriesJsonAsync()
        {
            var op = new ApiCallAsync <LogEntriesMDSResult>(this, MdsOp.GET, MDS_LOGBOOK_ENTRIES_PATH, null, MDS_LOGBOOK_PREFIX);

            return(await op.CallAsync());
        }
Exemplo n.º 20
0
        /// <summary>
        /// Get Logger status, CallAsync returns LogStatusResult object
        /// </summary>
        public async Task <LogStatusResult> GetLoggerStatusAsync()
        {
            var op = new ApiCallAsync <LogStatusResult>(this, MdsOp.GET, DATALOGGER_STATE_PATH);

            return(await op.CallAsync());
        }
Exemplo n.º 21
0
 /// <summary>
 /// Delete all the Logbook entries
 /// </summary>
 public async Task DeleteLogEntriesAsync()
 {
     var op = new ApiCallAsync(this, MdsOp.DELETE, LOGBOOK_ENTRIES_PATH);
     await op.CallAsync();
 }
Exemplo n.º 22
0
        /// <summary>
        /// Get Magnetometer configuration
        /// </summary>
        public async Task <MagnInfo> GetMagInfoAsync()
        {
            var op = new ApiCallAsync <MagnInfo>(this, MdsOp.GET, MAG_INFO_PATH);

            return(await op.CallAsync());
        }
Exemplo n.º 23
0
        /// <summary>
        /// Get state of all Leds in the system
        /// </summary>
        public async Task <LedsResult> GetLedsStateAsync()
        {
            var op = new ApiCallAsync <LedsResult>(this, MdsOp.GET, LEDS_PATH);

            return(await op.CallAsync());
        }
Exemplo n.º 24
0
        /// <summary>
        /// Get Battery level, CallAsync returns BatteryResult
        /// </summary>
        public async Task <BatteryResult> GetBatteryLevelAsync()
        {
            var op = new ApiCallAsync <BatteryResult>(this, MdsOp.GET, BATTERY_PATH);

            return(await op.CallAsync());
        }
Exemplo n.º 25
0
        /// <summary>
        /// Get IMU configuration
        /// </summary>
        public async Task <IMUInfo> GetIMUInfoAsync()
        {
            var op = new ApiCallAsync <IMUInfo>(this, MdsOp.GET, IMU_INFO_PATH);

            return(await op.CallAsync());
        }
Exemplo n.º 26
0
        /// <summary>
        /// Get Gyrometer configuration
        /// </summary>
        public async Task <GyroInfo> GetGyroInfoAsync()
        {
            var op = new ApiCallAsync <GyroInfo>(this, MdsOp.GET, GYRO_INFO_PATH);

            return(await op.CallAsync());
        }
Exemplo n.º 27
0
        /// <summary>
        /// Get device info
        /// </summary>
        public async Task <DeviceInfoResult> GetDeviceInfoAsync()
        {
            var op = new ApiCallAsync <DeviceInfoResult>(this, MdsOp.GET, INFO_PATH);

            return(await op.CallAsync());
        }
Exemplo n.º 28
0
        /// <summary>
        /// Create a new logbook entry resource (increment log Id). Returns the new log Id.
        /// </summary>
        public async Task <CreateLogResult> CreateLogEntryAsync()
        {
            var op = new ApiCallAsync <CreateLogResult>(this, MdsOp.POST, LOGBOOK_ENTRIES_PATH);

            return(await op.CallAsync());
        }
Exemplo n.º 29
0
        /// <summary>
        /// Get details of Logbook entries by accessing the suunto://{serial}/Mem/Logbook/Entries REST endpoint
        /// </summary>
        public async Task <LogEntriesResult> GetLogEntriesAsync()
        {
            var op = new ApiCallAsync <LogEntriesResult>(this, MdsOp.GET, LOGBOOK_ENTRIES_PATH);

            return(await op.CallAsync());
        }
Exemplo n.º 30
0
        /// <summary>
        /// Get device info
        /// </summary>
        public async Task <DetailedTime> GetDetailedTimeAsync()
        {
            var op = new ApiCallAsync <DetailedTime>(this, MdsOp.GET, DETAILED_TIME_PATH);

            return(await op.CallAsync());
        }