A Service-Oriented ZigBee Gateway for Smart Environments