src/luos.c
service_t *Luos_CreateService(SERVICE_CB service_cb, uint8_t type, const char *alias, revision_t revision)
{
    uint8_t i           = 0;
    service_t *service  = &service_table[service_number];
    service->ll_service = Robus_ServiceCreate(type);

    // Link the service to his callback
    service->service_cb = service_cb;
    // Save default alias
    for (i = 0; i < MAX_ALIAS_SIZE - 1; i++)
    {
        service->default_alias[i] = alias[i];
        if (service->default_alias[i] == '\0')
            break;
    }
    service->default_alias[i] = '\0';
    // Initialise the service alias to 0
    memset((void *)service->alias, 0, sizeof(service->alias));
    if (Luos_ReadAlias(service_number, (uint8_t *)service->alias) == FAILED)
    {
        // if no alias saved keep the default one
        for (i = 0; i < MAX_ALIAS_SIZE - 1; i++)
        {
            service->alias[i] = alias[i];
            if (service->alias[i] == '\0')
                break;
        }
        service->alias[i] = '\0';
    }

    //Initialise the service revision to 0
    memset((void *)service->revision.unmap, 0, sizeof(revision_t));
    // Save firmware version
    for (i = 0; i < sizeof(revision_t); i++)
    {
        service->revision.unmap[i] = revision.unmap[i];
    }

    //initiate service statistics
    service->node_statistics               = &luos_stats;
    service->ll_service->ll_stat.max_retry = &service->statistics.max_retry;

    service_number++;
    LUOS_ASSERT(service_number <= MAX_SERVICE_NUMBER);
    return service;
}
/******************************************************************************
 * @brief API to Create a service
 * @param callback msg handler for the service
 * @param type of service corresponding to object dictionnary
 * @param alias for the service string (15 caracters max).
 * @param version FW for the service (tab[MajorVersion,MinorVersion,Patch])
 * @return service object pointer.
 ******************************************************************************/
@brief API to Create a service
@param callback msg handler for the service
@param type of service corresponding to object dictionnary
@param alias for the service string (15 caracters max).
@param version FW for the service (tab[MajorVersion,MinorVersion,Patch])
@return service object pointer.
@brief API to Create a service @param callback msg handler for the service @param type of service corresponding to object dictionnary @param alias for the service string ( 15 caracters max ) . @param version FW for the service ( tab [ MajorVersion MinorVersion Patch ] ) @return service object pointer .
service_t *Luos_CreateService(SERVICE_CB service_cb, uint8_t type, const char *alias, revision_t revision)
{
    uint8_t i           = 0;
    service_t *service  = &service_table[service_number];
    service->ll_service = Robus_ServiceCreate(type);
    service->service_cb = service_cb;
    for (i = 0; i < MAX_ALIAS_SIZE - 1; i++)
    {
        service->default_alias[i] = alias[i];
        if (service->default_alias[i] == '\0')
            break;
    }
    service->default_alias[i] = '\0';
    memset((void *)service->alias, 0, sizeof(service->alias));
    if (Luos_ReadAlias(service_number, (uint8_t *)service->alias) == FAILED)
    {
        for (i = 0; i < MAX_ALIAS_SIZE - 1; i++)
        {
            service->alias[i] = alias[i];
            if (service->alias[i] == '\0')
                break;
        }
        service->alias[i] = '\0';
    }
    memset((void *)service->revision.unmap, 0, sizeof(revision_t));
    for (i = 0; i < sizeof(revision_t); i++)
    {
        service->revision.unmap[i] = revision.unmap[i];
    }
    service->node_statistics               = &luos_stats;
    service->ll_service->ll_stat.max_retry = &service->statistics.max_retry;
    service_number++;
    LUOS_ASSERT(service_number <= MAX_SERVICE_NUMBER);
    return service;
}
service_t * Luos_CreateService ( SERVICE_CB service_cb , uint8_t type , const char * alias , revision_t revision ) { uint8_t i = 0 ; service_t * service = & service_table [ service_number ] ; service -> ll_service = Robus_ServiceCreate ( type ) ; service -> service_cb = service_cb ; for ( i = 0 ; i < MAX_ALIAS_SIZE - 1 ; i ++ ) { service -> default_alias [ i ] = alias [ i ] ; if ( service -> default_alias [ i ] == ' \0 ' ) break ; } service -> default_alias [ i ] = ' \0 ' ; memset ( ( void * ) service -> alias , 0 , sizeof ( service -> alias ) ) ; if ( Luos_ReadAlias ( service_number , ( uint8_t * ) service -> alias ) == FAILED ) { for ( i = 0 ; i < MAX_ALIAS_SIZE - 1 ; i ++ ) { service -> alias [ i ] = alias [ i ] ; if ( service -> alias [ i ] == ' \0 ' ) break ; } service -> alias [ i ] = ' \0 ' ; } memset ( ( void * ) service -> revision . unmap , 0 , sizeof ( revision_t ) ) ; for ( i = 0 ; i < sizeof ( revision_t ) ; i ++ ) { service -> revision . unmap [ i ] = revision . unmap [ i ] ; } service -> node_statistics = & luos_stats ; service -> ll_service -> ll_stat . max_retry = & service -> statistics . max_retry ; service_number ++ ; LUOS_ASSERT ( service_number <= MAX_SERVICE_NUMBER ) ; return service ; }
@brief API to Create a service
 @param callback msg handler for the service
 @param type of service corresponding to object dictionnary
 @param alias for the service string (15 caracters max).
@brief API to Create a service @param callback msg handler for the service @param type of service corresponding to object dictionnary @param alias for the service string ( 15 caracters max ) .
// Link the service to his callback // Save default alias // Initialise the service alias to 0 // if no alias saved keep the default one //Initialise the service revision to 0 // Save firmware version //initiate service statistics