mavishak / cnss-embedded

1 stars 0 forks source link

Gaining access to control (ON/OFF mode) #27

Open mavishak opened 3 years ago

mavishak commented 3 years ago

04/05/2021

We started building the functionality that will allow us to turn on and off the motion sensor:

Here is the HTTP request:

GET /devices//control.json?auth= HTTP/1.0\r\n Host: \r\n\r\n


sprintf((char)http,"GET /devices/%s/control/state.json?auth=%s HTTP/1.0\r\nHost: %s\r\n\r\n",(char)device_id,(char)firebase_auth_key,(char)firebase_host); // HTTP/1.0- Allow only one request

For AT commands need to add one more \r\n:

sprintf((char)http,"GET /devices/%s/control/state.json?auth=%s HTTP/1.0\r\nHost: %s\r\n\r\n\r\n",(char)device_id,(char)firebase_auth_key,(char)firebase_host); // HTTP/1.0- Allow only one request

mavishak commented 3 years ago

As of now our main:

int main(void)
{

    init_usart2(); // for debugging

    init_queue();
    init_sensor_with_interrupt();

    init_timer2();// for monitoring switch state.
    init_timer3(); //for sensor delay
    init_timer4(); //for ESP8266 timeout

    init_usart1(); // for ESP8266

    write_usart2((uint8_t*)("\r\n_______________\r\n"));//For test

    while(1)
    {
        do_event();
        monitor_switch_state(120); // every 2 minutes
    }
}

monitor_switch_state() is a function in system_control.c if 120 seconds passed since the last time the event "control_Handler" was queued, it queues it.

"control_Handler" calls "checkSwitchState", there the conrtol state (ON/OFF mode) is sampled from realtime database firebase.

If it comes back as "on" the sensor is enabled: its handler is enabled - need to check that is good enough

If it comes back as "off", null or if the comuniction is down the sensor is disabled: its handler is disabled - need to check that is good enough

tried to disable clock source from rcc - that did not work.

A few problems to look out for: