mirror of
https://github.com/Ai-Thinker-Open/Ai-Thinker-Open_RTL8710BX_ALIOS_SDK.git
synced 2026-07-06 02:45:37 +00:00
rel_1.6.0 init
This commit is contained in:
commit
27b3e2883d
19359 changed files with 8093121 additions and 0 deletions
11
Living_SDK/example/bluetooth/bleadv/bleadv.mk
Normal file
11
Living_SDK/example/bluetooth/bleadv/bleadv.mk
Normal 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
|
||||
76
Living_SDK/example/bluetooth/bleadv/main.c
Normal file
76
Living_SDK/example/bluetooth/bleadv/main.c
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue