-
Notifications
You must be signed in to change notification settings - Fork 1
/
tpsn.h
54 lines (45 loc) · 1.07 KB
/
tpsn.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef TPSN_H_
#define TPSN_H_
#include "contiki.h"
#include "net/rime.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include "node-id.h"
#include "sys/rtimer.h"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "tpsn.h"
typedef enum {
DISCOVERY = 0, SYNC_PULSE = 1, SYNC_REQ = 2, SYNC_ACK = 3
} MessageType;
typedef struct {
MessageType type;
uint16_t level;
uint16_t broadcast_id;
uint16_t sender_id;
} DiscoveryMessage;
typedef struct {
MessageType type;
uint16_t sender_id;
} SyncPulseMessage;
typedef struct {
MessageType type;
uint16_t sender_id, destination_id;
clock_time_t t1;
} SyncRequestMessage;
typedef struct {
MessageType type;
uint16_t sender_id, destination_id;
clock_time_t t1, t2, t3;
} SyncAckMessage;
typedef struct {
MessageType type;
uint16_t data[200];
} AbstractMessage;
static void handle_discovery(DiscoveryMessage);
static void handle_sync_pulse();
static void handle_sync_ack(SyncAckMessage);
static void handle_sync_req(SyncRequestMessage);
static void sync();
#endif