@@ -409,11 +409,11 @@ void modcellular_notify_cell_info(API_Event_t* event) {
409
409
410
410
typedef struct _sms_obj_t {
411
411
mp_obj_base_t base ;
412
- uint8_t index ;
413
- uint8_t status ;
414
- uint8_t pn_type ;
415
412
mp_obj_t phone_number ;
416
413
mp_obj_t message ;
414
+ uint8_t pn_type ;
415
+ uint8_t index ;
416
+ uint8_t purpose ;
417
417
} sms_obj_t ;
418
418
419
419
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
424
424
// message (str): message contents;
425
425
// ========================================
426
426
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 };
428
428
static const mp_arg_t allowed_args [] = {
429
429
{ MP_QSTR_phone_number , MP_ARG_REQUIRED | MP_ARG_OBJ , {.u_obj = MP_OBJ_NULL } },
430
430
{ MP_QSTR_message , MP_ARG_REQUIRED | MP_ARG_OBJ , {.u_obj = MP_OBJ_NULL } },
431
431
{ MP_QSTR_pn_type , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 0 } },
432
432
{ 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 } },
434
434
};
435
435
436
436
mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
437
437
mp_arg_parse_all_kw_array (n_args , n_kw , all_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
438
438
439
439
sms_obj_t * self = m_new_obj (sms_obj_t );
440
440
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 ;
444
441
self -> phone_number = args [ARG_phone_number ].u_obj ;
445
442
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 ;
446
446
return MP_OBJ_FROM_PTR (self );
447
447
}
448
448
@@ -459,7 +459,7 @@ STATIC mp_obj_t modcellular_sms_inbox(mp_obj_t self_in) {
459
459
// True if inbox.
460
460
// ========================================
461
461
sms_obj_t * self = MP_OBJ_TO_PTR (self_in );
462
- uint8_t s = self -> status ;
462
+ uint8_t s = self -> purpose ;
463
463
REQUIRES_VALID_SMS_STATUS (s );
464
464
return mp_obj_new_bool (s & (SMS_STATUS_READ | SMS_STATUS_UNREAD ));
465
465
}
@@ -471,7 +471,7 @@ STATIC mp_obj_t modcellular_sms_unread(mp_obj_t self_in) {
471
471
// True if unread.
472
472
// ========================================
473
473
sms_obj_t * self = MP_OBJ_TO_PTR (self_in );
474
- uint8_t s = self -> status ;
474
+ uint8_t s = self -> purpose ;
475
475
REQUIRES_VALID_SMS_STATUS (s );
476
476
return mp_obj_new_bool (s & SMS_STATUS_UNREAD );
477
477
}
@@ -483,7 +483,7 @@ STATIC mp_obj_t modcellular_sms_sent(mp_obj_t self_in) {
483
483
// True if it was sent.
484
484
// ========================================
485
485
sms_obj_t * self = MP_OBJ_TO_PTR (self_in );
486
- uint8_t s = self -> status ;
486
+ uint8_t s = self -> purpose ;
487
487
REQUIRES_VALID_SMS_STATUS (s );
488
488
return mp_obj_new_bool (!(s | SMS_STATUS_UNSENT ));
489
489
}
@@ -502,8 +502,8 @@ STATIC mp_obj_t modcellular_sms_send(size_t n_args, const mp_obj_t *args) {
502
502
503
503
sms_obj_t * self = MP_OBJ_TO_PTR (args [0 ]);
504
504
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" );
507
507
508
508
const char * destination_c = mp_obj_str_get_str (self -> phone_number );
509
509
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) {
536
536
537
537
sms_obj_t * self = MP_OBJ_TO_PTR (self_in );
538
538
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 " );
541
541
return mp_const_none ;
542
542
}
543
543
@@ -546,7 +546,7 @@ STATIC mp_obj_t modcellular_sms_withdraw(mp_obj_t self_in) {
546
546
return mp_const_none ;
547
547
}
548
548
549
- self -> status = 0 ;
549
+ self -> purpose = 0 ;
550
550
self -> index = 0 ;
551
551
return mp_const_none ;
552
552
}
@@ -643,9 +643,9 @@ STATIC void modcellular_sms_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
643
643
// .message
644
644
} else if (attr == MP_QSTR_message ) {
645
645
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 );
649
649
// .inbox
650
650
} else if (attr == MP_QSTR_inbox ) {
651
651
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_
679
679
// SMS.__str__()
680
680
// ========================================
681
681
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)" ,
683
683
mp_obj_str_get_str (self -> phone_number ),
684
684
mp_obj_str_get_str (self -> message ),
685
685
self -> pn_type ,
686
686
self -> index ,
687
- self -> status
687
+ self -> purpose
688
688
);
689
689
}
690
690
@@ -720,7 +720,7 @@ STATIC mp_obj_t modcellular_sms_from_record(SMS_Message_Info_t* record) {
720
720
sms_obj_t * self = m_new_obj_with_finaliser (sms_obj_t );
721
721
self -> base .type = & modcellular_sms_type ;
722
722
self -> index = record -> index ;
723
- self -> status = (uint8_t )record -> status ;
723
+ self -> purpose = (uint8_t )record -> status ;
724
724
self -> pn_type = (uint8_t )record -> phoneNumberType ;
725
725
self -> phone_number = mp_obj_new_str ((char * )record -> phoneNumber + 1 , SMS_PHONE_NUMBER_MAX_LEN - 1 );
726
726
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
754
754
sms_obj_t * self = m_new_obj_with_finaliser (sms_obj_t );
755
755
self -> base .type = & modcellular_sms_type ;
756
756
self -> index = 0 ;
757
- self -> status = 0 ;
757
+ self -> purpose = 0 ;
758
758
self -> pn_type = 0 ;
759
759
self -> phone_number = mp_obj_new_str ((char * )header + 1 , i - 1 );
760
760
self -> message = mp_obj_new_str ((char * )content , content_length );
0 commit comments