mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
remove dir after moving it to platforms
This commit is contained in:
parent
2d04a09a69
commit
0f6940d34d
@ -1,79 +0,0 @@
|
||||
#
|
||||
# Makefile for MSP-EXP430F5438 demos with PAN1323 Bluetooth modules
|
||||
#
|
||||
# mspgcc is used: http://sourceforge.net/apps/mediawiki/mspgcc/index.php?title=MSPGCC_Wiki
|
||||
#
|
||||
|
||||
BTSTACK_ROOT = ../..
|
||||
|
||||
CC = msp430-gcc
|
||||
CFLAGS = -mmcu=msp430f5438a -Os -Wall -fno-toplevel-reorder -I. -I../src -I../firmware -I${BTSTACK_ROOT} -I${BTSTACK_ROOT}/chipset-cc256x -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/ble -I${BTSTACK_ROOT}/include
|
||||
LDFLAGS = -mmcu=msp430f5438a
|
||||
|
||||
CORE = \
|
||||
../src/hal_tick.c \
|
||||
../src/hal_cpu.c \
|
||||
../firmware/hal_board.c \
|
||||
../firmware/hal_compat.c \
|
||||
../firmware/hal_usb.c \
|
||||
${BTSTACK_ROOT}/src/btstack_memory.c \
|
||||
${BTSTACK_ROOT}/src/linked_list.c \
|
||||
${BTSTACK_ROOT}/src/memory_pool.c \
|
||||
${BTSTACK_ROOT}/src/run_loop.c \
|
||||
${BTSTACK_ROOT}/src/run_loop_embedded.c
|
||||
|
||||
COMMON = \
|
||||
../src/hal_uart_dma.c \
|
||||
${BTSTACK_ROOT}/src/hci_dump.c \
|
||||
${BTSTACK_ROOT}/src/hci.c \
|
||||
${BTSTACK_ROOT}/src/hci_cmds.c \
|
||||
${BTSTACK_ROOT}/src/utils.c \
|
||||
${BTSTACK_ROOT}/src/remote_device_db_memory.c \
|
||||
${BTSTACK_ROOT}/ble/att.c \
|
||||
${BTSTACK_ROOT}/ble/att_dispatch.c \
|
||||
${BTSTACK_ROOT}/ble/att_server.c \
|
||||
${BTSTACK_ROOT}/ble/l2cap_le.c \
|
||||
${BTSTACK_ROOT}/ble/sm.c \
|
||||
${BTSTACK_ROOT}/ble/le_device_db_memory.c \
|
||||
${BTSTACK_ROOT}/chipset-cc256x/bt_control_cc256x.c \
|
||||
${BTSTACK_ROOT}/chipset-cc256x/bluetooth_init_cc2564_2.10.c \
|
||||
${BTSTACK_ROOT}/src/hci_transport_h4_ehcill_dma.c \
|
||||
../firmware/hal_lcd.c \
|
||||
../firmware/hal_lcd_fonts.c \
|
||||
|
||||
# ${BTSTACK_ROOT}/ble/utils_le.c \
|
||||
# ${BTSTACK_ROOT}/ble/hci_cmds_le.c \
|
||||
# ${BTSTACK_ROOT}/ble/hci_le.c \
|
||||
|
||||
LCD = ../firmware/hal_lcd.c ../firmware/hal_lcd_fonts.c
|
||||
|
||||
CORE_OBJ = $(CORE:.c=.o)
|
||||
COMMON_OBJ = $(COMMON:.c=.o)
|
||||
LCD_OBJ = $(LCD:.c=.o)
|
||||
|
||||
# create .hex file from .out
|
||||
%.hex: %.out
|
||||
msp430-objcopy -O ihex $< $@
|
||||
|
||||
# create firmware image from common objects and example source file
|
||||
all: ble_server.out
|
||||
|
||||
# compile .ble description
|
||||
profile.h: profile.gatt
|
||||
python ${BTSTACK_ROOT}/ble/compile-gatt.py $< $@
|
||||
|
||||
ble_server.out: profile.h ble_server.o ${CORE_OBJ} ${COMMON_OBJ} ${LCD_OBJ}
|
||||
${CC} $^ ${LDFLAGS} -o $@
|
||||
|
||||
|
||||
clean:
|
||||
rm -f profile.h *.o *.out *.hex ../driver/*.o ../../src/*.o ../src/*.o ../firmware/*.o ${BTSTACK_ROOT}/chipset-cc256x/*.o ${BTSTACK_ROOT}/src/*.o ${BTSTACK_ROOT}/ble/*.o
|
||||
|
||||
size: all
|
||||
msp430-size ../firmware/*.o
|
||||
msp430-size ../src/*.o
|
||||
msp430-size ${BTSTACK_ROOT}/chipset-cc256x/*.o
|
||||
msp430-size ${BTSTACK_ROOT}/src/*.o
|
||||
msp430-size ${BTSTACK_ROOT}/ble/*.o
|
||||
msp430-size *.o
|
||||
msp430-size *.out
|
@ -1,323 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 BlueKitchen GmbH
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holders nor the names of
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* 4. Any redistribution, use, or modification is done solely for
|
||||
* personal benefit and not for any commercial purpose or for
|
||||
* monetary gain.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
|
||||
* RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Please inquire about commercial licensing options at
|
||||
* contact@bluekitchen-gmbh.com
|
||||
*
|
||||
*/
|
||||
|
||||
// *****************************************************************************
|
||||
//
|
||||
// att device demo
|
||||
//
|
||||
// *****************************************************************************
|
||||
|
||||
// TODO: seperate BR/EDR from LE ACL buffers
|
||||
// TODO: move LE init into HCI
|
||||
// ..
|
||||
|
||||
// NOTE: Supports only a single connection
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "btstack-config.h"
|
||||
|
||||
#include <msp430x54x.h>
|
||||
|
||||
#include "bt_control_cc256x.h"
|
||||
#include "hal_board.h"
|
||||
#include "hal_compat.h"
|
||||
#include "hal_usb.h"
|
||||
#include "hal_lcd.h"
|
||||
#include "hal_usb.h"
|
||||
#include "UserExperienceGraphics.h"
|
||||
|
||||
#include <btstack/run_loop.h>
|
||||
|
||||
#include "btstack_memory.h"
|
||||
#include "bt_control_cc256x.h"
|
||||
#include "hci.h"
|
||||
#include "hci_dump.h"
|
||||
#include "l2cap.h"
|
||||
|
||||
#include "sm.h"
|
||||
#include "att.h"
|
||||
#include "att_server.h"
|
||||
#include "gap_le.h"
|
||||
#include "le_device_db.h"
|
||||
|
||||
#define FONT_HEIGHT 12 // Each character has 13 lines
|
||||
#define FONT_WIDTH 8
|
||||
#define MAX_CHR01_VALUE_LENGTH 40
|
||||
|
||||
static uint16_t chr01_value_length = 0;
|
||||
static char chr01_value[MAX_CHR01_VALUE_LENGTH];
|
||||
static char chr02_value = 0;
|
||||
|
||||
void doLCD(void){
|
||||
//Initialize LCD and backlight
|
||||
// 138 x 110, 4-level grayscale pixels.
|
||||
halLcdInit();
|
||||
// halLcdBackLightInit();
|
||||
// halLcdSetBackLight(0); // 8 for normal
|
||||
halLcdSetContrast(100);
|
||||
halLcdClearScreen();
|
||||
halLcdImage(TI_TINY_BUG, 4, 32, 104, 12 );
|
||||
|
||||
halLcdPrintLine("BTstack on ", 0, 0);
|
||||
halLcdPrintLine("TI MSP430", 1, 0);
|
||||
halLcdPrintLine("LE Write Test", 2, 0);
|
||||
halLcdPrintLine("NOT CONNECTED", 4, 0);
|
||||
halLcdPrintLine("Attribute 0x0022:", 6, 0);
|
||||
halLcdPrintLine("- NO VALUE -", 7, 0);
|
||||
}
|
||||
|
||||
void overwriteLine(int line, char *text){
|
||||
halLcdClearImage(130, FONT_HEIGHT, 0, line*FONT_HEIGHT);
|
||||
halLcdPrintLine(text, line, 0);
|
||||
}
|
||||
|
||||
// enable LE, setup ADV data
|
||||
static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
if (packet_type != HCI_EVENT_PACKET) return;
|
||||
bd_addr_t addr;
|
||||
uint8_t adv_data[] = { 02, 01, 05, 03, 02, 0xf0, 0xff };
|
||||
|
||||
switch (packet[0]) {
|
||||
case BTSTACK_EVENT_STATE:
|
||||
// bt stack activated, get started - set local name
|
||||
if (packet[2] == HCI_STATE_WORKING) {
|
||||
printf("Working!\n");
|
||||
hci_send_cmd(&hci_le_set_advertising_data, sizeof(adv_data), adv_data);
|
||||
}
|
||||
break;
|
||||
|
||||
case BTSTACK_EVENT_NR_CONNECTIONS_CHANGED:
|
||||
if (packet[2]) {
|
||||
overwriteLine(4, "CONNECTED");
|
||||
} else {
|
||||
overwriteLine(4, "NOT CONNECTED");
|
||||
}
|
||||
break;
|
||||
|
||||
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
||||
// restart advertising
|
||||
hci_send_cmd(&hci_le_set_advertise_enable, 1);
|
||||
break;
|
||||
|
||||
case HCI_EVENT_COMMAND_COMPLETE:
|
||||
if (COMMAND_COMPLETE_EVENT(packet, hci_read_bd_addr)){
|
||||
bt_flip_addr(addr, &packet[6]);
|
||||
printf("BD ADDR: %s\n", bd_addr_to_str(addr));
|
||||
break;
|
||||
}
|
||||
if (COMMAND_COMPLETE_EVENT(packet, hci_le_set_advertising_data)){
|
||||
hci_send_cmd(&hci_le_set_scan_response_data, 10, adv_data);
|
||||
break;
|
||||
}
|
||||
if (COMMAND_COMPLETE_EVENT(packet, hci_le_set_scan_response_data)){
|
||||
hci_send_cmd(&hci_le_set_advertise_enable, 1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// test profile
|
||||
#include "profile.h"
|
||||
|
||||
static uint16_t get_read_att_value_len(uint16_t att_handle){
|
||||
uint16_t value_len;
|
||||
switch(att_handle){
|
||||
case ATT_CHARACTERISTIC_FFF1_01_VALUE_HANDLE:
|
||||
value_len = chr01_value_length;
|
||||
break;
|
||||
case ATT_CHARACTERISTIC_FFF2_01_VALUE_HANDLE:
|
||||
value_len = 1;
|
||||
break;
|
||||
default:
|
||||
value_len = 0;
|
||||
break;
|
||||
}
|
||||
return value_len;
|
||||
}
|
||||
|
||||
static uint16_t get_write_att_value_len(uint16_t att_handle){
|
||||
uint16_t value_len;
|
||||
switch(att_handle){
|
||||
case ATT_CHARACTERISTIC_FFF1_01_VALUE_HANDLE:
|
||||
value_len = MAX_CHR01_VALUE_LENGTH;
|
||||
break;
|
||||
case ATT_CHARACTERISTIC_FFF2_01_VALUE_HANDLE:
|
||||
value_len = 1;
|
||||
break;
|
||||
default:
|
||||
value_len = 0;
|
||||
break;
|
||||
}
|
||||
return value_len;
|
||||
}
|
||||
|
||||
static uint16_t get_bytes_to_copy(uint16_t value_len, uint16_t offset, uint16_t buffer_size){
|
||||
if (value_len <= offset ) return 0;
|
||||
|
||||
uint16_t bytes_to_copy = value_len - offset;
|
||||
if (bytes_to_copy > buffer_size) {
|
||||
bytes_to_copy = buffer_size;
|
||||
}
|
||||
return bytes_to_copy;
|
||||
}
|
||||
|
||||
uint16_t att_read_callback(uint16_t con_handle, uint16_t att_handle, uint16_t offset, uint8_t * buffer, uint16_t buffer_size){
|
||||
printf("READ Callback, handle %04x\n", att_handle);
|
||||
uint16_t value_len = get_read_att_value_len(att_handle);
|
||||
if (!buffer) return value_len;
|
||||
|
||||
uint16_t bytes_to_copy = get_bytes_to_copy(value_len, offset, buffer_size);
|
||||
if (!bytes_to_copy) return 0;
|
||||
|
||||
switch(att_handle){
|
||||
case ATT_CHARACTERISTIC_FFF1_01_VALUE_HANDLE:
|
||||
memcpy(buffer, &chr01_value[offset], bytes_to_copy);
|
||||
break;
|
||||
case ATT_CHARACTERISTIC_FFF2_01_VALUE_HANDLE:
|
||||
buffer[offset] = chr02_value;
|
||||
break;
|
||||
}
|
||||
return bytes_to_copy;
|
||||
}
|
||||
|
||||
// write requests
|
||||
static int att_write_callback(uint16_t con_handle, uint16_t att_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size){
|
||||
printf("WRITE Callback, handle %04x\n", att_handle);
|
||||
|
||||
uint16_t value_len = get_write_att_value_len(att_handle);
|
||||
uint16_t bytes_to_copy = get_bytes_to_copy(value_len, offset,buffer_size);
|
||||
if (!bytes_to_copy) return ATT_ERROR_INVALID_OFFSET;
|
||||
|
||||
switch(att_handle){
|
||||
case ATT_CHARACTERISTIC_FFF1_01_VALUE_HANDLE:
|
||||
buffer[buffer_size] = 0;
|
||||
memcpy(&chr01_value[offset], buffer, bytes_to_copy);
|
||||
chr01_value_length = bytes_to_copy + offset;
|
||||
|
||||
printf("New text: %s\n", buffer);
|
||||
overwriteLine(7, (char*)buffer);
|
||||
break;
|
||||
case ATT_CHARACTERISTIC_FFF2_01_VALUE_HANDLE:
|
||||
printf("New value: %u\n", buffer[offset]);
|
||||
if (buffer[offset]) {
|
||||
LED_PORT_OUT |= LED_2;
|
||||
} else {
|
||||
LED_PORT_OUT &= ~LED_2;
|
||||
}
|
||||
chr02_value = buffer[offset];
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// main
|
||||
int main(void)
|
||||
{
|
||||
// stop watchdog timer
|
||||
WDTCTL = WDTPW + WDTHOLD;
|
||||
|
||||
//Initialize clock and peripherals
|
||||
halBoardInit();
|
||||
halBoardStartXT1();
|
||||
halBoardSetSystemClock(SYSCLK_16MHZ);
|
||||
|
||||
// Debug UART
|
||||
halUsbInit();
|
||||
|
||||
// show off
|
||||
doLCD();
|
||||
|
||||
// init debug UART
|
||||
halUsbInit();
|
||||
|
||||
// init LEDs
|
||||
LED_PORT_OUT |= LED_1 | LED_2;
|
||||
LED_PORT_DIR |= LED_1 | LED_2;
|
||||
|
||||
/// GET STARTED with BTstack ///
|
||||
btstack_memory_init();
|
||||
run_loop_init(RUN_LOOP_EMBEDDED);
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_dma_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
hci_uart_config_t * config = hci_uart_config_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, config, control, remote_db);
|
||||
|
||||
// use eHCILL
|
||||
// bt_control_cc256x_enable_ehcill(1);
|
||||
|
||||
// set up l2cap_le
|
||||
l2cap_init();
|
||||
|
||||
// setup le device db
|
||||
le_device_db_init();
|
||||
|
||||
// setup SM: Display only
|
||||
sm_init();
|
||||
sm_set_io_capabilities(IO_CAPABILITY_DISPLAY_ONLY);
|
||||
sm_set_authentication_requirements( SM_AUTHREQ_BONDING | SM_AUTHREQ_MITM_PROTECTION);
|
||||
|
||||
// setup ATT server
|
||||
att_server_init(profile_data, NULL, att_write_callback);
|
||||
att_server_register_packet_handler(app_packet_handler);
|
||||
|
||||
printf("Run...\n\r");
|
||||
|
||||
// ready - enable irq used in h4 task
|
||||
__enable_interrupt();
|
||||
|
||||
// turn on!
|
||||
hci_power_control(HCI_POWER_ON);
|
||||
|
||||
LED_PORT_OUT &= ~LED_2;
|
||||
|
||||
// go!
|
||||
run_loop_execute();
|
||||
|
||||
// happy compiler!
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
|
||||
#ifndef __BTSTACK_CONFIG
|
||||
#define __BTSTACK_CONFIG
|
||||
|
||||
#define EMBEDDED
|
||||
|
||||
#define HAVE_INIT_SCRIPT
|
||||
#define HAVE_BZERO
|
||||
#define HAVE_TICK
|
||||
|
||||
#define HAVE_EHCILL
|
||||
#define HAVE_BLE
|
||||
|
||||
// #define ENABLE_LOG_INFO
|
||||
#define ENABLE_LOG_ERROR
|
||||
|
||||
#define HCI_ACL_PAYLOAD_SIZE 52
|
||||
|
||||
//
|
||||
|
||||
#define MAX_NO_HCI_CONNECTIONS 1
|
||||
#define MAX_NO_GATT_CLIENTS 0
|
||||
#define MAX_NO_GATT_SUBCLIENTS 0
|
||||
#define MAX_NO_L2CAP_SERVICES 0
|
||||
#define MAX_NO_L2CAP_CHANNELS 0
|
||||
#define MAX_NO_RFCOMM_MULTIPLEXERS 0
|
||||
#define MAX_NO_RFCOMM_SERVICES 0
|
||||
#define MAX_NO_RFCOMM_CHANNELS 0
|
||||
#define MAX_NO_BNEP_SERVICES 0
|
||||
#define MAX_NO_BNEP_CHANNELS 0
|
||||
#define MAX_NO_DB_MEM_DEVICE_LINK_KEYS 2
|
||||
#define MAX_NO_DB_MEM_DEVICE_NAMES 0
|
||||
#define MAX_NO_DB_MEM_SERVICES 0
|
||||
|
||||
#endif
|
@ -1,11 +0,0 @@
|
||||
PRIMARY_SERVICE, GAP_SERVICE
|
||||
CHARACTERISTIC, GAP_DEVICE_NAME, READ, "BTstack"
|
||||
CHARACTERISTIC, GAP_APPEARANCE, READ, 00 00
|
||||
|
||||
PRIMARY_SERVICE, GATT_SERVICE
|
||||
CHARACTERISTIC, GATT_SERVICE_CHANGED, READ,
|
||||
|
||||
PRIMARY_SERVICE, FFF0
|
||||
CHARACTERISTIC, FFF1, READ | WRITE | DYNAMIC,
|
||||
CHARACTERISTIC, FFF2, READ | WRITE | DYNAMIC,
|
||||
CHARACTERISTIC, 00001234-0000-1000-8000-00805F9B34FB, READ | WRITE | DYNAMIC,
|
Loading…
x
Reference in New Issue
Block a user