예제 #1
0
파일: get.c 프로젝트: jkx/DIY-Wireless-Bug
void send_set(uint8_t dst, uint8_t device, int16_t value) {
	uart_putstr_P(PSTR("send_set()\r\n"));
	struct packet_t *packet=get_tx_packet();
	set_devices(packet,0xff,device);
	set_data_int16(packet,value);
	send(dst,SET,packet);
}
예제 #2
0
void bugone_loop() {
    uint8_t *bufcontents;
    uint8_t i;

    // RFM12 managment
    rfm12_tick();
    if (rfm12_rx_status() == STATUS_COMPLETE) {
        bufcontents=rfm12_rx_buffer();
        recv(bufcontents);
    }

    // Every minutes
    if (seconds > 20) {
        struct packet_t *packet = get_tx_packet();
        application_t *application;
        int8_t len;
        uart_putstr_P(PSTR("\r\n"));
        i=0;
        while ( (application = get_app(i)) != NULL) {
            i++;
            uart_putstr_P(PSTR("#"));
            if (application->get == NULL) { continue; }
                set_devices(packet,i,0x29);
                len=application->get(packet);
                if (len > 0) {
                    //data.remaining_len-=len;
                    //data.buf+=len;
                }
        }
        send(0xFF,6,packet);
        seconds=0;
    }

    // Asynchronous events
    if (wake_me_up > 0) {
        struct packet_t *packet = get_tx_packet();
        int8_t len;
        uart_putstr_P(PSTR("\r\n"));
        set_devices(packet,wake_me_up,42);
        len=applications[wake_me_up].get(packet);
        send(0xFF,VALUE,packet);
        wake_me_up = 0;
    }
}
예제 #3
0
파일: get.c 프로젝트: jkx/DIY-Wireless-Bug
void recv_get(struct packet_t *packet) {
	uint8_t device_src,device_dst;
	uint8_t len;
	application_t* app;

	struct packet_t *send_packet = get_tx_packet();

	while (get_devices(packet,&device_src,&device_dst)) {
		app=app_get(device_dst);
		set_devices(send_packet,device_dst,device_src);
		len=app->get(send_packet);
	//	if (len > 0) {
	//		data.remaining_len-=len;
	//	}
	}
	send(packet->network->src,VALUE,send_packet);
}