RetroArch
Classes | Macros | Enumerations | Functions | Variables
bte.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <ogcsys.h>
#include <gccore.h>
#include <lwp_threads.h>
#include "bt.h"
#include "bte.h"
#include "hci.h"
#include "l2cap.h"
#include "btmemb.h"
#include "physbusif.h"
Include dependency graph for bte.c:

Classes

struct  bt_state
 
struct  ctrl_req_t
 

Macros

#define STACKSIZE   32768
 
#define MQ_BOX_SIZE   256
 
#define HCI_VENDOR_OGF   0x3f
 
#define HCI_VENDOR_PATCH_START_OCF   0x4f
 
#define HCI_VENDOR_PATCH_CONT_OCF   0x4c
 
#define HCI_VENDOR_PATCH_END_OCF   0x4f
 

Enumerations

enum  bte_state {
  STATE_NOTREADY = -1, STATE_READY = 0, STATE_CONNECTING, STATE_CONNECTED,
  STATE_DISCONNECTING, STATE_DISCONNECTED, STATE_SENDING, STATE_SENT,
  STATE_RECEIVING, STATE_RECEIVED, STATE_FAILED
}
 

Functions

static u8 ppc_stack [STACKSIZEATTRIBUTE_ALIGN (8)
 
err_t acl_wlp_completed (void *arg, struct bd_addr *bdaddr)
 
err_t link_key_not (void *arg, struct bd_addr *bdaddr, u8_t *key)
 
err_t pin_req (void *arg, struct bd_addr *bdaddr)
 
err_t l2cap_connected (void *arg, struct l2cap_pcb *l2cappcb, u16_t result, u16_t status)
 
err_t l2cap_accepted (void *arg, struct l2cap_pcb *l2cappcb, err_t err)
 
err_t acl_conn_complete (void *arg, struct bd_addr *bdaddr)
 
err_t l2cap_disconnect_cfm (void *arg, struct l2cap_pcb *pcb)
 
err_t l2cap_disconnected_ind (void *arg, struct l2cap_pcb *pcb, err_t err)
 
err_t bte_input (void *arg, struct l2cap_pcb *pcb, struct pbuf *p, err_t err)
 
err_t bte_callback (void(*f)(void *), void *ctx)
 
err_t bte_hci_apply_patch_complete (void *arg, struct hci_pcb *pcb, u8_t ogf, u8_t ocf, u8_t result)
 
err_t bte_hci_patch_complete (void *arg, struct hci_pcb *pcb, u8_t ogf, u8_t ocf, u8_t result)
 
err_t bte_hci_initcore_complete (void *arg, struct hci_pcb *pcb, u8_t ogf, u8_t ocf, u8_t result)
 
err_t bte_hci_initsub_complete (void *arg, struct hci_pcb *pcb, u8_t ogf, u8_t ocf, u8_t result)
 
err_t bte_inquiry_complete (void *arg, struct hci_pcb *pcb, struct hci_inq_res *ires, u16_t result)
 
err_t bte_read_stored_link_key_complete (void *arg, struct hci_pcb *pcb, u8_t ogf, u8_t ocf, u8_t result)
 
err_t bte_read_bd_addr_complete (void *arg, struct hci_pcb *pcb, u8_t ogf, u8_t ocf, u8_t result)
 
 MEMB (bte_pcbs, sizeof(struct bte_pcb), MEMP_NUM_BTE_PCB)
 
 MEMB (bte_ctrl_reqs, sizeof(struct ctrl_req_t), MEMP_NUM_BTE_CTRLS)
 
static void bte_reset_all ()
 
static void bt_alarmhandler (syswd_t alarm, void *cbarg)
 
static s32 __bte_waitcmdfinish (struct bt_state *state)
 
static s32 __bte_cmdfinish (struct bt_state *state, err_t err)
 
static s32 __bte_waitrequest (struct ctrl_req_t *req)
 
static void __bte_close_ctrl_queue (struct bte_pcb *pcb)
 
static s32 __bte_send_pending_request (struct bte_pcb *pcb)
 
static s32 __bte_send_request (struct ctrl_req_t *req)
 
static err_t __bte_shutdown_finished (void *arg, struct hci_pcb *pcb, u8_t ogf, u8_t ocf, u8_t result)
 
static void bte_process_handshake (struct bte_pcb *pcb, u8_t param, void *buf, u16_t len)
 
static void bte_process_data (struct bte_pcb *pcb, u8_t param, void *buf, u16_t len)
 
static err_t bte_process_input (void *arg, struct l2cap_pcb *pcb, struct pbuf *p, err_t err)
 
void BTE_Init ()
 
void BTE_Shutdown ()
 
s32 BTE_InitCore (btecallback cb)
 
s32 BTE_ApplyPatch (btecallback cb)
 
s32 BTE_InitSub (btecallback cb)
 
s32 BTE_ReadStoredLinkKey (struct linkkey_info *keys, u8 max_cnt, btecallback cb)
 
s32 BTE_ReadBdAddr (struct bd_addr *bdaddr, btecallback cb)
 
struct bte_pcbbte_new ()
 
s32 bte_registerdeviceasync (struct bte_pcb *pcb, struct bd_addr *bdaddr, s32(*conn_cfm)(void *arg, struct bte_pcb *pcb, u8 err))
 
s32 bte_inquiry (struct inquiry_info *info, u8 max_cnt, u8 flush)
 
s32 bte_inquiry_ex (struct inquiry_info_ex *info, u8 max_cnt, u8 flush)
 
s32 bte_disconnect (struct bte_pcb *pcb)
 
s32 bte_senddata (struct bte_pcb *pcb, void *message, u16 len)
 
s32 bte_sendmessageasync (struct bte_pcb *pcb, void *message, u16 len, s32(*sent)(void *arg, struct bte_pcb *pcb, u8 err))
 
s32 bte_sendmessage (struct bte_pcb *pcb, void *message, u16 len)
 
void bte_arg (struct bte_pcb *pcb, void *arg)
 
void bte_received (struct bte_pcb *pcb, s32(*recv)(void *arg, void *buffer, u16 len))
 
void bte_disconnected (struct bte_pcb *pcb, s32(disconn_cfm)(void *arg, struct bte_pcb *pcb, u8 err))
 
err_t bte_hci_initcore_complete2 (void *arg, struct hci_pcb *pcb, u8_t ogf, u8_t ocf, u8_t result)
 

Variables

static struct bt_state btstate
 
static u8_t bte_patch0 [184]
 
static u8_t bte_patch1 [92]
 
void(*)(struct bd_addr *bdaddr, u8 reason) BTE_SetDisconnectCallback (void(*callback)(struct bd_addr *bdaddr, u8 reason))
 

Macro Definition Documentation

◆ HCI_VENDOR_OGF

#define HCI_VENDOR_OGF   0x3f

◆ HCI_VENDOR_PATCH_CONT_OCF

#define HCI_VENDOR_PATCH_CONT_OCF   0x4c

◆ HCI_VENDOR_PATCH_END_OCF

#define HCI_VENDOR_PATCH_END_OCF   0x4f

◆ HCI_VENDOR_PATCH_START_OCF

#define HCI_VENDOR_PATCH_START_OCF   0x4f

◆ MQ_BOX_SIZE

#define MQ_BOX_SIZE   256

◆ STACKSIZE

#define STACKSIZE   32768

Enumeration Type Documentation

◆ bte_state

enum bte_state
Enumerator
STATE_NOTREADY 
STATE_READY 
STATE_CONNECTING 
STATE_CONNECTED 
STATE_DISCONNECTING 
STATE_DISCONNECTED 
STATE_SENDING 
STATE_SENT 
STATE_RECEIVING 
STATE_RECEIVED 
STATE_FAILED 

Function Documentation

◆ __bte_close_ctrl_queue()

static void __bte_close_ctrl_queue ( struct bte_pcb pcb)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __bte_cmdfinish()

static s32 __bte_cmdfinish ( struct bt_state state,
err_t  err 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __bte_send_pending_request()

static s32 __bte_send_pending_request ( struct bte_pcb pcb)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __bte_send_request()

static s32 __bte_send_request ( struct ctrl_req_t req)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __bte_shutdown_finished()

static err_t __bte_shutdown_finished ( void arg,
struct hci_pcb pcb,
u8_t  ogf,
u8_t  ocf,
u8_t  result 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __bte_waitcmdfinish()

static s32 __bte_waitcmdfinish ( struct bt_state state)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __bte_waitrequest()

static s32 __bte_waitrequest ( struct ctrl_req_t req)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ acl_conn_complete()

err_t acl_conn_complete ( void arg,
struct bd_addr bdaddr 
)
Here is the caller graph for this function:

◆ acl_wlp_completed()

err_t acl_wlp_completed ( void arg,
struct bd_addr bdaddr 
)
Here is the caller graph for this function:

◆ ATTRIBUTE_ALIGN()

static u8 ppc_stack [STACKSIZE] ATTRIBUTE_ALIGN ( )
static

◆ bt_alarmhandler()

static void bt_alarmhandler ( syswd_t  alarm,
void cbarg 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BTE_ApplyPatch()

s32 BTE_ApplyPatch ( btecallback  cb)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bte_arg()

void bte_arg ( struct bte_pcb pcb,
void arg 
)

◆ bte_callback()

err_t bte_callback ( void(*)(void *)  f,
void ctx 
)

◆ bte_disconnect()

s32 bte_disconnect ( struct bte_pcb pcb)
Here is the call graph for this function:

◆ bte_disconnected()

void bte_disconnected ( struct bte_pcb pcb,
s32(disconn_cfm)(void *arg, struct bte_pcb *pcb, u8 err)   
)

◆ bte_hci_apply_patch_complete()

err_t bte_hci_apply_patch_complete ( void arg,
struct hci_pcb pcb,
u8_t  ogf,
u8_t  ocf,
u8_t  result 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bte_hci_initcore_complete()

err_t bte_hci_initcore_complete ( void arg,
struct hci_pcb pcb,
u8_t  ogf,
u8_t  ocf,
u8_t  result 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bte_hci_initcore_complete2()

err_t bte_hci_initcore_complete2 ( void arg,
struct hci_pcb pcb,
u8_t  ogf,
u8_t  ocf,
u8_t  result 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bte_hci_initsub_complete()

err_t bte_hci_initsub_complete ( void arg,
struct hci_pcb pcb,
u8_t  ogf,
u8_t  ocf,
u8_t  result 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bte_hci_patch_complete()

err_t bte_hci_patch_complete ( void arg,
struct hci_pcb pcb,
u8_t  ogf,
u8_t  ocf,
u8_t  result 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BTE_Init()

void BTE_Init ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BTE_InitCore()

s32 BTE_InitCore ( btecallback  cb)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BTE_InitSub()

s32 BTE_InitSub ( btecallback  cb)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bte_input()

err_t bte_input ( void arg,
struct l2cap_pcb pcb,
struct pbuf p,
err_t  err 
)

◆ bte_inquiry()

s32 bte_inquiry ( struct inquiry_info info,
u8  max_cnt,
u8  flush 
)
Here is the call graph for this function:

◆ bte_inquiry_complete()

err_t bte_inquiry_complete ( void arg,
struct hci_pcb pcb,
struct hci_inq_res ires,
u16_t  result 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bte_inquiry_ex()

s32 bte_inquiry_ex ( struct inquiry_info_ex info,
u8  max_cnt,
u8  flush 
)
Here is the call graph for this function:

◆ bte_new()

struct bte_pcb* bte_new ( )
Here is the call graph for this function:

◆ bte_process_data()

static void bte_process_data ( struct bte_pcb pcb,
u8_t  param,
void buf,
u16_t  len 
)
static
Here is the caller graph for this function:

◆ bte_process_handshake()

static void bte_process_handshake ( struct bte_pcb pcb,
u8_t  param,
void buf,
u16_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bte_process_input()

static err_t bte_process_input ( void arg,
struct l2cap_pcb pcb,
struct pbuf p,
err_t  err 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bte_read_bd_addr_complete()

err_t bte_read_bd_addr_complete ( void arg,
struct hci_pcb pcb,
u8_t  ogf,
u8_t  ocf,
u8_t  result 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bte_read_stored_link_key_complete()

err_t bte_read_stored_link_key_complete ( void arg,
struct hci_pcb pcb,
u8_t  ogf,
u8_t  ocf,
u8_t  result 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BTE_ReadBdAddr()

s32 BTE_ReadBdAddr ( struct bd_addr bdaddr,
btecallback  cb 
)
Here is the call graph for this function:

◆ BTE_ReadStoredLinkKey()

s32 BTE_ReadStoredLinkKey ( struct linkkey_info keys,
u8  max_cnt,
btecallback  cb 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bte_received()

void bte_received ( struct bte_pcb pcb,
s32(*)(void *arg, void *buffer, u16 len recv 
)
Here is the call graph for this function:

◆ bte_registerdeviceasync()

s32 bte_registerdeviceasync ( struct bte_pcb pcb,
struct bd_addr bdaddr,
s32(*)(void *arg, struct bte_pcb *pcb, u8 err)  conn_cfm 
)
Here is the call graph for this function:

◆ bte_reset_all()

static void bte_reset_all ( )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bte_senddata()

s32 bte_senddata ( struct bte_pcb pcb,
void message,
u16  len 
)
Here is the call graph for this function:

◆ bte_sendmessage()

s32 bte_sendmessage ( struct bte_pcb pcb,
void message,
u16  len 
)
Here is the call graph for this function:

◆ bte_sendmessageasync()

s32 bte_sendmessageasync ( struct bte_pcb pcb,
void message,
u16  len,
s32(*)(void *arg, struct bte_pcb *pcb, u8 err)  sent 
)
Here is the call graph for this function:

◆ BTE_Shutdown()

void BTE_Shutdown ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ l2cap_accepted()

err_t l2cap_accepted ( void arg,
struct l2cap_pcb l2cappcb,
err_t  err 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ l2cap_connected()

err_t l2cap_connected ( void arg,
struct l2cap_pcb l2cappcb,
u16_t  result,
u16_t  status 
)

◆ l2cap_disconnect_cfm()

err_t l2cap_disconnect_cfm ( void arg,
struct l2cap_pcb pcb 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ l2cap_disconnected_ind()

err_t l2cap_disconnected_ind ( void arg,
struct l2cap_pcb pcb,
err_t  err 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ link_key_not()

err_t link_key_not ( void arg,
struct bd_addr bdaddr,
u8_t key 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MEMB() [1/2]

MEMB ( bte_pcbs  ,
sizeof(struct bte_pcb ,
MEMP_NUM_BTE_PCB   
)

◆ MEMB() [2/2]

MEMB ( bte_ctrl_reqs  ,
sizeof(struct ctrl_req_t ,
MEMP_NUM_BTE_CTRLS   
)

◆ pin_req()

err_t pin_req ( void arg,
struct bd_addr bdaddr 
)
Here is the caller graph for this function:

Variable Documentation

◆ bte_patch0

u8_t bte_patch0[184]
static
Initial value:
= {
0x70,0x99,0x08,0x00,0x88,0x43,0xd1,0x07,0x09,0x0c,0x08,0x43,0xa0,0x62,0x19,0x23,
0xdb,0x01,0x33,0x80,0x7c,0xf7,0x88,0xf8,0x28,0x76,0x80,0xf7,0x17,0xff,0x43,0x78,
0xeb,0x70,0x19,0x23,0xdb,0x01,0x33,0x87,0x7c,0xf7,0xbc,0xfb,0x0b,0x60,0xa3,0x7b,
0x01,0x49,0x0b,0x60,0x90,0xf7,0x96,0xfb,0xd8,0x1d,0x08,0x00,0x00,0xf0,0x04,0xf8,
0x00,0x23,0x79,0xf7,0xe3,0xfa,0x00,0x00,0x00,0xb5,0x00,0x23,0x11,0x49,0x0b,0x60,
0x1d,0x21,0xc9,0x03,0x0b,0x60,0x7d,0x20,0x80,0x01,0x01,0x38,0xfd,0xd1,0x0e,0x4b,
0x0e,0x4a,0x13,0x60,0x47,0x20,0x00,0x21,0x96,0xf7,0x96,0xff,0x46,0x20,0x00,0x21,
0x96,0xf7,0x92,0xff,0x0a,0x4a,0x13,0x68,0x0a,0x48,0x03,0x40,0x13,0x60,0x0a,0x4a,
0x13,0x68,0x0a,0x48,0x03,0x40,0x13,0x60,0x09,0x4a,0x13,0x68,0x09,0x48,0x03,0x40,
0x13,0x60,0x00,0xbd,0x24,0x80,0x0e,0x00,0x81,0x03,0x0f,0xfe,0x5c,0x00,0x0f,0x00,
0x60,0xfc,0x0e,0x00,0xfe,0xff,0x00,0x00,0xfc,0xfc,0x0e,0x00,0xff,0x9f,0x00,0x00,
0x30,0xfc,0x0e,0x00,0x7f,0xff,0x00,0x00
}

◆ bte_patch1

u8_t bte_patch1[92]
static
Initial value:
= {
0x07,0x20,0xbc,0x65,0x01,0x00,0x84,0x42,0x09,0xd2,0x84,0x42,0x09,0xd1,0x21,0x84,
0x5a,0x00,0x00,0x83,0xf0,0x74,0xff,0x09,0x0c,0x08,0x43,0x22,0x00,0x61,0x00,0x00,
0x83,0xf0,0x40,0xfc,0x00,0x00,0x00,0x00,0x23,0xcc,0x9f,0x01,0x00,0x6f,0xf0,0xe4,
0xfc,0x03,0x28,0x7d,0xd1,0x24,0x3c,0x62,0x01,0x00,0x28,0x20,0x00,0xe0,0x60,0x8d,
0x23,0x68,0x25,0x04,0x12,0x01,0x00,0x20,0x1c,0x20,0x1c,0x24,0xe0,0xb0,0x21,0x26,
0x74,0x2f,0x00,0x00,0x86,0xf0,0x18,0xfd,0x21,0x4f,0x3b,0x60
}

◆ BTE_SetDisconnectCallback

void(*)(struct bd_addr *bdaddr, u8 reason) BTE_SetDisconnectCallback(void(*callback)(struct bd_addr *bdaddr, u8 reason))

◆ btstate

struct bt_state btstate
static