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

appli_config.c « app « STM32_WPAN « BLE_MeshLightingProvisioner « BLE « Applications « P-NUCLEO-WB55.Nucleo « Projects - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6a94692e466dc4a3c6559ed5a6ed731b2a6b21a8 (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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
/**
******************************************************************************
* @file    appli_config.c
* @author  BLE Mesh Team
* @version V1.13.000
* @date    20-10-2020
* @brief   Config Model APIs callback from ST BLE Mesh Library
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
*                             www.st.com/SLA0044
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include <string.h>
#include "hal_common.h"
#include "ble_mesh.h"
#include "appli_config.h"
#include "mesh_cfg.h"

/** @addtogroup ST_BLE_Mesh
*  @{
*/

/** @addtogroup Application_Mesh_Models
*  @{
*/

/* Private define ------------------------------------------------------------*/

/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/


/*****************************Config Model Callbacks***************************/
/**
* @brief  Callback from Config Model to receive the AppKey Add Command
* @param  Structure Pointer having parameters - netKeyIndex, appKeyIndex
*                                               appKey, keySize & status
* @retval none
*/ 
void Appli_GetAppKeyAddParamsCb(model_securityKeyParams_t* appKeyAddParams)
{
  TRACE_I(TF_CONFIG_SERVER,"AppKey Add received for netKeyIndex %.2x, appKeyIndex %.2x \r\n",\
          appKeyAddParams->netKeyIndex, appKeyAddParams->appKeyIndex);

  TRACE_I(TF_CONFIG_SERVER,"Status is : %.2x \r\n", appKeyAddParams->status);
  /*Success Command*/
  if(appKeyAddParams->status == 0x00)
  {
    TRACE_I(TF_CONFIG_SERVER,"AppKey is: ");
    for (MOBLEUINT8 count=0 ; count<appKeyAddParams->keySize; count++)
    {
      TRACE_I(TF_CONFIG_SERVER,"%.2x", *(appKeyAddParams->appKey));
      appKeyAddParams->appKey++;
    }  
    TRACE_I(TF_CONFIG_SERVER," \r\n");
  }
}

/**
* @brief  Callback from Config Model to receive the AppKey Delete Command
* @param  Structure Pointer having parameters - netKeyIndex, appKeyIndex
*                                               appKey, keySize & status
* @retval none
*/ 
void Appli_GetAppKeyDeleteParamsCb(model_securityKeyParams_t* appKeyDeleteParams)
{
  TRACE_I(TF_CONFIG_SERVER,"App Key Delete received for netKeyIndex %.2x, appKeyIndex %.2x \r\n",\
          appKeyDeleteParams->netKeyIndex, appKeyDeleteParams->appKeyIndex);
  
  TRACE_I(TF_CONFIG_SERVER,"Status is : %.2x \r\n", appKeyDeleteParams->status);
}

/**
* @brief  Callback from Config Model to receive the AppKey List
* @param  Structure Pointer having parameters - netKeyIndex, appKeyIndexes & appKeyListParams Size
* @retval none
*/ 
void Appli_GetAppKeyListParamsCb(model_appKeyListParams_t* appKeyListParams)
{
  TRACE_I(TF_CONFIG_SERVER,"App Key List for netKeyIndex %.2x is \r\n", appKeyListParams->netKeyIndex);
  TRACE_I(TF_CONFIG_SERVER,"Status is : %.2x \r\n", appKeyListParams->status);
  /*Success*/
  if(appKeyListParams->status == 0x00)
  {
    TRACE_I(TF_CONFIG_SERVER,"AppKey Indexes are: \r\n");
    for (MOBLEUINT8 count=0 ; count< appKeyListParams->appKeyIndexList_size; count++)
    {
      TRACE_I(TF_CONFIG_SERVER,"%.2x", *(appKeyListParams->appKeyIndexList));
      appKeyListParams->appKeyIndexList++;
    }  
   TRACE_I(TF_CONFIG_SERVER," \r\n");
  }
}

/**
* @brief  Callback from Config Model to receive the Updated App Key
* @param  Structure Pointer having parameters - netKeyIndex, appKeyIndex
*                                               appKey, keySize & status
* @retval none
*/ 
void Appli_GetAppKeyUpdateParamsCb(model_securityKeyParams_t* appKeyUpdatedParams)
{
  TRACE_I(TF_CONFIG_SERVER,"App Key Update received for netKeyIndex %.2x, appKeyIndex %.2x \r\n",\
          appKeyUpdatedParams->netKeyIndex, appKeyUpdatedParams->appKeyIndex);

  TRACE_I(TF_CONFIG_SERVER,"Status is : %.2x \r\n", appKeyUpdatedParams->status);
  
  /*Success Command*/
  if(appKeyUpdatedParams->status == 0x00)
  {
    TRACE_I(TF_CONFIG_SERVER,"Updated AppKey is: ");
    for (MOBLEUINT8 count=0 ; count<appKeyUpdatedParams->keySize; count++)
    {
      TRACE_I(TF_CONFIG_SERVER,"%.2x", *(appKeyUpdatedParams->appKey));
      appKeyUpdatedParams->appKey++;
    }
    TRACE_I(TF_CONFIG_SERVER," \r\n");
    TRACE_I(TF_CONFIG_SERVER,"It will be replaced by old appKey after Key Refresh \r\n");
  }
  
}

/**
* @brief  Callback from Config Model to receive the NetKey Add Command
* @param  Structure Pointer having parameters - netKeyIndex & netKey
* @retval none
*/ 
void Appli_GetNetKeyAddParamsCb(model_securityKeyParams_t* netKeyAddParams)
{
  TRACE_I(TF_CONFIG_SERVER,"Net Key Add received for netKeyIndex %.2x \r\n",\
                                               netKeyAddParams->netKeyIndex);

  TRACE_I(TF_CONFIG_SERVER,"Status is : %.2x \r\n", netKeyAddParams->status);

  /*Success Command*/
  if(netKeyAddParams->status == 0x00)
  {
    TRACE_I(TF_CONFIG_SERVER,"NetKey is: ");
    for (MOBLEUINT8 count=0 ; count < netKeyAddParams->keySize; count++)
    {
      TRACE_I(TF_CONFIG_SERVER,"%.2x", *(netKeyAddParams->netKey));
      netKeyAddParams->netKey++;
    } 
    TRACE_I(TF_CONFIG_SERVER," \r\n");
  }
}

/**
* @brief  Callback from Config Model to receive the NetKey Delete Command
* @param  Structure Pointer having parameters - netKeyIndex & netKey
* @retval none
*/ 
void Appli_GetNetKeyDeleteParamsCb(model_securityKeyParams_t* netKeyDeleteParams)
{ 
   TRACE_I(TF_CONFIG_SERVER,"Net Key Delete received for netKeyIndex %d \r\n",\
                                               netKeyDeleteParams->netKeyIndex);
   TRACE_I(TF_CONFIG_SERVER,"Status is : %.2x \r\n", netKeyDeleteParams->status);
}

/**
* @brief  Callback from Config Model to receive the NetKey List
* @param  Structure Pointer having parameters - netKeyIndexes & netKeyListParams Size
* @retval none
*/ 
void Appli_GetNetKeyListParamsCb(model_netKeyListParams_t* netKeyListParams)
{
  TRACE_I(TF_CONFIG_SERVER,"Status is : %.2x \r\n", netKeyListParams->status);
  TRACE_I(TF_CONFIG_SERVER,"NetKey Indexes are: \r\n");
  for (MOBLEUINT8 count=0 ; count< netKeyListParams->netKeyIndexList_size; count++)
  {
    TRACE_I(TF_CONFIG_SERVER,"%.2x", *(netKeyListParams->netKeyIndexList));
    netKeyListParams->netKeyIndexList++;
  }
  TRACE_I(TF_CONFIG_SERVER," \r\n");  
}


/**
* @brief  Callback from Config Model to receive the Updated NetKey Command
* @param  Structure Pointer having parameters - netKeyIndex & netKey
* @retval none
*/ 
void Appli_GetNetKeyUpdateParamsCb(model_securityKeyParams_t* netKeyUpdatedParams)
{
  TRACE_I(TF_CONFIG_SERVER,"Net Key Update received for netKeyIndex %d \r\n",\
                                     netKeyUpdatedParams->netKeyIndex);
  
  TRACE_I(TF_CONFIG_SERVER,"Status is : %.2x \r\n", netKeyUpdatedParams->status);
  if(netKeyUpdatedParams->status == 0)
  {
    TRACE_I(TF_CONFIG_SERVER,"Updated NetKey is:");
    for (MOBLEUINT8 count=0; count<netKeyUpdatedParams->keySize; count++)
    {
      TRACE_I(TF_CONFIG_SERVER,"%.2x", *(netKeyUpdatedParams->netKey));
      netKeyUpdatedParams->netKey++;
    }
  TRACE_I(TF_CONFIG_SERVER," \r\n");
  TRACE_I(TF_CONFIG_SERVER,"It will be replaced by old netKey after Key Refresh \r\n");
  }
}

/**
* @brief  Callback from Config Model to receive the AppKey binding params
* @param  Structure Pointer having parameters - elementIndex, appKeyIndex & modelID
* @retval none
*/ 
void Appli_GetAppKeyBindingParamsCb(model_appKeyBindingParams_t* appKeyBindParams)
{
  TRACE_I(TF_CONFIG_SERVER,"AppKey binding received for elementIndex %d, modelID %.2lx,\
          appKeyIndex %.2x & status %.2x \r\n", appKeyBindParams->elementIndex,\
          appKeyBindParams->modelID, appKeyBindParams->appKeyIndex, appKeyBindParams->status);
}

/**
* @brief  Callback from Config Model to receive the AppKey Unbinding params
* @param  Structure Pointer having parameters - elementIndex, appKeyIndex & modelID
* @retval none
*/ 
void Appli_GetAppKeyUnBindingParamsCb(model_appKeyBindingParams_t* appKeyUnbindParams)
{
  TRACE_I(TF_CONFIG_SERVER,"AppKey unbinding received for elementIndex %d, modelID %.2lx,\
          appKeyIndex %.2x & status %.2x \r\n",appKeyUnbindParams->elementIndex,\
          appKeyUnbindParams->modelID, appKeyUnbindParams->appKeyIndex,\
          appKeyUnbindParams->status);  
}

/**
* @brief  Callback from Config Model to receive the Subscription Add params
* @param  Structure Pointer having parameters - elementIndex, appKeyIndex, modelID
*            subAddress, isVirtual & allSubDeleted
* @retval none
*/ 
void Appli_GetSubAddParamsCb(model_subParams_t* subAddParams)
{
  
  TRACE_I(TF_CONFIG_SERVER,"Status is : %.2x \r\n", subAddParams->status); 
  if(subAddParams->isVirtual)
  {
    TRACE_I(TF_CONFIG_SERVER,"Subscription Virtual Add received for elementIndex %d, modelID %.2lx & subAddress %.2x \r\n",\
                              subAddParams->elementIndex, subAddParams->modelID,\
                                                 subAddParams->subAddress);     
  }
  
  else
  {
    TRACE_I(TF_CONFIG_SERVER,"Subscription Add received for elementIndex %d, modelID %.2lx & subAddress %.2x \r\n",\
                              subAddParams->elementIndex, subAddParams->modelID,\
                                                 subAddParams->subAddress); 
  }
}

/**
* @brief  Callback from Config Model to receive the Subscription Delete params
* @param  Structure Pointer having parameters - elementIndex, appKeyIndex, modelID
*            subAddress, isVirtual & allSubDeleted
* @retval none
*/ 
void Appli_GetSubDeleteParamsCb(model_subParams_t* subDeleteParams)
{
  TRACE_I(TF_CONFIG_SERVER,"Status is : %.2x \r\n", subDeleteParams->status); 
  if(subDeleteParams->isVirtual)
  {
    TRACE_I(TF_CONFIG_SERVER,"Subscription Virtual Add Delete received for elementIndex %d, modelID %.2lx & subAddress %.2x \r\n",\
                              subDeleteParams->elementIndex, subDeleteParams->modelID,\
                                                 subDeleteParams->subAddress);     
    
  }
  
  else if(subDeleteParams->allSubDeleted)
  {
    
     TRACE_I(TF_CONFIG_SERVER,"Delete All Subscription received for elementIndex %d, modelID %.2lx \r\n",\
                              subDeleteParams->elementIndex, subDeleteParams->modelID);        
    
  }
  else
  {
    TRACE_I(TF_CONFIG_SERVER,"Subscription Delete received for elementIndex %d, modelID %.2lx & subAddress %.2x \r\n",\
                              subDeleteParams->elementIndex, subDeleteParams->modelID,\
                                                 subDeleteParams->subAddress); 
  }  
}

/**
* @brief  Callback from Config Model to receive the Subscription Overwrite params
* @param  Structure Pointer having parameters - elementIndex, appKeyIndex, modelID
*            subAddress, isVirtual & allSubDeleted
* @retval none
*/ 
void Appli_GetSubOverwriteParamsCb(model_subParams_t* subOverwriteParams)
{
  TRACE_I(TF_CONFIG_SERVER,"Status is : %.2x \r\n", subOverwriteParams->status); 
  if(subOverwriteParams->isVirtual)
  {
    TRACE_I(TF_CONFIG_SERVER,"Subscription Virtual Overwrite received for elementIndex %d, modelID %.2lx & subAddress %.2x \r\n",\
                    subOverwriteParams->elementIndex, subOverwriteParams->modelID,\
                                                 subOverwriteParams->subAddress);     
    
  }
  
  else
  {
    TRACE_I(TF_CONFIG_SERVER,"Subscription Overwrite received for elementIndex %d, modelID %.2lx & subAddress %.2x \r\n",\
                     subOverwriteParams->elementIndex, subOverwriteParams->modelID,\
                                                 subOverwriteParams->subAddress); 
  }  
}

/**
* @brief  Callback from Config Model to receive the Publication Parameters
* @param  Structure Pointer having parameters - modelID, elementAddress,
*         Publish Address, PublishPeriod, PublishTTL, Credential Flag, 
*         Publish AppKeyIndex, Retransmit Count, Restransmit Interval Steps & status
* @retval none
*/ 
void Appli_GetPublicationSetParamsCb(model_publicationparams_t* pPubParameters)
{
  if(pPubParameters->modelID == SENSOR_SERVER_MODEL_ID)
  {
    Sensor_ModelPublishSet(pPubParameters);
  }
}

/**
* @brief  Callback from Config Model to receive the Publication Parameters
* @param  Structure Pointer having parameters - modelID, elementAddress,
*         Publish Address, PublishPeriod, PublishTTL, Credential Flag, 
*         Publish AppKeyIndex, Retransmit Count, Restransmit Interval Steps & status
* @retval none
*/ 
void Appli_GetPublicationGetParamsCb(model_publicationparams_t* pPubParameters)
{
  TRACE_I(TF_CONFIG_SERVER,"Status is : %.2x \r\n", pPubParameters->status); 
  TRACE_I(TF_CONFIG_SERVER,"Received Publication parameters:  credentialFlag = %.2x,\
          elementAddress = %.2x, modelID = %.2lx, appKeyIndex = %.2x,\
          publishPeriod = %.2x, publishRetransmitCount = %.2x, publishRetransmitIntervalSteps = %.2x,\
          publishTTL = %.2x \r\n", pPubParameters->credentialFlag, pPubParameters->elementAddress, pPubParameters->modelID,\
          pPubParameters->publishAppKeyIndex, pPubParameters->publishPeriod, pPubParameters->publishRetransmitCount,\
          pPubParameters->publishRetransmitIntervalSteps, pPubParameters->publishTTL);
}

/**
* @}
*/

/**
* @}
*/
/******************* (C) COPYRIGHT 2017 STMicroelectronics *****END OF FILE****/