Main Page   File List   File Members  

SlipMootooth_GBI_wht_c_nt.c File Reference

This is the source file of GBI documented. It has most of the functions and the most interesting variables in GBI further described. More...

#include "white_interface.h"

Functions

unsigned int strlen (const char *s)
 Returns the length of a string in byte. More...

char * strcpy (char *to, const char *from)
 Copy a string onto another thus replacing it. More...

void connect (void)
 Where all the fun begins... More...

int vccPrintPdxDebugInfo (const char *format,...)
 To display messages in VCC.

void poin_entry_Init ()
void poin_entry_Run ()

Variables

L2CA_Packet L2CA_packet_out
 The packet prepared to be sent to L2CAP. More...

L2CA_Packet * L2CA_packet_in
 The address of the packet arrived at the L2CA_Packet_In port from L2CAP. More...

L2CA_Packet L2CA_packet
 Where the value of *L2CA_packet_in is copied. More...

int FLAG = 1
 A flag to make sure connect() (Connect Request) is called once only. More...

char in_String [20]
 This is where a string from the game device is stored before it's sent to L2CAP. More...

char out_String [20]
 This is where a string from L2CAP is stored. More...

int connected
 The primary indication of a connection event. More...

int configured
 This is set to 1 when Master and Slave are configured. More...

int connection_established
 This is set to 1 when Master and Slave are connected. More...

TBluetoothDeviceAddress BD_ADDR
 Unique Bluetooth address of target device (48-bit).

ID_t Identifier = 0x00
 This value must match the value received in the L2CA_ConnectInd event.

CID_t CID = 0x00
 Channel Identifier representing local end-point of the communication channel.

Response_t L2CA_response = 0x0
 0x0 indicates a successful operation.

Status_t status = 0x0
 0x0 means "No further information".

OutMTU_t OutMTU = 0x0
 Maximum transmission unit the local channel (LCID) will send.

vccUnsigned32 TokenRate = 0x0
 One of QoS paramters dealing with the traffic characteristics of the outgoing data flow that are specified in Configuration packets' "OutFlow" parameter.

vccUnsighed32 TokenBucketSize = 0x0
 Another QoS parameter within the same flowspec as TokenRate.

vccUnsighed32 PeakBandwidth = 0x0
 Another QoS parameter within the same flowspec as TokenRate.

vccUnsigned32 Latency = 0x0
 Another QoS parameter within the same flowspec as TokenRate.

vccUnsighed32 DelayVariation = 0x0
 Another QoS parameter within the same flowspec as TokenRAte.

Result_t Result = 0x0
 0x0 indicates a successfull operation.

N_t N = 0x0
 Number of bytes transferred to InBuffer in a Read Confirm packet.


Detailed Description

This is the source file of GBI documented. It has most of the functions and the most interesting variables in GBI further described.


Function Documentation

void connect void   
 

Where all the fun begins...

When connect() is called, it will prepare a Connection Request packet by setting up several parameters before the packet is sent to the lower layers.

Where is it called ?
connect() is called the very first time poin_entry_Run() function is executed by the Master only and in order to prevent the second connect() function to be called a flag would be set to false (=0) afterward.

void poin_entry_Init  
 

This function is VCC specific and it's body is executed once by VCC before the program is started. It is often used to initialise variables. Here, the "connected", "configured" and "connection_established" variables are initialised to false (=0).

void poin_entry_Run  
 

VCC keeps itself very busy by looping the input ports of a function unit. Whenever an input port received something, the body of poin_entry_Run() will be executed.

This function can be separated into four parts :

Start_Run_Enabled()
This statement is true when an integer value TRIGGER from GBI-Test has entered GBI's Start_Run port in order that the poin_entry_Run() function in it would be executed for the first time to send a Connection Request.
FLAG and MASTER
If both FLAG and Is_Master conditions hold (are True), the Master GBI would set up a Connection Request packet and send it to L2CAP. Then FLAG is set to false.
Input_Enabled()

When a string enters GBI. The codes that deal with the Input port is activated and executed (Input_Enabled()). GBI copies it into an input buffer "in_string" by calling the strcpy() function. Then it will find out the length of the string in "in_string" buffer when setting up a Write Request packet in order to transfer this string. It will call the strlen() function to archieve that. The result is stored in the variable "Length". In the for loop that follows, the string in the "in_string" buffer will be copied byte by byte into "Outbuffer". In the end the Write Request packet will now carry a string and it will be posted down to L2CAP to the other device.

