Arduino driver library for Decawave DW1000  Dec 20 2016
DW1000Mac.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 by Leopold Sayous <leosayous@gmail.com> and Thomas Trojer <thomas@trojer.net>
3  * Decawave DW1000 library for arduino.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * @file DW1000Mac.h
18  * Arduino global library (header file) working with the DW1000 library
19  * for the Decawave DW1000 UWB transceiver IC. This class has the purpose
20  * to generate the mac layer
21  *
22  * @todo everything, this class is only a prototype
23  */
24 
25 #define FC_1 0x41
26 #define FC_1_BLINK 0xC5
27 #define FC_2 0x8C
28 #define FC_2_SHORT 0x88
29 
30 #define PAN_ID_1 0xCA
31 #define PAN_ID_2 0xDE
32 
33 #define SHORT_MAC_LEN 9
34 #define LONG_MAC_LEN 15
35 
36 
37 #ifndef _DW1000MAC_H_INCLUDED
38 #define _DW1000MAC_H_INCLUDED
39 
40 #include <Arduino.h>
41 #include "DW1000Device.h"
42 
43 class DW1000Device;
44 
45 class DW1000Mac {
46 public:
47  //Constructor and destructor
48  DW1000Mac(DW1000Device* parent);
49  DW1000Mac();
50  ~DW1000Mac();
51 
52 
53  //setters
54  void setDestinationAddress(byte* destinationAddress);
55  void setDestinationAddressShort(byte* shortDestinationAddress);
56  void setSourceAddress(byte* sourceAddress);
57  void setSourceAddressShort(byte* shortSourceAddress);
58 
59 
60  //for poll message we use just 2 bytes address
61  //total=12 bytes
62  void generateBlinkFrame(byte frame[], byte sourceAddress[], byte sourceShortAddress[]);
63 
64  //the short fram usually for Resp, Final, or Report
65  //2 bytes for Desination Address and 2 bytes for Source Address
66  //total=9 bytes
67  void generateShortMACFrame(byte frame[], byte sourceShortAddress[], byte destinationShortAddress[]);
68 
69  //the long frame for Ranging init
70  //8 bytes for Destination Address and 2 bytes for Source Address
71  //total of
72  void generateLongMACFrame(byte frame[], byte sourceShortAddress[], byte destinationAddress[]);
73 
74  //in order to decode the frame and save source Address!
75  void decodeBlinkFrame(byte frame[], byte address[], byte shortAddress[]);
76  void decodeShortMACFrame(byte frame[], byte address[]);
77  void decodeLongMACFrame(byte frame[], byte address[]);
78 
79  void incrementSeqNumber();
80 
81 
82 private:
83  uint8_t _seqNumber = 0;
84  void reverseArray(byte to[], byte from[], int16_t size);
85 
86 };
87 
88 
89 #endif
90 
void incrementSeqNumber()
Definition: DW1000Mac.cpp:146
void generateLongMACFrame(byte frame[], byte sourceShortAddress[], byte destinationAddress[])
Definition: DW1000Mac.cpp:91
void setSourceAddress(byte *sourceAddress)
Definition: DW1000Device.h:37
void generateShortMACFrame(byte frame[], byte sourceShortAddress[], byte destinationShortAddress[])
Definition: DW1000Mac.cpp:62
Definition: DW1000Mac.h:45
~DW1000Mac()
Definition: DW1000Mac.cpp:35
void setDestinationAddress(byte *destinationAddress)
void decodeBlinkFrame(byte frame[], byte address[], byte shortAddress[])
Definition: DW1000Mac.cpp:116
void decodeShortMACFrame(byte frame[], byte address[])
Definition: DW1000Mac.cpp:127
void setSourceAddressShort(byte *shortSourceAddress)
void setDestinationAddressShort(byte *shortDestinationAddress)
void generateBlinkFrame(byte frame[], byte sourceAddress[], byte sourceShortAddress[])
Definition: DW1000Mac.cpp:40
DW1000Mac()
Definition: DW1000Mac.cpp:30
void decodeLongMACFrame(byte frame[], byte address[])
Definition: DW1000Mac.cpp:136