hti/HtiFramework/src/HtiCommAdapter.cpp
changeset 13 33016869e0dd
parent 0 a03f92240627
equal deleted inserted replaced
0:a03f92240627 13:33016869e0dd
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include "HtiCommAdapter.h"
    19 #include "HtiCommAdapter.h"
    20 #include "HtiDispatcher.h"
    20 #include "HtiDispatcher.h"
    21 #include "HTICommPluginInterface.h"
    21 #include "HtiCommPluginInterface.h"
    22 #include "HtiMessage.h"
    22 #include "HtiMessage.h"
    23 #include "HtiNotifier.h"
    23 #include "HtiNotifier.h"
    24 
    24 
    25 #include "HTILogging.h"
    25 #include "HtiLogging.h"
    26 
    26 
    27 //default value for max message size for incoming messages
    27 //default value for max message size for incoming messages
    28 //used if value in constructor is not valid (<0)
    28 //used if value in constructor is not valid (<0)
    29 const static TInt KMaxMessageSize = 10 * 1024; // 10 KB
    29 const static TInt KMaxMessageSize = 10 * 1024; // 10 KB
    30 
    30 
   211             }
   211             }
   212         }
   212         }
   213     // USB errors from d32usbc.h
   213     // USB errors from d32usbc.h
   214     else if ( -6700 > iStatus.Int() && iStatus.Int() > -6712 )
   214     else if ( -6700 > iStatus.Int() && iStatus.Int() > -6712 )
   215         {
   215         {
       
   216         if(iDispatcher->CommReconnect())
       
   217             {
       
   218             return;
       
   219             }
       
   220 
   216         if ( iDispatcher->GetShowErrorDialogs() )
   221         if ( iDispatcher->GetShowErrorDialogs() )
   217             {
   222             {
   218             TBuf<48> errorText;
   223             TBuf<48> errorText;
   219             errorText.Append( _L( "USB connection lost (" ) );
   224             errorText.Append( _L( "USB connection lost (" ) );
   220             errorText.AppendNum( iStatus.Int() );
   225             errorText.AppendNum( iStatus.Int() );
   224         User::Exit( KErrDisconnected );
   229         User::Exit( KErrDisconnected );
   225         }
   230         }
   226     else if ( iStatus == KErrDisconnected )
   231     else if ( iStatus == KErrDisconnected )
   227         {
   232         {
   228         // This happens if Bluetooth connection is lost.
   233         // This happens if Bluetooth connection is lost.
       
   234         if(iDispatcher->CommReconnect())
       
   235             {
       
   236             return;
       
   237             }
       
   238         
   229         if ( iDispatcher->GetShowErrorDialogs() )
   239         if ( iDispatcher->GetShowErrorDialogs() )
   230             {
   240             {
   231             CHtiNotifier::ShowErrorL(
   241             CHtiNotifier::ShowErrorL(
   232                     _L( "Connection lost. HTI stopped." ), KErrDisconnected );
   242                     _L( "Connection lost. HTI stopped." ), KErrDisconnected );
   233             }
   243             }
   257                 }
   267                 }
   258             else
   268             else
   259                 {
   269                 {
   260                 HTI_LOG_FORMAT( "Error %d, reissue request", iStatus.Int() );
   270                 HTI_LOG_FORMAT( "Error %d, reissue request", iStatus.Int() );
   261                 iDispatcher->Notify( iStatus.Int() );
   271                 iDispatcher->Notify( iStatus.Int() );
       
   272                 User::After(2000000);
   262                 ReceiveMessage();
   273                 ReceiveMessage();
   263                 }
   274                 }
   264             break;
   275             break;
   265         case EReceivingCont:
   276         case EReceivingCont:
   266             //process
   277             //process
   287                 HTI_LOG_TEXT( "and dismiss received HTI msg beginning" );
   298                 HTI_LOG_TEXT( "and dismiss received HTI msg beginning" );
   288                 delete iMsgToReceive;
   299                 delete iMsgToReceive;
   289                 iMsgToReceive = NULL;
   300                 iMsgToReceive = NULL;
   290 
   301 
   291                 iDispatcher->Notify( iStatus.Int() );
   302                 iDispatcher->Notify( iStatus.Int() );
   292 
   303                 User::After(2000000);
   293                 ReceiveMessage();
   304                 ReceiveMessage();
   294                 }
   305                 }
   295             break;
   306             break;
   296         case ESending:
   307         case ESending:
   297             HTI_LOG_TEXT( "ESending" );
   308             HTI_LOG_TEXT( "ESending" );