Write Request
Switches and Cases
This section is the core of GBI. It has the codes for most interface events between GBI and L2CAP. Most of these cases are taken directly from RFCOMM. The main differences are the implementation of Read and Write Requests and the removal of the Disconnection service primitve event. The documentation for each of these cases are documented separately in Interfaces Documentation.

char* strcpy char *    to,
const char *    from
 

Copy a string onto another thus replacing it.

This c library function is called to copy a string from one location to another.

Where is it called ?
strcpy() is called once when a string has entered the Input port and it is then copied into the "in_String" buffer.

		strcpy(in_String, Input_Value());
			  
Parameters:
to is the destination of a copied string, in GBI it is the "in_String" buffer.


from is the source of the string, in GBI it is the string returned by Input_Value().

unsigned int strlen const char *    s
 

Returns the length of a string in byte.

This c library function is called to find out the length of a string in bytes.

Where is it called ?
This function is called twice when GBI is preparing a Write Request packet with the input string that enters into GBI from GBI-Test or the "outside" environment.
Parameter:
s A pointer to location of the string s, here it is the address of the input buffer "in_string".
Returns:
An unsigned integer representing the length of s in byte.


Variable Documentation

int configured
 

This is set to 1 when Master and Slave are configured.

configured is first set to false (=0) in poin_entry_Init().

When either Master or Slave had received a Configuration Indication it will return a Configuration Response packet. Then it will immediately set up a Read Request packet and sends it to L2CAP to be ready for any incoming data. After that configurated is set to true (=1). Usually Slave will be configured just before Master.

int connected
 

The primary indication of a connection event.

connected is first set to false (=0) in poin_entry_Init().

After Slave had received the Connection Indication packet and sent back a Connection Response packet back to the Master, connected is set to true (=1).

However, although it is set to true Master and Slave are NOT truely connected, yet. They are connected when "connection_established" is true. This variable is not very important.

int connection_established
 

This is set to 1 when Master and Slave are connected.

connection_established is also first set to false (=0) in poin_entry_Init().

This variable is set to true (=0) right after where the configured variable is set to true.

Not only it informs the players that the connection has truely been made, it is also used as a flag to prevent any incoming string from the upper layer before a full connection from entering GBI through the Input port.

	     if(Input_Enabled()) { 
	         if(connection_established) { 
	

int FLAG = 1
 

A flag to make sure connect() (Connect Request) is called once only.

connect() is called only by the Master and when the FLAG is true (=1). Then FLAG will be set to false (=0) to make sure that connect() would never be called again.

char in_String[20]
 

This is where a string from the game device is stored before it's sent to L2CAP.

A 20 bytes array of character type that is used for storing aa string from the upper layer (Game).

In this practical the length of a message is limited to less than 20 bytes.

L2CA_Packet L2CA_packet
 

Where the value of *L2CA_packet_in is copied.

Don't really think it is being used at all!

L2CA_Packet* L2CA_packet_in
 

The address of the packet arrived at the L2CA_Packet_In port from L2CAP.

*L2CA_packet_in points to the location of the packet arrived from L2CAP. It is used it the switch statements to check what kind of service incoming packet is asking.

	switch(L2CA_packet_in->Service.__unionTag) {
	    case L2CA_Service_Union_Indication_tag: {
	       switch(L2CA_packet_in->Service.__union.Indication.__unionTag) {
	           case L2CA_Indication_Union_ConnectInd_tag: {
	

L2CA_Packet L2CA_packet_out
 

The packet prepared to be sent to L2CAP.

L2CA_packet_out is the packet of data sent from GBI down to L2CAP. It contains the vital information about the type of service primitive event it is carrying (eg. Connection Request) and the parameter values for such an event. This packet is sent out via the L2CA_Packet_Out port.

char out_String[20]
 

This is where a string from L2CAP is stored.

GBI copies byte by byte the data from the InBuffer of a Read Confirm packet into this 20 bytes array of character type buffer. Then the content in out_String would be posted to the upper layer (Game).


Generated on Sun May 12 18:58:57 2002 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002