-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathDev_Switch.h
64 lines (52 loc) · 1.36 KB
/
Dev_Switch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* @file Dev_Switch.h
*
* Switch API of IoTgo (iotgo.iteadstudio.com)
*
* @author Wu Pengfei (email:<[email protected]>)
* @date 2014/11/11
* @copyright
* Copyright (C) 2013-2014 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#ifndef __DEV_SWITCH_H__
#define __DEV_SWITCH_H__
#include "IoTgo.h"
/**
* @addtogroup Switch
* @{
*/
/**
* Indicates the state of switch device.
*/
enum SwitchState
{
SWITCH_STATE_OFF = 0, /**< switch off */
SWITCH_STATE_ON = 1, /**< switch on */
};
/**
* Switch, subclass of IoTgo, provides simple methods to control switch device.
*
*/
class Switch: public IoTgo
{
public: /* public methods */
Switch(NetInterface *net, uint16_t sw_pin);
int32_t sync(void);
int32_t getState(int32_t *state);
int32_t on(void);
int32_t off(void);
private: /* private methods */
int32_t setState(int32_t state);
private: /* private static data members */
static const char *STATE[];
static const char *VALUE_ON[];
static const char *VALUE_OFF[];
private:
uint16_t sw_pin;
};
/** @} */
#endif /* #ifndef __DEV_SWITCH_H__ */