Optimal configuration of LoRa networks in smart cities