include "../sensor.lt";

type native.SensorStatus = SensorStatus ~ {
    online_since : TimePoint ~ <TimeSince UnixEpoch> ~ Milliseconds ~ ℤ ~ native.UInt64 ;
    battery_charge : Energy ~ mAh ~ native.UInt32 ;
    battery_capacity : Energy ~ mAh ~ native.UInt32 ;
    min_sampling_period : Duration ~ Milliseconds ~ native.UInt32 ;
    cur_sampling_period : Duration ~ Milliseconds ~ native.UInt32 ;
    max_chunk_size : ℤ ~ native.UInt32 ;
    cur_chunk_size : ℤ ~ native.UInt32 ;
    n_chunk_capacity : ℤ ~ native.UInt32 ;
    n_full_data_chunks : ℤ ~ native.UInt32 ;
    n_empty_data_chunks : ℤ ~ native.UInt32 ;
} ;

type native.DataChunk = DataChunk ~ {
    begin : TimePoint ~ <TimeSince UnixEpoch> ~ Milliseconds ~ native.UInt64 ;
    data : [~<LengthPrefix x86.UInt32>
                  Temperature
               ~  Celsius
               ~  ℝ
               ~  native.Float64
           ] ;
} ;

type native.Sensor = Sensor ~ {
    get_status : {} -> InternSensorStatus ;
    set_sampling_period : Duration~Milliseconds~UInt32 -> (Ok | OutOfRange)~Byte ;
    pop_data_chunk : {} -> InternDataChunk ;
} ;