1.蓝牙适配

This commit is contained in:
payton 2023-12-12 19:24:49 +08:00
parent 6b10066e59
commit e8a1816bfc
3 changed files with 38 additions and 6 deletions

View File

@ -67,6 +67,7 @@ SINT32 sf_in_update(void);
void sf_set_card_statu(UINT32 val); void sf_set_card_statu(UINT32 val);
UINT32 sf_get_card_statu(void); UINT32 sf_get_card_statu(void);
BOOL sf_system_check_bt_ko(void);
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
} }

View File

@ -629,11 +629,29 @@ BOOL sf_load_ko(void)
return ret2; return ret2;
} }
BOOL sf_system_check_bt_ko(void)
{
char command[26] = "lsmod | grep rtk_btusb";
FILE *fp = popen(command, "r");
char result[256];
fgets(result, sizeof(result), fp);
pclose(fp);
if (result[0] == '\0') {
MLOGI("rtk_btusb module is not loaded.\n");
return FALSE;
} else {
MLOGI("rtk_btusb module is loaded.\n");
return TRUE;
}
}
BOOL sf_load_bt_ko(void) BOOL sf_load_bt_ko(void)
{ {
BOOL ret2 = TRUE; BOOL ret2 = TRUE;
int ret = 0; int ret = 0;
ret = system("modprobe hci_uart"); MLOGI("start.\n");
ret = system("modprobe rtk_btusb");
if(0 != ret) if(0 != ret)
{ {
ret2 = FALSE; ret2 = FALSE;

View File

@ -30,6 +30,7 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <net/if.h> #include <net/if.h>
#include "sf_blue_app.h" #include "sf_blue_app.h"
#include "sf_device.h"
extern int hciconfig_start_advertising(const char *ssid); extern int hciconfig_start_advertising(const char *ssid);
extern int hciconfig_close_device(void); extern int hciconfig_close_device(void);
@ -131,14 +132,26 @@ static void *sf_bluetooth_piscan_task(void *arg)
//system("export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/misc:/customer/rocus/lib"); //system("export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/misc:/customer/rocus/lib");
//system("adduser messagebus"); //system("adduser messagebus");
system("rtk_hciattach -n -s 115200 ttyS1 rtk_h5 &"); // system("rtk_hciattach -n -s 115200 ttyS1 rtk_h5 &");
// for (i = 0; i < 40; i++) {
// if (access("/tmp/blue_setup_complete", F_OK) == 0) {
// printf("blue setup complete\r\n");
// remove("/tmp/blue_setup_complete");
// break;
// } else {
// usleep(500 * 1000);
// if(39 == i)
// {
// MLOGE("blue setup fall!!\n");
// return NULL;
// }
// }
// }
for (i = 0; i < 40; i++) { for (i = 0; i < 40; i++) {
if (access("/tmp/blue_setup_complete", F_OK) == 0) { if (sf_system_check_bt_ko() == TRUE) {
printf("blue setup complete\r\n");
remove("/tmp/blue_setup_complete");
break; break;
} else { } else {
usleep(500 * 1000); usleep(500 * 1000);