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

vendor.c « Src « MeshModel « mesh « ble « STM32_WPAN « ST « Middlewares - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a08bd7ce6a5a7727a0e18430cd6997a4ffc0b212 (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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
/**
******************************************************************************
* @file    vendor.c
* @author  BLE Mesh Team
* @brief   Vendor model middleware file
******************************************************************************
* @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 "hal_common.h"
#include "mesh_cfg.h"
#include "ble_mesh.h"
#include "vendor.h"
#include "appli_test.h"
#include "appli_vendor.h"
#include "models_if.h"
#include "common.h"
#include <string.h>

/** @addtogroup MODEL_VENDOR
*  @{
*/

/** @addtogroup Vendor_Model_Callbacks
*  @{
*/

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/

/*Appli Buffer - Toggle the LEDs*/
/*0x03 = SubCommand for LED Toggle*/
MOBLEUINT8 AppliBuffer[DATA_BUFFER_LENGTH] = {0x01,0x00};
MOBLEUINT16 CommandStatus = 0;
MOBLEUINT8 Vendor_SendDataFreqState = 0x00;
extern MOBLEUINT8 NumberOfElements;
extern MOBLEUINT8 ResponseBuffer[VENDOR_DATA_BUFFER_SIZE];
extern MOBLEUINT16 BuffLength;
extern MOBLEUINT8 Appli_LedState;
/*
-------------*******************-------------------------
Vendor Model Opcode Table
*/
MOBLEUINT16 Vendor_Opcodes_Table[] =
{
  APPLI_TEST_CMD,
  APPLI_DEVICE_INFO_CMD,
  APPLI_LED_CONTROL_STATUS_CMD,
  APPLI_ELEMENT_TYPE_CMD,
  APPLI_SENSOR_CNTRL_CMD,
  APPLI_DATA_CNTRL_CMD
};

char *Board_Type[] =
{
  "BLUENRG1_BRD_TYPE",           
  "BLUENRG2_BRD_TYPE",             
  "BLUENRG_MS_BRD_TYPE",
  "STM32WB55XX"
}; 
/* Private function prototypes -----------------------------------------------*/
#if ENABLE_APPLI_TEST
  extern MOBLEUINT8 txDataArray[];
  extern MOBLEUINT8 successCounter;
  extern MOBLEUINT8 sendCounter;
#endif
/* Private functions ---------------------------------------------------------*/

/**
* @brief  Call back function called when action is required on node itself  
* @param  *pmsgParam Pointer to structure of message header for parameters:
*          elementIndex, src, dst addresses, TTL, RSSI, NetKey & AppKey Offset                                     
* @param  command: Receiving command code
* @param  *data: Pointer to the data received from peer_addr
* @param  length: Length of the data
* @param  response: 1 if command acknowledgement is expected by peer_addr 
* @retval MOBLE_RESULT status of result
*/ 
MOBLE_RESULT Vendor_WriteLocalDataCb(MODEL_MessageHeader_t *pmsgParams,  
                                     MOBLEUINT8 command, 
                                     MOBLEUINT8 const *data, 
                                     MOBLEUINT32 length, 
                                     MOBLEBOOL response)
{
  
  MOBLE_COMMAND_STATUS status = STATUS_SUCCESS;
  
  /* Traces for the Data */
  uint16_t idx = 0;
  TRACE_I(TF_VENDOR_M, 
          "Vendor_WriteLocalDataCb: elementIndex=[%02x], peer_addr=[%02x], dst_peer=[%02x], command=[%02x], Response=[%02x]\n\r", 
          pmsgParams->elementIndex,
          pmsgParams->peer_addr, 
          pmsgParams->dst_peer, 
          command, 
          response);
  
  TRACE_I(TF_VENDOR_M, "DATA_RECEIVED length = %ld\n\r",length);
  
         for (idx=0; idx<length; idx++)
         {
           TRACE_I(TF_VENDOR_M,"data[%d]= %d",idx,data[idx]);  
           TRACE_I(TF_VENDOR_M,"\n\r");
         }
         
           switch (command)
           {
             
           case APPLI_TEST_CMD:
             {
               /*This is callback when ever command is coming for test of response
                 time,command reached count, data byte sent
               */          
               VendorAppli_cb.TestCommand_cb(data, length);
               break;
             }    
             
           case APPLI_LED_CONTROL_STATUS_CMD:
             {
               /* 
               Message Received     B0     B1    B2      B3    B4    B5    B6     B7 
               B0 - Sub-Cmd LED
               B1-B7 - Data Bytes       
               */          
      VendorAppli_cb.LEDControlCommand_Cb(data, length, pmsgParams->elementIndex,\
                                                           pmsgParams->dst_peer);
               break;
             }
           case APPLI_DATA_CNTRL_CMD:
             {
               /*This is callback when ever command is coming for test of response
                 time,command reached count, data byte sent
               */          
               VendorAppli_cb.DataControlCommand_cb(data,length);    
               break;       
             }            
             /* Default case - Not valid command */
           default:
             {
               status = STATUS_INVALID_COMMAND;
               break;
             }
           }
                   
         /* this expression is used to send the status of data received wheather it
         is correct or not , First 3 bits are for status and last 5 bit are for sub commands
         */
         ResponseBuffer[0] = ResponseBuffer[0] | (status << 5);
                 
         /* 
         If response is true, Message response will be sent      
         Message Response     B0     B1    B2      B3    B4    B5    B6     B7 
         B0 - Sub-Cmd 
         B1-B7 - Response Bytes if any 
         */
         if (response == MOBLE_TRUE)
         {
           if (ADDRESS_IS_UNICAST(pmsgParams->dst_peer))
           {
             VendorModel_SendResponse(VENDOR_STMICRO_CID, pmsgParams, command, ResponseBuffer, BuffLength);
             TRACE_M(TF_VENDOR,"Sending Response for Unicast \n\r");
           }
           else
           {
             /* Randomize responses*/
             BLEMesh_ModelsDelayPacket(pmsgParams, command, ResponseBuffer, BuffLength);
             TRACE_M(TF_VENDOR,"Sending Response for Multicast \n\r");
           }		
         }
         
         if (status == STATUS_SUCCESS)
         {
           return MOBLE_RESULT_SUCCESS;  
         }
         else
         {
           return MOBLE_RESULT_FAIL;
         }
         
}
         
         
/**
* @brief  Call back function called when some data is required from node    
* *pmsgParam Pointer to structure of message header for parameters:
*            elementIndex, src, dst addresses, TTL, RSSI, NetKey & AppKey Offset
* @param  command: Receiving command code 
* @param  data: Pointer to the data
* @param  length: Length of the data
* @param  response: Response Enable. For future use
* @retval MOBLE_RESULT status of result
*/
MOBLE_RESULT Vendor_ReadLocalDataCb(MODEL_MessageHeader_t *pmsgParams,  
                                   MOBLEUINT8 command, 
                                   MOBLEUINT8 const *data, 
                                   MOBLEUINT32 length, 
                                   MOBLEBOOL response)
{  
 
 MOBLE_RESULT status = MOBLE_RESULT_SUCCESS;
 MOBLEUINT8 getBuff[5];
 
 /* Traces for the Data */
  TRACE_M(TF_VENDOR_M,
          "Vendor_ReadLocalDataCb: elementIndex=[%02x], peer_addr=[%02x], dst_peer_addr=[%02x], command=[%02x], Response=[%02x]\n\r", 
          pmsgParams->elementIndex,
          pmsgParams->peer_addr, 
          pmsgParams->dst_peer, 
          command, 
          response);
  
  TRACE_I(TF_VENDOR_M,"DATA_RECEIVED length = %ld\n\r",length);
  
        for (MOBLEUINT8 idx=0; idx<length; idx++)
        {
          TRACE_I(TF_VENDOR_M,"data[%d]= %d",idx,data[idx]); 
          TRACE_I(TF_VENDOR_M,"\n\r");
        }
        
          /* Check which command is in packet */
          switch(command)
          {
          case APPLI_TEST_CMD:
            {
              /* 
              Message Received     B0     B1    B2      B3    B4    B5    B6     B7 
              B0 - Sub-Cmd for APPLI_TEST_CMD
              B1-B7 - Data Bytes if any  
              this function gives back the number count of command received by 
              the receiver.
              */
              VendorAppli_cb.GetTestCount(getBuff);
              ResponseBuffer[0] = APPLI_TEST_INC_COUNTER;
              ResponseBuffer[1] = getBuff[0];
              ResponseBuffer[2] = getBuff[1];
              ResponseBuffer[3] = getBuff[2];
              ResponseBuffer[4] = getBuff[3];
              BuffLength = 5;
              break;
            }
          case APPLI_DEVICE_INFO_CMD:     
            {
              /*
              Message Received     B0     B1    B2      B3    B4    B5    B6     B7 
              B0 - Sub-Cmd for APPLI_DEVICE_INFO_CMD
              B1-B7 - Data Bytes if any      
              
              */
              status =  VendorAppli_cb.DeviceInfoCommand_cb(data, length);
              break;
            }
          case APPLI_SENSOR_CNTRL_CMD:
            {
              /*Insert Sensors related commands here*/
              break;
            }
          case APPLI_ELEMENT_TYPE_CMD:
            {
              /*
              Message Received with Command APPLI_ELEMENT_TYPE_CMD
              */
              ResponseBuffer[0] = ELEMENT_TYPE_LED;
              ResponseBuffer[1] = ELEMENT_TYPE_LED;
              ResponseBuffer[2] = ELEMENT_TYPE_SWITCH;
              BuffLength  = 3;      
              break;
            }
          case APPLI_LED_CONTROL_STATUS_CMD:
            {
              /*
              Message Received with Command APPLI_LED_CONTROL_STATUS_CMD
              ResponseBuffer will send the response of selected Element
              */
      
      TRACE_M(TF_VENDOR,"Appli_LED_Control_Status callback received for elementIndex %d \r\n", pmsgParams->elementIndex);     
      /*User Need to send the status as per the element selected*/
                ResponseBuffer[0] = Appli_LedState;
              BuffLength = 1;  
              
              break;
            }
          case APPLI_DATA_CNTRL_CMD:
            {
              /*This is callback when ever command is coming for test of response
                time,command reached count, data byte sent
              */          
           
              break;       
            }  
            
          default:
            {
              status = MOBLE_RESULT_INVALIDARG;
              break;
            }   
            
          }
  
        /* this expression is used to send the status of data received wheather it
        is correct or not , First 3 bits are for status and last 5 bit are for sub commands
        */
        ResponseBuffer[0] = ResponseBuffer[0] | (status << 5);
        /* Check if the command executed sucessfully or not */ 
        
        if (MOBLE_RESULT_SUCCESS == status)
        {
          
          /* 
          Read Command will always be reliable      
          Message Response     B0     B1    B2      B3    B4    B5    B6     B7 
          B0 - Sub-Cmd for which response is needed
          B1-B7 - Data Bytes if any 
          */
         if (ADDRESS_IS_UNICAST(pmsgParams->dst_peer))
          {
            VendorModel_SendResponse(VENDOR_STMICRO_CID, pmsgParams, command, ResponseBuffer, BuffLength);
          }
          else
          {
            /* Randomize responses*/
            BLEMesh_ModelsDelayPacket(pmsgParams, command, ResponseBuffer, BuffLength);
          }
        }
        /* Command not successfully processed */
        else
        {
          if (ADDRESS_IS_UNICAST(pmsgParams->dst_peer))
          {
            VendorModel_SendResponse(VENDOR_STMICRO_CID, pmsgParams, command, ResponseBuffer, 1);
          }
          else
          {
            /* Randomize responses*/
            BLEMesh_ModelsDelayPacket(pmsgParams, command, ResponseBuffer, 1);
          }
        }
        
        if (status == MOBLE_RESULT_SUCCESS)
        {
          return MOBLE_RESULT_SUCCESS;  
        }
        else
        {
          return MOBLE_RESULT_FAIL;
        }
}
                  
                  
/**
* @brief  Call back function called when some data is send by the node to app   
* *pmsgParam Pointer to structure of message header for parameters:
*             elementIndex, src, dst addresses, TTL, RSSI, NetKey & AppKey Offset
* @param  data: Pointer to the data
* @param  length: Length of the data
* @retval MOBLE_RESULT status of result
*/  
MOBLE_RESULT Vendor_OnResponseDataCb(MODEL_MessageHeader_t *pmsgParam,  
                                     MOBLEUINT8 command, 
                                     MOBLEUINT8 const *pRxData, 
                                     MOBLEUINT32 dataLength, 
                                     MOBLEBOOL response)
{
   MOBLEUINT32 timeStampRcv;
   MOBLEUINT8 subCmd = pRxData[0];
   MOBLEUINT16 hitcmdcount = 0;
   MOBLEUINT8 increment = 1;
   MOBLEUINT8 idx;
  /* Traces for the Data */
  TRACE_I(TF_VENDOR_M,
          "Vendor_OnResponseDataCb: elementIndex=[%02x], peer_addr=[%02x], dst_peer_addr=[%02x], command=[%02x], Response=[%02x]\n\r", 
          pmsgParam->elementIndex,
          pmsgParam->peer_addr, 
          pmsgParam->dst_peer, 
          command, 
          response);
  TRACE_I(TF_VENDOR_M,"DATA_RECEIVED length = %ld\n\r", dataLength);
  TRACE_M(TF_VENDOR_M,"#%02hx-%02hx! \n\r",command,pRxData[0]);
  
  switch(command)
  {
    case APPLI_TEST_CMD:
      {
         switch(subCmd)
         {             
             case APPLI_TEST_ECHO: 
               { 
                 /* this case is responsible for printing of the received back data byte from 
                    receiver node.
                 */       
                 for(idx =1;idx<dataLength;idx++)
                 {
                   TRACE_I(TF_VENDOR_M,"Response data %d\n\r", pRxData[idx]);
                 }
                 break;
               }
             case APPLI_TEST_RANDOMIZATION_RANGE:  
               {
                 /*Insert Test related Commands here*/
                 break;
               }
             case APPLI_TEST_COUNTER:
               { 
         /* this case is responsible for the printing the time stamp when the responce 
            is received by the sender node.
         */
                 timeStampRcv = Clock_Time();

                 Packet_ResponseTimeStamp(timeStampRcv);
                  
                 /*Insert Test related Commands here*/
                 break;
               }
             case APPLI_TEST_INC_COUNTER: 
               { 
           /* This case is responsible for the printing of the number count of command 
              received by receiver.
           */     
                 hitcmdcount = (MOBLEUINT32)(pRxData[4] << 24);
                 hitcmdcount |=(MOBLEUINT32)( pRxData[3] << 16);
                 hitcmdcount |=(MOBLEUINT32)( pRxData[2] << 8);
                 hitcmdcount |=(MOBLEUINT32)( pRxData[1]);                
                 TRACE_I(TF_VENDOR_M,"NUMBER OF COMMANDS RECEIVED %d \r\n",hitcmdcount);
                 /*Insert Test related Commands here*/
                 break;
               }
             case APPLI_MODEL_PUBLISH_SELECT:
               {
                  
                 break;
               }
             default:
               {              
                  break;
               }
         }
         break;
      }                  
  case APPLI_LED_CONTROL_STATUS_CMD:
    {
      TRACE_I(TF_VENDOR_M,"Led State %d \r\n",pRxData[0]);
      break;
    }
   case APPLI_DEVICE_INFO_CMD:
     {
      switch(subCmd)
         {             
             case IC_TYPE: 
               { 
                 TRACE_I(TF_VENDOR_M,"IC type is %s \r\n" ,Board_Type[pRxData[1]-1]); 
                 break;
               }
         case LIB_VER:
           {
             while(increment!=8)
             {
               TRACE_I(TF_VENDOR_M,"Lib Version is %d \r\n",pRxData[increment]);
               increment++;
             }
             increment=1;
             break;
           }
           case LIB_SUB_VER:
             {
               while(increment!=7)
               {
                 if(pRxData[increment] != R_ASCI_CODE)
                 {
                   TRACE_I(TF_VENDOR_M,"Lib Sub Version is %x \r\n",pRxData[increment]);
                 }
                 else
                 {
                   TRACE_I(TF_VENDOR_M,"Lib Sub Version is %c \r\n",pRxData[increment]);
                 }
                  increment++;
               }
             increment=1;
             break;   
             }
         }
      break;
     }
    case APPLI_DATA_CNTRL_CMD:  
      {
        for (MOBLEUINT8 idx=0; idx<dataLength; idx++)
        {
          TRACE_I(TF_VENDOR_M,"data[%d]= %d",idx,pRxData[idx]); 
          TRACE_I(TF_VENDOR_M,"\n\r");
        }
        break;
      }
       default:
    {              
        break;
    }
      
  }   
      
         return MOBLE_RESULT_SUCCESS;
} 
                           
                           
/**
* @brief  State machine for Vendor Model
* @param  void
* @retval void
*/ 
void Vendor_Process(void)
{
  BLEMesh_ModelsSendDelayedPacket();
  
  if (Vendor_SendDataFreqState == 0xFF)
  {
    Appli_Vendor_SendBigDataPacket();
  }
}
                           
                           
/**
* @brief  Publish Command for Vendor Model
* @param  srcAddress: Source Address of Node 
* @retval void
*/          
void Vendor_Publish(MOBLE_ADDRESS srcAddress)
{
  MOBLE_RESULT result = MOBLE_RESULT_SUCCESS;
  /* changes the LED status on other nodes in the network */
  if(CommandStatus == APPLI_CMD_ON)
  {
    AppliBuffer[0] = APPLI_CMD_OFF;
  }
  else
  {
    AppliBuffer[0] = APPLI_CMD_ON;
  }

  result = BLEMesh_SetRemotePublication(VENDORMODEL_STMICRO_ID1, srcAddress,
                                            APPLI_LED_CONTROL_STATUS_CMD, 
                                            AppliBuffer, sizeof(AppliBuffer),
                                            MOBLE_FALSE, MOBLE_TRUE);

   if(result)
   {
     TRACE_I(TF_VENDOR_M,"Publication Error \r\n");
   }

  CommandStatus = AppliBuffer[0];
}
         
/**
* @brief  Test Command with Vendor Model used to calculate the time of packet to
  reach at destination.
* @param  publishAddress: Publish Address of the message 
* @param  elementIndex: index of the element
* @retval void
*/          
void Vendor_TestRemoteData(MOBLE_ADDRESS src ,MOBLE_ADDRESS dst ,MOBLEUINT8 elementIndex)
{

  /* changes the LED status on other nodes in the network */
    MOBLE_RESULT result = MOBLE_RESULT_SUCCESS;
    AppliBuffer[0] = APPLI_TEST_COUNTER;
   
    result = BLEMesh_SetRemotePublication(VENDORMODEL_STMICRO_ID1, src,
                                          APPLI_TEST_CMD, 
                                          AppliBuffer, sizeof(AppliBuffer),
                                          MOBLE_TRUE, MOBLE_TRUE);

     if(result)
     {
          TRACE_I(TF_VENDOR_M,"Publication Error \r\n");
     }

  CommandStatus = AppliBuffer[0];
}
         
/**
* @brief  Test Command with Vendor Model used to calculate the time of packet to
  reach at destination.
* @param  publishAddress: Publish Address of the message 
* @param  elementIndex: index of the element
* @retval void
*/          
void Vendor_TestCounterInc(MOBLE_ADDRESS src ,MOBLE_ADDRESS dst ,MOBLEUINT8 elementIndex)
{

  /* changes the LED status on other nodes in the network */
    MOBLE_RESULT result = MOBLE_RESULT_SUCCESS;
    AppliBuffer[0] = APPLI_TEST_INC_COUNTER;
  
    result = BLEMesh_SetRemotePublication(VENDORMODEL_STMICRO_ID1, src,
                                          APPLI_TEST_CMD, 
                                          AppliBuffer, sizeof(AppliBuffer),
                                          MOBLE_FALSE, MOBLE_TRUE);

    if(result)
    {
      TRACE_I(TF_VENDOR_M,"Publication Error \r\n");
    }
}         
         
/**
* @brief  Set the state of the Vendor Data frequency
* @param  State: New state of sending vendor packet frequency 
* @retval void
*/          
void Vendor_SendDataFreq(MOBLEUINT8 freq)
{
    /* Data to be sent continuosly with out any time gap */ 
    if ((freq == 0xFF) || (freq == 0x00))
    {
        Vendor_SendDataFreqState = freq;
    }
    else
    {
        TRACE_I(TF_VENDOR_M, "Invalid Data send Freq parameter \r\n");
    }
}
         
/**
* @brief   GenericModelServer_GetOpcodeTableCb: This function is call-back 
*          from the library to send Model Opcode Table info to library
* @param  MODEL_OpcodeTableParam_t:  Pointer to the Generic Model opcode array 
* @param  length: Pointer to the Length of Generic Model opcode array
* @retval MOBLE_RESULT
*/ 
MOBLE_RESULT VendorModel_PID1_GetOpcodeTableCb(const MODEL_OpcodeTableParam_t **data, 
                                                 MOBLEUINT16 *length)
{ 
  return MOBLE_RESULT_SUCCESS;
}


/**
* @brief  GenericModelServer_GetStatusRequestCb : This function is call-back 
from the library to send response to the message from peer
* @param *pmsgParam Pointer to structure of message header for parameters:
*         elementIndex, src, dst addresses, TTL, RSSI, NetKey & AppKey Offset
* @param  opcode: Received opcode of the Status message callback
* @param  pResponsedata: Pointer to the buffer to be updated with status
* @param  plength: Pointer to the Length of the data, to be updated by application
* @param  pRxData: Pointer to the data received in packet.
* @param  dataLength: length of the data in packet.
* @param  response: Value to indicate wheather message is acknowledged meassage or not.
* @retval MOBLE_RESULT
*/ 
MOBLE_RESULT VendorModel_PID1_GetStatusRequestCb(MODEL_MessageHeader_t *pmsgParams,  
                                    MOBLEUINT16 opcode, 
                                    MOBLEUINT8 *pResponsedata, 
                                    MOBLEUINT32 *plength, 
                                    MOBLEUINT8 const *pRxData,
                                    MOBLEUINT32 dataLength,
                                    MOBLEBOOL response)

{
  return MOBLE_RESULT_SUCCESS;    
}

/**
* @brief  VendorModelServer_ProcessMessageCb: This is a callback function from
the library whenever a Generic Model message is received
* @param *pmsgParam Pointer to structure of message header for parameters:
*         elementIndex, src, dst addresses, TTL, RSSI, NetKey & AppKey Offset
* @param  opcode: Received opcode of the Status message callback
* @param  pData: Pointer to the buffer to be updated with status
* @param  length: Length of the parameters received 
* @param  response: if TRUE, the message is an acknowledged message
* @param  pRxData: Pointer to the data received in packet.
* @param  dataLength: length of the data in packet.
* @param  response: Value to indicate wheather message is acknowledged meassage or not.
* @retval MOBLE_RESULT
*/ 
MOBLE_RESULT VendorModel_PID1_ProcessMessageCb(MODEL_MessageHeader_t *pmsgParams,  
                                                 MOBLEUINT16 opcode, 
                                                 MOBLEUINT8 const *pRxData, 
                                                 MOBLEUINT32 dataLength, 
                                                 MOBLEBOOL response
                                                   )
{
  
  MOBLE_RESULT result = MOBLE_RESULT_SUCCESS;
  MOBLEUINT8 command;
  MOBLEBOOL cmd_response;
    
  /*tClockTime delay_t = Clock_Time();*/
  
  TRACE_I(TF_VENDOR_M, 
          "elementIndex=[0x%02x], dst_peer=[0x%02x], peer_add=[0x%02x], opcode=[0x%02x]\r\n",
          pmsgParams->elementIndex, 
          pmsgParams->dst_peer,
          pmsgParams->peer_addr, 
          opcode);

  /*  opcode: response  : Read-Write           : Command   
                          R/nW : 1 = Read
                                 0 = Write

               0            1                    Response of data
               1            1                    Read Data  
               0            0                    Write with no Response
               1            0                    Write with Response

            #define VENDOR_CMD_RESPONSE                          0x20
            #define VENDOR_CMD_READ_nWRITE                       0x10
  */
  
  command = (MOBLEUINT8) (opcode & 0x0F);
  if (opcode & VENDOR_CMD_RESPONSE)
  {
    cmd_response = MOBLE_TRUE;
  }
  else
  {
    cmd_response = MOBLE_FALSE;
  }
         
      
  
    /* Parse the command */
    if( (cmd_response == MOBLE_FALSE) && (opcode & VENDOR_CMD_READ_nWRITE))
    { /* Response Packet is received */
       TRACE_I(TF_VENDOR_M,"Response received from remote node \n\r");

       Vendor_OnResponseDataCb(pmsgParams, command, pRxData, dataLength, MOBLE_FALSE);
    }
    else if ( (cmd_response == MOBLE_TRUE) && (opcode & VENDOR_CMD_READ_nWRITE))
    { /* Read Packet is received */
       TRACE_M(TF_VENDOR_M,"Read Command received   \n\r");
       result = Vendor_ReadLocalDataCb(pmsgParams, command, pRxData, dataLength, MOBLE_TRUE);
    }
    else 
    {  /* Write Commands with or without response received */
       TRACE_M(TF_VENDOR_M,"Command Write received, process the command\n\r");
       result = Vendor_WriteLocalDataCb(pmsgParams, command, pRxData, dataLength, cmd_response );
    }

return result;
}
    
__weak MOBLE_RESULT Packet_ResponseTimeStamp(MOBLEUINT32 rcvTimeStamp)
{
  return MOBLE_RESULT_SUCCESS;
}

/**
* @}
*/

/**
* @}
*/

/******************* (C) COPYRIGHT 2020 STMicroelectronics *****END OF FILE****/