当前位置: 首页>>代码示例>>Java>>正文


Java AttributeEvent.HEARTBEAT_FIRST属性代码示例

本文整理汇总了Java中com.o3dr.services.android.lib.drone.attribute.AttributeEvent.HEARTBEAT_FIRST属性的典型用法代码示例。如果您正苦于以下问题:Java AttributeEvent.HEARTBEAT_FIRST属性的具体用法?Java AttributeEvent.HEARTBEAT_FIRST怎么用?Java AttributeEvent.HEARTBEAT_FIRST使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.o3dr.services.android.lib.drone.attribute.AttributeEvent的用法示例。


在下文中一共展示了AttributeEvent.HEARTBEAT_FIRST属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    final Activity activity = getActivity();
    if(activity == null)
        return;

    final String action = intent.getAction();
    switch (action) {
        case AttributeEvent.STATE_DISCONNECTED:
            updateMavlinkVersionPreference(null);
            updateFirmwareVersionPreference(null);
            break;

        case AttributeEvent.HEARTBEAT_FIRST:
        case AttributeEvent.HEARTBEAT_RESTORED:
            int mavlinkVersion = intent.getIntExtra(AttributeEventExtra.EXTRA_MAVLINK_VERSION, -1);
            if (mavlinkVersion == -1)
                updateMavlinkVersionPreference(null);
            else
                updateMavlinkVersionPreference(String.valueOf(mavlinkVersion));
            break;

        case AttributeEvent.STATE_CONNECTED:
        case AttributeEvent.TYPE_UPDATED:
            Drone drone = dpApp.getDrone();
            if (drone.isConnected()) {
                Type droneType = drone.getAttribute(AttributeType.TYPE);
                updateFirmwareVersionPreference(droneType.getFirmwareVersion());
            } else
                updateFirmwareVersionPreference(null);
            break;
    }
}
 
开发者ID:sommishra,项目名称:DroidPlanner-Tower,代码行数:33,代码来源:SettingsFragment.java

示例2: onDroneEvent

@Override
public void onDroneEvent(String event, Bundle bundle) {
    try {
        final String action = new Intent(event).getAction();
        switch (action) {
            case AttributeEvent.STATE_DISCONNECTED:
                PebbleKit.closeAppOnPebble(applicationContext, DP_UUID);
                stopSelf();
                break;
            case AttributeEvent.STATE_CONNECTED:
            case AttributeEvent.HEARTBEAT_FIRST:
                PebbleKit.startAppOnPebble(applicationContext, DP_UUID);
                Thread.sleep(250);
                sendDataToWatchNow(drone);
                break;
            //Telem gets slow updates
            case AttributeEvent.BATTERY_UPDATED:
            case AttributeEvent.ATTITUDE_UPDATED:
                sendDataToWatchIfTimeHasElapsed(drone);
                break;
            //Mode changes get fast updates
            case AttributeEvent.STATE_VEHICLE_MODE:
            case AttributeEvent.FOLLOW_START:
            case AttributeEvent.STATE_ARMING:
            case AttributeEvent.STATE_UPDATED:
                sendDataToWatchNow(drone);
                break;
            //Follow type update gets fast update
            case AttributeEvent.FOLLOW_UPDATE:
                final FollowState followState = drone.getAttribute(AttributeType.FOLLOW_STATE);
                if(followState != null){
                    final FollowType followType = followState.getMode();
                    if(!previousFollowType.equals(followType)){
                        previousFollowType = followType;
                        sendDataToWatchNow(drone);
                    }
                }
        }
    }catch(Exception e){
        //TODO figure out what was messing up here
    }
}
 
开发者ID:DroidPlanner,项目名称:tower-pebble,代码行数:42,代码来源:PebbleCommunicatorService.java


注:本文中的com.o3dr.services.android.lib.drone.attribute.AttributeEvent.HEARTBEAT_FIRST属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。