simple_pair.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * ESPRESSIF MIT License
  3. *
  4. * Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
  5. *
  6. * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
  7. * it is free of charge, to any person obtaining a copy of this software and associated
  8. * documentation files (the "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
  11. * to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all copies or
  14. * substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. *
  23. */
  24. #ifndef __SIMPLE_PAIR_H__
  25. #define __SIMPLE_PAIR_H__
  26. typedef enum {
  27. SP_ST_STA_FINISH = 0,
  28. SP_ST_AP_FINISH = 0,
  29. SP_ST_AP_RECV_NEG,
  30. SP_ST_STA_AP_REFUSE_NEG,
  31. /* all following is err */
  32. SP_ST_WAIT_TIMEOUT,
  33. SP_ST_SEND_ERROR,
  34. SP_ST_KEY_INSTALL_ERR,
  35. SP_ST_KEY_OVERLAP_ERR, //means the same macaddr has two different keys
  36. SP_ST_OP_ERROR,
  37. SP_ST_UNKNOWN_ERROR,
  38. SP_ST_MAX,
  39. } SP_ST_t;
  40. typedef void (*simple_pair_status_cb_t)(u8 *sa, u8 status);
  41. int register_simple_pair_status_cb(simple_pair_status_cb_t cb);
  42. void unregister_simple_pair_status_cb(void);
  43. int simple_pair_init(void);
  44. void simple_pair_deinit(void);
  45. int simple_pair_state_reset(void);
  46. int simple_pair_ap_enter_announce_mode(void);
  47. int simple_pair_sta_enter_scan_mode(void);
  48. int simple_pair_sta_start_negotiate(void);
  49. int simple_pair_ap_start_negotiate(void);
  50. int simple_pair_ap_refuse_negotiate(void);
  51. int simple_pair_set_peer_ref(u8 *peer_mac, u8 *tmp_key, u8 *ex_key);
  52. int simple_pair_get_peer_ref(u8 *peer_mac, u8 *tmp_key, u8 *ex_key);
  53. #endif /* __SIMPLE_PAIR_H__ */