mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-15 23:42:52 +00:00
moved setup_printf(baud) into BTstack.h
This commit is contained in:
parent
c8566a6b5e
commit
3d7b27c5a7
@ -81,6 +81,29 @@ static void (*gattCharacteristicWrittenCallback)(BLEStatus status, BLEDevice * d
|
|||||||
static void (*gattCharacteristicSubscribedCallback)(BLEStatus status, BLEDevice * device) = NULL;
|
static void (*gattCharacteristicSubscribedCallback)(BLEStatus status, BLEDevice * device) = NULL;
|
||||||
static void (*gattCharacteristicUnsubscribedCallback)(BLEStatus status, BLEDevice * device) = NULL;
|
static void (*gattCharacteristicUnsubscribedCallback)(BLEStatus status, BLEDevice * device) = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
// retarget printf to Serial
|
||||||
|
#ifdef ENERGIA
|
||||||
|
extern "C" int putchar(int c) {
|
||||||
|
Serial.write((uint8_t)c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
static void setup_printf(int baud) {
|
||||||
|
Serial.begin(baud);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static FILE uartout = {0} ;
|
||||||
|
static int uart_putchar (char c, FILE *stream) {
|
||||||
|
Serial.write(c);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void setup_printf(int baud) {
|
||||||
|
Serial.begin(baud);
|
||||||
|
fdev_setup_stream (&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);
|
||||||
|
stdout = &uartout;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// HAL CPU Implementation
|
// HAL CPU Implementation
|
||||||
extern "C" void hal_cpu_disable_irqs(void){ }
|
extern "C" void hal_cpu_disable_irqs(void){ }
|
||||||
extern "C" void hal_cpu_enable_irqs(void) { }
|
extern "C" void hal_cpu_enable_irqs(void) { }
|
||||||
|
@ -19,6 +19,11 @@ typedef enum BLEStatus {
|
|||||||
|
|
||||||
typedef void (*btstack_packet_handler_t) (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
typedef void (*btstack_packet_handler_t) (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setup printf to use Serial with given baud rate
|
||||||
|
*/
|
||||||
|
void setup_printf(int baud);
|
||||||
|
|
||||||
class UUID {
|
class UUID {
|
||||||
private:
|
private:
|
||||||
uint8_t uuid[16];
|
uint8_t uuid[16];
|
||||||
|
@ -15,30 +15,6 @@ const uint8_t adv_data[] = {
|
|||||||
0x11,0x15,0xD0,0x00,0x2D,0x12,0x1E,0x4B,0x0F,0xA4,0x99,0x4E,0xCE,0xB5,0x31,0xF4,0x05,0x79
|
0x11,0x15,0xD0,0x00,0x2D,0x12,0x1E,0x4B,0x0F,0xA4,0x99,0x4E,0xCE,0xB5,0x31,0xF4,0x05,0x79
|
||||||
};
|
};
|
||||||
|
|
||||||
// retarget printf
|
|
||||||
#ifdef ENERGIA
|
|
||||||
extern "C" {
|
|
||||||
int putchar(int c) {
|
|
||||||
Serial.write((uint8_t)c);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void setup_printf(void) {
|
|
||||||
Serial.begin(9600);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static FILE uartout = {0} ;
|
|
||||||
static int uart_putchar (char c, FILE *stream) {
|
|
||||||
Serial.write(c);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static void setup_printf(void) {
|
|
||||||
Serial.begin(9600);
|
|
||||||
fdev_setup_stream (&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);
|
|
||||||
stdout = &uartout;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
printf("packet_handler type %u, event 0x%02x\n", packet_type, packet[0]);
|
printf("packet_handler type %u, event 0x%02x\n", packet_type, packet[0]);
|
||||||
ancs_client_hci_event_handler(packet_type, channel, packet, size);
|
ancs_client_hci_event_handler(packet_type, channel, packet, size);
|
||||||
@ -65,7 +41,7 @@ void ancs_callback(ancs_event_t * event){
|
|||||||
|
|
||||||
void setup(void){
|
void setup(void){
|
||||||
|
|
||||||
setup_printf();
|
setup_printf(9600);
|
||||||
|
|
||||||
printf("BTstack ANCS Client starting up...\n");
|
printf("BTstack ANCS Client starting up...\n");
|
||||||
|
|
||||||
|
@ -39,18 +39,6 @@ char counterString[20];
|
|||||||
|
|
||||||
static timer_source_t heartbeat;
|
static timer_source_t heartbeat;
|
||||||
|
|
||||||
// setup printf
|
|
||||||
static FILE uartout = {0} ;
|
|
||||||
static int uart_putchar (char c, FILE *stream) {
|
|
||||||
Serial.write(c);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static void setup_printf(int baud) {
|
|
||||||
Serial.begin(baud);
|
|
||||||
fdev_setup_stream (&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);
|
|
||||||
stdout = &uartout;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup(void){
|
void setup(void){
|
||||||
|
|
||||||
setup_printf(9600);
|
setup_printf(9600);
|
||||||
|
@ -2,18 +2,6 @@
|
|||||||
#include <BTstack.h>
|
#include <BTstack.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
|
||||||
// setup printf
|
|
||||||
static FILE uartout = {0} ;
|
|
||||||
static int uart_putchar (char c, FILE *stream) {
|
|
||||||
Serial.write(c);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static void setup_printf(int baud) {
|
|
||||||
Serial.begin(baud);
|
|
||||||
fdev_setup_stream (&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);
|
|
||||||
stdout = &uartout;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint16_t value_handle;
|
static uint16_t value_handle;
|
||||||
|
|
||||||
void setup(void){
|
void setup(void){
|
||||||
|
@ -4,32 +4,8 @@
|
|||||||
|
|
||||||
UUID uuid("E2C56DB5-DFFB-48D2-B060-D0F5A71096E0");
|
UUID uuid("E2C56DB5-DFFB-48D2-B060-D0F5A71096E0");
|
||||||
|
|
||||||
// retarget printf
|
|
||||||
#ifdef ENERGIA
|
|
||||||
extern "C" {
|
|
||||||
int putchar(int c) {
|
|
||||||
Serial.write((uint8_t)c);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void setup_printf(void) {
|
|
||||||
Serial.begin(9600);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static FILE uartout = {0} ;
|
|
||||||
static int uart_putchar (char c, FILE *stream) {
|
|
||||||
Serial.write(c);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static void setup_printf(void) {
|
|
||||||
Serial.begin(9600);
|
|
||||||
fdev_setup_stream (&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);
|
|
||||||
stdout = &uartout;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void setup(void){
|
void setup(void){
|
||||||
setup_printf();
|
setup_printf(9600);
|
||||||
BTstack.iBeaconConfigure(&uuid, 4711, 2);
|
BTstack.iBeaconConfigure(&uuid, 4711, 2);
|
||||||
BTstack.setup();
|
BTstack.setup();
|
||||||
BTstack.startAdvertising();
|
BTstack.startAdvertising();
|
||||||
|
@ -2,18 +2,6 @@
|
|||||||
#include <BTstack.h>
|
#include <BTstack.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
|
||||||
// setup printf
|
|
||||||
static FILE uartout = {0} ;
|
|
||||||
static int uart_putchar (char c, FILE *stream) {
|
|
||||||
Serial.write(c);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static void setup_printf(int baud) {
|
|
||||||
Serial.begin(baud);
|
|
||||||
fdev_setup_stream (&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);
|
|
||||||
stdout = &uartout;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup(void){
|
void setup(void){
|
||||||
setup_printf(9600);
|
setup_printf(9600);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user