Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ble_lld_transport.h « lld « ble_lld « STM32_WPAN « ST « Middlewares - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 71027e9a0e14e58d1f48c6b92285d093420a3942 (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/**
  ******************************************************************************
  * @file    ble_lld_transport.h
  * @author  MCD Application Team
  * @brief   Definitions of command id and structures for transport
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2019-2012 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */

#ifndef BLE_LLD_TRANSPORT_H
#define BLE_LLD_TRANSPORT_H

#ifdef __cplusplus
extern "C" {
#endif

#include "stm32_wpan_common.h"
#include "ipBLE_lld_public.h"

/* Commands to radio MCU */
typedef enum
{
  BLE_LLD_UNUSED_CMDCODE = 0,
  BLE_LLD_GETSTATUS_CMDCODE,
  BLE_LLD_SETCHANNEL_CMDCODE,
  BLE_LLD_SETTXATTRIBUTES_CMDCODE,
  BLE_LLD_SETBACKTOBACKTIME_CMDCODE,
  BLE_LLD_SETTXPOWER_CMDCODE,
  BLE_LLD_SETTX_RX_PHY_CMDCODE,
  BLE_LLD_STOPACTIVITY_CMDCODE,
  BLE_LLD_SETENCRYPTIONCOUNT_CMDCODE,
  BLE_LLD_SETENCRYPTIONATTRIBUTES_CMDCODE,
  BLE_LLD_SETENCRYPTFLAGS_CMDCODE,
  BLE_LLD_ENCRYPTPLAINDATA_CMDCODE,
  BLE_LLD_STARTTONE_CMDCODE,
  BLE_LLD_STOPTONE_CMDCODE,
  BLE_LLD_SETRESERVEDAREA_CMDCODE,
  BLE_LLD_MAKEACTIONPACKETPENDING_CMDCODE,
  BLE_LLD_INIT_CMDCODE,
} BLE_LLD_Code_t;

/* Responses from radio MCU */
typedef enum
{
  BLE_LLD_RSP_END,
} BLE_LLD_rsp_t;

/** Parameters for command BLE_LLD_SETENCRYPTIONCOUNT_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t stateMachineNo;
  uint8_t countTx[5];
  uint8_t countRcv[5];
} param_BLE_LLD_cryptCount_t;

/** Parameters for command BLE_LLD_SETENCRYPTIONATTRIBUTES_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t stateMachineNo;
  uint8_t encIv[AES_IV_SIZE];
  uint8_t encKey[AES_KEY_SIZE];
} param_BLE_LLD_cryptAttr_t;

/** Parameters for command BLE_LLD_SETENCRYPTFLAGS_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t encFlag;
  uint8_t StateMachineNo;
} param_BLE_LLD_cryptFlags_t;

/** Parameters for command BLE_LLD_ENCRYPTPLAINDATA_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t key[AES_KEY_SIZE];
  uint8_t plainData[AES_BLOCK_SIZE];
  uint8_t cypherData[AES_BLOCK_SIZE];
} param_BLE_LLD_crypt_t;

/** Parameters for command BLE_LLD_STARTTONE_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t channel;
  uint8_t power;
} param_BLE_LLD_toneStart_t;

/** Parameters for command BLE_LLD_SETCHANNEL_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t channel;
  uint8_t stateMachineNo;
} param_BLE_LLD_chan_t;

/** Parameters for command BLE_LLD_SETTXATTRIBUTES_CMDCODE */
typedef PACKED_STRUCT
{
  uint32_t networkId;
  uint8_t stateMachineNo;
} param_BLE_LLD_txAttr_t;

/** Parameters for command BLE_LLD_SETBACKTOBACKTIME_CMDCODE */
typedef PACKED_STRUCT
{
  uint32_t backToBackTime;
} param_BLE_LLD_b2b_t;

/** Parameters for command BLE_LLD_SETTXPOWER_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t power;
} param_BLE_LLD_power_t;

/** Parameters for command BLE_LLD_SETTX_RX_PHY_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t txPhy;
  uint8_t rxPhy;
  uint8_t stateMachineNo;
} param_BLE_LLD_phy_t;

/** Parameters for command BLE_LLD_SETRESERVEDAREA_CMDCODE */
typedef PACKED_STRUCT
{
  uint32_t wakeupTime;
  uint32_t receiveWindowLength;
  uint8_t nextTrue;
  uint8_t nextFalse;
  uint8_t stateMachineNo;
  uint8_t actionTag;
  uint8_t actionPacketNb;
  ipBLE_lld_txrxdata_Type *buffer; // Rx or Tx buffer in shared memory
} param_BLE_LLD_reserved_t;

/** Parameters for command BLE_LLD_MAKEACTIONPACKETPENDING_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t actionPacketNb;
} param_BLE_LLD_mkPending_t;

/** Parameters for command BLE_LLD_INIT_CMDCODE */
typedef PACKED_STRUCT
{
  uint32_t startupTime;
  uint8_t lowSpeedOsc;
  uint8_t whitening;
} param_BLE_LLD_init_t;

/** Parameters for replies */
typedef PACKED_STRUCT
{
  uint32_t status;
  uint32_t timestampReceive;
  uint32_t rssi;
  uint8_t actionPacketNb;
} param_BLE_LLD_m0Reply_t;

/** Parameters for commands and response */
typedef union
{
  param_BLE_LLD_cryptCount_t cryptCount;
  param_BLE_LLD_cryptAttr_t cryptAttr;
  param_BLE_LLD_cryptFlags_t cryptFlags;
  param_BLE_LLD_crypt_t encrypt;
  param_BLE_LLD_toneStart_t toneStart;
  param_BLE_LLD_chan_t chan;
  param_BLE_LLD_txAttr_t txAttr;
  param_BLE_LLD_b2b_t b2b;
  param_BLE_LLD_power_t power;
  param_BLE_LLD_phy_t phy;
  param_BLE_LLD_reserved_t reserved;
  param_BLE_LLD_mkPending_t pending;
  param_BLE_LLD_init_t init;
  param_BLE_LLD_m0Reply_t reply;
} __attribute__((packed)) param_BLE_LLD_t;

typedef PACKED_STRUCT
{
  uint8_t returnValue;
  param_BLE_LLD_t params;
} msg_BLE_LLD_t;

// Used to pack message pointer into generic payload
typedef PACKED_STRUCT
{
  msg_BLE_LLD_t *msg;
} payload_BLE_LLD_t;

#ifdef __cplusplus
}
#endif

#endif /* BLE_LLD_TRANSPORT_H */