Ejemplo n.º 1
0
__interrupt void TIMER0_A0_ISR (void)
#endif
{
    if (j == 3) {
        P1DIR = DISPLAY_32K | DISPLAY_SUPPLY | DISPLAY_RESET | SCLK | SDO | CS;
        P1OUT |= DISPLAY_SUPPLY;
        P1SEL |= DISPLAY_32K;
        handle_clock();
        j = 0;
    } else {
        j++;
    }
}
Ejemplo n.º 2
0
void handle_stlv_packet(unsigned char* packet)
{
    stlv_packet pack = packet;
    char type_buf[MAX_ELEMENT_TYPE_BUFSIZE];

    element_handle handle = get_first_element(pack);
    while (IS_VALID_STLV_HANDLE(handle))
    {
        int type_len = get_element_type(pack, handle, type_buf, sizeof(type_buf));
        log_info("Read Element: %x\n", type_buf[0]);
        switch (type_buf[0])
        {
        case ELEMENT_TYPE_ECHO:
            {
                int data_len = get_element_data_size(pack, handle, type_buf, type_len);
                unsigned char* data = get_element_data_buffer(pack, handle, type_buf, type_len);
                log_info("echo: ");
                print_stlv_string(data, data_len);
                log_info("\n");
                handle_echo(data, data_len);
            }
            break;

        case ELEMENT_TYPE_CLOCK:
            {
                int data_len = get_element_data_size(pack, handle, type_buf, type_len);
                unsigned char* data = get_element_data_buffer(pack, handle, type_buf, type_len);
                log_info("clock: %d/%d/%d %d:%d:%d\n",
                    (int)data[0], (int)data[1], (int)data[2], (int)data[3], (int)data[4], (int)data[5]);
                handle_clock(data[0], data[1], data[2], data[3], data[4], data[5]);
                if (data_len >= 8)
                    handle_phone_info(data[6], data[7]);
            }
            break;

        case ELEMENT_TYPE_MESSAGE:
            if (type_len == 2)
            {
                switch (type_buf[1])
                {
                case ELEMENT_TYPE_MESSAGE_SMS:
                    log_info("notification(SMS):\n");
                    break;
                case ELEMENT_TYPE_MESSAGE_FB:
                    log_info("notification(Facebook):\n");
                    break;
                case ELEMENT_TYPE_MESSAGE_TW:
                    log_info("notification(Twitter):\n");
                    break;
                default:
                    break;
                }
                handle_msg_element(type_buf[1], pack, handle);
            }
            break;

        case ELEMENT_TYPE_FILE:
            handle_file(pack, handle);
            break;

        case ELEMENT_TYPE_GET_FILE:
            {
                int data_len = get_element_data_size(pack, handle, type_buf, type_len);
                uint8_t* data = get_element_data_buffer(pack, handle, type_buf, type_len);
                STLV_BUF_BEGIN_TEMP_STRING(data, data_len);
                handle_get_file((char*)data);
                STLV_BUF_END_TEMP_STRING(data, data_len);
            }
            break;

        case ELEMENT_TYPE_ACTIVITY_DATA:
            handle_get_activity();
            break;

        case ELEMENT_TYPE_LIST_FILES:
            {
                int data_len = get_element_data_size(pack, handle, type_buf, type_len);
                uint8_t* data = get_element_data_buffer(pack, handle, type_buf, type_len);
                STLV_BUF_BEGIN_TEMP_STRING(data, data_len);
                handle_list_file((char*)data);
                STLV_BUF_END_TEMP_STRING(data, data_len);
            }
            break;

        case ELEMENT_TYPE_REMOVE_FILE:
            {
                int data_len = get_element_data_size(pack, handle, type_buf, type_len);
                uint8_t* data = get_element_data_buffer(pack, handle, type_buf, type_len);
                STLV_BUF_BEGIN_TEMP_STRING(data, data_len);
                uint8_t file_name_pos = 0;
                for (uint8_t i = 0; i < data_len; ++i)
                {
                    if (data[i] == ';')
                        data[i] = '\0';

                    if (data[i] == '\0')
                    {
                        handle_remove_file((char*)(&data[file_name_pos]));
                        file_name_pos = i + 1;
                    }
                }
                STLV_BUF_END_TEMP_STRING(data, data_len);
            }
           break;

#if 0
        case ELEMENT_TYPE_SPORT_HEARTBEAT:
            {
                int data_len = get_element_data_size(pack, handle, type_buf, type_len);
                uint8_t* data = get_element_data_buffer(pack, handle, type_buf, type_len);
                STLV_BUF_BEGIN_TEMP_STRING(data, data_len);
                handle_sports_heartbeat((char*)data);
                STLV_BUF_END_TEMP_STRING(data, data_len);
            }
            break;
        case ELEMENT_TYPE_SPORTS_DATA:
            handle_get_sports_data();
            break;
#endif
        case ELEMENT_TYPE_SPORTS_GRID:
            log_info("Get Sports Grid Request\n");
            handle_get_sports_grid();
            break;

        case ELEMENT_TYPE_ALARM:
            {
                int data_len = get_element_data_size(pack, handle, type_buf, type_len);
                uint8_t* data = get_element_data_buffer(pack, handle, type_buf, type_len);
                if (data_len != sizeof(alarm_conf_t))
                {
                    log_info("Alarm element decode failed: length mismatch (%d/%d)", data_len, sizeof(alarm_conf_t));
                }
                else
                {
                    handle_alarm((alarm_conf_t*)data);
                }
            }
            break;

        case ELEMENT_TYPE_SN:
            handle_get_device_id();
            break;

        case ELEMENT_TYPE_ACTIVITY:
            handle_gps_data(pack, handle);
            break;

        case ELEMENT_TYPE_GESTURE_CONTROL:
            {
                int data_len = get_element_data_size(pack, handle, type_buf, type_len);
                uint8_t* data = get_element_data_buffer(pack, handle, type_buf, type_len);
                if (data_len != 5)
                {
                    log_info("gesture control decode failed: length mismatch (%d/1)", data_len);
                }
                else
                {
                    handle_gesture_control(*data, data + 1);
                }
            }
            break;

        case ELEMENT_TYPE_WATCHCONFIG:
            {
                int data_len = get_element_data_size(pack, handle, type_buf, type_len);
                uint8_t* data = get_element_data_buffer(pack, handle, type_buf, type_len);
                log_info("Set Watch UI Config %d/%d", data_len, (int)sizeof(ui_config));
                //if (data_len >= (int)sizeof(ui_config))
                    handle_set_watch_config((ui_config*)(data + 1));
            }
            break;

        case ELEMENT_TYPE_UNLOCK_WATCH:
            handle_unlock_watch();
            break;

        case ELEMENT_TYPE_DAILY_ACTIVITY:
            handle_daily_activity();
            break;

        }

        handle = get_next_element(pack, handle);

    }
}
Ejemplo n.º 3
0
void proxy_instance::worker_thread(){
    HC_LOG_TRACE("");

    proxy_msg m;
    state_table_map::iterator it_state_table;

    //##-- add all interfaces --##
    //upsteam
    registrate_if(m_upstream);
    //downsteams (only one)
    for ( it_state_table=m_state_table.begin() ; it_state_table != m_state_table.end(); it_state_table++ ){
        registrate_if(it_state_table->first);
    }

    //##-- general query --##
    //nach registrate_if ausgelagert
    //send_gq_to_all();

    //##-- initiate GQ timer --##
    m.type = proxy_msg::CLOCK_MSG;
    m.msg = new struct clock_msg(clock_msg::SEND_GQ_TO_ALL);
    m_timing->add_time(MC_TV_QUERY_INTERVAL*1000 /*msec*/,this,m);

    //##-- thread working loop --##
    while(m_running){
        m = m_job_queue.dequeue();
        HC_LOG_DEBUG("received new job. type: " << m.msg_type_to_string());
        switch(m.type){
        case proxy_msg::TEST_MSG: {
            struct test_msg* t= (struct test_msg*) m.msg.get();
            t->test();
            break;
        }
        case proxy_msg::RECEIVER_MSG: {
            struct receiver_msg* t= (struct receiver_msg*) m.msg.get();
            handle_igmp(t);
            break;
        }
        case proxy_msg::CLOCK_MSG: {
            struct clock_msg* t = (struct clock_msg*) m.msg.get();
            handle_clock(t);
            break;
        }
        case proxy_msg::CONFIG_MSG: {
            struct config_msg* t = (struct config_msg*) m.msg.get();
            handle_config(t);
            break;
        }
        case proxy_msg::DEBUG_MSG: {
            struct debug_msg* t = (struct debug_msg*) m.msg.get();
            handle_debug_msg(t);
            break;
        }

        case proxy_msg::EXIT_CMD: m_running = false; break;
        default: HC_LOG_ERROR("unknown message format");
        }
    }

    //##-- timing --##
    //remove all running times
    m_timing->stop_all_time(this);

    //##-- del all interfaces --##
    //upsteam
    unregistrate_if(m_upstream);
    //downsteams
    for ( it_state_table=m_state_table.begin() ; it_state_table != m_state_table.end(); it_state_table++ ){
        unregistrate_if(it_state_table->first);
    }

    HC_LOG_DEBUG("worker thread proxy_instance end");
}