LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_bt.c File Reference
#include "lms2012.h"
#include "c_com.h"
#include "c_bt.h"
#include "c_i2c.h"

Go to the source code of this file.

Macros

#define LEGO_BUNDLE_SEED_ID   "9RNK8ZF528"
 
#define LEGO_BUNDLE_ID   "com.lego.lms"
 

Enumerations

enum  {
  I_AM_IN_IDLE = 0, I_AM_MASTER = 1, I_AM_SLAVE = 2, I_AM_SCANNING = 3,
  STOP_SCANNING = 4, TURN_ON = 5, TURN_OFF = 6, RESTART = 7,
  BLUETOOTH_OFF = 8
}
 
enum  { MSG_BUF_EMPTY = 0, MSG_BUF_LEN = 1, MSG_BUF_BODY = 2, MSG_BUF_FULL = 3 }
 
enum  { MODE1 = 0, MODE2 = 1 }
 

Functions

void setOutputInstance (BT_GLOBALS *_Instance)
 
BT_GLOBALSgetBtInstance ()
 
UBYTE BtConnectTo (UBYTE Port, bdaddr_t BtAddr)
 
void BtTxMsgs (void)
 
void BtSetup (UBYTE State)
 cBtSetup More...
 
UWORD cBtHandleHCI (void)
 cBtHandleHCI More...
 
void BtDisconnectAll (void)
 
UBYTE BtClearSearchListEntry (UBYTE Index)
 
UBYTE cBtFindDevChNo (UBYTE ChNo, UBYTE *pIndex)
 
UBYTE cBtFindDevConnHandle (UBYTE ConnHandle, UBYTE *pIndex)
 
UBYTE cBtFindDevAdr (bdaddr_t *pAdr, UBYTE *pIndex)
 
void cBtSetDevConnectedStatus (UBYTE Index)
 
void cBtCloseDevConnection (UBYTE Index)
 
UBYTE cBtFindSearchAdr (bdaddr_t *pAdr, UBYTE *pIndex)
 
void cBtSetSearchConnectedStatus (UBYTE Index)
 
void cBtClearSearchConnectedStatus (UBYTE Index)
 
void BtCloseBtSocket (SLONG *pBtSocket)
 
void cBtStrNoColonToBa (UBYTE *pBtStrAddr, bdaddr_t *pAddr)
 
void DecodeMode1 (UBYTE BufNo)
 
void DecodeMode2 (void)
 
void BtClose (void)
 
UBYTE BtIssueHciVisible (UBYTE Visible, UBYTE Page)
 
void BtSetupHciSocket (void)
 
void BtSetupPinEvent (void)
 
void SetupListeningSocket (int *Socket)
 
void BtClearChBuf (UBYTE ChNo)
 
void BtInit (char *pName)
 
void BtExit (void)
 
void BtCloseCh (UBYTE ChIndex)
 
UWORD BtRequestName (void)
 
UBYTE BtStartScan (void)
 
UBYTE BtStopScan (void)
 
UWORD cBtReadCh0 (UBYTE *pBuf, UWORD Length)
 
UWORD cBtReadCh1 (UBYTE *pBuf, UWORD Length)
 
UWORD cBtReadCh2 (UBYTE *pBuf, UWORD Length)
 
UWORD cBtReadCh3 (UBYTE *pBuf, UWORD Length)
 
UWORD cBtReadCh4 (UBYTE *pBuf, UWORD Length)
 
UWORD cBtReadCh5 (UBYTE *pBuf, UWORD Length)
 
UWORD cBtReadCh6 (UBYTE *pBuf, UWORD Length)
 
UWORD cBtReadCh7 (UBYTE *pBuf, UWORD Length)
 
void DecodeBtStream (UBYTE BufNo)
 
void BtTurnOnSeq (void)
 
void BtTurnOffSeq (void)
 
void BtUpdate (void)
 
void create_paired_device_reply (DBusPendingCall *pending, void *user_data)
 
UBYTE create_paired_device (DBusConnection *conn, const char *adapter_path, const char *agent_path, const char *capabilities, const char *device, UBYTE Port)
 
UBYTE BtSetMode2 (UBYTE Mode2)
 
UBYTE BtGetMode2 (UBYTE *pMode2)
 
UBYTE BtSetOnOff (UBYTE On)
 
UBYTE BtGetOnOff (UBYTE *On)
 
