#pragma once

#define MASK_ID 0x1F
#define MASK_VCC 0x1FFF
#define MASK_VALUE 0x3FF
#define MASK_STATE 0x1
#define MASK_TYPE 0xF

#define ID(value) (value & 0x1F)
#define VCC(value) (((unsigned long)value & MASK_VCC) << 5)
#define TEMP(value) (((unsigned long)value & MASK_VALUE) << 18)
#define HUMIDITY(value) (((unsigned long)value & MASK_VALUE) << 18)
#define VALUE(value) (((unsigned long)value & MASK_VALUE) << 18)
#define STATE(value) ((value & MASK_STATE) << 27)
#define TYPE(value) (((unsigned long)value & MASK_TYPE) << 28)

#define GET_TYPE(value) (((unsigned long)value >> 28) & MASK_TYPE)
#define GET_STATE(value) ((value >> 27) & MASK_STATE)
#define GET_TEMP(value) (((unsigned long)value >> 18) & MASK_VALUE)
#define GET_HUMIDITY(value) (((unsigned long)value >> 18) & MASK_VALUE)
#define GET_VALUE(value) (((unsigned long)value >> 18) & MASK_VALUE)
#define GET_VCC(value) (((unsigned long)value >> 5) & MASK_VCC)

enum SensorType : unsigned short {
	GENERIC = 4,
	HUMIDITY = 5,
	TEMPERATURE = 6,
	CONTACT = 7
};

enum SensorId : unsigned short {
	WINDOW1 = 1,
	WINDOW2 = 2,
	WATER_SENSOR = 3,
	TEMP_SENSOR = 4,
	LIGHT_SENSOR = 5,
	MOVEMENT_SENSOR = 6,
	OIL_SENSOR = 7
};
