Skip to content

Commit

Permalink
Added gitignore file and fixed MakeFile CONTIKI path.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nejc Bizjak committed Apr 23, 2016
1 parent 0fdb1a6 commit c87a213
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.map
*.z1
*symbols.c
*symbols.h
*.a
obj_z1/
2 changes: 1 addition & 1 deletion gateway/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CONTIKI_PROJECT = herd_monitor_gateway
all: $(CONTIKI_PROJECT)

CONTIKI = ../..
CONTIKI = ../../..
CONTIKI_WITH_RIME = 1
include $(CONTIKI)/Makefile.include
2 changes: 1 addition & 1 deletion node/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CONTIKI_PROJECT = herd_monitor_node
all: $(CONTIKI_PROJECT)

CONTIKI = ../..
CONTIKI = ../../..
CONTIKI_WITH_RIME = 1
include $(CONTIKI)/Makefile.include
34 changes: 31 additions & 3 deletions node/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,44 @@
#include <stdlib.h>

#define TMP102_READ_INTERVAL (CLOCK_SECOND) // Poll the sensor every second
#define NUMBER_OF_COWS 15 //Number of cows

PROCESS (herd_monitor_node, "Herd monitor - node");
AUTOSTART_PROCESSES (&herd_monitor_node);

static void
broadcast_recv(struct broadcast_conn *c, const linkaddr_t *from)
{
int cow_id = from->u8[1];
printf("broadcast message received from cow %d: '%s'\n",
from->u8[1], (char *)packetbuf_dataptr());
}

static const struct broadcast_callbacks broadcast_call = {broadcast_recv};
static struct broadcast_conn broadcast;

static int neighbour_list[NUMBER_OF_COWS - 1];

PROCESS_THREAD (herd_monitor_node, ev, data)
{
static struct etimer et;

PROCESS_EXITHANDLER(broadcast_close(&broadcast);)

PROCESS_BEGIN();
{

}

broadcast_open(&broadcast, 129, &broadcast_call);
while(1) {
/* Delay 2-4 seconds */
etimer_set(&et, CLOCK_SECOND * 4 + random_rand() % (CLOCK_SECOND * 4));

PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));

packetbuf_copyfrom("Hello", 6);
broadcast_send(&broadcast);
printf("broadcast message sent\n");
}


PROCESS_END ();
}

0 comments on commit c87a213

Please sign in to comment.