This paper presents a project on building intelligent middleware on wireless sensor devices for machine-to-machine systems (M2M). Most current M2M and IoT applications are built for fixed sensor platforms with a specific wireless network support. Such software supports a unique set of sensors, and results in applications that are fragile and cannot be ported to other platforms. Our research is to develop intelligent middleware for deploying flexible and evolvable applications. We implement the application deployment capability where an M2M application does not need to be constrained on what and how sensors are deployed. Our intelligent M2M middleware can automatically perform sensor identification, node configuration, software upgrade, and system re-configuration.