all groups > dotnet compact framework > january 2006 >
You're in the

dotnet compact framework

group:

IrDA Device Discovery


IrDA Device Discovery BeeEmm
1/31/2006 3:00:30 AM
dotnet compact framework:
I am trying to Discover Device using the following code snippet

byte[] buffer = irdaSocket.GetSocketOption((SocketOptionLevel)0xff,
SocketOptionName.DontRoute, 4 + (maxDevices * 32));

I found this somewhere on the web but I am tring to understand it a bit
more. Does anyone have a reference document that defines :

1. What format the data in "buffer" would be?
2. Why is (SocketOptionLevel)0xff used?
3. Why is SocketOptionName.DontRoute used?

The IRDA protocol I think will be TinyTP since it is windows but I'm
not sure.

By the way I am rolling my own code here because I want to use it on
..NET desktop not on the compact framework, so I cant use the assembly
provided there.

Thanks
BeeEmm
Re: IrDA Device Discovery BeeEmm
1/31/2006 5:53:24 AM
Peter,

Thanks for your reply. I think I have seen this site before but
unfortunately I cannot use it because it does not have source code and
I'm sure it is copyrighted. For my application I cannot use this
assembly.

I need to create my own source code. I would also like to get a better
understanding of IrDA communication within the .NET framework. I
especially want to knwo about the low level message format so I can
decode it.

Thanks
BeeEmm
Re: IrDA Device Discovery Peter Foot [MVP]
1/31/2006 11:42:46 AM
The IrDA classes as part of http://32feet.net work on both Compact and
desktop frameworks. It exposes additional functionality over and above the
..NETCF version.

Peter

--
Peter Foot
Windows Embedded MVP
www.peterfoot.net | www.inthehand.com

[quoted text, click to view]

Re: IrDA Device Discovery Peter Foot [MVP]
1/31/2006 9:21:12 PM
Right, well under the hood it's all based around the IrDA extensions for
winsock which are included in the SDK in af_irda.h. This has all the Socket
Option constants and the definition of the structure used for device
information when you do a discovery.

Peter

--
Peter Foot
Windows Embedded MVP
www.peterfoot.net | www.inthehand.com

[quoted text, click to view]

Re: IrDA Device Discovery Alan J. McFarlane
1/31/2006 10:36:14 PM
Seems Peter beat me to a reply, but I'm rather verbose as usual... :-)

In article news:1138705230.775708.177080@g43g2000cwa.googlegroups.com,
[quoted text, click to view]
Firstly, note that this very very similar to a call from a native
program to the Winsock getsockopt function: there's little difference in
the call and no difference in the return data, so...

[quoted text, click to view]

See
http://www.alanjmcf.me.uk/comms/infrared/Microsoft%20Windows%20IrDA%20programming.html#_Toc97565826

[quoted text, click to view]
See
http://www.alanjmcf.me.uk/comms/infrared/Microsoft%20Windows%20IrDA%20programming.html#_Toc97565825
and the contents for AF_Irda.h; nothing that:
#define SOL_IRLMP 0x00FF
...
#define IRLMP_ENUMDEVICES 0x00000010
And note that SocketOptionName.DontRoute has value 0x10.

For maintainability/understandability I would personally have written:
const int SOL_IRLMP = 0x00FF
const int IRLMP_ENUMDEVICES = 0x00000010
...
byte[] deviceList = sock.GetSocketOption(
(SocketOptionLevel))SOL_IRLMP,
(SocketOptionName)IRLMP_ENUMDEVICES,
SizeofULONG + numToDiscover*SizeofDEVICE_INFO);
(or similar :-) )

[quoted text, click to view]
Yup, see
http://www.alanjmcf.me.uk/comms/infrared/Microsoft%20Windows%20IrDA%20programming.html#_Toc97565837

[quoted text, click to view]
Well I can recommend Peter's 32feet.NET library, why reinvent the wheel?
Of course that depends on whether his license fits your needs...
--
Alan J. McFarlane
http://www.alanjmcf.me.uk/
Please follow-up in the newsgroup for the benefit of all.
Re: IrDA Device Discovery BeeEmm
2/1/2006 3:43:38 AM
Alan and Peter thank you very much for your replies, I think I must be
talking to the 2 IRDA/.NET gurus. Your names appear everywhere on the
search engines.

The details provided are excellent. Alan I was put off a bit my some of
your code as it seemed to be unmanaged C++ MFC-type code. I do not have
access to AF_IrDA.h.

I have a question about a connection. When specifying the service name
in the follwoing call:

client = new IrDAClient(ServiceName);

How important is the service name? What happens with this value through
the IrDA stack and the IrDA message sent?

I have seen the following values:-
"SampleIrDAService"
"IrDAFtp"
"IrDA:IrCOMM"
"IrLPT"
....

Is this just free format text or is it interpreted?

In .NET how do you determine whether the connection will be TinyTP or
IrLMP (Non-TinyTP) mode?

Another thing I would like to clarify is the values passed to
- sock.GetSocketOption( )

What are the valid values for (SocketOptionLevel)?


Thanks,
BeeEmm
Re: IrDA Device Discovery Alan J. McFarlane
2/1/2006 7:36:21 PM
In article news:1138794218.904308.313630@o13g2000cwo.googlegroups.com,
[quoted text, click to view]
There were two pieces of code, the first was two lines of C quoted from
AF_IrDA.h just to show the correct option level and name values to
request an IrDA "enumerate devices" operation, and that they matched the
values (misnamed) in the sample you quoted.

The other bit of code was C# (with at least one typo), that showed doing
the operation and getting a byte array in return. If you prefer VB.NET,
it would be like:
Dim deviceList As byte() = sock.GetSocketOption( _
CType(SOL_IRLMP, SocketOptionLevel), _
CType(IRLMP_ENUMDEVICES, SocketOptionName), _
SizeofULONG + numToDiscover*SizeofDEVICE_INFO)
(with suitable definitions of the four constants)

[quoted text, click to view]
Very important. When one's using TCP/IP the remote service's port
number is required, for instance 80 for HTTP, 25 for SMTP, etc etc.
IrDA locates services by name and thus the service name is required
(behind the scenes the Service Name is used to find a port number, by
querying the peer's IAS (Information Access Service) database, but in
Windows that's handled automagically by the stack).

[quoted text, click to view]
See my "IrDA uses" document
(http://www.alanjmcf.me.uk/comms/infrared/IrDA%20uses%20(brief).html)
for most of the common services one will find. If you're creating both
ends of the connection create a new one of the form "<myCorp>:<MySvc>"
e.g. "ACME:MeterReading", the max length appears to be 64 but you
shouldn't need anywhere near that length...

[quoted text, click to view]
It's pretty much just a byte array that's compared byte by byte, but its
always ASCII really. As I noted above a query of the peer's IAS
database is carried out to find the port number, the name being in the
lookup.

[quoted text, click to view]
As I noted previously, a connection is TinyTP unless set to IrLMP with
the respective socket option.

[quoted text, click to view]
It depends which protocol stack you are delaing with. For IrDA, only
SOL_IRLMP is supported above the socket level's SOL_SOCKET, for TCP/IP
there are IPPROTO_IP and IPPROTO_TCP, see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/socket_options.asp
This is all Winsock stuff, see its documentation, or even BSD sockets
documentation... If you're not experience with sockets and socket
options that's yet another reason to use an IrDAClient class... :-)

BTW MSDN's documentation of the IrDA stack is incomplete and incorrect,
use my reference...
--
Alan J. McFarlane
http://www.alanjmcf.me.uk/
Please follow-up in the newsgroup for the benefit of all.
AddThis Social Bookmark Button