UBYTE BtSetVisibility (UBYTE State)
 
UBYTE BtGetVisibility (void)
 
UBYTE cBtFindDevName (UBYTE *pItem, UBYTE *pName, UBYTE StartIndex)
 
UBYTE cBtFindSearchName (UBYTE *pItem, UBYTE *pName)
 
UBYTE Connect (bdaddr_t BdAddr, UBYTE PortNo)
 
UBYTE cBtConnect (UBYTE *pDevName)
 
UBYTE cBtDiscDevIndex (UBYTE Index)
 
UBYTE cBtDiscChNo (UBYTE ChNo)
 
UBYTE cBtDisconnect (UBYTE *pName)
 
UBYTE cBtI2cBufReady (void)
 
UWORD cBtI2cToBtBuf (UBYTE *pBuf, UWORD Size)
 
UWORD cBtDevWriteBuf (UBYTE *pBuf, UWORD Size)
 
UWORD cBtDevWriteBuf1 (UBYTE *pBuf, UWORD Size)
 
UWORD cBtDevWriteBuf2 (UBYTE *pBuf, UWORD Size)
 
UWORD cBtDevWriteBuf3 (UBYTE *pBuf, UWORD Size)
 
UWORD cBtDevWriteBuf4 (UBYTE *pBuf, UWORD Size)
 
UWORD cBtDevWriteBuf5 (UBYTE *pBuf, UWORD Size)
 
UWORD cBtDevWriteBuf6 (UBYTE *pBuf, UWORD Size)
 
UWORD cBtDevWriteBuf7 (UBYTE *pBuf, UWORD Size)
 
UBYTE cBtInsertInDeviceList (bdaddr_t *pBtAdr, UBYTE *pIndex)
 
void cBtInsertDevConnHandle (UBYTE Index, UWORD ConnHandle)
 
UBYTE cBtGetHciBusyFlag (void)
 
UBYTE cBtGetBtType (UBYTE *pCod)
 
UBYTE cBtGetNoOfConnListEntries (void)
 
UBYTE cBtGetConnListEntry (UBYTE Item, UBYTE *pName, SBYTE Length, UBYTE *pType)
 
UBYTE cBtGetNoOfDevListEntries (void)
 
UBYTE cBtGetDevListEntry (UBYTE Item, SBYTE *pConnected, SBYTE *pType, UBYTE *pName, SBYTE Length)
 
UBYTE cBtGetNoOfSearchListEntries (void)
 
UBYTE cBtGetSearchListEntry (UBYTE Item, SBYTE *pConnected, SBYTE *pType, SBYTE *pParred, UBYTE *pName, SBYTE Length)
 
UBYTE cBtDeleteFavourItem (UBYTE *pName)
 
UBYTE cBtGetStatus (void)
 
void cBtGetId (UBYTE *pId, UBYTE Length)
 
UBYTE cBtSetName (UBYTE *pName, UBYTE Length)
 
UBYTE cBtGetChNo (UBYTE *pName, UBYTE *pChNos)
 
UBYTE cBtGetEvent (void)
 
void cBtGetIncoming (UBYTE *pName, UBYTE *pCod, UBYTE Len)
 
UBYTE cBtSetPin (UBYTE *pPin)
 
UBYTE cBtSetPasskey (UBYTE Accept)
 
void cBtSetTrustedDev (UBYTE *pBtAddr, UBYTE *pPin, UBYTE PinSize)
 
UWORD cBtSetBundleId (UBYTE *pId)
 
UWORD cBtSetBundleSeedId (UBYTE *pSeedId)
 

Variables

BT_GLOBALSgBtInstance
 

Macro Definition Documentation

#define LEGO_BUNDLE_ID   "com.lego.lms"

Definition at line 180 of file c_bt.c.

#define LEGO_BUNDLE_SEED_ID   "9RNK8ZF528"

Definition at line 179 of file c_bt.c.

Enumeration Type Documentation

anonymous enum
Enumerator
I_AM_IN_IDLE 
I_AM_MASTER 
I_AM_SLAVE 
I_AM_SCANNING 
STOP_SCANNING 
TURN_ON 
TURN_OFF 
RESTART 
BLUETOOTH_OFF 

Definition at line 182 of file c_bt.c.

anonymous enum
Enumerator
MSG_BUF_EMPTY 
MSG_BUF_LEN 
MSG_BUF_BODY 
MSG_BUF_FULL 

