AP6256 Enable STATION

·

2 min read

Enable STATION

$ git diff code/application/source/cardv/SrcCode/UIWnd/SPORTCAM/UIInfo/UICfgDefault.h
diff --git a/code/application/source/cardv/SrcCode/UIWnd/SPORTCAM/UIInfo/UICfgDefault.h b/code/application/source/cardv/SrcCode/UIWnd/SPORTCAM/UIInfo/UICfgDefault.h
index 2be9216..f051325 100755
--- a/code/application/source/cardv/SrcCode/UIWnd/SPORTCAM/UIInfo/UICfgDefault.h
+++ b/code/application/source/cardv/SrcCode/UIWnd/SPORTCAM/UIInfo/UICfgDefault.h
@@ -202,7 +202,7 @@

 // Wi-Fi
 #define DEFAULT_MOVIE_WIFI_AUTO_RECORDING_OPTION    WIFI_AUTO_RECORDING_ON
-#define DEFAULT_WIFI_MODE                           NET_AP_MODE
+#define DEFAULT_WIFI_MODE                           NET_STATION_MODE
 #if (WIFI_FINALCAM_APP_STYLE == ENABLE || UCTRL_APP_MOVIE_FEATURE_SETGET == ENABLE || YOUKU_SDK == ENABLE)
 #define DEFAULT_MOVIE_WIFI_APP_PREVIEW_SIZE    WIFI_MOVIE_APP_PREVIEW_SIZE_VGA_16_9
 #endif

DHCP

elif [ "$1" == "sta" ]; then
        #echo /lib/firmware/bcmdhd/fw_bcmdhd.bin > /sys/module/bcmdhd/parameters/firmware_path
        echo /lib/firmware/bcmdhd/fw_bcmdhd_apsta.bin > /sys/module/bcmdhd/parameters/firmware_path
        wpa_supplicant -Dnl80211 -i wlan0 -c /var/run/wpa_supplicant.conf &
        TRY=0
        while [ 1 ]
        do
                        UP=`ifconfig wlan0 | grep UP`
                        echo "UP=$UP"

                        if [ -z "$UP" ]; then
                                        echo "TRY=$TRY"
                                        if [ $TRY -gt 5 ]; then
                                                        hostapd stop
                                                        exit 255
                                        else
                                                        TRY=$((${TRY}+1))
                                                        sleep 1
                                        fi
                        else
                                        echo "UP ok"
                                        # ifconfig wlan0 192.168.1.1
                                        ifconfig wlan0 0.0.0.0
                                        break
                        fi
        done

        udhcpc -i wlan0
        TRY=0
        while [ 1 ]
        do
                        DHCP=`ps`
                        DHCP=`echo $DHCP | grep udhcpc`
                        echo "DHCP=$DHCP"

                        if [ -z "$DHCP" ]; then
                                        echo "TRY=$TRY"
                                        if [ $TRY -gt 5 ]; then
                                                        echo "Can't run udhcpc"
                                                        exit 255
                                        else
                                                        TRY=$((${TRY}+1))
                                                        sleep 1
                                        fi
                        else
                                        echo "udhcpd ok"
                                        exit 0
                        fi
        done
fi

Set IP Address

$ git diff code/application/source/cardv/SrcCode/UIWnd/SPORTCAM/UIFlow/UIFlowWiFi/UIFlowWndWiFiMovie.c
diff --git a/code/application/source/cardv/SrcCode/UIWnd/SPORTCAM/UIFlow/UIFlowWiFi/UIFlowWndWiFiMovie.c b/code/application/source/cardv/SrcCode/UIWnd/SPORTCAM/UIFlow/UIFlowWiFi/UIFlowWndWiFiMovie.c
index 3f3144c..e277a15 100755
--- a/code/application/source/cardv/SrcCode/UIWnd/SPORTCAM/UIFlow/UIFlowWiFi/UIFlowWndWiFiMovie.c
+++ b/code/application/source/cardv/SrcCode/UIWnd/SPORTCAM/UIFlow/UIFlowWiFi/UIFlowWndWiFiMovie.c
@@ -2,7 +2,7 @@

 #include "UIFramework.h"
 #include "UIFrameworkExt.h"
