Due to the inherent nature of their heterogeneity, resource scarcity and dynamism, the provision of middleware for future networked embedded environments is a challenging task. In this paper we present a middleware approach that addresses these key challenges; we also discuss its application in a realistic networked embedded environment. Our application scenario involves fire management in a road tunnel that is instrumented with networked sensor and actuator devices. These devices are able to reconfigure their behaviour and their information dissemination strategies as they become damaged under emergency conditions, and firefighters are able to coordinate their operations and manage sensors and actuators through dynamic reprogramming. Our supporting middleware is based on a two-level architecture: the foundation is a language-independent, component-based programming model that is sufficiently minimal to run on any of the devices typically found in networked embedded environments. Above this is a layer of software components that offer the necessary middleware functionality. Rather than providing a monolithic middleware 'layer', we separate orthogonal areas of middleware functionality into self-contained components that can be selectively and individually deployed according to current resource constraints and application needs. Crucially, the set of such components can be updated at runtime to provide the basis of a highly dynamic and reconfigurable system.