Pregunta

Me pregunto si alguien ha logrado crear un código de trabajo para enviar mensajes binarios (para configurar teléfonos Symbian) y también tener algunos ejemplos de datos binarios. Hasta ahora, todas las muestras que he encontrado no salen de la Bandeja de salida o nunca regresan.

// 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();

En general, no estoy seguro de los valores correctos para el puerto y la clase. También sería bueno tener alguna cadena binaria correcta para la prueba. Ahora no estoy seguro de si el código es malo o los datos.

¿Fue útil?

Solución 2

La solución que funcionó es usar RComm y " DATAPORT :: 1 " para enviar el SMS binario utilizando comandos AT (como usar un módem).

Otros consejos

Utilice la especificación JSR120 y el kit de herramientas inalámbricas. contienen código de ejemplo de Java que funcionará seguro.

Estos se implementan directamente utilizando objetos RSocket en Symbian C ++.

Si realmente desea hacerlo en C ++, la forma más sencilla es copiar su TMsvEntry en la entrada del servicio de SMS. En tu código anterior, eso significa usar " iSmsMtm- > ServiceId () " en lugar de " KMsvGlobalOutBoxIndexEntryId " ;. también, simplemente copie el mensaje al servicio, pero muévalo a la bandeja de salida después de que se haya enviado con éxito.

enchufe descarado: http://www.quickrecipesonsymbianos.com contendrá una explicación de la mensajería de Symbian C ++ API será un código de ejemplo simple y reutilizable.

Si desea enviar el SMS de forma silenciosa (y evitar la complejidad de usar las API de mensajería), debe enviarlo a través de un RSocket : http://wiki.forum.nokia.com/index.php/How_to_send_an_SMS_using_sockets

Dependiendo de sus necesidades, esto podría ser más adecuado que usar las API de mensajería.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top