Skip to content

Commit

Permalink
Fix response payload off by one
Browse files Browse the repository at this point in the history
  • Loading branch information
ps2 committed Apr 12, 2017
1 parent 253f266 commit 17ad417
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion rbc_mesh/include/mesh_aci.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void mesh_aci_command_check(void);
void mesh_aci_rbc_event_handler(rbc_mesh_event_t* p_evt);

/** Set app command handler */
typedef uint16_t (*app_cmd_handler_t) (uint8_t *data, uint16_t length, uint8_t *response, uint8_t *response_length);
typedef uint16_t (*app_cmd_handler_t) (uint8_t *data, uint8_t length, uint8_t *response, uint8_t *response_length);
void mesh_aci_app_cmd_handler_set(app_cmd_handler_t app_cmd_handler);

#endif /* _MESH_ACI_H__ */
1 change: 0 additions & 1 deletion rbc_mesh/include/serial_evt.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ typedef __packed_armcc struct

typedef __packed_armcc struct
{
uint8_t app_cmd_opcode;
uint8_t data[RBC_MESH_VALUE_MAX_LEN];
} __packed_gcc serial_evt_cmd_rsp_params_app_cmd_t;

Expand Down
2 changes: 1 addition & 1 deletion rbc_mesh/src/mesh_aci.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ static void serial_command_handler(serial_cmd_t* p_serial_cmd)
error_code = NRF_ERROR_NOT_SUPPORTED;
}

serial_evt.length += 1 + 1 + 1 ; /* opcode + command + status */
serial_evt.length += 1 + 1 + 1; /* opcode + command + status */
serial_evt.params.cmd_rsp.status = error_code_translate(error_code);

serial_handler_event_send(&serial_evt);
Expand Down
16 changes: 9 additions & 7 deletions src/app_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ uint16_t app_cmd_handler(uint8_t *data, uint8_t len, uint8_t *response, uint8_t

uint16_t error_code;

switch(cmd.opcode) {
case APP_CMD_OPCODE_SET_TIME:
switch(cmd->opcode) {
case APP_CMD_OPCODE_SET_EPOCH_TIME:
{
set_epoch_time(cmd.set_epoch_time.epoch, cmd.set_epoch_time.ms);
set_epoch_time(cmd->params.set_epoch_time.epoch, cmd->params.set_epoch_time.ms);
error_code = NRF_SUCCESS;
*response_length = 0;
}
break;
default:
error_code = NRF_ERROR_NOT_SUPPORTED;
}

toggle_led(LED_RED);
data[0] = 0xfa;
*response_length = 1;
return NRF_SUCCESS;
response[0] = 0xfa;
response[1] = 0xba;
*response_length = 2;
return error_code;
}

0 comments on commit 17ad417

Please sign in to comment.