1.5.3.2 Using The Library

The PRIME User PIBs service library is called by the PRIME Stack to get and set user PIBs.

The following example illustrates how the User PIBs service can be used.

Example of PRIME User PIBs library usage

static void mlme_get_request_result_cb(uint8_t result, uint16_t pibAttrib, void *pibValue, uint8_t pibSize)
{
    /* Generate callback to upper layer */
}

static void mlme_set_request_result_cb(uint8_t result)
{
    /* Generate callback to upper layer */
}

void mlme_init(void)
{
    /* Set callbacks to User PIBs Service */
    SRV_USER_PIB_GetRequestCbRegister(mlme_get_request_result_cb);
    SRV_USER_PIB_SetRequestCbRegister(mlme_set_request_result_cb);
}

void mlme_get_request(uint16_t pibAttrib)
{
    /* Check user additional access */
    if ((pibAttrib >= 0xF000) && (pibAttrib <= 0xFCFF)) 
    {
        /* Get value from user application */
        SRV_USER_PIB_GetRequest(pibAttrib);
    } 
}

void mlme_set_request(uint16_t pibAttrib, void *pibValue, uint8_t pibSize)
{
    /* Check user additional access */
    if ((pibAttrib >= 0xF000) && (pibAttrib <= 0xFCFF)) 
    {
        /* Set value in user application */
        SRV_USER_PIB_SetRequest(pibAttrib, pibValue, pibSize);
    }
}