Goal-oriented communications for the IoT and application to data compression