Definition at line 195 of file c_bt.c.

anonymous enum
Enumerator
MODE1 
MODE2 

Definition at line 204 of file c_bt.c.

Function Documentation

void BtClearChBuf ( UBYTE  ChNo)

Definition at line 327 of file c_bt.c.

UBYTE BtClearSearchListEntry ( UBYTE  Index)

Definition at line 2151 of file c_bt.c.

void BtClose ( void  )

Definition at line 1529 of file c_bt.c.

void BtCloseBtSocket ( SLONG pBtSocket)

Definition at line 443 of file c_bt.c.

void BtCloseCh ( UBYTE  ChIndex)

Definition at line 453 of file c_bt.c.

UBYTE BtConnectTo ( UBYTE  Port,
bdaddr_t  BtAddr 
)

Definition at line 1910 of file c_bt.c.

void BtDisconnectAll ( void  )

Definition at line 481 of file c_bt.c.

void BtExit ( void  )

Definition at line 426 of file c_bt.c.

UBYTE BtGetMode2 ( UBYTE pMode2)

Definition at line 1990 of file c_bt.c.

UBYTE BtGetOnOff ( UBYTE On)

Definition at line 2042 of file c_bt.c.

UBYTE BtGetVisibility ( void  )

Definition at line 2114 of file c_bt.c.

void BtInit ( char *  pName)

Definition at line 349 of file c_bt.c.

UBYTE BtIssueHciVisible ( UBYTE  Visible,
UBYTE  Page 
)

Definition at line 2052 of file c_bt.c.

UWORD BtRequestName ( void  )

Definition at line 629 of file c_bt.c.

UBYTE BtSetMode2 ( UBYTE  Mode2)

Definition at line 1936 of file c_bt.c.

UBYTE BtSetOnOff ( UBYTE  On)

Definition at line 2000 of file c_bt.c.

void BtSetup ( UBYTE  State)

cBtSetup

Function that handles all state switching

Definition at line 511 of file c_bt.c.

void BtSetupHciSocket ( void  )

Definition at line 248 of file c_bt.c.

void BtSetupPinEvent ( void  )

Definition at line 261 of file c_bt.c.

UBYTE BtSetVisibility ( UBYTE  State)

Definition at line 2076 of file c_bt.c.

UBYTE BtStartScan ( void  )

Definition at line 646 of file c_bt.c.

UBYTE BtStopScan ( void  )

Definition at line 664 of file c_bt.c.

void BtTurnOffSeq ( void  )

Definition at line 1561 of file c_bt.c.

void BtTurnOnSeq ( void  )

Definition at line 1207 of file c_bt.c.

void BtTxMsgs ( void  )

Definition at line 2461 of file c_bt.c.

void BtUpdate ( void  )

Definition at line 1572 of file c_bt.c.

void cBtClearSearchConnectedStatus ( UBYTE  Index)

Definition at line 2830 of file c_bt.c.

void cBtCloseDevConnection ( UBYTE  Index)

Definition at line 2813 of file c_bt.c.

UBYTE cBtConnect ( UBYTE pDevName)

Definition at line 2276 of file c_bt.c.

UBYTE cBtDeleteFavourItem ( UBYTE pName)

Definition at line 3556 of file c_bt.c.

UWORD cBtDevWriteBuf ( UBYTE pBuf,
UWORD  Size 
)

Definition at line 2547 of file c_bt.c.

UWORD cBtDevWriteBuf1 ( UBYTE pBuf,
UWORD  Size 
)

Definition at line 2577 of file c_bt.c.

UWORD cBtDevWriteBuf2 ( UBYTE pBuf,
UWORD  Size 
)

Definition at line 2592 of file c_bt.c.

UWORD cBtDevWriteBuf3 ( UBYTE pBuf,
UWORD  Size 
)

Definition at line 2607 of file c_bt.c.

UWORD cBtDevWriteBuf4 ( UBYTE pBuf,
UWORD  Size 
)

Definition at line 2622 of file c_bt.c.

UWORD cBtDevWriteBuf5 ( UBYTE pBuf,
UWORD  Size 
)

Definition at line 2637 of file c_bt.c.

UWORD cBtDevWriteBuf6 ( UBYTE pBuf,
UWORD  Size 
)

Definition at line 2652 of file c_bt.c.

UWORD cBtDevWriteBuf7 ( UBYTE pBuf,
UWORD  Size 
)

