|
|
User login
Feeds |
Sending String via Bluetooth
|
|||||
| Wed, 2003-12-03 10:39 | |
|
Hi !! So, another question for you Symbian Guru !! Let's Start !! I've done the follow: _LIT(KFormat,"[%c]"); TBuf<2> first; first.Format(KFormat,65); // I Get 'A' TBuf<2> second; second.Format(KFormat,66); // I Get 'B' It work. NOW I've to send them via Bluetooth both at the same time, so I need to send AB, right ?? But If I do this: RSocket iSendingSocket; iSendingSocket.Write(first && second, iStatus); It's wrong, that for sure.. How is it possible to send first and second in a string by using BT ![]() Any ideas ![]() Screener_it |
|
Forum posts: 70
It is very Simple
_LIT(KFormat,"[%c,%c]");
first.Format(KFormat,65,66); // I Get 'A' and 'B'
To learn Symbian U have to try it yourself !!. Asking continues questions always will not help !
MeenuJ
Forum posts: 11
It is very Simple
_LIT(KFormat,"[%c,%c]");
first.Format(KFormat,65,66); // I Get 'A' and 'B'
To learn Symbian U have to try it yourself !!. Asking continues questions always will not help !
MeenuJ
As i see the KFormat example above, it's a bit much for a relatively simple conversion of two characters. - Is there anywhere somone has written something about this?
Regards
Forum posts: 100
You can use a Lexer object to convert from TReal to TDesC8. To convert HBuf into a TDesC8 assign the output of its Des method to a new TDesC8.
Regards, Aljaz
Forum posts: 73
void CMessageClient::Create()
{
TBuf<256> tgt;
TBuf8<256> iMessagge;
_LIT(KFormat,"%c%c%c");
tgt.Format(KFormat,65,66,65^66);
Convert(tgt);
}
void CMessageClient::Convert(TDesC16& aUnicode)
{
CnvUtfConverter::ConvertFromUnicodeToUtf8(iMessagge, aUnicode);
}
So, when I want to send the string I just call
void CMessageClient::Send()
{
iSendingSocket.Write(iMessagge, iStatus);
SetActive();
}
And it works good. I'm sorry menuji if I post too many question in the forum... I'm a newbie and I try to do by myself but it's quite hard.
When I was able to do I answer I have done it, when I need help I have always say "Please" and never post it multiple times...
That's all.
Sorry for the bad english, hope you understand.
Screener_it
Forum posts: 11
You can use a Lexer object to convert from TReal to TDesC8. To convert HBuf into a TDesC8 assign the output of its Des method to a new TDesC8.
Regards, Aljaz
Hi, now i might sound silly, but here goes.
I need to get from a TReal to a TDesC8 (via. bt) and from a TDesC8 to a TReal again.
This is causing me quite some problems. I never thourght would be this complicated. I've written a almost complete application sending and reveiving messages via BlueTooth, but can I get from a TDesc8 to a TReal and back? ...
It's only a matter of taking 4 (or
Forum posts: 11
Solution was:
go from TDesC8 to TReal32
aBuffer is a TDesC8 returned from the BTEngine.
TPtrC8 TempPtrC8 = aBuffer.Mid(2,3); //Picks out the right characters
TLex8 TempLex = TLex8(TempPtrC8); //Create TLex8 from it.
TReal32 TempReal32; //Real for the result.
if (TempLex.Val(TempReal32)!=KErrNone) { // do the conversion.
_LIT(KERROR,"Error converting from LEX to REAL");
iEnv->InfoMsg(KERROR);
}
And the other way from TReal32 to TDesC8 :
TPtr8 buf = iOutBuffer->Des();
buf.Zero(); //empty buf
... put some other two bytes into buf.
TBuf<8> TempReal; //new temp TBuf
TempReal.Num(aRating,TRealFormat(3,1)); //Put aRating (TReal32) into TempReal
for (TInt i=0;i<TempReal.Length();i++) //append it the the original buf.
{
buf.Append(TempReal[i]);
}