/
sonoff.c
155 lines (124 loc) · 5.65 KB
/
sonoff.c
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
Copyright (C) AC SOFTWARE SP. Z O.O.
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
const uint8_t rsa_public_key_bytes[512] = {
0xd4, 0xa4, 0x43, 0xdf, 0xc8, 0xd7, 0xa9, 0xa1,
0x78, 0x70, 0x5d, 0x38, 0xe4, 0x33, 0x7f, 0x28,
0x97, 0x12, 0xac, 0xbe, 0xb4, 0xf2, 0x91, 0x17,
0x05, 0x96, 0xfb, 0xc3, 0xd8, 0x41, 0xb9, 0xdd,
0x00, 0xcd, 0xec, 0x1e, 0x4e, 0x35, 0x92, 0x23,
0x25, 0x87, 0xa7, 0x96, 0x96, 0x4c, 0xb3, 0x1c,
0x3f, 0xa1, 0xdd, 0x5b, 0x9a, 0x9b, 0x6c, 0x1b,
0x76, 0xaa, 0x9c, 0x1a, 0xa6, 0xfd, 0x15, 0xb0,
0x4b, 0x5b, 0x91, 0x63, 0xd8, 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6, 0x8e, 0xc8, 0x27, 0x21,
0x9b, 0xeb, 0x55, 0x40, 0x16, 0x9a, 0x75, 0x32,
0xf7, 0xfd, 0xef, 0x40, 0x67, 0x49, 0xc8, 0x64,
0xf8, 0x6d, 0x06, 0x71, 0xd0, 0xf5, 0xee, 0xe6,
0xcd, 0xd5, 0xa3, 0x6f, 0x8f, 0x78, 0x65, 0x0d,
0x1a, 0x53, 0x29, 0x1f, 0x73, 0x10, 0xe6, 0x2c,
0x4a, 0x9a, 0x44, 0x23, 0xea, 0xc5, 0x36, 0x55,
0x1c, 0x8a, 0x14, 0x7e, 0x87, 0x27, 0x1e, 0xf9,
0xc9, 0xb2, 0x69, 0x0a, 0xa7, 0xef, 0x44, 0x12,
0xe7, 0x33, 0x5f, 0x4a, 0xb1, 0x44, 0x4b, 0xc9
};
#define B_RELAY1_PORT 12
#define B_CFG_PORT 0
void supla_esp_board_set_device_name(char *buffer, uint8 buffer_size) {
#ifdef __BOARD_sonoff_ds18b20
ets_snprintf(buffer, buffer_size, "SONOFF-DS18B20");
#else
ets_snprintf(buffer, buffer_size, "SONOFF");
#endif
}
void supla_esp_board_gpio_init(void) {
supla_input_cfg[0].type = INPUT_TYPE_BTN_MONOSTABLE;
supla_input_cfg[0].gpio_id = B_CFG_PORT;
supla_input_cfg[0].flags = INPUT_FLAG_PULLUP | INPUT_FLAG_CFG_BTN;
supla_input_cfg[0].relay_gpio_id = B_RELAY1_PORT;
supla_input_cfg[0].channel = 0;
// ---------------------------------------
// ---------------------------------------
supla_relay_cfg[0].gpio_id = B_RELAY1_PORT;
supla_relay_cfg[0].flags = RELAY_FLAG_RESTORE_FORCE;
supla_relay_cfg[0].channel = 0;
}
void supla_esp_board_set_channels(TDS_SuplaDeviceChannel_B *channels, unsigned char *channel_count) {
#ifdef __BOARD_sonoff_ds18b20
*channel_count = 2;
#else
*channel_count = 1;
#endif
channels[0].Number = 0;
channels[0].Type = SUPLA_CHANNELTYPE_RELAY;
channels[0].FuncList = SUPLA_BIT_FUNC_POWERSWITCH \
| SUPLA_BIT_FUNC_LIGHTSWITCH;
channels[0].Default = SUPLA_CHANNELFNC_POWERSWITCH;
channels[0].value[0] = supla_esp_gpio_relay_on(B_RELAY1_PORT);
#ifdef __BOARD_sonoff_ds18b20
channels[1].Number = 1;
channels[1].Type = SUPLA_CHANNELTYPE_THERMOMETERDS18B20;
channels[1].FuncList = 0;
channels[1].Default = 0;
supla_get_temperature(channels[1].value);
#endif
}
void supla_esp_board_send_channel_values_with_delay(void *srpc) {
supla_esp_channel_value_changed(0, supla_esp_gpio_relay_on(B_RELAY1_PORT));
}