本文整理汇总了Java中com.getpebble.android.kit.util.PebbleDictionary.addUint8方法的典型用法代码示例。如果您正苦于以下问题:Java PebbleDictionary.addUint8方法的具体用法?Java PebbleDictionary.addUint8怎么用?Java PebbleDictionary.addUint8使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.getpebble.android.kit.util.PebbleDictionary
的用法示例。
在下文中一共展示了PebbleDictionary.addUint8方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendImagePacket
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendImagePacket()
{
PebbleDictionary data = new PebbleDictionary();
data.addUint8(0, (byte) 1);
data.addUint8(1, (byte) 2);
data.addUint16(2, (short) 0); //Image size placeholder
int maxBytesToSend = PebbleUtil.getBytesLeft(data, getService().getPebbleCommunication().getConnectedWatchCapabilities());
int bytesToSend = Math.min(callerImageBytes.length - callerImageNextByte, maxBytesToSend);
byte[] bytes = new byte[bytesToSend];
System.arraycopy(callerImageBytes, callerImageNextByte, bytes, 0, bytesToSend);
data.addUint16(2, (short) bytesToSend); //Image size placeholder
data.addBytes(3, bytes);
getService().getPebbleCommunication().sendToPebble(data);
Timber.d("Sent image packet %d / %d", callerImageNextByte, callerImageBytes.length);
callerNameUpdateRequired = false;
callerImageNextByte += bytesToSend;
if (callerImageNextByte >= callerImageBytes.length)
callerImageNextByte = -1;
}
示例2: sendGroupNames
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendGroupNames()
{
if (nextGroupNameToSend >= pickedContactGroups.size())
{
nextGroupNameToSend = -1;
return;
}
PebbleDictionary packet = new PebbleDictionary();
packet.addUint8(0, (byte) 0);
packet.addUint8(1, (byte) 2);
packet.addUint8(2, (byte) nextGroupNameToSend);
int num = Math.min(nextGroupNameToSend + 3, pickedContactGroups.size() - 1) - nextGroupNameToSend;
for (int i = 0; i <= num; i++)
{
packet.addString(3 + i, pickedContactGroups.get(nextGroupNameToSend + i).getName());
}
nextGroupNameToSend += 3;
getService().getPebbleCommunication().sendToPebble(packet);
}
示例3: initializeSegment
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
* Sends values like transport mode (line number) and other segment related values
* Doesn't send the waypoints, they have to be sent after calling this.
* Parameters: line = transport line e.g. 550, hours = hours of day,
* minutes = minutes of hour...
*/
public void initializeSegment(String line, String stopName, String stopCode, int hours, int minutes, int seconds) {
PebbleDictionary dictionary = new PebbleDictionary();
dictionary.addUint8(KEY_COMMAND, (byte) COMMAND_INIT_SEGMENT);
dictionary.addString(KEY_LINE_NUMBER, line);
dictionary.addString(KEY_FIRST_STOP_NAME, stopName);
dictionary.addString(KEY_FIRST_STOP_CODE, stopCode);
dictionary.addUint8(KEY_START_TIME_HOUR, (byte) hours);
dictionary.addUint8(KEY_START_TIME_MIN, (byte) minutes);
dictionary.addUint8(KEY_START_TIME_SEC, (byte) seconds);
/**
* En-queue this message to MessageHandler.
*/
System.out.println("PEBBLE_DBG: sending time:" + hours + "." + minutes + "." + seconds);
messageManager.offer(dictionary);
System.out.println("DBG PebbleCommunication:initializeSegment: " + line);
}
示例4: sendWatchappIcon
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private boolean sendWatchappIcon()
{
Timber.d("Sending icon");
PebbleDictionary data = new PebbleDictionary();
data.addUint8(0, (byte) 1);
data.addUint8(1, (byte) 2);
data.addInt32(2, curSendingNotification.id);
curSendingNotification.needsIconSending = false;
// Only send icon if it can fit into one Appmessage
if (curSendingNotification.iconData.length <= PebbleUtil.getBytesLeft(data, getService().getPebbleCommunication().getConnectedWatchCapabilities()))
{
data.addBytes(3, curSendingNotification.iconData);
getService().getPebbleCommunication().sendToPebble(data);
return true;
}
else
{
Timber.d("Sending failed! Icon cannot fit into AppMessage.");
return sendNextMessage(); //Icon sending failed, send next message in a row.
}
}
示例5: updateCurrentWeather
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的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);
}
示例6: sendPrecipitation
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的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();
}
}
}
}
示例7: getPebbleSdSettings
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的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);
}
示例8: getPebbleData
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的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);
}
示例9: noNetworkFound
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的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);
}
示例10: discover
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的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.");
}
}
}
示例11: sendNoNewDataMsg
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
* Inform the watch that its dataset is up-to-date
*/
private void sendNoNewDataMsg() {
Log.d("PebbleCommunication", "Informing watch that its dataset is up-to-date");
PebbleDictionary data = new PebbleDictionary();
data.addUint8(PEBBLE_KEY_COMMAND, PEBBLE_COMMAND_NO_NEW_DATA);
sendMessage(data, false);
}
示例12: sendInitDataMsg
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
* Sends init message.
*
* @param numberOfItems
* @param syncId
* Id of this sync process to report to the watch
*/
private void sendInitDataMsg(int numberOfItems, byte syncId) {
Log.d("PebbleCommunication", "sending init message, advertising " + numberOfItems + " items and syncId " + syncId);
PebbleDictionary data = new PebbleDictionary();
data.addUint8(PEBBLE_KEY_COMMAND, PEBBLE_COMMAND_INIT_DATA); // command
data.addUint8(PEBBLE_KEY_NUM_ITEMS, (byte) numberOfItems); // number of items we will send
data.addUint8(PEBBLE_KEY_SYNC_ID, syncId); // id of the data we're about to send (to compare against existing data)
data.addUint8(PEBBLE_KEY_VERSION, CURRENT_WATCHAPP_VERSION_MINIMUM); // expected minimum watchapp version
addPebbleSettings(data); // general and design settings
sendMessage(data, false);
}
示例13: sendItem
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
* Sends a message with the item
*
* @param e the item to send
* @param index the index in this sync
*/
private void sendItem(AgendaItem e, int index) {
PebbleDictionary data = new PebbleDictionary();
data.addUint8(PEBBLE_KEY_COMMAND, PEBBLE_COMMAND_ITEM); // command
data.addUint8(PEBBLE_KEY_ITEM_INDEX, (byte) index);
data.addString(PEBBLE_KEY_ITEM_TEXT1, e.line1 == null ? "" : stringToSendableString(e.line1.text));
data.addString(PEBBLE_KEY_ITEM_TEXT2, e.line2 == null ? "" : stringToSendableString(e.line2.text));
data.addUint8(PEBBLE_KEY_ITEM_DESIGN1, e.line1 == null ? 0 : getPebbleDesign(e.line1, 1));
data.addUint8(PEBBLE_KEY_ITEM_DESIGN2, e.line2 == null ? 0 : getPebbleDesign(e.line2, 2));
data.addInt32(PEBBLE_KEY_ITEM_START_TIME, e.getStartTimeInPebbleFormat());
data.addInt32(PEBBLE_KEY_ITEM_END_TIME, e.getEndTimeInPebbleFormat());
sendMessage(data, false);
}
示例14: sendFirstItemHalf
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
* Sends a message with the first half of an item
* @param e the item to send
* @param index the index in this sync
*/
private void sendFirstItemHalf(AgendaItem e, int index) {
PebbleDictionary data = new PebbleDictionary();
data.addUint8(PEBBLE_KEY_COMMAND, PEBBLE_COMMAND_ITEM_1); // command
data.addUint8(PEBBLE_KEY_ITEM_INDEX, (byte) index);
data.addString(PEBBLE_KEY_ITEM_TEXT1, e.line1 == null ? "" : stringToSendableString(e.line1.text));
data.addUint8(PEBBLE_KEY_ITEM_DESIGN1, e.line1 == null ? 0 : getPebbleDesign(e.line1, 1));
data.addInt32(PEBBLE_KEY_ITEM_START_TIME, e.getStartTimeInPebbleFormat());
sendMessage(data, false);
}
示例15: sendSecondItemHalf
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
* Sends a message with the first half of an item
* @param e the item to send
* @param index the index in this sync
*/
private void sendSecondItemHalf(AgendaItem e, int index) {
PebbleDictionary data = new PebbleDictionary();
data.addUint8(PEBBLE_KEY_COMMAND, PEBBLE_COMMAND_ITEM_2); // command
data.addUint8(PEBBLE_KEY_ITEM_INDEX, (byte) index);
data.addString(PEBBLE_KEY_ITEM_TEXT2, e.line2 == null ? "" : stringToSendableString(e.line2.text));
data.addUint8(PEBBLE_KEY_ITEM_DESIGN2, e.line2 == null ? 0 : getPebbleDesign(e.line2, 2));
data.addInt32(PEBBLE_KEY_ITEM_END_TIME, e.getEndTimeInPebbleFormat());
sendMessage(data, false);
}