Project

General

Profile

Revision 1394

Added by Chris Mar over 13 years ago

changed template main to use new basic wireless

View differences:

main.c
2 2
#include <wireless.h>
3 3
#include <wl_basic.h>
4 4

  
5
#define CHAN 0xE	/* channel to use for wireless communication */
6
#define WL_BASIC_GROUP 8		/* group and type numbers for sending test packets */
5
#define CHAN 0xE	       /* channel to use for wireless communication */
7 6

  
8
void packet_receive(char type, int source, unsigned char* packet, int length);
9
PacketGroupHandler wl_basic_group_handler = {WL_BASIC_GROUP, NULL, NULL, &packet_receive, NULL};
7
unsigned char* packet;
10 8

  
11 9
int main(void)
12 10
{
13 11
	/* initialize components, set wireless channel */
14 12
	dragonfly_init(ALL_ON);
15
	wl_basic_init(&packet_receive);
13
	wl_basic_init_default();
16 14
	wl_set_channel(CHAN);
17 15

  
18
	/* set up a packet group (or something) to receive packets */
19
	//wl_register_packet_group(&wl_basic_group_handler);
16
	while (1) {
17
		packet = wl_basic_do();
18
        if (packet != 0) {
19
            if (current_packet.length > 0) {
20
                if (packet[0] == 'r')
21
                    orb_set_color(RED);
22
                else if (packet[0] == 'b')
23
                    orb_set_color(BLUE);
24
            }
25
        }
20 26

  
21
	while (1)
22
	{
23
		wl_do();
24

  
25 27
		/* send a packet with no useful info for testing */
26 28
        if (button1_click() ) {
27
		    wl_basic_send_global_packet(1, NULL, 0);
29
		    wl_basic_send_global_packet(1, "r", 2);
28 30
        }
29 31
        if (button2_click() ) {
30
		    wl_basic_send_global_packet(2, NULL, 0);
32
		    wl_basic_send_global_packet(1, "b", 2);
31 33
        }
32 34
	}
33 35

  
......
36 38
	return 0;
37 39
}
38 40

  
39
void packet_receive(char type, int source, unsigned char* packet, int length)
40
{
41
	if ( type == 1 ) {
42
        orb_set_color(RED);
43
    }
44
    else if ( type == 2 ) {
45
        orb_set_color(BLUE);
46
    }
47
}
48

  

Also available in: Unified diff