Skip to content

Commit 395ed3f

Browse files
committed
cellular: rename SMS status -> purpose
1 parent 7ef7e1e commit 395ed3f

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

ports/gprs_a9/modcellular.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,11 @@ void modcellular_notify_cell_info(API_Event_t* event) {
409409

410410
typedef struct _sms_obj_t {
411411
mp_obj_base_t base;
412-
uint8_t index;
413-
uint8_t status;
414-
uint8_t pn_type;
415412
mp_obj_t phone_number;
416413
mp_obj_t message;
414+
uint8_t pn_type;
415+
uint8_t index;
416+
uint8_t purpose;
417417
} sms_obj_t;
418418

419419
mp_obj_t modcellular_sms_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
@@ -424,25 +424,25 @@ mp_obj_t modcellular_sms_make_new(const mp_obj_type_t *type, size_t n_args, size
424424
// message (str): message contents;
425425
// ========================================
426426

427-
enum { ARG_phone_number, ARG_message, ARG_pn_type, ARG_index, ARG_status };
427+
enum { ARG_phone_number, ARG_message, ARG_pn_type, ARG_index, ARG_purpose };
428428
static const mp_arg_t allowed_args[] = {
429429
{ MP_QSTR_phone_number, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
430430
{ MP_QSTR_message, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
431431
{ MP_QSTR_pn_type, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
432432
{ MP_QSTR_index, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
433-
{ MP_QSTR_status, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
433+
{ MP_QSTR_purpose, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
434434
};
435435

436436
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
437437
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
438438

439439
sms_obj_t *self = m_new_obj(sms_obj_t);
440440
self->base.type = type;
441-
self->index = args[ARG_index].u_int;
442-
self->status = args[ARG_status].u_int;
443-
self->pn_type = args[ARG_pn_type].u_int;
444441
self->phone_number = args[ARG_phone_number].u_obj;
445442
self->message = args[ARG_message].u_obj;
443+
self->pn_type = args[ARG_pn_type].u_int;
444+
self->index = args[ARG_index].u_int;
445+
self->purpose = args[ARG_purpose].u_int;
446446
return MP_OBJ_FROM_PTR(self);
447447
}
448448

@@ -459,7 +459,7 @@ STATIC mp_obj_t modcellular_sms_inbox(mp_obj_t self_in) {
459459
// True if inbox.
460460
// ========================================
461461
sms_obj_t *self = MP_OBJ_TO_PTR(self_in);
462-
uint8_t s = self->status;
462+
uint8_t s = self->purpose;
463463
REQUIRES_VALID_SMS_STATUS(s);
464464
return mp_obj_new_bool(s & (SMS_STATUS_READ | SMS_STATUS_UNREAD));
465465
}
@@ -471,7 +471,7 @@ STATIC mp_obj_t modcellular_sms_unread(mp_obj_t self_in) {
471471
// True if unread.
472472
// ========================================
473473
sms_obj_t *self = MP_OBJ_TO_PTR(self_in);
474-
uint8_t s = self->status;
474+
uint8_t s = self->purpose;
475475
REQUIRES_VALID_SMS_STATUS(s);
476476
return mp_obj_new_bool(s & SMS_STATUS_UNREAD);
477477
}
@@ -483,7 +483,7 @@ STATIC mp_obj_t modcellular_sms_sent(mp_obj_t self_in) {
483483
// True if it was sent.
484484
// ========================================
485485
sms_obj_t *self = MP_OBJ_TO_PTR(self_in);
486-
uint8_t s = self->status;
486+
uint8_t s = self->purpose;
487487
REQUIRES_VALID_SMS_STATUS(s);
488488
return mp_obj_new_bool(!(s | SMS_STATUS_UNSENT));
489489
}
@@ -502,8 +502,8 @@ STATIC mp_obj_t modcellular_sms_send(size_t n_args, const mp_obj_t *args) {
502502

503503
sms_obj_t *self = MP_OBJ_TO_PTR(args[0]);
504504

505-
if (self->status != 0)
506-
mp_raise_ValueError("A message with non-zero status cannot be sent");
505+
if (self->purpose != 0)
506+
mp_raise_ValueError("A message with non-zero purpose cannot be sent");
507507

508508
const char* destination_c = mp_obj_str_get_str(self->phone_number);
509509
const char* message_c = mp_obj_str_get_str(self->message);
@@ -536,8 +536,8 @@ STATIC mp_obj_t modcellular_sms_withdraw(mp_obj_t self_in) {
536536

537537
sms_obj_t *self = MP_OBJ_TO_PTR(self_in);
538538

539-
if (self->index == 0 || self->status == 0) {
540-
mp_raise_ValueError("Cannot withdraw SMS with zero index/status");
539+
if (self->index == 0 || self->purpose == 0) {
540+
mp_raise_ValueError("Cannot withdraw SMS with zero index/purpose");
541541
return mp_const_none;
542542
}
543543

@@ -546,7 +546,7 @@ STATIC mp_obj_t modcellular_sms_withdraw(mp_obj_t self_in) {
546546
return mp_const_none;
547547
}
548548

549-
self->status = 0;
549+
self->purpose = 0;
550550
self->index = 0;
551551
return mp_const_none;
552552
}
@@ -643,9 +643,9 @@ STATIC void modcellular_sms_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
643643
// .message
644644
} else if (attr == MP_QSTR_message) {
645645
dest[0] = self->message;
646-
// .status
647-
} else if (attr == MP_QSTR_status) {
648-
dest[0] = mp_obj_new_int(self->status);
646+
// .purpose
647+
} else if (attr == MP_QSTR_purpose) {
648+
dest[0] = mp_obj_new_int(self->purpose);
649649
// .inbox
650650
} else if (attr == MP_QSTR_inbox) {
651651
dest[0] = modcellular_sms_inbox(self_in);
@@ -679,12 +679,12 @@ STATIC void modcellular_sms_print(const mp_print_t *print, mp_obj_t self_in, mp_
679679
// SMS.__str__()
680680
// ========================================
681681
sms_obj_t *self = MP_OBJ_TO_PTR(self_in);
682-
mp_printf(print, "SMS(\"%s\", \"%s\", pn_type=%d, index=%d, status=%d)",
682+
mp_printf(print, "SMS(\"%s\", \"%s\", pn_type=%d, index=%d, purpose=%d)",
683683
mp_obj_str_get_str(self->phone_number),
684684
mp_obj_str_get_str(self->message),
685685
self->pn_type,
686686
self->index,
687-
self->status
687+
self->purpose
688688
);
689689
}
690690

@@ -720,7 +720,7 @@ STATIC mp_obj_t modcellular_sms_from_record(SMS_Message_Info_t* record) {
720720
sms_obj_t *self = m_new_obj_with_finaliser(sms_obj_t);
721721
self->base.type = &modcellular_sms_type;
722722
self->index = record->index;
723-
self->status = (uint8_t)record->status;
723+
self->purpose = (uint8_t)record->status;
724724
self->pn_type = (uint8_t)record->phoneNumberType;
725725
self->phone_number = mp_obj_new_str((char*)record->phoneNumber + 1, SMS_PHONE_NUMBER_MAX_LEN - 1);
726726
self->message = mp_obj_new_str((char*)record->data, record->dataLen);
@@ -754,7 +754,7 @@ STATIC mp_obj_t modcellular_sms_from_raw(uint8_t* header, uint32_t header_length
754754
sms_obj_t *self = m_new_obj_with_finaliser(sms_obj_t);
755755
self->base.type = &modcellular_sms_type;
756756
self->index = 0;
757-
self->status = 0;
757+
self->purpose = 0;
758758
self->pn_type = 0;
759759
self->phone_number = mp_obj_new_str((char*)header + 1, i - 1);
760760
self->message = mp_obj_new_str((char*)content, content_length);

0 commit comments

Comments
 (0)