Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible pointer types between CellularAtParseTokenHandler_t and functions in cellular_common_api.h #164

Closed
thirtytwobits opened this issue Feb 29, 2024 · 2 comments
Assignees

Comments

@thirtytwobits
Copy link

Most of the implementations I've seen of this interface are like FreeRTOS-Cellular-Interface-Reference-Quectel-BG96/source/cellular_bg96_urc_handler.c where an array of CellularAtParseTokenMap_t is defined using functions like Cellular_CommonUrcProcessCereg from cellular_common_api.h:

CellularAtParseTokenMap_t CellularUrcHandlerTable[] =
{
    { "CEREG",          Cellular_CommonUrcProcessCereg },
    { "CGREG",          Cellular_CommonUrcProcessCgreg },
    { "CREG",           Cellular_CommonUrcProcessCreg  },
    { "POWERED DOWN",   _Cellular_ProcessPowerDown     },
    { "PSM POWER DOWN", _Cellular_ProcessPsmPowerDown  },
    { "QIND",           _Cellular_ProcessIndication    },
    { "QIOPEN",         _Cellular_ProcessSocketOpen    },
    { "QIURC",          _Cellular_ProcessSocketurc     },
    { "QSIMSTAT",       _Cellular_ProcessSimstat       },
    { "RDY",            _Cellular_ProcessModemRdy      }
};

If you look at CellularAtParseTokenHandler_t, however, you'll see it's defined as a function pointer to a function that does not return a value whereas Cellular_CommonUrcProcessCgreg returns a CellularError_t. Are the implementations wrong to use this function in this manner or is there a flaw in the interface design?

@chinglee-iot chinglee-iot self-assigned this Mar 4, 2024
@chinglee-iot
Copy link
Member

@thirtytwobits
URC parsing error is handled in port URC handler implementation. Therefore, it is defined as a function pointer with no return value. Cellular_CommonUrcProcessCgreg is common handler implementation for 3GPP URC. The return value helps to indicate the URC parsing status to the port. Cellular port can make use of this common handler with the following example code:

void _Cellular_ProcessCgreg( CellularContext_t * pContext,
                                               char * pInputLine )
{
    CellularPktStatus_t pktStatus;
    pktStatus = Cellular_CommonUrcProcessCgreg( pContext, pInputLine );
    if( pktStatus != CELLULAR_PKT_STATUS_OK )
    {
        /* Handle different packet status error code here. */
    }
}

Thank you for creating this issue. We would like to create a PR to update BG96 port with the example above.

@chinglee-iot
Copy link
Member

The BG96 implementation is updated in this PR FreeRTOS/FreeRTOS-Cellular-Interface-Reference-Quectel-BG96@1c71555. Thank you for reporting this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants