×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    1

    Infrared socket connection between Symbian device and Windows

    Hi,

    I am having peculiar difficulties with infrared sockets. I have
    created a simple application that sends and receives data via an
    infrared socket connection, acting either as a server (listening on a
    socket) or a client (doing the discovery). A similar application
    exists for Windows as well. The problem is that the infrared socket
    connection between two Symbian devices or between two Windows machines
    works perfectly, but when the machines are mixed the data flows only
    to Symbian device but not to the Windows machine. The situation is the
    same regardless which device (Symbian or Windows) is acting as a
    server or what versions of Windows (NT, 2000, 98) or Symbian devices
    (9210, 7650) are used.

    At this point I am not sure whether the culprit is the Symbian or
    Windows application, but I would like to know whether anyone has
    succeeded in creating a working two-way irda socket connection between
    a Symbian device and a Windows machine.

    ++Vespe

  2. #2
    Registered User
    Join Date
    Mar 2003
    Location
    Kiev, Ukraine
    Posts
    20
    Same with me except I didn't try all the combinations as you did.

    At this point my connection solution is using RCommServ and RComm. And no sockets.
    Last edited by bobline; 2003-04-16 at 14:24.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    25
    The following works fine for me, between any IR capable devices,
    including windows.

    IRDA server:
    =============================================
    TProtocolName protoName(KTxtIrTinyTP);
    TProtocolDesc proto;

    TInt err = iSocketServ.FindProtocol(protoName, proto);
    if (err)
    return EFalse;

    err = iListenSock.Open(iSocketServ, proto.iAddrFamily, proto.iSockType, proto.iProtocol);
    if (err)
    return EFalse;

    TIrdaSockAddr iAddress;
    // not sure if you can just omit setting the port
    int port = 4;
    iAddress.SetPort(port);
    err = iListenSock.Bind(iAddress);
    if (err)
    return EFalse;

    RNetDatabase aNetdb;
    err = aNetdb.Open(iSocketServ, proto.iAddrFamily, proto.iProtocol);
    if (err)
    return EFalse;

    TIASDatabaseEntry entry;

    entry.SetClassName(_L(8"MYService"));
    entry.SetAttributeName(_L8("IrDA:TinyTP:LsapSel"));
    entry.SetToInteger(port);
    aNetdb.Add(entry);
    aNetdb.Close();

    err = iListenSock.Listen(1);
    if (err)
    return EFalse;


    iSock.Open(iSocketServ); // Open abstract socket
    if (err)
    return EFalse;

    TRequestStatus iStatus(KRequestPending);
    iListenSock.Accept(iSock, iStatus);
    User::WaitForRequest(iStatus);

    iListenSock.CancelAccept();
    return EFalse;
    ========================================

    IRDA client:
    ========================================
    TInt err;

    TProtocolName protoName(KTxtIrTinyTP);
    TProtocolDesc proto;

    err = iSocketServ.FindProtocol(protoName, proto);
    if (err)
    return EFalse;

    err = iResolver.Open(iSocketServ, proto.iAddrFamily, proto.iProtocol);
    if (err)
    return EFalse;

    TInt i = 0;
    TIrdaSockAddr iAddress;
    // set the address using the resolver
    ....

    err = iSock.Open(iSocketServ, proto.iAddrFamily, proto.iSockType, proto.iProtocol);
    if (err)
    return EFalse;

    RNetDatabase aNetdb;
    err = aNetdb.Open(iSocketServ, proto.iAddrFamily, proto.iProtocol);
    if (err)
    return EFalse;

    TUint remDevAddr = iAddress.GetRemoteDevAddr();
    TInt port = IASQuery(aNetdb, KTxtIrDAMophun, KTxtIrDATinyTP, remDevAddr);
    iNetdb.Close();

    if (port < 0)
    return EFalse;

    iAddress.SetPort(port);

    TRequestStatus aStatus;
    iSock.Connect(iAddress, aStatus);
    User::WaitForRequest(aStatus);

    // aStatus reflects connection result

    =============================================

    // IASQuery function copied from SDK
    TInt IASQuery(RNetDatabase &aIAS,const TDesC8 &aClassName,
    const TDesC8 &aAttributeName,TUint aRemDevAddr)
    //
    // Synchronous IAS query. RTimer timeout of 5 seconds on the query.
    //
    {
    TIASQuery querybuf(aClassName,aAttributeName,aRemDevAddr);
    TRequestStatus stat1,stat2;
    TIASResponse results;

    aIAS.Query(querybuf,results,stat2);
    RTimer tim;
    tim.CreateLocal();
    tim.After(stat1,5000000L);
    User::WaitForRequest(stat1,stat2);

    if (stat1.Int()==KErrNone) // TIMER COMPLETED - IAS QUERY
    { // REQUEST HAS TIMED OUT.
    aIAS.Cancel();
    return KErrNotFound;
    }

    tim.Cancel();
    if (stat2.Int()==KErrNone) // IAS QUERY COMPLETED OK.
    {
    switch(results.Type())
    {
    case EIASDataMissing: // Missing
    break;

    case EIASDataInteger: // Integer
    TInt num;
    if (results.GetInteger(num)==KErrNone)
    return TUint8(num);
    else
    {
    // Bad type
    }
    break;

    case EIASDataOctetSequence: // Byte sequence
    //results.GetOctetSeq(res);
    //DumpBuf(res);
    break;

    case EIASDataUserString: // String. Use
    break; // results.GetCharString8()
    // to get string

    default: // Bad type
    break;
    }
    }
    else if (stat2.Int()!=KErrNone) // IAS QUERY COMPLETED
    { // UNSUCCESSFULLY.
    switch (stat2.Int())
    {
    case KErrUnknown: // No such attribute
    break;

    case KErrBadName: // No such class
    break;

    default: // Unknown error
    break;
    }
    }
    else
    {
    // Unknown error on IAS query
    }

    return KErrNotFound;
    }

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    8

    the code does not work for me

    thank you for your code first
    but when I integrate it to my code,complie and run
    and the problem occured.the debugger poped(vc6)
    and if i chose to go on,the "kenal erroe..."will pop in the emulator
    the problem is the same with the code in the sdk
    "How to create a simple beaming application"
    why is that?
    Thanks!

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    25
    I never use the emulator when using anything
    network/socket related so I don't know
    whether my app worked in the emulator or
    not.

    Are you sure IrDA sockets work in the
    emulator? Perhaps it is only the IRCOMM
    serial port that works?

    -Anders

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    8
    well I do not know if they would work under emulator
    If not,the debuging process must be annoying
    recompile,package,sis......

  7. #7
    Regular Contributor
    Join Date
    Jun 2003
    Posts
    73
    to bobline:when I use irComm,pc side can not receive anything
    from 7650,though connection is set.and do you install irComm drivers for 2000 and xp?if not, irComm still work?
    thanks!

    steven2ffff@vip.sina.com

  8. #8
    Registered User
    Join Date
    Mar 2003
    Posts
    25
    Do you mean IrCOMM as with an emulated
    serial port on the PC? I have never tried that.
    I'm not sure you can use IrCOMM with
    IrDA sockets on symbian, I think you have
    to use the serial driver.

    -Anders

  9. #9
    Regular Contributor
    Join Date
    Jun 2003
    Posts
    73
    but I think irComm IS emulated serial port
    isn't it?and which port do you use to get income data?
    ever tried ir printing and glass term?

  10. #10
    Registered User
    Join Date
    Mar 2003
    Location
    Kiev, Ukraine
    Posts
    20
    To steven2ffff:

    I am not using PC, I am writing on Mac. I don't have any problems with IrDA here.

  11. #11
    Registered User
    Join Date
    Jul 2003
    Posts
    14
    Hi can anyone help me out? i trying to use the simple beaming application and try to run the send program but then it crash as it cannot open the RHostresolver even though i put in the right parameters. Does anyone noe why? and could anyone be kind to post out their full workable infra coding?

  12. #12
    Registered User
    Join Date
    Mar 2003
    Posts
    4

    more connection problems :(

    Hi,

    I've been having similar problems, and I wondered if anyone might be able to help?

    I've been trying to send data between a pc (winxp) and a nokia 3650. I've been through the posts on this forum and I've managed to get some stuff working.

    I have a server running on the PC which opens a socket and binds it to an address...

    SOCKADDR_IRDA ServSockAddr = { AF_IRDA, 0, 0, 0, 0, "MyIrDAService" };

    It then listens for an connections.

    The client runs on the phone, and discovers the PC and finds the port using IASQuery (from the API reference), with "MyIrDAService" as the classname, and "IrDA:TinyTP:LsapSel" as the attribute.

    I can then connect the socket to that address/port, and that all works fine. On the PC, accept completes and it all looks like everything's going well... but then I try and send stuff!

    I call

    _LIT8(KSomeData, "some data");
    iSock.Send(KSomeData, KExpeditedDataOpt, aStatus);
    User::WaitForRequest(aStatus);

    to send some data to the PC, and on the PC I just call

    len = recv(client_sock, buf, sizeof(buf), 0);

    on the connected socket. The send call returns, and WaitForRequest returns ok - and I can do that several times with no problem. recv never returns though... at least not until the client closes the socket, at which point it returns 0 (I don't get any errors from WSAGetLastError() either).

    Does anyone have any ideas why I might be able to establish a connection, but not be able to actually receive any data, even though the send seems to be working?

    thanks in advance,
    Tony.

  13. #13
    Registered User
    Join Date
    Mar 2003
    Posts
    4

    solved (partially)

    Hi,

    I think I've gone some way to solving this... I was using some example code from msdn for the server, and that code was setting some IrCOMM IAS attributes. As the IAS entry already exists (or at least I think it should do), there's no need to do that, and in fact messing about with it seems to break it

    So, I just took that code out and now I can receive some data from the phone. Currently not everything I send get received, but it's better than it was!

    Anyway, thought I'd post this in case anyone else has this problem.

    cheers,
    Tony.

  14. #14
    Registered User
    Join Date
    Oct 2003
    Posts
    2

    Nokia 3650 to WIn

    Hi folks,

    Sounds like many of us have struggled with the same problems. I've been trying to get a simple send/receive application between a 3650 and a WinPC to work for sometime now. Very frustrating! I wish the Symbian documentation was better.

    My server runs on the PC and the client on the 3650. At this point I can discover the server, query my service using IAS and connect to it from the 3650. So far, so good. But I can't seem to be able to send or receive anything. Send just hangs (never returns) and receive returns with error -5 (NotSupported)! As far as I know, I'm doing nothing special that should cause this failure. Any help would be much appreciated.

    A second question, I tried discovery using the HostResolver and the Ioctl discovery indicator. If there is no peer, HostResolver returns with an error immediately, which means I need to loop constantly. The Ioctl blocks until a peer is discovered (good) but then the socket connect fails (bad)! Any insights?

    My PC server is your basic code:
    - load winsock
    - create socket
    - bind
    - listen
    - accept(new sock)
    - send/recv on new sock

    The 3650 code is:
    - connect to socket server
    - force load of TinyTP protocol
    - open socket
    - open host resolver
    - get by name
    - do IAS lookup, set address
    - connect
    - send/recv on socket

    Thanks in advance,

    Nitin

  15. #15
    Registered User
    Join Date
    Mar 2003
    Posts
    25

    RecvOneOrMore not supported

    RecvOneOrMore does not work, god knows why, but Recv
    seems to work.

    There is another problem: if you call Recv, but only read part
    of the data that was received the rest of the data seems to be
    lost.

    I solved this by always doing reads that are always the
    size of the receive buffer and then extract the parts
    of the data I need.

    You can get the size of the receive buffer by calling:
    TPckgBuf<TUint> recvLen;
    GetOpt(KSORecvBuf, KSOLSocket, recvLen);

    -Anders

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •