/* Attach a specified sensor descriptor to a sensor device. 
Applications invoke this routine to attach a  */
bool sensor_attach(sensor_t *sensor, sensor_type_t type, int num, void *aux)
/* Attach a specified sensor descriptor to a sensor device. 
Applications invoke this routine to attach a  */
bool sensor_attach(sensor_t *sensor, sensor_type_t type, int num, void *aux)
{
	bool attached = false;
	sensor_hal_t *hal = sensor_find(type);
	sensor->hal  = hal;
	sensor->type = type;  
	sensor->aux  = aux;
	if ((hal != NULL) &&
			((hal->sensor_init)(sensor, num))) {
		sensor->mod = SENSOR_STATE_NORMAL;
		sensor->err = SENSOR_ERR_NONE;
		attached = true;
	} else {
		sensor->err = SENSOR_ERR_DRIVER;
	}
	return attached;
}