Definition at line 2667 of file c_bt.c.

UBYTE cBtDiscChNo ( UBYTE  ChNo)

Definition at line 2396 of file c_bt.c.

UBYTE cBtDiscDevIndex ( UBYTE  Index)

Definition at line 2381 of file c_bt.c.

UBYTE cBtDisconnect ( UBYTE pName)

Definition at line 2415 of file c_bt.c.

UBYTE cBtFindDevAdr ( bdaddr_t *  pAdr,
UBYTE pIndex 
)

Definition at line 2700 of file c_bt.c.

UBYTE cBtFindDevChNo ( UBYTE  ChNo,
UBYTE pIndex 
)

Definition at line 2739 of file c_bt.c.

UBYTE cBtFindDevConnHandle ( UBYTE  ConnHandle,
UBYTE pIndex 
)

Definition at line 2719 of file c_bt.c.

UBYTE cBtFindDevName ( UBYTE pItem,
UBYTE pName,
UBYTE  StartIndex 
)

Definition at line 2120 of file c_bt.c.

UBYTE cBtFindSearchAdr ( bdaddr_t *  pAdr,
UBYTE pIndex 
)

Definition at line 2682 of file c_bt.c.

UBYTE cBtFindSearchName ( UBYTE pItem,
UBYTE pName 
)

Definition at line 2168 of file c_bt.c.

UBYTE cBtGetBtType ( UBYTE pCod)

Definition at line 3456 of file c_bt.c.

UBYTE cBtGetChNo ( UBYTE pName,
UBYTE pChNos 
)

Definition at line 3680 of file c_bt.c.

UBYTE cBtGetConnListEntry ( UBYTE  Item,
UBYTE pName,
SBYTE  Length,
UBYTE pType 
)

Definition at line 3489 of file c_bt.c.

UBYTE cBtGetDevListEntry ( UBYTE  Item,
SBYTE pConnected,
SBYTE pType,
UBYTE pName,
SBYTE  Length 
)

Definition at line 3523 of file c_bt.c.

UBYTE cBtGetEvent ( void  )

Definition at line 4174 of file c_bt.c.

UBYTE cBtGetHciBusyFlag ( void  )

Definition at line 3433 of file c_bt.c.

void cBtGetId ( UBYTE pId,
UBYTE  Length 
)

Definition at line 3645 of file c_bt.c.

void cBtGetIncoming ( UBYTE pName,
UBYTE pCod,
UBYTE  Len 
)

Definition at line 4184 of file c_bt.c.

UBYTE cBtGetNoOfConnListEntries ( void  )

Definition at line 3483 of file c_bt.c.

UBYTE cBtGetNoOfDevListEntries ( void  )

Definition at line 3517 of file c_bt.c.

UBYTE cBtGetNoOfSearchListEntries ( void  )

Definition at line 3536 of file c_bt.c.

UBYTE cBtGetSearchListEntry ( UBYTE  Item,
SBYTE pConnected,
SBYTE pType,
SBYTE pParred,
UBYTE pName,
SBYTE  Length 
)

Definition at line 3542 of file c_bt.c.

UBYTE cBtGetStatus ( void  )

Definition at line 3621 of file c_bt.c.

UWORD cBtHandleHCI ( void  )

cBtHandleHCI

CONNECTION MANAGEMENT

Scenarious :

CONNECTING:

    Connecting brick:                                  Remote brick:
    (IDLE state)                                       (SLAVE state)

Connect to brick (Issued from byte codes) |

  • Set busy flag |
  • Disable page inquiry |
  • Open socket —> | —> EVT_CONN_REQUEST | - Issue remote name request (might not be known) | | EVT_CONN_COMPLETE <— | —> EVT_CONN_COMPLETE
  • Update Device list | - Disable page inquiry
  • Update Search list | - Insert all info in dev list (Except connected) | | Socket write ready (Remote socket open) <— | —> Success on accept listen socket (Socket gives remote address)
  • NoOfConnDevices++ | - Set slave mode
  • Update Search list to connected | - NoOfConnDevices++
  • Update Device list to connected | - Update Device list to connected | - Update Search list to connected

Disconnecting brick: | Remote brick: | Disconnect (Issued from byte codes) |

  • Close bluetooth socket | —> Socket indicates remote socket closed | - Close socket | | EVT_DISCONN_COMPLETE <— | —> EVT_DISCONN_COMPLETE
  • Update Search list to disconnected | - Update Search list to disconnected
  • Update Device list to disconnected | - Update Device list to disconnected
  • NoofConnDevices– | - NoofConnDevices–
  • If NoofConnDevices = 0 -> set idle mode | - If NoofConnDevices = 0 -> set idle mode | |

