Microchip® Advanced Software Framework

appEngine_t2bf_atmel.c File Reference
#include <string.h>
#include <stdio.h>
#include "compiler.h"
#include "appEngine_t2bf_atmel.h"
#include "t2bf.h"
#include "time.h"
#include "unistr.h"

Macros

#define T2BF_LITE_COD   { 0x18, 0x01, 0x01 }
 
#define T2BFENG_MAX_NAME_LENGTH   20
 
#define T2BFENG_MAX_SEARCH_RESULT   10
 
#define T2BFENG_MAX_SEARCH_TIMEOUT   15
 

Typedefs

typedef uint16 TMyNameString [T2BFENG_MAX_NAME_LENGTH]
 

Enumerations

enum  TAppEngineStateEnum {
  AppEngine_Idle_State,
  AppEngine_Inquiry_State,
  AppEngine_Connecting_State,
  AppEngine_Connected_State,
  AppEngine_Disconnecting_State
}
 

Functions

void AppEngineBtCb (TT2BFBtEvent event, TBdAddr bdAddr, TServiceId id)
 Callback function that handles events from t2BF. More...
 
void AppEngineConnectButton (void)
 Handles functionality coupled to press of the Connect button. More...
 
boolean AppEngineInit (TAppEnginePrintCb *pCb, TString deviceName)
 Initializes the Bluetooth functionality. More...
 
void AppEngineInquiryButton (void)
 Handles functionality coupled to press of the Inquiry button. More...
 
boolean AppEngineInternalSendData (uint16 dataLength, uint8 *pData)
 Sends data over SPP. More...
 
void AppEngineJoystickButton (TAppEngineJoystick joystick)
 Sends a letter for each direction on the joystick. More...
 
void AppEngineNotifyCallback (TString textToDisplay)
 Callback function used to access write functionality defined by the application. More...
 
void AppEngineSelectDeviceButton (void)
 Handles functionality coupled to press of the Select button. More...
 
void AppEngineSppCb (TT2BFSppEvent event, TPort port)
 Callback function that handles events related to the SPP connection. More...
 
void AppEngineTimeoutCb (uint32 value)
 

Variables

TBdAddr myBdAddr
 
uint16 myBytes
 
uint8 myBytesBuffer [22]
 
uint8 myIndex = 0
 
TUTF16String myName = NULL
 
TPort mySppPort
 
TAppEngineStateEnum myState = AppEngine_Idle_State
 
TT2BFStatus myStatus
 
static TBdAddr pMyBdAddress [T2BFENG_MAX_SEARCH_RESULT]
 
TAppEnginePrintCbpMyCb
 
static TT2BFDeviceInfo pMyDeviceInfo [T2BFENG_MAX_SEARCH_RESULT]
 
static TMyNameString pMyName [T2BFENG_MAX_SEARCH_RESULT]
 

#define T2BF_LITE_COD   { 0x18, 0x01, 0x01 }

Referenced by AppEngineInit().

#define T2BFENG_MAX_NAME_LENGTH   20
#define T2BFENG_MAX_SEARCH_RESULT   10

Referenced by AppEngineInquiryButton().

#define T2BFENG_MAX_SEARCH_TIMEOUT   15

Referenced by AppEngineInquiryButton().

typedef uint16 TMyNameString[T2BFENG_MAX_NAME_LENGTH]

Enumerator
AppEngine_Idle_State 
AppEngine_Inquiry_State 
AppEngine_Connecting_State 
AppEngine_Connected_State 
AppEngine_Disconnecting_State 

void AppEngineBtCb ( TT2BFBtEvent  event,
TBdAddr  bdAddr,
TServiceId  id 
)

Callback function that handles events from t2BF.

Parameters
eventSpecifies the occurred event.
bdAddrIdentifies the remote unit, if applicable.
TServiceIdIdentifies to t2BF module the issued the event.
Return values
None.

References AppEngine_Idle_State, AppEngineNotifyCallback(), myBytes, myBytesBuffer, myState, T2BF_BT_EVENT_INQUIRY_COMPLETE, and T2BF_BT_EVENT_INQUIRY_RESULT.

Referenced by AppEngineInit().

void AppEngineConnectButton ( void  )

Handles functionality coupled to press of the Connect button.

