-
Notifications
You must be signed in to change notification settings - Fork 0
/
Message_Prep.c
66 lines (50 loc) · 1.19 KB
/
Message_Prep.c
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
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Message_Prep.c
*
* Created on: 11/30/2015
* Author: KDolgikh
*/
#include <stdint.h>
#include "Message_Prep.h"
#include "Radio.h"
#include "States.h"
#include "Message_Prep.h"
#include "CH_TDMA_Assign.h"
uint8_t Message_Prep_CH_TDMA (
uint8_t opcode,
uint32_t cycles,
uint8_t *ptr)
{
uint8_t length = 0; // payload length
uint8_t lgth = 0;
ptr[OPCODE_POS] = opcode; // 0
lgth = long_int_divide(cycles, &ptr[CYCLES_POS_LOWER]);
length = lgth + 1;
return length;
}
uint8_t Message_Prep_CH_Sense (uint8_t opcode, uint8_t *ptr)
{
uint8_t length = 0; // payload length
ptr[OPCODE_POS] = opcode;
length = 1;
return length;
}
uint8_t Message_Prep_Sense (uint8_t opcode, int32_t temp, uint8_t *ptr)
{
uint8_t length = 0; // payload length
uint8_t lgth = 0;
ptr[OPCODE_POS] = opcode;
lgth = long_int_divide_temp(temp, &ptr[TEMP_POS_LOWER]);
length = lgth + 1;
return length;
}
uint8_t Message_Prep_BS (uint8_t opcode, uint8_t node_addr, int32_t temp, uint8_t *ptr)
{
uint8_t length = 0; // payload length
uint8_t lgth = 0;
ptr[OPCODE_POS] = opcode;
ptr[BS_ND_ADDR_POS] = node_addr;
lgth = long_int_divide_temp(temp, &ptr[BS_TEMP_POS_LOW]);
length = lgth + 2;
return length;
}