conn_systemreset.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */
  12. #include <stdint.h>
  13. #include "ble_serialization.h"
  14. #include "ser_hal_transport.h"
  15. #include "ser_sd_transport.h"
  16. uint32_t conn_systemreset(void)
  17. {
  18. uint32_t err_code = NRF_SUCCESS;
  19. uint8_t * p_tx_buf = NULL;
  20. uint32_t tx_buf_len = 0;
  21. err_code = ser_hal_transport_tx_pkt_alloc(&p_tx_buf, (uint16_t *)&tx_buf_len);
  22. if (err_code != NRF_SUCCESS)
  23. {
  24. return err_code;
  25. }
  26. SER_ASSERT_LENGTH_LEQ(SER_PKT_TYPE_SIZE, tx_buf_len);
  27. p_tx_buf[SER_PKT_TYPE_POS] = SER_PKT_TYPE_RESET_CMD;
  28. tx_buf_len = SER_PKT_TYPE_SIZE;
  29. err_code = ser_sd_transport_cmd_write(p_tx_buf, tx_buf_len, NULL);
  30. if (err_code != NRF_SUCCESS)
  31. {
  32. err_code = NRF_ERROR_INTERNAL;
  33. }
  34. return err_code;
  35. }