Update GSM SMS (LTE part).

This commit is contained in:
bossiel 2010-04-14 23:58:39 +00:00
parent 050464a58e
commit 40db2e569a
9 changed files with 71 additions and 20 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -37,7 +37,7 @@
TSMS_BEGIN_DECLS
/** SMS TPDU SMS-SUBMIT message as per 3GPP TS 23.040 section 9.2.2.2
/** SMS @a SMS-SUBMIT message as per 3GPP TS 23.040 section 9.2.2.2
*/
typedef struct tsms_tpdu_submit_s
{
@ -88,6 +88,27 @@ tsms_tpdu_submit_t;
TINYSMS_API tsms_tpdu_submit_t* tsms_tpdu_submit_create(uint8_t mr, const tsms_address_string_t smsc, const tsms_address_string_t dest);
/**@ingroup tsms_tpdu_group
* @def tsms_tpdu_submit_serialize
* Serializes a @a SMS-SUBMIT message as binary content.
* @param self A pointer to the @a SMS-SUBMIT (@ref tsms_tpdu_submit_t) message to serialize.
* @param output A pointer to the output buffer. Should be valid.
* @retval Zero if succeed and non-zero error code otherwise.
*/
/**@ingroup tsms_tpdu_group
* @def tsms_tpdu_submit_tohexastring
* Serializes a @a SMS-SUBMIT message as hexa-string content.
* @param self A pointer to the @a SMS-SUBMIT (@ref tsms_tpdu_submit_t) message to serialize.
* @retval A pointer to the hexa-string if succeed and Null otherwise.
*/
/**@ingroup tsms_tpdu_group
* @def tsms_tpdu_submit_set_userdata
* Sets the content of the @a SMS-SUBMIT message.
* @param self A pointer to the @a SMS-SUBMIT (@ref tsms_tpdu_submit_t).
* @param udata A pointer the content.
* @param alpha The alphabet used to encode the content.
* @retval Zero if succeed and non-zero error code otherwise.
*/
#define tsms_tpdu_submit_serialize(self, output) tsms_tpdu_message_serialize(TSMS_TPDU_MESSAGE(self), output, tsk_true)
#define tsms_tpdu_submit_tostring(self) tsms_tpdu_message_tostring(TSMS_TPDU_MESSAGE(self), tsk_true)
#define tsms_tpdu_submit_tohexastring(self) tsms_tpdu_message_tohexastring(TSMS_TPDU_MESSAGE(self), tsk_true)

View File

@ -153,6 +153,9 @@ bail:
return TSMS_TPDU_MESSAGE(self);
}
/** internal function used to serialize a SMS-SUBMIT message
*/
int _tsms_tpdu_submit_serialize(const tsms_tpdu_submit_t* self, tsk_buffer_t* output)
{
uint8_t _1byte;
@ -198,8 +201,21 @@ int _tsms_tpdu_submit_serialize(const tsms_tpdu_submit_t* self, tsk_buffer_t* ou
tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->dcs, 1); /*1o*/
/* 3GPP TS 23.040 ==> 9.2.3.12 TP-Validity-Period
* Only TP-VP (Relative format) is supported. This field is used in conjonction with TP-VPF. */
tsk_buffer_append(output, &self->vp, 1); /*1o*/
* 1o for Relative format (9.2.3.12.1)
* 7o for Absolute format (9.2.3.12.2)
* 7o for Enhanced format (9.2.3.12.3)*/
switch(self->vpf){
case tsms_tpdu_vpf_relative:
tsk_buffer_append(output, &self->vp, 1);
break;
case tsms_tpdu_vpf_enhanced:
case tsms_tpdu_vpf_absolute:
tsk_buffer_append(output, &self->vp, 7);
break;
default:
case tsms_tpdu_vpf_not_present:
break;
}
/* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL) */
tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->udl, 1); /*1o*/
@ -210,6 +226,16 @@ int _tsms_tpdu_submit_serialize(const tsms_tpdu_submit_t* self, tsk_buffer_t* ou
return 0;
}
/**@ingroup tsms_tpdu_group
* Creates new SMS-SUBMIT message.
* @a SMS-SUBMIT messages are used to convey short messages from the MS (Mobile Station) to the SC (Service Center).
* @a SMS-SUBMIT-REPORT messages are used for positive or negative acknowledgement to an @a SMS-DELIVER or @a SMS-STATUS-REPORT.
* For more information, please refer to 3GPP TS 23.040 section 9.2.2.2.
* @param mr TP-Message-Reference (TP-MR) as per 3GPP TS 23.040 section 9.2.3.6.
* @param smsc SMSC address. e.g. "+331253688".
* @param dest The destination address. e.g. "+331253688".
* @retval @a SMS-SUBMIT message.
*/
tsms_tpdu_submit_t* tsms_tpdu_submit_create(uint8_t mr, const tsms_address_string_t smsc, const tsms_address_string_t dest)
{
tsms_tpdu_submit_t* ret = tsk_null;

View File

@ -151,7 +151,7 @@ tsms_address_t* tsms_address_deserialize(const void* data, size_t size, tsms_add
address = TSMS_ADDRESS_CREATE(tsk_null, xtype);
*length = 1 /*Address-Length*/ + 1 /*Type-of-Address*/ + addr_len /* digits */;
}
/* 2 - Type-of-Address
+----+----+----+----+----+----+----+----+
| 1 | TON | NPI |
@ -173,7 +173,7 @@ tsms_address_t* tsms_address_deserialize(const void* data, size_t size, tsms_add
tsk_strcat_2(&address->digits, "%.2x", _1byte);
}
}
bail:
return address;
}

View File

@ -37,6 +37,11 @@
#include <string.h> /* strlen() */
/**@defgroup tsms_tpdu_group Service provided by the SM-TL (Transport)
*/
/**@defgroup tsms_rpdu_group Service provided by the SM-RL (Relay)
*/
/* ======================== TPDU ========================
=========================================================*/
@ -65,7 +70,7 @@ int tsms_tpdu_message_init(tsms_tpdu_message_t* self, tsms_tpdu_mti_t mti)
return -1;
}
/**
/** Serialize any TP-Message.
*/
int tsms_tpdu_message_serialize(const tsms_tpdu_message_t* self, tsk_buffer_t* output, tsk_bool_t MobOrig)
{
@ -101,6 +106,8 @@ int tsms_tpdu_message_serialize(const tsms_tpdu_message_t* self, tsk_buffer_t* o
}
}
/** Deserialize any TP-Message.
*/
tsms_tpdu_message_t* tsms_tpdu_message_deserialize(const void* data, size_t size, tsk_bool_t MobOrig)
{
tsms_tpdu_mti_t mti;

View File

@ -71,8 +71,8 @@ tsk_bool_t bin_equals(const uint8_t* b1, const uint8_t* b2, size_t size)
#define RUN_TEST_ALL 0
#define RUN_TEST_PACKING 0
#define RUN_TEST_TPDU 0
#define RUN_TEST_RPDU 1
#define RUN_TEST_TPDU 1
#define RUN_TEST_RPDU 0
#ifdef _WIN32_WCE

View File

@ -32,11 +32,15 @@ void test_submit()
tsms_tpdu_submit_t* submit = tsk_null;
tsk_buffer_t* buffer = tsk_null;
char* hex;
const char* smsc = "+331000009";
const char* destination = "+333361234567";
const char* short_message = "hello world";
uint8_t mr = 0xF5;
submit = tsms_tpdu_submit_create(__pdu_last_mr++, "+3310000095", "+3361234567");
submit = tsms_tpdu_submit_create(mr, smsc, destination);
/* sending */
if((buffer = tsms_pack_to_7bit(USER_DATA))){
/* encode the user data to GSM 7-bit alphabet */
if((buffer = tsms_pack_to_7bit(short_message))){
ret = tsms_tpdu_submit_set_userdata(submit, buffer, tsms_alpha_7bit);
if((hex = tsms_tpdu_submit_tohexastring(submit))){
TSK_DEBUG_INFO("SMS-SUBMIT=%s", hex);
@ -47,7 +51,8 @@ void test_submit()
/* receiving */
buffer = TSK_BUFFER_CREATE_NULL();
tsms_tpdu_submit_serialize(submit, buffer);
ret = tsms_tpdu_submit_serialize(submit, buffer);
// send(socket, buffer->data, buffer->size);
TSK_OBJECT_SAFE_FREE(submit);
submit = (tsms_tpdu_submit_t*)tsms_tpdu_message_deserialize_mo(buffer->data, buffer->size);

View File

@ -203,10 +203,6 @@
<Filter
Name="tpdu"
>
<File
RelativePath=".\include\tinysms\tpdu\tsms_tpdu.h"
>
</File>
<File
RelativePath=".\include\tinysms\tpdu\tsms_tpdu_command.h"
>
@ -261,10 +257,6 @@
<Filter
Name="tpdu"
>
<File
RelativePath=".\src\tpdu\tsms_tpdu.c"
>
</File>
<File
RelativePath=".\src\tpdu\tsms_tpdu_command.c"
>