#pragma once

#include <TinySensor.h>
#include <RCSwitch.h>

#define ID(value) (value & 0x1F)
#define STATE(value) ((value & 0x1) << 5)
#define VCC(value) ((value & 0x1FFF) << 6)

class ContactSensor: public TinySensor {

public:
	ContactSensor(short id, short senderPin) :
			TinySensor(id, senderPin) {
	}

	void sendStateAndVoltage(bool state) {
		sendInfo(ID(id) | VCC(readVcc()) | STATE(!state) | TYPE(7));
	}

	void sendState(bool state) {
		sendInfo(ID(id) | VCC(0) | STATE(!state) | TYPE(7));
	}
};
