7. Weather Sync
Sync weather information to the device. Currently only supports real-time weather sync, no weather forecast support.
Sample Code
//WatchManager is a subclass of WatchOpImpl, must be configured in sdk 1.3
WatchManager watchManager = WatchManager.getInstance();
String province = "Province";
String city = "City";
byte weatherCode = 0;//Weather code, refer to weather code table
byte temperature = 0;//Temperature
byte humidity = 0; //Humidity
byte windPower = 0; //Wind power level
byte windDirectionCode = 0; //Direction code, refer to direction code table
long time = System.currentTimeMillis(); //Time
//Build weather information
PushInfoDataToDeviceCmd.Weather weather = new PushInfoDataToDeviceCmd.Weather(province, city,
weatherCode, temperature,
humidity, windPower, windDirectionCode,
time
);
//Execute sync weather info function and wait for result callback
watchManager.syncWeatherInfo(weather, new OnWatchOpCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Weather sync success
}
@Override
public void onFailed(BaseError error) {
//Weather sync failure
//error - Error message
}
});
7.1. Weather Code Table
Code |
Description |
Code |
Description |
Code |
Description |
|---|---|---|---|---|---|
0 |
Sunny |
11 |
Shower rain |
22 |
Extreme rainfall |
1 |
Few clouds |
12 |
Thunder shower |
23 |
Sleet/rain and snow/snow weather |
2 |
Partly cloudy |
13 |
Thunder shower with hail |
24 |
Snow |
3 |
Cloudy |
14 |
Rain/light rain/fine rain |
25 |
Snow shower |
4 |
Overcast |
15 |
Moderate rain/heavy rain |
26 |
Light snow/moderate snow |
5 |
Windy |
16 |
Heavy rain/storm |
27 |
Moderate snow/heavy snow |
6 |
Calm |
17 |
Storm/severe storm |
28 |
Heavy snow/blizzard |
7 |
Strong wind |
18 |
Severe storm/extreme storm |
29 |
Blizzard |
8 |
Hurricane |
19 |
Extreme storm |
30 |
Dust |
9 |
Tropical storm |
20 |
Strong shower |
31 |
Dust storm |
10 |
Haze |
21 |
Strong thunder shower |
32 |
Sandstorm |
33 |
Strong sandstorm |
34 |
Tornado |
35 |
Fog/mist/dense fog |
36 |
Hot |
37 |
Cold |
38 |
Unknown |
7.2. Direction Code Table
code |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
Description |
No wind |
East |
South |
West |
North |
Southeast |
Northeast |
Northwest |
Southwest |
Variable |