Pergunta
Gostaria de saber se alguém conseguiu criar um código de trabalho para o envio de mensagens binárias (para configurar telefones Symbian) e têm também alguma amostra de dados binários. Até agora, todas as amostras que tenho encontrado não conseguem deixar a caixa de saída ou nunca mais voltar.
// 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();
Na maior parte eu não tenho certeza sobre os valores corretos para a porta e classe. Além disso, alguns string binária correta seria bom ter para o teste. Agora eu não tenho certeza se TheCode é ruim ou os dados.
Solução 2
A solução que funcionou é usar RComm e "DATAPORT :: 1" para enviar o SMS binário usando comandos AT (como usar um modem).
Outras dicas
Use a especificação JSR120 eo kit de ferramentas sem fio. eles contêm java exemplo de código que irá funcionar com certeza.
Estes são implementados usando diretamente objetos RSocket em Symbian C ++.
Se você realmente quiser fazê-lo em C ++, a maneira mais simples é copiar o seu TMsvEntry para a entrada do serviço de sms. Em seu código acima, isso significa usar "iSmsMtm-> serviceId ()" em vez de "KMsvGlobalOutBoxIndexEntryId". Também, basta copiar a mensagem para o serviço, mas não movê-lo para a caixa de saída depois de ter sido enviada com sucesso.
plug descarado: http://www.quickrecipesonsymbianos.com irá conter uma explicação de mensagens do Symbian C ++ API simples vontade e exemplo de código reutilizável.
Se você deseja enviar o SMS silenciosamente (e evitar a complexidade de usar as APIs de mensagens), você deve enviá-lo através de um RSocket
: http://wiki.forum.nokia.com/index.php/How_to_send_an_SMS_using_sockets
Dependendo de suas necessidades isso pode ser mais adequado do que usar as APIs de mensagens.