Definition at line 2907 of file c_bt.c.

UBYTE cBtI2cBufReady ( void  )

Definition at line 2523 of file c_bt.c.

UWORD cBtI2cToBtBuf ( UBYTE pBuf,
UWORD  Size 
)

Definition at line 2536 of file c_bt.c.

void cBtInsertDevConnHandle ( UBYTE  Index,
UWORD  ConnHandle 
)

Definition at line 2836 of file c_bt.c.

UBYTE cBtInsertInDeviceList ( bdaddr_t *  pBtAdr,
UBYTE pIndex 
)

Definition at line 2759 of file c_bt.c.

UWORD cBtReadCh0 ( UBYTE pBuf,
UWORD  Length 
)

Definition at line 706 of file c_bt.c.

UWORD cBtReadCh1 ( UBYTE pBuf,
UWORD  Length 
)

Definition at line 727 of file c_bt.c.

UWORD cBtReadCh2 ( UBYTE pBuf,
UWORD  Length 
)

Definition at line 749 of file c_bt.c.

UWORD cBtReadCh3 ( UBYTE pBuf,
UWORD  Length 
)

Definition at line 771 of file c_bt.c.

UWORD cBtReadCh4 ( UBYTE pBuf,
UWORD  Length 
)

Definition at line 793 of file c_bt.c.

UWORD cBtReadCh5 ( UBYTE pBuf,
UWORD  Length 
)

Definition at line 815 of file c_bt.c.

UWORD cBtReadCh6 ( UBYTE pBuf,
UWORD  Length 
)

Definition at line 837 of file c_bt.c.

UWORD cBtReadCh7 ( UBYTE pBuf,
UWORD  Length 
)

Definition at line 858 of file c_bt.c.

UWORD cBtSetBundleId ( UBYTE pId)

Definition at line 4265 of file c_bt.c.

UWORD cBtSetBundleSeedId ( UBYTE pSeedId)

Definition at line 4279 of file c_bt.c.

void cBtSetDevConnectedStatus ( UBYTE  Index)

Definition at line 2806 of file c_bt.c.

UBYTE cBtSetName ( UBYTE pName,
UBYTE  Length 
)

Definition at line 3651 of file c_bt.c.

UBYTE cBtSetPasskey ( UBYTE  Accept)

Definition at line 4212 of file c_bt.c.

UBYTE cBtSetPin ( UBYTE pPin)

Definition at line 4191 of file c_bt.c.

void cBtSetSearchConnectedStatus ( UBYTE  Index)

Definition at line 2823 of file c_bt.c.

void cBtSetTrustedDev ( UBYTE pBtAddr,
UBYTE pPin,
UBYTE  PinSize 
)

Definition at line 4240 of file c_bt.c.

void cBtStrNoColonToBa ( UBYTE pBtStrAddr,
bdaddr_t *  pAddr 
)

Definition at line 4249 of file c_bt.c.

UBYTE Connect ( bdaddr_t  BdAddr,
UBYTE  PortNo 
)

Definition at line 2187 of file c_bt.c.

UBYTE create_paired_device ( DBusConnection *  conn,
const char *  adapter_path,
const char *  agent_path,
const char *  capabilities,
const char *  device,
UBYTE  Port 
)

Definition at line 1865 of file c_bt.c.

void create_paired_device_reply ( DBusPendingCall *  pending,
void *  user_data 
)

Definition at line 1837 of file c_bt.c.

void DecodeBtStream ( UBYTE  BufNo)

Definition at line 879 of file c_bt.c.

void DecodeMode1 ( UBYTE  BufNo)

Definition at line 920 of file c_bt.c.

void DecodeMode2 ( void  )

Definition at line 893 of file c_bt.c.

BT_GLOBALS* getBtInstance ( )

Definition at line 171 of file c_bt.c.

void setOutputInstance ( BT_GLOBALS _Instance)

Definition at line 166 of file c_bt.c.

void SetupListeningSocket ( int *  Socket)

Definition at line 295 of file c_bt.c.

Variable Documentation

BT_GLOBALS* gBtInstance

Definition at line 164 of file c_bt.c.