Paso 5: Software (aplicaciones Android por inventor de las apps, Firmware por MPLAB)
#include "fileheader.h"
[] main_page de const char = "C 0%";
[] time_page de const char = "T %1";
debug Char [7];
Int32 http_get_page(char *file_str)
{
Int32 file_loc = 0;
int8 i = 0;
int8 días = 0;
int8 mes = 0;
int8 año = 0;
int8 hora = 0;
int8 min = 0;
int8 segundo = 0;
int8 dow = 0;
[dimmer] static char = "/ D";
Static char del ventilador [] = "/ F";
Static char powersocket [] = "/ S";
Static char hilo [] = "/ A";
Static char magneticlock [] = "/ L";
Static char statecheck [] = "/ C";
Static char rtc_io [] = "/ T";
depurar [0] = file_str [0];
depurar [1] = file_str [1];
depurar [2] = file_str [2];
depurar [3] = file_str [3];
depurar [4] = file_str [4];
control de intensidad
Si (stricmp(file_str[1],dimmer[1])==0)
{
me =(file_str[2] & 0b11001111) * 100 + ([3] de file_str y 0b11001111) * 10 + (file_str [4] y 0b11001111);
bulb_brightness(i);
file_loc=label_address(Main_Page);
}
control de alarma
Si (stricmp(file_str,alarmsystem)==0)
{
toggle_alarm_state();
file_loc=label_address(Main_Page);
}
rtc_io
Si (stricmp(file_str[1],rtc_io[1])==0)
{
if(file_str[2]=='s') //set tiempo
{
días = (file_str [3] y 0b11001111) * 10 + (file_str [4] y 0b11001111);
mes = (file_str [5] y 0b11001111) * 10 + (file_str [6] y 0b11001111);
año = (file_str [7] y 0b11001111) * 10 + (file_str [8] y 0b11001111);
Dow = (file_str [9] y 0b11001111);
hora = (file_str [10] y 0b11001111) * 10 + (file_str [11] y 0b11001111); min = (file_str [12] y 0b11001111) * 10 + (file_str [13] y 0b11001111);
en segundo lugar = (file_str [14] y 0b11001111) * 10 + (file_str [15] y 0b11001111); ds1307_set_date_time(Days,month,Year,Dow,hour,min,Second);
file_loc=label_address(time_page);
}
if(file_str[2]=='g') //get tiempo
{file_loc=label_address(time_page);}
if(file_str[2]=='r') //configuration rtc io
set_rtc_io (encendido/apagado, que entrada-salida hr on min on, hr apagado, min OFF)
{set_rtc_io(file_str[3] & 0b11001111, file_str[4] & 0b11001111, (file_str[5] & 0b11001111) * 10 + (file_str [6] y 0b11001111), (file_str [7] & 0b11001111) * 10 + (file_str [8] y 0b11001111), (file_str [9] & 0b11001111) * 10 + (file_str [10] y 0b11001111), (file_str [11] & 0b11001111) * 10 + (file_str [12] y 0b11001111)); file_loc=label_address(time_page);} }
para el ventilador si (stricmp (file_str [1] fan [1]) == 0) {if(stricmp(file_str[2],'1')==0) {fan_speed1();} if(stricmp(file_str[2],'2')==0) {fan_speed2();} if(stricmp(file_str[2],'3')==0) {fan_speed3();} if(stricmp(file_str[2],'o')==0) {fan_off();} if(stricmp(file_str[2],'r')==0) {fan_rotate_toggle()}; file_loc=label_address(main_page);}
para cerradura magnética si (stricmp(file_str,magneticlock)==0) {toggle_magnetic_lock_state(); file_loc=label_address(main_page);}
para la toma de corriente si (stricmp (file_str [1], powersocket [1]) == 0) {if(stricmp(file_str[2],'1')==0) {toggle_power_socket1_state();} if(stricmp(file_str[2],'2')==0) {toggle_power_socket2_state();} if(stricmp(file_str[2],'3')==0) {toggle_power_socket3_state()}; file_loc=label_address(main_page);}
de estado Compruebe si (stricmp (file_str, statecheck) == 0) {file_loc=label_address(main_page);}
Return(file_loc); }
int8 http_format_char (int32 archivo, id de char, char * str, max_ret int8) {char new_str [50]; int8 len = 0;
* str = 0;
{Switch(ID)}
caso '0': sprintf(new_str,"%2d%2d%2d%3d%d%d%d%d%d%d%d%d%d%d%d%s",hr,min,get_temperature(), get_bulb_brightness(), input_state(speed1), input_state(speed2), input_state(speed3), input_state(rotate), input_state(magnetic_lock_signal),input_state(power_socket_signal1),input_state(power_socket_signal2),input_state(power_socket_signal3),input_state(voice_sensor_signal) , input_state(alarm_signal),T,debug); len=strlen(new_str); rotura;
case '1': sprintf(new_str,"%2d%2d%1d%1d%1d%2d%2d%2d%2d%2d%2d%2d%2d%2d%2d%2d%2d",hr,min,rtc.io0,rtc.io1,rtc.io2,hr_on_io0,min_on_io0,hr_off_io0,min_off_io0,hr_on_io1,min_on_io1,hr_off_io1,min_off_io1,hr_on_io2,min_on_io2,hr_off_io2,min_off_io2); len=strlen(new_str); rotura; } Si (len) {si (len > max_ret) {len = max_ret;} memcpy(str,new_str,len);}
Return(len); }
void http_exec_cgi (archivo de int32, char * clave, char * val) {;}
void main {}
delay_ms(1000);
rtc_io_init();
power_socket_init();
bulb_dimmer_init();
voice_control_alarm_system_init();
magnetic_lock_init();
temperature_sensor_init();
fan_init();
MACAddrInit();
IPAddrInit();
StackInit();
delay_ms(10);
mientras
{
StackTask();
}
}