rel_1.6.0 init

This commit is contained in:
guocheng.kgc 2020-06-18 20:06:52 +08:00 committed by shengdong.dsd
commit 27b3e2883d
19359 changed files with 8093121 additions and 0 deletions

View file

@ -0,0 +1,11 @@
NAME := bleadv
$(NAME)_SOURCES := main.c
$(NAME)_INCLUDES := ../../../kernel/protocols/bluetooth/include \
../../../kernel/protocols/bluetooth/core/include
ble = 1
$(NAME)_COMPONENTS += protocols.bluetooth yloop cli
GLOBAL_DEFINES += AOS_NO_WIFI CONFIG_BT_SMP

View file

@ -0,0 +1,76 @@
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#include <stdio.h>
#include <string.h>
#include <aos/aos.h>
#include <aos/kernel.h>
#include <misc/slist.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
extern int hci_driver_init();
extern int bt_enable(bt_ready_cb_t cb);
void ble_sample(void)
{
bt_addr_t addr = {.val = { 0x80, 0x81, 0x82, 0x83, 0x84, 0x05 }};
struct bt_le_adv_param adv_param = {
.options = 0, \
.interval_min = BT_GAP_ADV_FAST_INT_MIN_2, \
.interval_max = BT_GAP_ADV_FAST_INT_MAX_2, \
.own_addr = &addr, \
};
int err;
uint8_t data[] = { 0x6 }; // LE General Discoverable and BR/EDR not supported
char *adv_name = "AOS-BLE-HELLO";
const struct bt_data adv_data[] = {
BT_DATA(BT_DATA_FLAGS, data, 1),
BT_DATA(BT_DATA_NAME_COMPLETE, adv_name, strlen(adv_name))
};
printf("Starting Advertiser Demo\n");
hci_driver_init();
err = bt_enable(NULL);
if (err) {
printf("Bluetooth init failed (err %d)\n", err);
return;
}
printf("Bluetooth initialized\n");
do {
aos_msleep(400);
/* Start advertising */
err = bt_le_adv_start(&adv_param, adv_data, ARRAY_SIZE(adv_data), NULL, 0);
if (err) {
printf("Advertising failed to start (err %d)\n", err);
return;
}
aos_msleep(400);
err = bt_le_adv_stop();
if (err) {
printf("Advertising failed to stop (err %d)\n", err);
return;
}
} while (1);
}
static void app_delayed_action(void *arg)
{
ble_sample();
}
int application_start(int argc, char **argv)
{
aos_post_delayed_action(1000, app_delayed_action, NULL);
aos_loop_run();
return 0;
}