examples/google_voice_assistant/main/wmfwparse.cpp
/*
 *  Function:  ProcessBinFile
 * 
 *  @brief  Parses a WMFW file for loading to the device
 * 
 *  This function reads in a WMFW file, processes it, and sends it block by
 *  block to the device.
 * 
 *  @param  filename    File to parse
 *  
 */


@brief  Parses a WMFW file for loading to the device

This function reads in a WMFW file, processes it, and sends it block by
block to the device.

@param  filename    File to parse
@brief Parses a WMFW file for loading to the device This function reads in a WMFW file processes it and sends it block by block to the device . @param filename File to parse
int ProcessBinFile(const char *filename)
{
	int status = WMFW_SUCCESS;
	printf("\n\n----------------------------------------------------------\n");
	printf("Cofficient file processing...\n");
	FILE *binFile = fopen(filename, "rb");
	if (!binFile)
	{
		printf("\t%s could not be opened\n\tNo coefficent data will be downloaded\n\n", filename);
		return WMFW_SUCCESS;
	}
	else
	{
		printf("\t%s detected\n\tProcessing coefficent data", filename);
	}
	printf("\n----------------------------------------------------------\n\n");
	status = ProcessBinHeader(binFile);
	if (WMFW_SUCCESS != status)
	{
		printf("Error: ProcessBinHeader returned status %d.\n", status);
		return status;
	}
	while (WMFW_SUCCESS == status)
	{
		status = ProcessNextCoeffBlock(binFile);
	}
	if (binFile)
	{
		fclose(binFile);
		binFile = NULL;
	}
	if (WMFW_END_OF_FILE == status)
	{
		status = WMFW_SUCCESS;
	}
	return status;
}
int ProcessBinFile ( const char * filename ) { int status = WMFW_SUCCESS ; printf ( " \n \n \n " ) ; printf ( " \n " ) ; FILE * binFile = fopen ( filename , " " ) ; if ( ! binFile ) { printf ( " \t \n \t \n \n " , filename ) ; return WMFW_SUCCESS ; } else { printf ( " \t \n \t " , filename ) ; } printf ( " \n \n \n " ) ; status = ProcessBinHeader ( binFile ) ; if ( WMFW_SUCCESS != status ) { printf ( " \n " , status ) ; return status ; } while ( WMFW_SUCCESS == status ) { status = ProcessNextCoeffBlock ( binFile ) ; } if ( binFile ) { fclose ( binFile ) ; binFile = NULL ; } if ( WMFW_END_OF_FILE == status ) { status = WMFW_SUCCESS ; } return status ; }
Function:  ProcessBinFile
Function : ProcessBinFile
// Open our WMFW file // Note: This is not necessarily a fail condition, as a .bin file may not be required // and therefore not present // Read and process the header. // Now process all the blocks in the file.