[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bluetooth-dev] RE: Data stream and SCO Problem



 These are he routines i use to transmit 8bit binary correctly across the
 link (rs232).  This is in BP7/Delphi syntax, but can be easly ported into
 CPP. Another thing, make sure that your bytes are in network byte ordering
 or the remote might spew NAKs at you.

 The PPP routines below MAY not work in a actually PPP environment as I have
 not tested them.. My netlib is totally ****ed up.

 BTW! anyone have a 8bit Hamming encoder/decoder routine ? :-) As per my
 comments below I am not comfortible working at bit level.

procedure sendbyte(b : byte);
begin
     asyncsend(char(b));
end;
Procedure sendword(w:word);
Begin
     sendbyte(w shr 8);        { high byte }
     sendbyte(w and $00ff);    { low byte  }
end;
Procedure sendint(i:integer);
Begin
     sendbyte((i shr 8)); { highorder }
     sendbyte(lo(i));     { loworder  }
end;
Procedure sendlong(l:longint);
Begin
     sendword((l shr 16)); { highorder }
     sendbyte(hi(l)); sendbyte(lo(l)); { loworder  }
{ 32bit hex = 12345678h
  highorder = 1234 <= b shr 16
  loworder  = 5678 <= hi(b) lo(b) }
end;
procedure readword(var w : word);  { read two-byte word from datastream }
var x     : word;
begin
     x := $0000;
     x := ord(asyncread);
     w := (x shl 8) or ord(asyncread);
end;
procedure readint(var i : integer); { read two-byte integer from datastream }
var w : word;
begin
     readword(w);
     {$R-} i := integer(w); {$R+}
     { c1 := asyncread; c2 := asyncread;
       val(c1+c2, i, x); <--interesting how this from DD+ 5.0 didnt even work}
end;
procedure readlong(var l : longint);  { read four-byte word from datastream }
var x,y   : word;
begin
     readword(x); readword(y);
     l := x;
     l := (l shl 16) or y;
     { l := (x shl 32) or y;
       duh,  bits give me the willies. LOAD LOW then SHIFT UP }
end;
procedure PPP_sendbyte(b : byte);
{ Transmits a byte onto the PPP datastream, encrypting it if nessesary.      }
{ Compatible with PPP protocol frame. Adapted from iNET1.1 source.           }
begin
     if NOT (b in [$0..$20,$7d,$7e]) then sendbyte(b) else
        Begin
             sendbyte($7d); sendbyte((b xor $20));
        end;
end;
function PPP_readbyte : byte;                  { Reads from a PPP datastream }
var b : byte;
begin
     b := $00;
     b := ord(asyncread);
     if (b = $7d) then b := (ord(asyncread) xor $20); { get & decrypt it }
     PPP_readbyte := b;
end;
function PPP_readword : word;  { read two-byte word from datastream }
var x : word;
begin
     x := PPP_readbyte;
     x := (x shl 8) or PPP_readbyte;
     PPP_readword := x;
end;


ttyl,
-tkp (1:203/4269@xxxxxxx.stops to reply!
reply-to: teknopup@xxxxxxx.com
webpages: http://<B>tkp.darktech.org</B>, <B>download.at/dmsoft</B>, <B>rivercitycac.dtdns.net</B>
telnet: oasis.digitalatoll.darktech.org <-- Until i get packet.lib fixed:(
bbs: +1-916-381-3250,,,#22,#22  33.6kbps v34b/v42b/v90c 24/7 <-- direct dial up
-----------------------------------------------------------------------------
(_'---------------------------------------'_)
(_.=======================================._) My bone about your bone... 
-----------------------------------------------------------------------------


-On 10/09/2001, Lukas Valle <va tuned the radio for [bluetooth-dev] Data-

---[quoted material follows]-------
L>Hi all
L>
L>We have 2 Problems. At first we try to send data over a normal ACL Link.
L>If we send only text it works fine. But if we send binary data we have
L>only rubish on the receiver side. We analyzed the data and saw that the
L>transfer works fine, until we send 0x11 XON or 0x13 XOFF. The bytes
L>after 
L>that Byte are in false order (45 47 89 00 instead of 47 45 00 89).
L>How are you transfer binary data over ACL, if you don't want to use ppp? 
L>
L>The second problem is how to establish an SCO connection. Should we set
L>"define SCO_Link" to 1 in hci.c? We added an hci_add_sco_connection
L>function call to the btcon.c. But we can't compile it. We get all the
L>time an undefined reference error during compiling.
L>
L>Thanks for any help and input
---[end quoted material]---


--- Remember:  Modem sex begins with a "handshake"
*** MYREADER v.3.20.1999.07.25.r88; made for Net-tamer.

-
To unsubscribe from this list: send the line "unsubscribe bluetooth-dev" in
the body of a message to majordomo@xxxxxxx.com