@@ -56,17 +56,17 @@ function milesightDeviceEncode(payload) {
5656 if ( "jitter_config" in payload ) {
5757 encoded = encoded . concat ( setJitterConfig ( payload . jitter_config ) ) ;
5858 }
59- if ( "gpio_out_1_control " in payload ) {
60- encoded = encoded . concat ( controlOutputStatusWithDuration ( 1 , payload . gpio_out_1_control ) ) ;
59+ if ( "gpio_output_1_control " in payload ) {
60+ encoded = encoded . concat ( controlOutputStatusWithDuration ( 1 , payload . gpio_output_1_control ) ) ;
6161 }
62- if ( "gpio_out_2_control " in payload ) {
63- encoded = encoded . concat ( controlOutputStatusWithDuration ( 2 , payload . gpio_out_2_control ) ) ;
62+ if ( "gpio_output_2_control " in payload ) {
63+ encoded = encoded . concat ( controlOutputStatusWithDuration ( 2 , payload . gpio_output_2_control ) ) ;
6464 }
65- if ( "gpio_out_1 " in payload ) {
66- encoded = encoded . concat ( controlOutputStatus ( 1 , payload . gpio_out_1 ) ) ;
65+ if ( "gpio_output_1 " in payload ) {
66+ encoded = encoded . concat ( controlOutputStatus ( 1 , payload . gpio_output_1 ) ) ;
6767 }
68- if ( "gpio_out_2 " in payload ) {
69- encoded = encoded . concat ( controlOutputStatus ( 2 , payload . gpio_out_2 ) ) ;
68+ if ( "gpio_output_2 " in payload ) {
69+ encoded = encoded . concat ( controlOutputStatus ( 2 , payload . gpio_output_2 ) ) ;
7070 }
7171
7272 return encoded ;
@@ -225,16 +225,17 @@ function reportStatus(report_status) {
225225 * Set jitter config
226226 * @param {object } jitter_config
227227 * @param {number } jitter_config.all unit: millisecond
228- * @param {number } jitter_config.gpio_in_2 unit: millisecond
229- * @param {number } jitter_config.gpio_in_3 unit: millisecond
230- * @param {number } jitter_config.gpio_in_4 unit: millisecond
231- * @param {number } jitter_config.gpio_out_1 unit: millisecond
232- * @param {number } jitter_config.gpio_out_2 unit: millisecond
228+ * @param {number } jitter_config.gpio_input_1 unit: millisecond
229+ * @param {number } jitter_config.gpio_input_2 unit: millisecond
230+ * @param {number } jitter_config.gpio_input_3 unit: millisecond
231+ * @param {number } jitter_config.gpio_input_4 unit: millisecond
232+ * @param {number } jitter_config.gpio_output_1 unit: millisecond
233+ * @param {number } jitter_config.gpio_output_2 unit: millisecond
233234 * @example { "jitter_config": { "all": 100 } }
234- * @example { "jitter_config": { "gpio_in_1 ": 1000, "gpio_in_2 ": 1000 } }
235+ * @example { "jitter_config": { "gpio_input_1 ": 1000, "gpio_input_2 ": 1000 } }
235236 */
236237function setJitterConfig ( jitter_config ) {
237- var channel_map = { all : 0 , gpio_in_1 : 1 , gpio_in_2 : 2 , gpio_in_3 : 3 , gpio_in_4 : 4 , gpio_out_1 : 5 , gpio_out_2 : 6 } ;
238+ var channel_map = { all : 0 , gpio_input_1 : 1 , gpio_input_2 : 2 , gpio_input_3 : 3 , gpio_input_4 : 4 , gpio_output_1 : 5 , gpio_output_2 : 6 } ;
238239
239240 var data = [ ] ;
240241 for ( var key in channel_map ) {
@@ -252,23 +253,23 @@ function setJitterConfig(jitter_config) {
252253
253254/**
254255 * Control output with time
255- * @param {object } gpio_out_x_control
256- * @param {number } gpio_out_x_control .duration unit: millisecond
257- * @param {number } gpio_out_x_control .status values: (0: off, 1: on)
258- * @example { "gpio_out_1_control ": { "duration": 1000, "status": 1 } }
259- * @example { "gpio_out_2_control ": { "duration": 1000, "status": 0 } }
256+ * @param {object } gpio_output_x_control
257+ * @param {number } gpio_output_x_control .duration unit: millisecond
258+ * @param {number } gpio_output_x_control .status values: (0: off, 1: on)
259+ * @example { "gpio_output_1_control ": { "duration": 1000, "status": 1 } }
260+ * @example { "gpio_output_2_control ": { "duration": 1000, "status": 0 } }
260261 */
261- function controlOutputStatusWithDuration ( gpio_index , gpio_out_x_control ) {
262- var duration = gpio_out_x_control . duration ;
263- var status = gpio_out_x_control . status ;
262+ function controlOutputStatusWithDuration ( gpio_index , gpio_output_x_control ) {
263+ var duration = gpio_output_x_control . duration ;
264+ var status = gpio_output_x_control . status ;
264265 var gpio_chns = [ 1 , 2 ] ;
265266 if ( gpio_chns . indexOf ( gpio_index ) === - 1 ) {
266- throw new Error ( "gpio_out_x_control must be one of " + gpio_chns . join ( ", " ) ) ;
267+ throw new Error ( "gpio_output_x_control must be one of " + gpio_chns . join ( ", " ) ) ;
267268 }
268269 var on_off_map = { 0 : "off" , 1 : "on" } ;
269270 var on_off_values = getValues ( on_off_map ) ;
270271 if ( on_off_values . indexOf ( status ) === - 1 ) {
271- throw new Error ( "gpio_out_ " + gpio_index + "_control.status must be one of " + on_off_values . join ( ", " ) ) ;
272+ throw new Error ( "gpio_output_ " + gpio_index + "_control.status must be one of " + on_off_values . join ( ", " ) ) ;
272273 }
273274
274275 var buffer = new Buffer ( 7 ) ;
@@ -282,10 +283,10 @@ function controlOutputStatusWithDuration(gpio_index, gpio_out_x_control) {
282283
283284/**
284285 * Control output status
285- * @param {number } gpio_index values: (1: gpio_out_1 , 2: gpio_out_2 )
286+ * @param {number } gpio_index values: (1: gpio_output_1 , 2: gpio_output_2 )
286287 * @param {number } status values: (0: off, 1: on)
287- * @example { "gpio_out_1 ": 1 }
288- * @example { "gpio_out_2 ": 0 }
288+ * @example { "gpio_output_1 ": 1 }
289+ * @example { "gpio_output_2 ": 0 }
289290 */
290291function controlOutputStatus ( gpio_index , status ) {
291292 var gpio_chns = [ 1 , 2 ] ;
@@ -295,7 +296,7 @@ function controlOutputStatus(gpio_index, status) {
295296 var on_off_map = { 0 : "off" , 1 : "on" } ;
296297 var on_off_values = getValues ( on_off_map ) ;
297298 if ( on_off_values . indexOf ( status ) === - 1 ) {
298- throw new Error ( "gpio_out_ " + gpio_index + "_control.status must be one of " + on_off_values . join ( ", " ) ) ;
299+ throw new Error ( "gpio_output_ " + gpio_index + "_control.status must be one of " + on_off_values . join ( ", " ) ) ;
299300 }
300301
301302 var channel_ids = [ 0x07 , 0x08 ] ;
0 commit comments