-
- __WDPOP_LOG_FUNC_EXIT__;
- return NULL;
-}
-
-/**
- * This function let the app make a callback for discovering peer
- * @return TRUE
- * @param[in] peer the pointer to the discovered peer
- * @param[in] user_data the pointer to the main data structure
- */
-bool _wfd_app_discoverd_peer_cb(wifi_direct_discovered_peer_info_s *peer, void *user_data)
-{
- __WDPOP_LOG_FUNC_ENTER__;
- wfd_appdata_t *ad = (wfd_appdata_t *) user_data;
-
- if (NULL != peer->device_name) {
- WDPOP_LOGD( "discovered peer ssid[%s]\n", peer->device_name);
- strncpy(ad->discovered_peers[ad->discovered_peer_count].ssid, peer->device_name, 32);
- } else {
- WDPOP_LOGD( "peer's device name is NULL\n");
- }
-
- if (NULL != peer->mac_address) {
- WDPOP_LOGD( "discovered peer mac[%s]\n", peer->mac_address);
- strncpy(ad->discovered_peers[ad->discovered_peer_count].mac_address, peer->mac_address, 18);
- } else {
- WDPOP_LOGD( "peer's mac is NULL\n");
- }
-
- ad->discovered_peer_count++;
-
- __WDPOP_LOG_FUNC_EXIT__;
- return TRUE;
-
-}
-
-/**
- * This function let the app make a callback for registering discover event
- * @return void
- * @param[in] error_code the returned error code
- * @param[in] discovery_state the state of discover
- * @param[in] user_data the pointer to the main data structure
- */
-void _cb_discover(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data)
-{
- __WDPOP_LOG_FUNC_ENTER__;
- wfd_appdata_t *ad = (wfd_appdata_t *)user_data;
- int ret;
-
- switch (discovery_state) {
- case WIFI_DIRECT_DISCOVERY_STARTED:
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_DISCOVERY_STARTED\n");
- break;
-
- case WIFI_DIRECT_ONLY_LISTEN_STARTED:
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_ONLY_LISTEN_STARTED\n");
- break;
-
- case WIFI_DIRECT_DISCOVERY_FINISHED:
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_DISCOVERY_FINISHED\n");
- break;
-
- case WIFI_DIRECT_DISCOVERY_FOUND:
- WDPOP_LOGD( "event ------------------ WIFI_DIRECT_DISCOVERY_FOUND\n");
-
- if (NULL != ad->discovered_peers) {
- free(ad->discovered_peers);
- ad->discovered_peers = NULL;
- }
-
- ad->discovered_peers = calloc(10, sizeof(wfd_device_info_t));
- ad->discovered_peer_count = 0;
-
- ret = wifi_direct_foreach_discovered_peers(_wfd_app_discoverd_peer_cb, (void *) ad);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- WDPOP_LOGD( "get discovery result failed: %d\n", ret);
- }
- break;