rusefi-1/firmware/console/binary/bluetooth.h

47 lines
1.3 KiB
C
Raw Normal View History

2017-06-04 05:52:44 -07:00
/**
2020-05-02 19:20:41 -07:00
* @file bluetooth.h
2020-05-25 09:55:26 -07:00
* @file Bluethoot modules hardware initialization
2017-06-04 05:52:44 -07:00
*
* @date Aug 26, 2013
2020-05-02 19:20:41 -07:00
* @author andreika, (c) 2017
2020-01-13 18:57:43 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2017-06-04 05:52:44 -07:00
*/
2020-04-01 16:00:56 -07:00
#pragma once
2018-09-16 19:25:17 -07:00
#include "global.h"
2017-06-04 05:52:44 -07:00
#include "tunerstudio_io.h"
// The Bluetooth setup procedure will wait 10 seconds for the user to disconnect the UART cable.
// This is required because the BT setup procedure reads a response from the module during the communication.
// Thus any bytes sent from the Console Software may interfere with the procedure.
2019-01-28 17:00:17 -08:00
#define BLUETOOTH_COMMAND_TIMEOUT TIME_MS2I(10000)
2017-06-04 05:52:44 -07:00
// Supported Bluetooth module types
typedef enum {
2017-06-04 15:07:02 -07:00
BLUETOOTH_HC_05,
2017-06-04 05:52:44 -07:00
BLUETOOTH_HC_06,
BLUETOOTH_SPP,
2017-06-04 05:52:44 -07:00
} bluetooth_module_e;
/**
* Start Bluetooth module initialization using UART connection:
* - wait for PC communication disconnect;
* - reconfigure the UART;
* - send AT-commands to the module;
* - restore connection to PC.
*/
2020-05-02 21:30:35 -07:00
void bluetoothStart(ts_channel_s *btChannel, bluetooth_module_e moduleType, const char *baudRate, const char *name, const char *pinCode);
2017-06-04 05:52:44 -07:00
/**
* Cancel Bluetooth procedure
*/
void bluetoothCancel(void);
/**
* Called by runBinaryProtocolLoop() if a connection disconnect is detected.
* Bluetooth init code needs to make sure that there's no interference of the BT module and USB-UART (connected to PC)
*/
void bluetoothSoftwareDisconnectNotify();