AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/xplained/bname.c
uint8_t bacnet_name_encode(
    uint8_t *buffer,
    uint8_t buffer_len,
    uint8_t encoding,
    char *str,
    uint8_t str_len)
{
    unsigned len = 0;
    unsigned i = 0;

    if (str_len < (255-2)) {
        len = 1 + 1 + str_len;
        if (len <= buffer_len) {
            buffer[NVM_NAME_LENGTH(0)] = str_len;
            buffer[NVM_NAME_ENCODING(0)] = encoding;
            for (i = 0; i < str_len; i++) {
                buffer[NVM_NAME_STRING(0)+i] = str[i];
            }
        } else {
            len = 0;
        }
    }

    return len;
}
/*************************************************************************
* DESCRIPTION: Encode the name in a buffer in the sequence stored in EEPROM.
* RETURN: number of bytes in buffer, or 0 if too big to fit.
* NOTES: none
**************************************************************************/
Encode the name in a buffer in the sequence stored in EEPROM.
RETURN: number of bytes in buffer, or 0 if too big to fit.
NOTES: none
Encode the name in a buffer in the sequence stored in EEPROM . RETURN : number of bytes in buffer or 0 if too big to fit . NOTES : none
uint8_t bacnet_name_encode(
    uint8_t *buffer,
    uint8_t buffer_len,
    uint8_t encoding,
    char *str,
    uint8_t str_len)
{
    unsigned len = 0;
    unsigned i = 0;
    if (str_len < (255-2)) {
        len = 1 + 1 + str_len;
        if (len <= buffer_len) {
            buffer[NVM_NAME_LENGTH(0)] = str_len;
            buffer[NVM_NAME_ENCODING(0)] = encoding;
            for (i = 0; i < str_len; i++) {
                buffer[NVM_NAME_STRING(0)+i] = str[i];
            }
        } else {
            len = 0;
        }
    }
    return len;
}
uint8_t bacnet_name_encode ( uint8_t * buffer , uint8_t buffer_len , uint8_t encoding , char * str , uint8_t str_len ) { unsigned len = 0 ; unsigned i = 0 ; if ( str_len < ( 255 - 2 ) ) { len = 1 + 1 + str_len ; if ( len <= buffer_len ) { buffer [ NVM_NAME_LENGTH ( 0 ) ] = str_len ; buffer [ NVM_NAME_ENCODING ( 0 ) ] = encoding ; for ( i = 0 ; i < str_len ; i ++ ) { buffer [ NVM_NAME_STRING ( 0 ) + i ] = str [ i ] ; } } else { len = 0 ; } } return len ; }
DESCRIPTION: Encode the name in a buffer in the sequence stored in EEPROM.
DESCRIPTION : Encode the name in a buffer in the sequence stored in EEPROM .