EC200U SMS API semaphores

Using the sample code from the SDK, I am trying to expand on the SMS handling code.

void user_sms_event_callback(uint8_t nSim, int event_id, void *ctx)
{
	switch (event_id) {
	case QL_SMS_INIT_OK_IND: {
		QL_SMS_LOG("QL_SMS_INIT_OK_IND");
		ql_rtos_semaphore_release(sms_init_sem);
		break;
	}
	case QL_SMS_NEW_MSG_IND: {
		ql_sms_new_s *msg = (ql_sms_new_s *)ctx;
		QL_SMS_LOG("sim=%d, index=%d, storage memory=%d", nSim, msg->index, msg->mem);
#if READ_WHILE_NEW
		char *txt;
		if (NULL != (txt = malloc(SMS_MAX_LEN))) {
			memset(txt, 0, SMS_MAX_LEN);
			ql_sms_errcode_e e = ql_sms_read_msg(nSim, msg->index, txt, SMS_MAX_LEN, TEXT);
			if (QL_SMS_SUCCESS == e) {
				QL_SMS_LOG("read msg OK, msg=%s", txt);
			} else {
				QL_SMS_LOG("read sms FAIL %x", e);
			}
			free(txt);
		} else {
			QL_SMS_LOG("malloc ql_sms_msg_s fail");
		}

#endif
#if DELETE_WHILE_NEW
		ql_sms_errcode_e e = ql_sms_delete_msg(nSim, msg->index);
		if (QL_SMS_SUCCESS == e) {
			QL_SMS_LOG("delete sms OK %x", e);
		} else {
			QL_SMS_LOG("delete sms FAIL %x", e);
		}
#endif
		break;
	}
	case QL_SMS_LIST_IND: {
		ql_sms_msg_s *msg = (ql_sms_msg_s *)ctx;
		QL_SMS_LOG("sim=%d,index=%d, msg = %s", nSim, msg->index, msg->buf);
#if DELETE_WHILE_LISTING
		ql_sms_errcode_e e = ql_sms_delete_msg(nSim, msg->index);
		if (QL_SMS_SUCCESS == e) {
			QL_SMS_LOG("delete sms OK %x", e);
		} else {
			QL_SMS_LOG("delete sms FAIL %x", e);
		}
#endif
		break;
	}
	case QL_SMS_LIST_END_IND: {
		QL_SMS_LOG("QL_SMS_LIST_END_IND");
		ql_rtos_semaphore_release(sms_list_sem);
		break;
	}
	case QL_SMS_MEM_FULL_IND: {
		ql_sms_new_s *msg = (ql_sms_new_s *)ctx;
		QL_SMS_LOG("QL_SMS_MEM_FULL_IND sim=%d, memory=%d", nSim, msg->mem);
		break;
	}
	default:
		break;
	}
}

The structure of this code is identical to the sample in the SDK. However, there is new code to read and/or delete the SMS. If any of that functionality is enabled, it causes the system to reboot.

I get the impression that ql_sms_read_msg and ql_sms_delete_msg use their own semaphores, but those semaphores are not documented anywhere.

Do you have any other code that demonstrates best practices with the SMS API? The current SMS demo app leads to reboots when I try to call ql_sms_read_msg and ql_sms_delete_msg in user_sms_event_callback.

For now, solved the problem by implementing a queue to handle all the reads and deletes. The callback function can push messages to the queue.

HI
Thanks a lot for your feedback.
Felix