00001
00002
00007
00008
00025 #include "white_interface.h"
00026
00039 unsigned int strlen (const char *s);
00040
00056 char * strcpy (char *to, const char *from);
00057
00058
00067 void connect(void);
00068
00069 int vccPrintPdxDebugInfo(const char *format, ...);
00070
00071
00072
00078 L2CA_Packet L2CA_packet_out;
00079
00091 L2CA_Packet *L2CA_packet_in;
00092
00095 L2CA_Packet L2CA_packet;
00096
00097
00102 int FLAG = 1;
00103
00104
00110 char in_String[20];
00111
00115 char out_String[20];
00116
00117
00126 int connected;
00127
00137 int configured;
00138
00155 int connection_established;
00156
00157
00158 TBluetoothDeviceAddress BD_ADDR;
00159 ID_t Identifier = 0x00;
00160 CID_t CID = 0x00;
00161 Response_t L2CA_response = 0x0;
00162 Status_t status = 0x0;
00163 OutMTU_t OutMTU = 0x0;
00164 vccUnsigned32 TokenRate = 0x0;
00165 vccUnsighed32 TokenBucketSize = 0x0;
00166 vccUnsighed32 PeakBandwidth = 0x0;
00167 vccUnsigned32 Latency = 0x0;
00168 vccUnsighed32 DelayVariation = 0x0;
00169
00170
00171 Result_t Result = 0x0;
00172 N_t N = 0x0;
00173
00174
00175 void connect(void) {
00176
00177 if(IsMaster_Value())
00178 vccPrintPdxDebugInfo("%_START_ MASTER : GBI -connect() FIRST CONNECT_REQUEST to LL %_END_");
00179 else
00180 vccPrintPdxDebugInfo("%_START_ SLAVE : SHOULDN'T GET HERE!!! %_END_");
00181
00182
00183
00184 L2CA_packet_out.Service.__unionTag = L2CA_Service_Union_Connect_tag;
00185 L2CA_packet_out.Service.__union.Connect.__unionTag = L2CA_Connect_Union_Request_tag;
00186
00187 L2CA_packet_out.SourceID = 0x02;
00188 L2CA_packet_out.Service.__union.Connect.__union.Request.PSM = 0x3;
00189
00190 L2CA_packet_out.Service.__union.Connect.__union.Request.BD_ADDR.LAP = 0x123456;
00191 L2CA_packet_out.Service.__union.Connect.__union.Request.BD_ADDR.UAP = 0x12;
00192 L2CA_packet_out.Service.__union.Connect.__union.Request.BD_ADDR.NAP = 0x0;
00193
00194
00195 L2CA_Packet_Out_Post(&L2CA_packet_out);
00196
00197
00198 if(IsMaster_Value())
00199 vccPrintPdxDebugInfo("%_START_ MASTER : GBI -connect() ->sent [ConnectRequest] to LL %_END_");
00200 else
00201 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI -connect() SHOULDN't GET HERE!!! %_END_");
00202 }
00203
00204
00209 void poin_entry_Init() {
00210
00211 if(IsMaster_Value())
00212 vccPrintPdxDebugInfo("Master : Entered GBI poin_entry_Init()\n");
00213 else
00214 vccPrintPdxDebugInfo("Slave : Entered GBI poin_entry_Init()\n");
00215
00216
00217 connected = 0;
00218 configured = 0;
00219 connection_established = 0;
00220 }
00221
00222
00262 void poin_entry_Run() {
00263
00264 if(IsMaster_Value())
00265 vccPrintPdxDebugInfo("%_START_ Master : Entered GBI poin_entry_Run() %_END_");
00266 else
00267 vccPrintPdxDebugInfo("%_START_ Slave : Entered GBI poin_entry_Run() %_END_");
00268
00269
00270 if(Start_Run_Enabled()) {
00271
00272 if(IsMaster_Value())
00273 vccPrintPdxDebugInfo("%_START_ Master : Start_Run_Enabled!!! %_END_");
00274 else
00275 vccPrintPdxDebugInfo("%_START_ Slave : Start_Run_Enabled!!! %_END_");
00276 }
00277
00278
00279 if(FLAG) {
00280 if(IsMaster_Value()) {
00281
00282
00283 if(IsMaster_Value())
00284 vccPrintPdxDebugInfo("%_START_ Master : Entered GBI _Run() - ONLY CONNECT()!!!!! %_END_");
00285 else
00286 vccPrintPdxDebugInfo("%_START_ Slave : Shouldn't get here for connection!! %_END_");
00287
00288 FLAG = 0;
00289 connect();
00290 }
00291 }
00292
00293 if(Input_Enabled()) {
00294 if(connection_established){
00295
00296 int j;
00297
00298
00299 strcpy(in_String, Input_Value());
00300
00301
00302 if(IsMaster_Value())
00303 vccPrintPdxDebugInfo("%_START_ MASTER : GBI <-received [%s] from NET!!! %_END_", in_String);
00304 else
00305 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI <-received [%s] from NET!!! %_END_", in_String);
00306
00307
00308
00309 L2CA_packet_out.Service.__unionTag = L2CA_Service_Union_Write_tag;
00310 L2CA_packet_out.Service.__union.Write.__unionTag = L2CA_Write_Union_Request_tag;
00311
00312 L2CA_packet_out.SourceID = 0x02;
00313 L2CA_packet_out.Service.__union.Write.__union.Request.CID = CID;
00314 L2CA_packet_out.Service.__union.Write.__union.Request.Length = strlen(in_String);
00315
00316 for(j = 0; j < strlen(in_String); j++){
00317 L2CA_packet_out.Service.__union.Write.__union.Request.OutBuffer[j] = in_String[j];
00318 }
00319
00320 L2CA_Packet_Out_Post(&L2CA_packet_out);
00321
00322
00323 if(IsMaster_Value())
00324 vccPrintPdxDebugInfo("%_START_ MASTER : GBI ->sent [Write_Request] + String : %s %_END_", in_String);
00325 else
00326 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI ->sent [Write_Request] + String : %s %_END_", in_String);
00327 }
00328 }
00329
00330
00331 L2CA_packet_in = L2CA_Packet_In_Value();
00332 L2CA_packet = *L2CA_packet_in;
00333
00334 switch(L2CA_packet_in->Service.__unionTag) {
00335 case L2CA_Service_Union_Indication_tag: {
00336 switch(L2CA_packet_in->Service.__union.Indication.__unionTag) {
00337 case L2CA_Indication_Union_ConnectInd_tag: {
00338
00339
00340
00341 if(IsMaster_Value())
00342 vccPrintPdxDebugInfo("%_START_ MASTER : GBI <-received [ConnectInd] from LL - return ConnectResponse %_END_");
00343 else
00344 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI <-received [ConnectInd] from LL - return ConnectResponse %_END_");
00345
00346
00347
00348
00349 Identifier = L2CA_packet_in->Service.__union.Indication.__union.ConnectInd.Identifier;
00350 CID = L2CA_packet_in->Service.__union.Indication.__union.ConnectInd.CID;
00351 BD_ADDR = L2CA_packet_in->Service.__union.Indication.__union.ConnectInd.BD_ADDR;
00352
00353
00354 L2CA_packet_out.Service.__unionTag = L2CA_Service_Union_ConnectResponse_tag;
00355 L2CA_packet_out.Service.__union.ConnectResponse.__unionTag = L2CA_ConnectResponse_Union_Response_tag;
00356
00357 L2CA_packet_out.SourceID = 0x02;
00358 L2CA_packet_out.Service.__union.ConnectResponse.__union.Response.BD_ADDR = BD_ADDR;
00359 L2CA_packet_out.Service.__union.ConnectResponse.__union.Response.LCID = CID;
00360 L2CA_packet_out.Service.__union.ConnectResponse.__union.Response.Response = L2CA_response;
00361 L2CA_packet_out.Service.__union.ConnectResponse.__union.Response.Status = status;
00362
00363 L2CA_Packet_Out_Post(&L2CA_packet_out);
00364
00365
00366 if(IsMaster_Value())
00367 vccPrintPdxDebugInfo("%_START_ MASTER : GBI ->sent [ConnectResponse] to LL %_END_");
00368 else
00369 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI ->sent [ConnectResponse] to LL %_END_");
00370
00371
00372 connected = 1;
00373
00374
00375 if(IsMaster_Value())
00376 vccPrintPdxDebugInfo("%_START_ MASTER : Master should never get here!!! %_END_");
00377 else
00378 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI -ConnectInd --- #connected = 1# %_END_");
00379
00380 break;
00381 }
00382 case L2CA_Indication_Union_ConfigInd_tag: {
00383
00384
00385 if(IsMaster_Value())
00386 vccPrintPdxDebugInfo("%_START_ MASTER : GBI <-received [ConfigInd] from LL - return ConfigResponse %_END_");
00387 else
00388 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI <-received [ConfigInd] from LL - return ConfigResponse %_END_");
00389
00390
00391 CID = L2CA_packet_in->Service.__union.Indication.__union.ConfigInd.CID;
00392 OutMTU = L2CA_packet_in->Service.__union.Indication.__union.ConfigInd.OutMTU;
00393 TokenRate = L2CA_packet_in->Service.__union.Indication.__union.ConfigInd.InFlow.TokenRate;
00394 TokenBucketSize = L2CA_packet_in->Service.__union.Indication.__union.ConfigInd.InFlow.TokenBucketSize;
00395 PeakBandwidth = L2CA_packet_in->Service.__union.Indication.__union.ConfigInd.InFlow.PeakBandwidth;
00396 Latency = L2CA_packet_in->Service.__union.Indication.__union.ConfigInd.InFlow.Latency;
00397 DelayVariation = L2CA_packet_in->Service.__union.Indication.__union.ConfigInd.InFlow.DelayVariation;
00398
00399
00400 L2CA_packet_out.Service.__unionTag = L2CA_Service_Union_ConfigurationResponse_tag;
00401 L2CA_packet_out.Service.__union.ConfigurationResponse.__unionTag = L2CA_ConfigurationResponse_Union_Response_tag;
00402
00403 L2CA_packet_out.SourceID = 0x02;
00404 L2CA_packet_out.Service.__union.ConfigurationResponse.__union.Response.CID = CID;
00405 L2CA_packet_out.Service.__union.ConfigurationResponse.__union.Response.OutMTU = OutMTU;
00406 L2CA_packet_out.Service.__union.ConfigurationResponse.__union.Response.InFlow.TokenRate = TokenRate;
00407 L2CA_packet_out.Service.__union.ConfigurationResponse.__union.Response.InFlow.TokenBucketSize = TokenBucketSize;
00408 L2CA_packet_out.Service.__union.ConfigurationResponse.__union.Response.InFlow.PeakBandwidth = PeakBandwidth;
00409 L2CA_packet_out.Service.__union.ConfigurationResponse.__union.Response.InFlow.Latency = Latency;
00410 L2CA_packet_out.Service.__union.ConfigurationResponse.__union.Response.InFlow.DelayVariation = DelayVariation;
00411
00412 L2CA_Packet_Out_Post(&L2CA_packet_out);
00413
00414
00415 if(IsMaster_Value())
00416 vccPrintPdxDebugInfo("%_START_ MASTER : GBI ->sent [ConfigResponse] to LL %_END_");
00417 else
00418 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI ->sent [ConfigResponse] to LL %_END_");
00419
00420
00421
00422 L2CA_packet_out.Service.__unionTag = L2CA_Service_Union_Read_tag;
00423 L2CA_packet_out.Service.__union.Read.__unionTag = L2CA_Read_Union_Request_tag;
00424
00425 L2CA_packet_out.SourceID = 0x02;
00426 L2CA_packet_out.Service.__union.Read.__union.Request.CID = CID;
00427 L2CA_packet_out.Service.__union.Read.__union.Request.Length = 1504;
00428
00429 L2CA_Packet_Out_Post(&L2CA_packet_out);
00430
00431
00432 if(IsMaster_Value())
00433 vccPrintPdxDebugInfo("%_START_ MASTER : GBI -ConfigInd ->sent [Read_Request] to LL %_END_");
00434 else
00435 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI -ConfigInd ->sent [Read_Request] to LL %_END_");
00436
00437 configured = 1;
00438
00439
00440 if(IsMaster_Value())
00441 vccPrintPdxDebugInfo("%_START_ MASTER : GBI -ConfigInd --- #configured = 1# %_END_");
00442 else
00443 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI -ConfigInd --- #configured = 1# %_END_");
00444
00445 connection_established = 1;
00446
00447
00448 if(IsMaster_Value())
00449 vccPrintPdxDebugInfo("%_START_ Master : GBI -ConfigIndication --- #connection_established = 1# %_END_");
00450 else
00451 vccPrintPdxDebugInfo("%_START_ Slave : GBI -ConfigIndication --- #connection_established = 1# %_END_");
00452
00453
00454 break;
00455 }
00456
00457 case L2CA_Indication_Union_DisconnectInd_tag: {
00458 break;
00459 }
00460
00461 default:
00462 vccPrintPdxDebugInfo("%_START_ Error: default case in Service->Indication switch reached %_END_");
00463 break;
00464 }
00465 break;
00466 }
00467 case L2CA_Service_Union_Connect_tag: {
00468 CID = L2CA_packet_in->Service.__union.Connect.__union.Confirm.LCID;
00469
00470
00471 if(IsMaster_Value())
00472 vccPrintPdxDebugInfo("%_START_ MASTER : GBI <-received [ConnectConfirm] from LL - return ConfigRequest %_END_");
00473 else
00474 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI <-received [ConnectConfirm] from LL - return ConfigRequest %_END_");
00475
00476
00477 L2CA_packet_out.Service.__unionTag = L2CA_Service_Union_Configure_tag;
00478 L2CA_packet_out.Service.__union.Configure.__unionTag = L2CA_Configure_Union_Request_tag;
00479
00480 L2CA_packet_out.SourceID = 0x02;
00481 L2CA_packet_out.Service.__union.Configure.__union.Request.CID = CID;
00482 L2CA_packet_out.Service.__union.Configure.__union.Request.InMTU = 0x2A0;
00483 L2CA_packet_out.Service.__union.Configure.__union.Request.OutFlow.TokenRate = 0x00;
00484 L2CA_packet_out.Service.__union.Configure.__union.Request.OutFlow.TokenBucketSize = 0x00;
00485 L2CA_packet_out.Service.__union.Configure.__union.Request.OutFlow.PeakBandwidth = 0x00;
00486 L2CA_packet_out.Service.__union.Configure.__union.Request.OutFlow.Latency = 0x00;
00487 L2CA_packet_out.Service.__union.Configure.__union.Request.OutFlow.DelayVariation = 0x00;
00488 L2CA_packet_out.Service.__union.Configure.__union.Request.OutFlushTO = 0x1;
00489 L2CA_packet_out.Service.__union.Configure.__union.Request.LinkTO = 0x7d0;
00490
00491 L2CA_Packet_Out_Post(&L2CA_packet_out);
00492
00493
00494 if(IsMaster_Value())
00495 vccPrintPdxDebugInfo("%_START_ MASTER : GBI ->sent [ConfigRequest] to LL %_END_");
00496 else
00497 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI ->sent [ConfigRequest] to LL %_END_");
00498
00499 break;
00500 }
00501 case L2CA_Service_Union_Configure_tag: {
00502
00503
00504
00505 if(IsMaster_Value())
00506 vccPrintPdxDebugInfo("%_START_ MASTER : GBI <-received [ConfigureConfirm] from LL - return Read_Request %_END_");
00507 else
00508 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI <-received [ConfigureConfirm] from LL - return Read_Request %_END_");
00509
00510
00511 L2CA_packet_out.Service.__unionTag = L2CA_Service_Union_Read_tag;
00512 L2CA_packet_out.Service.__union.Read.__unionTag = L2CA_Read_Union_Request_tag;
00513
00514 L2CA_packet_out.SourceID = 0x02;
00515 L2CA_packet_out.Service.__union.Read.__union.Request.CID = CID;
00516 L2CA_packet_out.Service.__union.Read.__union.Request.Length = 1504;
00517
00518 L2CA_Packet_Out_Post(&L2CA_packet_out);
00519
00520
00521 if(IsMaster_Value())
00522 vccPrintPdxDebugInfo("%_START_ MASTER : GBI -Configure ->sent [Read_Request] to LL %_END_");
00523 else
00524 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI -Configure ->sent [Read_Request] to LL %_END_");
00525
00526
00527 configured = 1;
00528
00529
00530 if(IsMaster_Value())
00531 vccPrintPdxDebugInfo("%_START_ MASTER : GBI -Configure --- #configured = 1# %_END_");
00532 else
00533 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI -Configure --- #configured = 1# %_END_");
00534
00535
00536 connection_established = 1;
00537
00538
00539 if(IsMaster_Value())
00540 vccPrintPdxDebugInfo("%_START_ MASTER : GBI -Configure --- #connection_established = 1# %_END_");
00541 else
00542 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI -Configure --- #connection_established = 1# %_END_");
00543
00544
00545
00546 Set_Post(1);
00547
00548
00549 if(IsMaster_Value())
00550 vccPrintPdxDebugInfo("%_START_ MASTER : GBI -ConfigInd ->sent [Set_Post(1)] to NET %_END_");
00551 else
00552 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI -ConfigInd ->sent [Set_Post(1)] to NET %_END_");
00553
00554 break;
00555 }
00556 case L2CA_Service_Union_Read_tag: {
00557 int i;
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567 if(IsMaster_Value())
00568 vccPrintPdxDebugInfo("%_START_ MASTER : GBI ->received [Read_Confirm] from LL - return Read_Request %_END_");
00569 else
00570 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI ->received [Read_Confirm] from LL - return Read_Request %_END_");
00571
00572
00573
00574 Result = L2CA_packet_in->Service.__union.Read.__union.Result.Result;
00575 N = L2CA_packet_in->Service.__union.Read.__union.Result.N;
00576
00577
00578 for(i = 0; i < N; i++){
00579 out_String[i] = L2CA_packet_in->Service.__union.Read.__union.Result.InBuffer[i];
00580 }
00581 out_String[N] = 0;
00582
00583
00584 Output_Post(out_String);
00585
00586
00587 if(IsMaster_Value())
00588 vccPrintPdxDebugInfo("%_START_ MASTER : GBI -Read ->sent [%s] to NET %_END_", out_String);
00589 else
00590 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI -Read ->sent [%s] to NET %_END_", out_String);
00591
00592
00593
00594 L2CA_packet_out.Service.__unionTag = L2CA_Service_Union_Read_tag;
00595 L2CA_packet_out.Service.__union.Read.__unionTag = L2CA_Read_Union_Request_tag;
00596
00597 L2CA_packet_out.SourceID = 0x02;
00598 L2CA_packet_out.Service.__union.Read.__union.Request.CID = CID;
00599 L2CA_packet_out.Service.__union.Read.__union.Request.Length = 1504;
00600
00601 L2CA_Packet_Out_Post(&L2CA_packet_out);
00602
00603
00604 if(IsMaster_Value())
00605 vccPrintPdxDebugInfo("%_START_ MASTER : GBI -Read ->sent [Read_Request] to LL %_END_");
00606 else
00607 vccPrintPdxDebugInfo("%_START_ SLAVE : GBI -Read ->sent [Read_Request] to LL %_END_");
00608
00609 break;
00610 }
00611 case L2CA_Service_Union_Write_tag: {
00612
00613 break;
00614 }
00615 default:
00616 vccPrintPdxDebugInfo("%_START_ Error: default case in Service switch reached %_END_");
00617 break;
00618 }
00619 }
00620 }