NMT: Fix test of SMS code for different time zones

This commit is contained in:
Andreas Eversberg
2018-11-10 14:43:31 +01:00
parent 2cff22ef54
commit 73757ba083
4 changed files with 15 additions and 14 deletions

View File

@@ -1272,7 +1272,7 @@ static void tx_mt_complete(nmt_t *nmt, frame_t *frame)
}
if (trans->dms_call) {
time_t ti = time(NULL);
sms_deliver(nmt, sms_ref, trans->caller_id, trans->caller_type, SMS_PLAN_ISDN_TEL, ti, trans->sms_string);
sms_deliver(nmt, sms_ref, trans->caller_id, trans->caller_type, SMS_PLAN_ISDN_TEL, ti, 1, trans->sms_string);
}
}
}

View File

@@ -163,9 +163,9 @@ static int encode_address(uint8_t *data, const char *address, uint8_t type, uint
}
/* encode time stamp */
static int encode_time(uint8_t *data, time_t timestamp)
static int encode_time(uint8_t *data, time_t timestamp, int local)
{
struct tm *tm = localtime(&timestamp);
struct tm *tm = (local) ? localtime(&timestamp) : gmtime(&timestamp);
int length = 0;
uint8_t digit1, digit2;
int quarters, sign;
@@ -227,7 +227,7 @@ static int encode_time(uint8_t *data, time_t timestamp)
data[length++] = (digit2 << 4) | digit1;
/* zone */
quarters = timezone / 900;
quarters = (local) ? (timezone / 900) : 0;
if (quarters < 0) {
quarters = -quarters;
sign = 1;
@@ -244,7 +244,7 @@ static int encode_time(uint8_t *data, time_t timestamp)
static int encode_userdata(uint8_t *data, const char *message)
{
int length = 1;
char character;
uint8_t character;
int i, j, pos;
PDEBUG(DSMS, DEBUG_DEBUG, "Encode user data '%s'\n", message);
@@ -286,7 +286,7 @@ static int encode_userdata(uint8_t *data, const char *message)
}
/* deliver SMS (SC->MS) */
int sms_deliver(nmt_t *nmt, uint8_t ref, const char *orig_address, uint8_t orig_type, uint8_t orig_plan, time_t timestamp, const char *message)
int sms_deliver(nmt_t *nmt, uint8_t ref, const char *orig_address, uint8_t orig_type, uint8_t orig_plan, time_t timestamp, int local, const char *message)
{
uint8_t data[256], *tpdu_length;
int length = 0;
@@ -321,7 +321,7 @@ int sms_deliver(nmt_t *nmt, uint8_t ref, const char *orig_address, uint8_t orig_
length += encode_address(data + length, orig_address, orig_type, orig_plan); /* TP-OA */
data[length++] = 0; /* TP-PID */
data[length++] = 0; /* TP-DCS */
length += encode_time(data + length, timestamp);
length += encode_time(data + length, timestamp, local);
length += encode_userdata(data + length, message);
/* RP length */

View File

@@ -28,7 +28,7 @@ int sms_init_sender(nmt_t *nmt);
void sms_cleanup_sender(nmt_t *nmt);
int sms_submit(nmt_t *nmt, uint8_t ref, const char *orig_address, uint8_t orig_type, uint8_t orig_plan, int msg_ref, const char *dest_address, uint8_t dest_type, uint8_t dest_plan, const char *message);
void sms_deliver_report(nmt_t *nmt, uint8_t ref, int error, uint8_t cause);
int sms_deliver(nmt_t *nmt, uint8_t ref, const char *orig_address, uint8_t type, uint8_t plan, time_t timestamp, const char *message);
int sms_deliver(nmt_t *nmt, uint8_t ref, const char *orig_address, uint8_t type, uint8_t plan, time_t timestamp, int local, const char *message);
void sms_release(nmt_t *nmt);
void sms_reset(nmt_t *nmt);