/**
* @param array $device
* @param NAWSApiClient $client
* @return array $report : array with device or module ids as keys, and their data of the month as  values
* @brief retrieve month data for a device and its modules
*/
function getMonthReport($device, $client)
{
    $report = array();
    //step between two measurements
    $scale = '1month';
    //type of measures wanted
    $type = "Temperature,CO2,Humidity,Pressure,Noise,max_temp,date_max_temp,min_temp,date_min_temp,max_hum,date_max_hum,min_hum,date_min_hum,max_pressure,date_max_pressure,min_pressure,date_min_pressure,max_noise,date_max_noise,min_noise,date_min_noise,max_co2,date_max_co2,min_co2,date_min_co2";
    // main device
    try {
        $measure = $client->getMeasure($device['_id'], NULL, $scale, $type, NULL, "last", NULL, FALSE, FALSE);
        $measure = addMeasureKeys($measure, $type);
        $report[$device['_id']] = $measure;
    } catch (Netatmo\Exceptions\NAClientException $ex) {
        $report[$device['_id']] = "Error retrieving measure for " . $device['_id'] . ": " . $ex->getMessage();
    }
    foreach ($device['modules'] as $module) {
        switch ($module['type']) {
            //Outdoor
            case "NAModule1":
                $type = "temperature,humidity";
                break;
                //Wind Sensor
            //Wind Sensor
            case "NAModule2":
                $type = "WindStrength,WindAngle,GustStrength,GustAngle,date_max_gust";
                break;
                //Rain Gauge
            //Rain Gauge
            case "NAModule3":
                $type = "sum_rain";
                break;
                // Indoor
            // Indoor
            case "NAModule4":
                $type = "temperature,Co2,humidity,noise,pressure";
                break;
        }
        try {
            $measure = $client->getMeasure($device['_id'], $module['_id'], $scale, $type, NULL, "last", NULL, FALSE, FALSE);
            $measure = addMeasureKeys($measure, $type);
            $report[$module['_id']] = $measure;
        } catch (Netatmo\Exceptions\NAClientException $ex) {
            $report[$module['_id']] = "Error retrieving measure for " . $module['_id'] . ": " . $ex->getMessage();
        }
    }
    return $report;
}
 */
function printDevices($devices, $title = NULL)
{
    if (!is_null($devices) && is_array($devices) && !empty($devices)) {
        if (!is_null($title)) {
            printMessageWithBorder($title);
        }
        foreach ($devices as $device) {
            printWSBasicInfo($device);
        }
    }
}
//App client configuration
$scope = NAScopes::SCOPE_READ_STATION;
$config = array("client_id" => $client_id, "client_secret" => $client_secret, "username" => $test_username, "password" => $test_password);
$client = new NAWSApiClient($config);
//Authentication with Netatmo server (OAuth2)
try {
    $tokens = $client->getAccessToken();
} catch (NAClientException $ex) {
    handleError("An error happened while trying to retrieve your tokens: " . $ex->getMessage() . "\n", TRUE);
}
//Retrieve user's Weather Stations Information
try {
    //retrieve all stations belonging to the user, and also his favorite ones
    $data = $client->getData(NULL, TRUE);
    printMessageWithBorder("Weather Stations Basic Information");
} catch (NAClientException $ex) {
    handleError("An error occured while retrieving data: " . $ex->getMessage() . "\n", TRUE);
}
if (empty($data['devices'])) {