| BlueNRG-1 DK: BLE examples

- Main Page
- Modules
- Files

- File List

BLE_Chat_Master_Slave_main.c
Go to the documentation of this file.
1
2 /******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
3 * File Name : BLE_Chat_Master_Slave_main.c
4 * Author : VMA DIVISION
5 * Version : 1.0.0
6 * Date : 28-September-2015
7 * Description : Code demostrating the BLE Chat Master and Slave application (single application for both devices)
8 ********************************************************************************
9 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
10 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
11 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
12 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
13 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
14 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
15 *******************************************************************************/
16
179 /* Includes ------------------------------------------------------------------*/
180 #include <stdio.h>
181 #include <string.h>
182 #include "BlueNRG1_conf.h"
183 #include "ble_const.h"
184 #include "bluenrg1_stack.h"
185 #include "chat.h"
186 #include "clock.h"
187 #include "SDK_EVAL_Config.h"
188 #include "Chat_config.h"
189
190 /* External variables --------------------------------------------------------*/
191 /* Private typedef -----------------------------------------------------------*/
192 /* Private defines -----------------------------------------------------------*/
193 #define BLE_NEW_CHAT_VERSION_STRING "1.0.0"
194
195 #ifndef DEBUG
196 #define DEBUG 1
197 #endif
198
199 /* Private macros ------------------------------------------------------------*/
200 #if DEBUG
201 #include <stdio.h>
202 #define PRINTF(...) printf(__VA_ARGS__)
203 #else
204 #define PRINTF(...)
205 #endif
206
207 /* Private variables ---------------------------------------------------------*/
208 /* Private function prototypes -----------------------------------------------*/
209 /* Private functions ---------------------------------------------------------*/
210
211 /*******************************************************************************
212 * Function Name : main.
213 * Description : Main routine.
214 * Input : None.
215 * Output : None.
216 * Return : None.
217 *******************************************************************************/
218 int main(void)
219 {
220 uint8_t ret;
221
222 /* System Init */
223 SystemInit();
224
225 /* Identify BlueNRG1 platform */
226 SdkEvalIdentification();
227
228 /* Init Clock */
229 Clock_Init();
230
231 /* Configure I/O communication channel:
232 It requires the void IO_Receive_Data(uint8_t * rx_data, uint16_t data_size) function
233 where user received data should be processed */
234 SdkEvalComIOConfig(Process_InputData);
235
236 /* BlueNRG-1 stack init */
237 ret = BlueNRG_Stack_Initialization(&BlueNRG_Stack_Init_params);
238 if (ret != BLE_STATUS_SUCCESS) {
239 printf("Error in BlueNRG_Stack_Initialization() 0x%02x\r\n", ret);
240 while(1);
241 }
242
243 printf("BlueNRG-1 BLE Chat Master & Slave Application (version: %s)\r\n", BLE_NEW_CHAT_VERSION_STRING);
244
245 /* Init Chat Device */
246 ret = CHAT_DeviceInit();
247 if (ret != BLE_STATUS_SUCCESS) {
248 PRINTF("CHAT_DeviceInit()--> Failed 0x%02x\r\n", ret);
249 while(1);
250 }
251
252 PRINTF("BLE Stack Initialized & Device Configured\r\n");
253
254 while(1) {
255 /* BlueNRG-1 stack tick */
256 BTLE_StackTick();
257
258 /* Application tick */
259 APP_Tick();
260 }
261 }
262
263 #ifdef USE_FULL_ASSERT
264 /*******************************************************************************
265 * Function Name : assert_failed
266 * Description : Reports the name of the source file and the source line number
267 * where the assert_param error has occurred.
268 * Input : - file: pointer to the source file name
269 * - line: assert_param error line source number
270 * Output : None
271 * Return : None
272 *******************************************************************************/
273 void assert_failed(uint8_t* file, uint32_t line)
274 {
275 /* User can add his own implementation to report the file name and line number,
276 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
277
278 /* Infinite loop */
279 while (1)
280 {}
281 }
282 #endif
283
284 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/