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.
[/QUOTE]
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)
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?
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).
I have seen the following values:-
"SampleIrDAService"
"IrDAFtp"
"IrDA:IrCOMM"
"IrLPT"
...
See my "IrDA uses" document
(
http://www.alanjmcf.me.uk/comms/infrared/IrDA uses (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...
Is this just free format text or is it interpreted?
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.
In .NET how do you determine whether the connection will be TinyTP or
IrLMP (Non-TinyTP) mode?
As I noted previously, a connection is TinyTP unless set to IrLMP with
the respective socket option.
Another thing I would like to clarify is the values passed to
- sock.GetSocketOption( )
What are the valid values for (SocketOptionLevel)?
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...