本文整理汇总了Java中com.getpebble.android.kit.PebbleKit.sendDataToPebble方法的典型用法代码示例。如果您正苦于以下问题:Java PebbleKit.sendDataToPebble方法的具体用法?Java PebbleKit.sendDataToPebble怎么用?Java PebbleKit.sendDataToPebble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.getpebble.android.kit.PebbleKit
的用法示例。
在下文中一共展示了PebbleKit.sendDataToPebble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendForecast
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
private void sendForecast()
{
Collections.sort(m_forecast);
int utcOffset = TimeZone.getDefault().getRawOffset();
long startOfToday = getStartOfDay().getTime();
long minutesSinceStartOfToday = (Calendar.getInstance().getTime().getTime() - startOfToday) / 60000;
for (Forecast f : m_forecast) {
if (m_nackCount > 5)
return;
long minInFuture = (f.getTimeFrom().getTime() - startOfToday + utcOffset) / 60000;
// 172px, 1 px per half-hour period = 5160 minutes; but
// minInFuture is from startOfToday so we usually need to go higher than 5160
if (minInFuture - minutesSinceStartOfToday < 5200 && f.getTemperature() != null) {
PebbleDictionary out = new PebbleDictionary();
out.addInt16(KEY_FORECAST_MINUTES, (short)minInFuture);
out.addInt16(KEY_FORECAST_TEMPERATURE, (short)Math.round(f.getTemperature().getTemperatureDouble() * 10));
// TODO add wind speed? what else?
PebbleKit.sendDataToPebble(m_weatherService, WATCHAPP_UUID, out);
try {
Thread.sleep(SLEEP_BETWEEN_PACKETS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
示例2: updateLocation
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void updateLocation(double lat, double lon, String name, int distance) {
// Log.d(TAG, "updateLocation " + lat + " " + lon + " '" + name + "'");
if (name.isEmpty())
name = String.format("%.4f,%.4f", lat, lon);
PebbleDictionary out = new PebbleDictionary();
out.addInt32(KEY_LAT, (int)Math.round(lat * 1000));
out.addInt32(KEY_LON, (int)Math.round(lon * 1000));
out.addString(KEY_LOCATION_NAME, name);
PebbleKit.sendDataToPebble(m_weatherService, WATCHAPP_UUID, out);
}
示例3: updateCurrentWeather
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void updateCurrentWeather(double temperature, double cloudCover, WeatherIcon icon,
double windSpeed, double windBearing, double humidity, double dewPoint,
double pressure, double ozone, double precipIntensity) {
m_updatedSinceConnected = true;
// TODO send more to the pebble
String tempStr = Math.round(temperature) + "°";
if (icon == null)
return;
// Log.d(TAG, "updateCurrentWeather " + tempStr + " " + cloudCover + "% " + icon.getValue());
PebbleDictionary out = new PebbleDictionary();
out.addString(KEY_TEMPERATURE, tempStr);
out.addUint8(KEY_CLOUD_COVER, (byte)Math.round(cloudCover * 100)); // from fraction (e.g. 0.25) to int percent, so it fits in a byte
out.addUint8(KEY_WEATHER_ICON, icon.getValue());
PebbleKit.sendDataToPebble(m_weatherService, WATCHAPP_UUID, out);
}
示例4: sendPrecipitation
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
private void sendPrecipitation()
{
Collections.sort(m_precipitation);
int utcOffset = TimeZone.getDefault().getRawOffset();
long startOfToday = getStartOfDay().getTime();
long minutesSinceStartOfToday = (Calendar.getInstance().getTime().getTime() - startOfToday) / 60000;
for (Forecast f : m_precipitation) {
if (m_nackCount > 5)
return;
long minInFuture = (f.getTimeFrom().getTime() - startOfToday + utcOffset) / 60000;
// 172px, 1 px per half-hour period = 5160 minutes; but
// minInFuture is from startOfToday so we usually need to go higher than 5160
if (minInFuture - minutesSinceStartOfToday < 5200) {
PebbleDictionary out = new PebbleDictionary();
out.addInt16(KEY_PRECIPITATION_MINUTES, (short)minInFuture);
out.addUint8(KEY_FORECAST_PRECIPITATION, (byte) Math.round(f.getPrecipitation().getPrecipitation() * 10));
out.addUint8(KEY_FORECAST_PRECIPITATION_MIN, (byte) Math.round(f.getPrecipitation().getPrecipitationMin() * 10));
out.addUint8(KEY_FORECAST_PRECIPITATION_MAX, (byte) Math.round(f.getPrecipitation().getPrecipitationMax() * 10));
PebbleKit.sendDataToPebble(m_weatherService, WATCHAPP_UUID, out);
try {
Thread.sleep(SLEEP_BETWEEN_PACKETS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
示例5: sendNowCast
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
private void sendNowCast()
{
if (m_busySending)
return;
m_busySending = true;
long now = System.currentTimeMillis();
int utcOffset = TimeZone.getDefault().getRawOffset();
PebbleDictionary out = new PebbleDictionary();
int len = m_nowcast.size();
byte[] precipitation = new byte[len]; // in tenths of mm
byte[] minutesInFuture = new byte[len];
int i = 0;
for (Forecast f : m_nowcast) {
if (m_nackCount > 5)
return;
precipitation[i] = (byte) Math.round(f.getPrecipitation().getPrecipitation() * 10);
minutesInFuture[i] = (byte)((f.getTimeFrom().getTime() - now + utcOffset) / 60000);
Log.d(TAG, "nowcast " + f.getTimeFrom() + " (" + minutesInFuture[i] + " min from now)" + ": " + f.getPrecipitation());
++i;
try {
Thread.sleep(SLEEP_BETWEEN_PACKETS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
out.addBytes(KEY_NOWCAST_MINUTES, minutesInFuture);
out.addBytes(KEY_NOWCAST_PRECIPITATION, precipitation);
PebbleKit.sendDataToPebble(m_weatherService, WATCHAPP_UUID, out);
m_busySending = false;
}
示例6: onStartCommand
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if(!PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean("broadcast_to_pebble", false)) {
stopSelf();
return START_NOT_STICKY;
}
bgGraphBuilder = new BgGraphBuilder(mContext);
if(PebbleKit.isWatchConnected(mContext)) {
Log.i(TAG, "onStartCommand called. Sending Sync Request");
transactionFailed = false;
transactionOk = false;
sendStep = 5;
messageInTransit = false;
done = true;
sendingData = false;
dictionary.addInt32(SYNC_KEY, 0);
PebbleKit.sendDataToPebble(mContext, PEBBLEAPP_UUID, dictionary);
dictionary.remove(SYNC_KEY);
if(pebble_app_version.isEmpty() && sentInitialSync){
Log.d(TAG,"onStartCommand: No watch app version, sideloading");
sideloadInstall(mContext, WATCHAPP_FILENAME);
}
if(!pebble_app_version.contentEquals("xDrip-Pebble2") && sentInitialSync){
Log.d(TAG,"onStartCommand: Wrong watch app version, sideloading");
sideloadInstall(mContext, WATCHAPP_FILENAME);
}
sentInitialSync = true;
} else {
Log.d(TAG,"onStartCommand; No watch connected.");
}
return START_STICKY;
}
示例7: sendDownload
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void sendDownload() {
if (dictionary != null && mContext != null) {
Log.d(TAG, "sendDownload: Sending data to pebble");
messageInTransit = true;
transactionFailed = false;
transactionOk = false;
PebbleKit.sendDataToPebble(mContext, PEBBLEAPP_UUID, dictionary);
}
}
示例8: sendDownload
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void sendDownload(PebbleDictionary dictionary) {
if (PebbleKit.isWatchConnected(mContext)) {
if (dictionary != null && mContext != null) {
Log.d(TAG, "sendDownload: Sending data to pebble");
PebbleKit.sendDataToPebble(mContext, PEBBLEAPP_UUID, dictionary);
}
}
}
示例9: getPebbleSdSettings
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
/**
* Send our latest settings to the watch, then request Pebble App to send
* us its latest settings so we can check it has been set up correctly..
* Will be received as a message by the receiveData handler
*/
public void getPebbleSdSettings() {
Log.v(TAG, "getPebbleSdSettings() - sending required settings to pebble");
mUtil.writeToSysLogFile("SdDataSourcePebble.getPebbleSdSettings()");
sendPebbleSdSettings();
//Log.v(TAG, "getPebbleSdSettings() - requesting settings from pebble");
//mUtil.writeToSysLogFile("SdDataSourcePebble.getPebbleSdSettings() - and request settings from pebble");
PebbleDictionary data = new PebbleDictionary();
data.addUint8(KEY_SETTINGS, (byte) 1);
PebbleKit.sendDataToPebble(
mContext,
SD_UUID,
data);
}
示例10: sendPebbleSdSettings
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
/**
* Send the pebble watch settings that are stored as class member
* variables to the watch.
*/
public void sendPebbleSdSettings() {
Log.v(TAG, "sendPebblSdSettings() - preparing settings dictionary.. mSampleFreq=" + mSampleFreq);
mUtil.writeToSysLogFile("SdDataSourcePebble.sendPebbleSdSettings()");
// Watch Settings
final PebbleDictionary setDict = new PebbleDictionary();
setDict.addInt16(KEY_DEBUG, mDebug);
setDict.addInt16(KEY_DISPLAY_SPECTRUM, mDisplaySpectrum);
setDict.addInt16(KEY_DATA_UPDATE_PERIOD, mDataUpdatePeriod);
setDict.addInt16(KEY_MUTE_PERIOD, mMutePeriod);
setDict.addInt16(KEY_MAN_ALARM_PERIOD, mManAlarmPeriod);
setDict.addInt16(KEY_SD_MODE, mPebbleSdMode);
setDict.addInt16(KEY_SAMPLE_FREQ, mSampleFreq);
setDict.addInt16(KEY_SAMPLE_PERIOD, mSamplePeriod);
setDict.addInt16(KEY_ALARM_FREQ_MIN, mAlarmFreqMin);
setDict.addInt16(KEY_ALARM_FREQ_MAX, mAlarmFreqMax);
setDict.addUint16(KEY_WARN_TIME, mWarnTime);
setDict.addUint16(KEY_ALARM_TIME, mAlarmTime);
setDict.addUint16(KEY_ALARM_THRESH, mAlarmThresh);
setDict.addUint16(KEY_ALARM_RATIO_THRESH, mAlarmRatioThresh);
if (mFallActive)
setDict.addUint16(KEY_FALL_ACTIVE, (short) 1);
else
setDict.addUint16(KEY_FALL_ACTIVE, (short) 0);
setDict.addUint16(KEY_FALL_THRESH_MIN, mFallThreshMin);
setDict.addUint16(KEY_FALL_THRESH_MAX, mFallThreshMax);
setDict.addUint16(KEY_FALL_WINDOW, mFallWindow);
// Send Watch Settings to Pebble
Log.v(TAG, "sendPebbleSdSettings() - setDict = " + setDict.toJsonString());
PebbleKit.sendDataToPebble(mContext, SD_UUID, setDict);
}
示例11: getPebbleData
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
/**
* Request Pebble App to send us its latest data.
* Will be received as a message by the receiveData handler
*/
public void getPebbleData() {
Log.v(TAG, "getPebbleData() - requesting data from pebble");
mUtil.writeToSysLogFile("SdDataSourcePebble.getPebbleData() - requesting data from pebble");
PebbleDictionary data = new PebbleDictionary();
data.addUint8(KEY_DATA_TYPE, (byte) 1);
PebbleKit.sendDataToPebble(
mContext,
SD_UUID,
data);
}
示例12: doMessageUpdate
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
/**
* Sends a new word and definition to the watch and updates the textview
* within the main activity.
*/
private void doMessageUpdate()
{
// Make sure the watch is connected
if ( PebbleKit.isWatchConnected( getApplicationContext() ) )
{
// Make sure the current index is valid first
if ( currentIndex < 0 || currentIndex > wordsList.size() )
{
setRandomIndex();
}
PebbleDictionary dict = new PebbleDictionary();
dict.addString(
KEY_WORD, wordsList.get( currentIndex ) );
dict.addString( KEY_DEFINITION, definitionsList.get( currentIndex ) );
PebbleKit.sendDataToPebble( getApplicationContext(), MSG_UUID,
dict
);
txtview.setText( wordsList.get( currentIndex ) + " - "
+ definitionsList.get( currentIndex ) );
}
else
{
Toast.makeText(
getApplicationContext(),
"Warning, a pebble is not connected!",
Toast.LENGTH_LONG ).show();
}
}
示例13: sendDownload
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void sendDownload(PebbleDictionary dictionary) {
if (PebbleKit.isWatchConnected(context)) {
if (dictionary != null && context != null) {
Log.d(TAG, "Sending data to pebble");
PebbleKit.sendDataToPebble(context, PEBBLEAPP_UUID, dictionary);
}
}
}
示例14: noNetworkFound
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void noNetworkFound () {
if (PebbleKit.areAppMessagesSupported(getApplicationContext())) {
PebbleDictionary networkFail = new PebbleDictionary();
networkFail.addUint8(0, (byte) 0);
networkFail.addUint8(1, (byte) 0); // Filler value
networkFail.addString(2, "LIFX Network not found.");
Log.i("Dictionary", networkFail.toJsonString());
PebbleKit.sendDataToPebble(getApplicationContext(), PEBBLE_APP_UUID, networkFail);
Log.i("", "Data sent.");
}
PebbleKit.closeAppOnPebble(getApplicationContext(), PEBBLE_APP_UUID);
}
示例15: discover
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void discover() {
localNetworkContext = LFXClient.getSharedInstance(getApplicationContext()).getLocalNetworkContext();
localNetworkContext.connect();
bulbList = localNetworkContext.getAllLightsCollection().getLights();
Log.i("PebbLIFXService", "Bulb List: " + bulbList.toString());
if (bulbList == null) {
Log.e("PebbLIFXService","Nothing returned. No network found.");
sendMessage(0);
} else {
Log.i("PebbLIFXService", "Search has completed.");
int numberOfBulbs = bulbList.size();
Log.i("PebbLIFXService", "Bulb List Size:" + numberOfBulbs);
if (PebbleKit.areAppMessagesSupported(getApplicationContext())) {
PebbleDictionary bulbData = new PebbleDictionary();
bulbData.addUint8(0, (byte) 1);
bulbData.addUint8(1, (byte) numberOfBulbs); // Will only allow 255 bulbs to be passed.
int j = 2;
for (int i = 0; i < numberOfBulbs; i++) {
// First get the bulb name.
bulbData.addString(j++, bulbList.get(i).getLabel());
// Find out whether bulbs are on or off.
LFXPowerState a = bulbList.get(i).getPowerState();
if (a == LFXPowerState.ON) {
bulbData.addUint8(j++, (byte)1);
} else {
bulbData.addUint8(j++, (byte)0);
}
// TODO Fix brightness and hue getting. Returning nothing.
bulbData.addUint16(j++, (short)getUnsignedInt(bulbList.get(i).getColor().getBrightness()));
bulbData.addUint16(j++, (short)getUnsignedInt(bulbList.get(i).getColor().getHue()));
}
Log.i("PebbLIFXService", "Dictionary -> " + bulbData.toJsonString());
Log.i("PebbLIFXService", "Dictionary Size = " + bulbData.size());
PebbleKit.sendDataToPebble(getApplicationContext(), PEBBLE_APP_UUID, bulbData);
Log.i("PebbLIFXService", "Data sent.");
}
}
}