Parameters
None
Return values
None

References AppEngine_Connected_State, AppEngine_Connecting_State, AppEngine_Disconnecting_State, AppEngine_Idle_State, AppEngineNotifyCallback(), myBdAddr, mySppPort, myState, NULL, T2BF_STATUS_OK, T2BFSppConnect(), and T2BFSppDisconnect().

Referenced by app_engine().

boolean AppEngineInit ( TAppEnginePrintCb pCb,
TString  deviceName 
)

Initializes the Bluetooth functionality.

Parameters
pCbPointer to callback function that shall receive events from t2BF
deviceNameSets the user friendly name that are used when this unit is discovered by others.
Return values
trueInitialization successful.
falseBaud rate set point is out of range for the given input clock frequency.

References AppEngine_Idle_State, AppEngineBtCb(), AppEngineNotifyCallback(), AppEngineSppCb(), myBdAddr, myName, mySppPort, myState, myStatus, NULL, pMyCb, T2BF_AUTO_AUTH_ALLOW, T2BF_LITE_COD, T2BF_SEC_LEVEL_2, T2BF_SEC_NORMAL, T2BF_STATUS_OK, T2BFAutoAuthentication(), T2BFDiscoverable(), T2BFInit(), T2BFSppCreatePort(), T2BFSppOpen(), T2BFStart(), T2BFWriteName(), T2BFWritePin(), UNISTR_CHARSET_ASCII, UNISTR_ENCODING_NONE, and UNISTRToUtf16().

Referenced by app_engine().

void AppEngineInquiryButton ( void  )
boolean AppEngineInternalSendData ( uint16  dataLength,
uint8 pData 
)

Sends data over SPP.

Parameters
dataLengthDefines the length of the data that shall be sent using SPP.
pDataPoints to data area containing data to be sent.
Return values
trueTransmission succeeded.
falseTransmission failed.

References AppEngine_Connected_State, AppEngineNotifyCallback(), mySppPort, myState, and T2BFSppTx().

Referenced by AppEngineJoystickButton().

void AppEngineJoystickButton ( TAppEngineJoystick  joystick)

Sends a letter for each direction on the joystick.

Parameters
joystickIdentifies what direction the joystick has been pulled in.
Return values
None.

References AppEngine_Down, AppEngine_Left, AppEngine_Push, AppEngine_Right, AppEngine_Up, and AppEngineInternalSendData().

Referenced by app_engine().

void AppEngineNotifyCallback ( TString  textToDisplay)

Callback function used to access write functionality defined by the application.

Parameters
textToDisplayString to print.
Return values
None.

References pMyCb.

Referenced by AppEngineBtCb(), AppEngineConnectButton(), AppEngineInit(), AppEngineInquiryButton(), AppEngineInternalSendData(), AppEngineSelectDeviceButton(), and AppEngineSppCb().

void AppEngineSelectDeviceButton ( void  )

Handles functionality coupled to press of the Select button.

Parameters
None
Return values
None

References AppEngine_Idle_State, AppEngineNotifyCallback(), myBdAddr, myIndex, myState, pMyBdAddress, pMyName, and T2BFENG_MAX_NAME_LENGTH.

Referenced by app_engine().

void AppEngineSppCb ( TT2BFSppEvent  event,
TPort  port 
)

Callback function that handles events related to the SPP connection.

Parameters
eventSpecifies the occurred event.
portIdentifies the port on which the event occurred.
Return values
None.

References AppEngine_Connected_State, AppEngine_Idle_State, AppEngineNotifyCallback(), myBytes, myBytesBuffer, mySppPort, myState, T2BF_SPP_EVENT_CONNECTED, T2BF_SPP_EVENT_CONNECTION_LOST, T2BF_SPP_EVENT_DATA, T2BF_SPP_EVENT_DISCONNECTED, T2BFDiscoverable(), T2BFSppRx(), and T2BFSppRxCount().

Referenced by AppEngineInit().

void AppEngineTimeoutCb ( uint32  value)

uint8 myBytesBuffer[22]

Referenced by AppEngineBtCb(), and AppEngineSppCb().

TUTF16String myName = NULL

Referenced by AppEngineInit().

TT2BFStatus myStatus

Referenced by AppEngineInit().