user_main.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /******************************************************************************
  2. * Copyright 2013-2014 Espressif Systems (Wuxi)
  3. *
  4. * FileName: user_main.c
  5. *
  6. * Description: entry file of user application
  7. *
  8. * Modification history:
  9. * 2014/1/1, v1.0 create this file.
  10. *******************************************************************************/
  11. #include "ets_sys.h"
  12. #include "osapi.h"
  13. #include "user_interface.h"
  14. #include "user_devicefind.h"
  15. #include "user_webserver.h"
  16. #if ESP_PLATFORM
  17. #include "user_esp_platform.h"
  18. #endif
  19. void user_rf_pre_init(void)
  20. {
  21. }
  22. /******************************************************************************
  23. * FunctionName : user_init
  24. * Description : entry of user application, init user function here
  25. * Parameters : none
  26. * Returns : none
  27. *******************************************************************************/
  28. void user_init(void)
  29. {
  30. os_printf("SDK version:%s\n", system_get_sdk_version());
  31. #if ESP_PLATFORM
  32. /*Initialization of the peripheral drivers*/
  33. /*For light demo , it is user_light_init();*/
  34. /* Also check whether assigned ip addr by the router.If so, connect to ESP-server */
  35. user_esp_platform_init();
  36. #endif
  37. /*Establish a udp socket to receive local device detect info.*/
  38. /*Listen to the port 1025, as well as udp broadcast.
  39. /*If receive a string of device_find_request, it rely its IP address and MAC.*/
  40. user_devicefind_init();
  41. /*Establish a TCP server for http(with JSON) POST or GET command to communicate with the device.*/
  42. /*You can find the command in "2B-SDK-Espressif IoT Demo.pdf" to see the details.*/
  43. /*the JSON command for curl is like:*/
  44. /*3 Channel mode: curl -X POST -H "Content-Type:application/json" -d "{\"period\":1000,\"rgb\":{\"red\":16000,\"green\":16000,\"blue\":16000}}" http://192.168.4.1/config?command=light */
  45. /*5 Channel mode: curl -X POST -H "Content-Type:application/json" -d "{\"period\":1000,\"rgb\":{\"red\":16000,\"green\":16000,\"blue\":16000,\"cwhite\":3000,\"wwhite\",3000}}" http://192.168.4.1/config?command=light */
  46. #ifdef SERVER_SSL_ENABLE
  47. user_webserver_init(SERVER_SSL_PORT);
  48. #else
  49. user_webserver_init(SERVER_PORT);
  50. #endif
  51. }