-#include "PrjInc.h"
+#include "PrjInc.h"^M
 #include "UIWnd/UIFlow.h"
 #include "UIFlowWndWiFiMovieRes.c"
 #include "SysCommon.h"
@@ -240,7 +240,8 @@ void UIFlowWndWiFiMovie_UpdateWiFiData(BOOL bShow)
                     UxStatic_SetData(&UIFlowWiFiMoive_static_KeyCtrl, STATIC_VALUE, Txt_Pointer(buf2));
                 } else {
                     //get IP
-                    snprintf(buf3,sizeof(buf3), "IP : %s", UINet_GetIP());
+                    // snprintf(buf3,sizeof(buf3), "IP : %s", UINet_GetIP());^M
+                    snprintf(buf3,sizeof(buf3), "IP : %s", UINet_GetStaIP());^M
                     UxStatic_SetData(&UIFlowWiFiMoive_static_Station_SSIDCtrl, STATIC_VALUE, Txt_Pointer(buf1));
                     UxStatic_SetData(&UIFlowWiFiMoive_static_Station_KeyCtrl, STATIC_VALUE, Txt_Pointer(buf2));
                     UxStatic_SetData(&UIFlowWiFiMoive_static_Station_IPCtrl, STATIC_VALUE, Txt_Pointer(buf3));
@@ -275,7 +276,8 @@ void UIFlowWndWiFiMovie_UpdateWiFiData(BOOL bShow)
                     UxStatic_SetData(&UIFlowWiFiMoive_static_KeyCtrl, STATIC_VALUE, Txt_Pointer(buf2));
                 } else {
                     //get IP
-                    snprintf(buf3,sizeof(buf3), "IP : %s", UINet_GetIP());
+                    // snprintf(buf3,sizeof(buf3), "IP : %s", UINet_GetIP());^M
+                    snprintf(buf3,sizeof(buf3), "IP : %s", UINet_GetStaIP());^M
                     UxStatic_SetData(&UIFlowWiFiMoive_static_Station_SSIDCtrl, STATIC_VALUE, Txt_Pointer(buf1));
                     UxStatic_SetData(&UIFlowWiFiMoive_static_Station_KeyCtrl, STATIC_VALUE, Txt_Pointer(buf2));
                     UxStatic_SetData(&UIFlowWiFiMoive_static_Station_IPCtrl, STATIC_VALUE, Txt_Pointer(buf3));
@@ -609,7 +611,7 @@ INT32 UIFlowWndWiFiMovie_OnKeyDown(VControl *pCtrl, UINT32 paramNum, UINT32 *par

Get IP Address

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <arpa/inet.h>

void get_ip_address(const char *interface_name) {
    int fd;
    struct ifreq ifr;

    fd = socket(AF_INET, SOCK_DGRAM, 0);
    if (fd == -1) {
        perror("Socket failed");
        exit(EXIT_FAILURE);
    }

    strncpy(ifr.ifr_name, interface_name, IFNAMSIZ - 1);
    ifr.ifr_name[IFNAMSIZ - 1] = '\0';

    if (ioctl(fd, SIOCGIFADDR, &ifr) == -1) {
        perror("ioctl failed");
        close(fd);
        exit(EXIT_FAILURE);
    }

    struct sockaddr_in *ipaddr = (struct sockaddr_in *)&ifr.ifr_addr;
    printf("IP address of %s: %s\n", interface_name, inet_ntoa(ipaddr->sin_addr));

    close(fd);
}

int main(int argc, char *argv[]) {
    if (argc != 2) {
        fprintf(stderr, "Usage: %s <interface_name>\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    get_ip_address(argv[1]);
    return 0;
}