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

lls_app.c « App « STM32_WPAN « BLE_Proximity « 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: 8e1775d5840d64e1dd699e97dda870f7fa319260 (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
/**
  ******************************************************************************
  * @file    lls_app.c
  * @author  MCD Application Team
  * @brief   Link Loss Service Application
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2019-2021 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.
  *
  ******************************************************************************
  */



/* Includes ------------------------------------------------------------------*/
#include "app_common.h"

#include "dbg_trace.h"
#include "lls_app.h"
#include "ble.h"
#include "stm32_seq.h"
#include "app_ble.h"



/* Private typedef -----------------------------------------------------------*/
/* Private defines -----------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/**
 * START of Section BLE_APP_CONTEXT
 */

PLACE_IN_SECTION("BLE_APP_CONTEXT") static uint8_t AlertLevel;

/**
 * END of Section BLE_APP_CONTEXT
 */

/* Global variables ----------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Functions Definition ------------------------------------------------------*/
/* Private functions ----------------------------------------------------------*/
/* Public functions ----------------------------------------------------------*/
void LLSAPP_Init(void)
{
  AlertLevel = LLS_NO_ALERT_EVT;
}


void LLS_App_Notification(LLS_App_Notification_evt_t *pNotification)
{
  switch(pNotification->LLS_Evt_Opcode)
  {
    case LLS_NO_ALERT_EVT:
      {
        BLE_DBG_APP_MSG("Set Link Loss Alert Level to NO ALERT\n");
        AlertLevel = LLS_NO_ALERT_EVT;
      }
      break;

    case LLS_MID_ALERT_EVT:
      {
        BLE_DBG_APP_MSG("Set Link Loss Alert Level to MID ALERT\n");
        AlertLevel = LLS_MID_ALERT_EVT;
      }
      break;

    case LLS_HIGH_ALERT_EVT:
      {
        BLE_DBG_APP_MSG("Set Link Loss Alert Level to HIGH ALERT\n");
        AlertLevel = LLS_HIGH_ALERT_EVT;
      }
      break;

    case LLS_CONNECT_EVT:
      {
        BLE_DBG_APP_MSG("Connected with NO ALERT\n");
        BSP_LED_Off(LED_RED);
        BSP_LED_Off(LED_BLUE);
        BSP_LED_On(LED_GREEN);
      }
      break;

    case LLS_DISCONNECT_EVT:
      {
        if(AlertLevel == LLS_NO_ALERT_EVT)
        {
          BLE_DBG_APP_MSG("Disconnected with NO ALERT\n");
          BSP_LED_Off(LED_RED);
          BSP_LED_Off(LED_BLUE);
          BSP_LED_Off(LED_GREEN);
        }
        else if(AlertLevel == LLS_MID_ALERT_EVT)
        {
          BLE_DBG_APP_MSG("Disconnected with MID ALERT\n");
          BSP_LED_Off(LED_RED);
          BSP_LED_On(LED_BLUE);
          BSP_LED_Off(LED_GREEN);
        }
        else
        {
          BLE_DBG_APP_MSG("Disconnected with HIGH ALERT\n");
          BSP_LED_On(LED_RED);
          BSP_LED_Off(LED_BLUE);
          BSP_LED_Off(LED_GREEN);
        }
      }
      break;

   default:
      break;
  }

  return;
}