예제 #1
0
파일: gsm.c 프로젝트: AsherBond/ikran
cpr_status_e
gsm_send_msg (uint32_t cmd, cprBuffer_t buf, uint16_t len)
{
    phn_syshdr_t *syshdr;

    syshdr = (phn_syshdr_t *) cprGetSysHeader(buf);
    if (!syshdr) {
        return CPR_FAILURE;
    }
    syshdr->Cmd = cmd;
    syshdr->Len = len;

    if (cprSendMessage(gsm_msg_queue, buf, (void **) &syshdr) == CPR_FAILURE) {
        cprReleaseSysHeader(syshdr);
        return CPR_FAILURE;
    }
    return CPR_SUCCESS;
}
예제 #2
0
/**
 *
 * CC Provider wrapper for cprSendMessage
 *
 * @param   cmd - Command
 * @param   msg - msg ptr
 * @param   len - len of msg
 * @param   usr -
 *
 * @return  CPR_SUCCESS/CPR_FAILURE
 *
 * @pre     msg is a malloc mem ptr
 */
cpr_status_e
ccappTaskSendMsg (uint32_t cmd, void *msg, uint16_t len, uint32_t UsrInfo)
{
    phn_syshdr_t *syshdr;

    syshdr = (phn_syshdr_t *) cprGetSysHeader(msg);
    if (!syshdr) {
        return CPR_FAILURE;
    }
    syshdr->Cmd = cmd;
    syshdr->Len = len;
    syshdr->Usr.UsrInfo = UsrInfo;

    if (cprSendMessage(ccapp_msgq , (cprBuffer_t*)msg, (void **)&syshdr) == CPR_FAILURE) {
        cprReleaseSysHeader(syshdr);
        return CPR_FAILURE;
    }
    return CPR_SUCCESS;
}
/**
 *
 * Process the timers expired. Generally this is called when head timer
 * has expired.
 * @note we need to process the list as there could be
 * other timers too in the list which have expired.
 *
 */
void process_expired_timers() {
    static const char fname[] = "process_expired_timer";
    cprCallBackTimerMsg_t *timerMsg;
    void *syshdr;
    boolean processingTimers;

    /* nothing to do if no timers running */
    if (timerListHead == NULL) {
        return;
    }

    /* nothing to do if head has not expired */
    if (timerListHead->duration > 0) {
        return;
    }


    /* There are one or more expired timers on the list */
    processingTimers = TRUE;
    while (processingTimers) {
        if (timerListHead != NULL) {
            /*
             * Send msg to queue to indicate this timer has expired
             */
            if (timerListHead->duration <= 0) {
                timerMsg = (cprCallBackTimerMsg_t *)
                    cpr_malloc(sizeof(cprCallBackTimerMsg_t));
                if (timerMsg) {
                    timerMsg->expiredTimerName =
                        timerListHead->cprTimerPtr->name;
                    //CPR_INFO("%s: timer %s expired..\n",fname,
                    //       timerMsg->expiredTimerName);

                    timerMsg->expiredTimerId =
                        timerListHead->cprTimerPtr->applicationTimerId;
                    timerMsg->usrData =
                        timerListHead->cprTimerPtr->data;
                    syshdr = cprGetSysHeader(timerMsg);
                    if (syshdr) {
                        fillInSysHeader(syshdr,
                                        timerListHead->cprTimerPtr->applicationMsgId,
                                        sizeof(cprCallBackTimerMsg_t), timerMsg);
                        if (cprSendMessage(timerListHead->cprTimerPtr->callBackMsgQueue,
                                           timerMsg, (void **) &syshdr) == CPR_FAILURE) {
                            cprReleaseSysHeader(syshdr);
                            cpr_free(timerMsg);
                            CPR_ERROR("%s - Call to cprSendMessage failed\n", fname);
                            CPR_ERROR("%s - Unable to send timer %s expiration msg\n",
                                      fname, timerListHead->cprTimerPtr->name);
                        }
                    } else {
                        cpr_free(timerMsg);
                        CPR_ERROR("%s - Call to cprGetSysHeader failed\n", fname);
                        CPR_ERROR("%s - Unable to send timer %s expiration msg\n",
                                  fname, timerListHead->cprTimerPtr->name);
                    }
                } else {
                    CPR_ERROR("%s - Call to cpr_malloc failed\n", fname);
                    CPR_ERROR("%s - Unable to send timer %s expiration msg\n",
                              fname, timerListHead->cprTimerPtr->name);
                }
                (void) removeTimer(timerListHead->cprTimerPtr);
            } else {
                /* The rest of the timers on the list have not yet expired */
                processingTimers = FALSE;
            }
        } else {
            /* The timer list is now empty */
            processingTimers = FALSE;
        }
    } /* still more to process */
}