예시
list-menu피드백이 있습니까?

이 예시에서는 타사 USB 입력 장치 (이 경우 리모컨) 의 키를 사용하여 Cisco 장치의 특정 기능을 제어하는 방법을 보여 드리려고 해요.

블루투스 리모컨 (USB 동글로 연결됨) 의 버튼을 사용하여 대기, 볼륨 조절, Cisco 카메라 기기 제어 같은 기능을 관리하는 방법을 보여드릴게요. Cisco 장치 API를 통해 관련 이벤트를 수신하고 해당 작업을 실행하는 매크로를 개발할 수 있어요.

다음 예에서는 보통 글꼴로 쓰여진 텍스트를 입력해야 해요. 기울임꼴로 표시된 텍스트는 Cisco 디바이스에서 받은 응답이에요.

1

SSH로 시스코 디바이스에 로그인해요. 로컬 관리자가 필요해요.

2

타사 USB 리모컨을 사용할 수 있도록 장치를 구성하세요.


       xConfiguration Peripherals InputDevice Mode: On 
      ** end OK  
               

 

다음 명령을 사용하여 구성이 켜져 있는지 꺼져 있는지 확인할 수 있어요.


        xConfiguration Peripherals InputDevice Mode 
        *c xConfiguration Peripherals InputDevice Mode: On ** end OK  
                  
3

피드백을 받으려면 등록하세요. 리모컨 버튼을 눌렀다가 놓았을 때 알림을 받을 수 있어요.


       xFeedback Register /event/userinterface/inputdevice 
       ** end OK  
               

 

이 명령을 사용하여 기기가 어떤 피드백을 등록했는지 확인할 수 있어요.


        xFeedback list 
       /event/userinterface/inputdevice ** end OK  
                  
4

피드백 등록이 작동하는지 확인하려면 리모컨의 버튼을 눌렀다 놓으세요.

이 액션은 프레스드 이벤트와 릴리즈됨 이벤트 두 개를 생성해요. 버튼을 길게 누르면 버튼을 놓을 때까지 Pressed 이벤트가 보여요. 그러면 릴리즈됨 이벤트가 생성돼요.

Enter 키 눌렀다 놓으면 다음 이벤트가 실행돼요.

 
                   *e UserInterface InputDevice Key Action Key: KEY_ENTER *e UserInterface InputDevice Key Action Code: 28 *e UserInterface InputDevice Key Action Type: Pressed ** end *e UserInterface InputDevice Key Action Key: KEY_ENTER *e UserInterface InputDevice Key Action Code: 28 *e UserInterface InputDevice Key Action Type: Released ** end  
               
5

관련 InputDevice 이벤트를 수신하고 장치의 API를 사용하여 관련 작업을 수행하는 매크로를 작성하세요.

  • 대기, 볼륨 업, 볼륨 다운 버튼에 활기를 불어넣으세요. 매크로가 KEY_VOLUMUP, KEY_VOLUMEDOWN 또는 KEY_SLEEP을 포함하는 이벤트를 보면 관련 명령을 실행해요.

  • 화살표 키에 카메라 제어 함수를 만들어주세요. 버튼이 눌려 있는 한 계속 카메라를 움직이고 싶어요. 버튼을 놓으면 카메라 움직임이 멈춰요. 매크로가 KEY_LEFT, KEY_RIGHT, KEY_UP 또는 KEY_DOWN을 포함하는 이벤트를 보면 관련 명령을 실행해요.


       const xapi = require('xapi'); function com(command, args='') { xapi.command(command, args); log(command + ' ' + JSON.stringify(args)); } function log(event) { console.log(event); } function notify(message) { xapi.command('UserInterface Message TextLine Display', { Text: message, duration: 3 }); } function cameraControl(motor, direction, cameraId='1') { com('Camera Ramp', { 'CameraId': cameraId, [motor]: direction }); } function init() { let standbyState; xapi.status.get('Standby').then((state) => {standbyState = state.State === 'Off' ? false : true; }); xapi.status.on('Standby', state => { standbyState = state.State === 'Off' ? false : true; }); xapi.event.on('UserInterface InputDevice Key Action', press => { if (press.Type == "Pressed") { switch (press.Key) { case "KEY_LEFT": cameraControl('Pan', 'Left'); break; case "KEY_RIGHT": cameraControl('Pan', 'Right'); break; case "KEY_UP": cameraControl('Tilt', 'Up'); break; case "KEY_DOWN": cameraControl('Tilt', 'Down'); break; default: break; } } else if (press.Type == "Released") { switch (press.Key) { case "KEY_LEFT": cameraControl('Pan', 'Stop'); break; case "KEY_RIGHT": cameraControl('Pan', 'Stop'); break; case "KEY_UP": cameraControl('Tilt', 'Stop'); break; case "KEY_DOWN": cameraControl('Tilt', 'Stop'); break; case 'KEY_VOLUMEUP': com('Audio Volume Increase'); break; case 'KEY_VOLUMEDOWN': com('Audio Volume Decrease'); break; case 'KEY_SLEEP': com(standbyState ? 'Standby Deactivate' : 'Standby Activate'); break; default: break; } } }); } init(); 
     
이 문서가 도움이 되었습니까?
이 문서가 도움이 되었습니까?