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

custom_app.c « App « STM32_WPAN « BLE_AT_Server « 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: d7415c07507d3e3a7bee199f89fac522cf515821 (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
/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * File Name          : App/custon_app.c
  * Description        : Custom 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.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

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

#include "ble.h"
#include "hrs_app.h"
#include "stm32_seq.h"
#include "app_ble.h"
#include "stm32wb_at_ble.h"
#include "custom_app.h"
#include "ble_at_server.h"

extern Custom_Context_t Custom_Context;
extern uint8_t global_notif_serv_index;
extern uint8_t global_notif_char_index;
extern uint8_t global_notif_val_tab[64];
extern uint8_t global_notif_val_tab_len;
extern uint8_t global_indic_serv_index;
extern uint8_t global_indic_char_index;
extern uint8_t global_indic_val_tab[64];
extern uint8_t global_indic_val_tab_len;
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/

/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private defines ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macros ------------------------------------------------------------*/

/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
/**
 * START of Section BLE_APP_CONTEXT
 */

//PLACE_IN_SECTION("BLE_APP_CONTEXT") HRSAPP_Context_t HRSAPP_Context;

/**
 * END of Section BLE_APP_CONTEXT
 */

/* USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private functions prototypes-----------------------------------------------*/

/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Functions Definition ------------------------------------------------------*/
void CUSTOMS_Notification( CUSTOMS_App_Notification_evt_t *pNotification )
{
  stm32wb_at_BLE_EVT_WRITE_t param_BLE_EVT_WRITE;
  uint8_t i;
  
  switch (pNotification->Evt_Opcode)
  {
    case CUSTOM_NOTIFICATION_ENABLED:
      printf("custom_app notification enabled \r\n");
      break;

    case CUSTOM_NOTIFICATION_DISABLED:
      printf("custom_app notification disabled \r\n");
      break;
      
    case CUSTOM_INDICATION_ENABLED:
      printf("custom_app indication enabled \r\n");
      break;
      
    case CUSTOM_INDICATION_DISABLED:
      printf("custom_app indication or notification disabled \r\n");
      break;      
      
    case CUSTOM_WRITE_EVT:
      param_BLE_EVT_WRITE.svc_index = pNotification->service_index;
      param_BLE_EVT_WRITE.char_index = pNotification->charac_index;
      param_BLE_EVT_WRITE.val_tab_len = pNotification->length;
      for (i = 0; i < param_BLE_EVT_WRITE.val_tab_len; i++)
      {
        param_BLE_EVT_WRITE.val_tab[i] = pNotification->charac_value[i];
      }
      ble_at_server_Send_evt(BLE_EVT_WRITE, &param_BLE_EVT_WRITE);
      break;

    default:
      break;
  }

  return;
}

void Custom_Send_Notification_ATcommand(void)
{
  aci_gatt_update_char_value(Custom_Context.SvcHdle[global_notif_serv_index - CUSTOM_APP_SVC_OFFSET],
                             Custom_Context.CharHdle[global_notif_serv_index - CUSTOM_APP_SVC_OFFSET][global_notif_char_index - 1],
                             0, /* charValOffset */
                             global_notif_val_tab_len, /* charValueLen */
                             &global_notif_val_tab[0]);
  
  return;
}

void Custom_Send_Indication_ATcommand(void)
{
  aci_gatt_update_char_value(Custom_Context.SvcHdle[global_notif_serv_index - CUSTOM_APP_SVC_OFFSET],
                             Custom_Context.CharHdle[global_indic_serv_index - CUSTOM_APP_SVC_OFFSET][global_indic_char_index - 1],
                             0, /* charValOffset */
                             global_indic_val_tab_len, /* charValueLen */
                             &global_indic_val_tab[0]);
  
  return;
}

/* USER CODE BEGIN FD */

/* USER CODE END FD */