Domanda
Mi chiedo se qualcuno sia riuscito a creare un codice funzionante per l'invio di messaggi binari (per configurare i telefoni Symbian) e abbia anche qualche esempio di dati binari. Finora tutti i campioni che ho trovato non riescono a uscire dalla Posta in uscita o a non tornare più.
// Current entry is the Draft folder.
iSmsMtm->SwitchCurrentEntryL( KMsvDraftEntryId );
// Create a new SMS message entry as a child of the current context.
iSmsMtm->CreateMessageL( KUidMsgTypeSMS.iUid );
CMsvEntry& serverEntry = iSmsMtm->Entry();
TMsvEntry entry( serverEntry.Entry() );
/* Send Binary SMS */
CSmsHeader &hdr = iSmsMtm->SmsHeader();
CSmsMessage &msg = hdr.Message();
CSmsPDU &pdu = msg.SmsPDU();
CSmsUserData &userdata = pdu.UserData();
// Set the DCS byte
pdu.SetBits7To4(TSmsDataCodingScheme::ESmsDCSTextUncompressedWithNoClassInfo);
pdu.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabet8Bit);
pdu.SetClass(ETrue, TSmsDataCodingScheme::ESmsClass2);
char buf[]= {...}; //my binary data, 247 bytes long
// Construct a dummy message
HBufC8 * iMessage = HBufC8::NewL(300);
TPtr8 TempUDHBufDesc((TUint8*)buf,247,247);
iMessage->Des().Copy(TempUDHBufDesc);
_LOGFENTRY1(_L("mess length %d"),iMessage->Des().Length());
userdata.SetBodyL(*iMessage);
delete iMessage;
// Message will be sent immediately.
entry.SetSendingState( KMsvSendStateWaiting );
entry.iDate.UniversalTime(); // insert current time //Solution for HomeTime()
// Set the SMS message settings for the message.
CSmsHeader& header = iSmsMtm->SmsHeader();
CSmsSettings* settings = CSmsSettings::NewL();
CleanupStack::PushL( settings );
settings->CopyL( iSmsMtm->ServiceSettings() ); // restore settings
settings->SetDelivery( ESmsDeliveryImmediately ); // to be delivered immediately
settings->SetDeliveryReport(EFalse);
settings->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet8Bit); // IMPORTANT! For sending binary SMS
header.SetSmsSettingsL( *settings ); // new settings
// Let's check if there is a service center address.
if ( header.Message().ServiceCenterAddress().Length() == 0 )
{
// No, there isn't. We assume there is at least one service center
// number set and use the default service center number.
CSmsSettings* serviceSettings = &( iSmsMtm->ServiceSettings() );
// Check if number of service center addresses in the list is null.
if ( !serviceSettings->ServiceCenterCount() )
{ _LOGENTRY("No SC");
return ; // quit creating the message
}
else
{
CSmsNumber* smsCenter= CSmsNumber::NewL();
CleanupStack::PushL(smsCenter);
smsCenter->SetAddressL((serviceSettings->GetServiceCenter( serviceSettings->DefaultServiceCenter())).Address());
header.Message().SetServiceCenterAddressL( smsCenter->Address() );
CleanupStack::PopAndDestroy(smsCenter);
}
}
CleanupStack::PopAndDestroy( settings );
// Recipient number is displayed also as the recipient alias.
entry.iDetails.Set( _L("+3725038xxx") );
iSmsMtm->AddAddresseeL( _L("+3725038xxx") , entry.iDetails );
// Validate message.
if ( !ValidateL() )
{ _LOGENTRY("Not valid");
return ;
}
entry.SetVisible( ETrue ); // set message as visible
entry.SetInPreparation( EFalse ); // set together with the visibility flag
serverEntry.ChangeL( entry ); // commit changes
iSmsMtm->SaveMessageL(); // save message
TMsvSelectionOrdering selection;
CMsvEntry* parentEntry = CMsvEntry::NewL( iSmsMtm->Session(), KMsvDraftEntryId, selection );
CleanupStack::PushL( parentEntry );
// Move message to Outbox.
iOperation =parentEntry->MoveL( entry.Id(), KMsvGlobalOutBoxIndexEntryId, iStatus );
CleanupStack::PopAndDestroy( parentEntry );
iState = EWaitingForMoving;
SetActive();
Principalmente non sono sicuro dei valori corretti per porta e classe. Anche una stringa binaria corretta sarebbe utile per il test. Ora non sono sicuro se il codice sia errato o i dati.
Soluzione 2
La soluzione che ha funzionato è usare RComm e " DATAPORT :: 1 " per inviare l'SMS binario usando i comandi AT (come usare un modem).
Altri suggerimenti
Utilizzare le specifiche JSR120 e il toolkit wireless. contengono un codice di esempio Java che funzionerà sicuramente.
Questi sono implementati direttamente usando oggetti RSocket in Symbian C ++.
Se vuoi davvero farlo in C ++, il modo più semplice è copiare il tuo TMsvEntry alla voce del servizio sms. Nel tuo codice sopra, ciò significa utilizzare " iSmsMtm- > ServiceId () " invece di " KMsvGlobalOutBoxIndexEntryId " ;. inoltre, basta copiare il messaggio sul servizio ma spostarlo nella posta in uscita dopo che è stato inviato con successo.
spina spudorata: http://www.quickrecipesonsymbianos.com conterrà una spiegazione della messaggistica Symbian C ++ L'API eseguirà un codice di esempio semplice e riutilizzabile.
Se si desidera inviare l'SMS in silenzio (ed evitare la complessità dell'utilizzo delle API di messaggistica), è necessario inviarlo tramite un RSocket
: http://wiki.forum.nokia.com/index.php/How_to_send_an_SMS_using_sockets
A seconda delle tue esigenze, questo potrebbe essere più adatto rispetto all'utilizzo delle API di messaggistica.