From 8fec37fbbb0776f6ec7087e94e1a66df47a5c85c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Sat, 9 May 2026 03:48:52 +0000 Subject: [PATCH] Merge #3404 into n9_2.0 from refs/changes/3404/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit n94G相关代码提交 * refs/changes/3404/head: (1 commits squashed) - n94G相关代码提交 Signed-off-by: 罗正 <1732036298@qq.com> Merged-by: 罗正 <1732036298@qq.com> CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/3404 --- .../nativeui/phone/include/PhoneDirView.h | 1 - .../nativeui/phone/src/PhoneDirPresenter.cpp | 1 - .../nativeui/phone/src/PhoneDirView.cpp | 352 ++++++++---------- .../media/evb_standard/libjs_audio_recorder.a | Bin 289314 -> 289314 bytes .../third_party/lwip/CMakeLists.txt | 41 ++ .../freertos/src/test/lwip_test.c | 63 ++++ .../freertos/src/test/socket_test.c | 113 ++++++ .../lwip/lwip_adapter/liteos/src/arch/sio.c | 6 +- .../src/include/lwip/lwipopts_default.h | 12 +- .../lwip_adapter/liteos/src/test/lwip_test.c | 63 ++++ .../liteos/src/test/socket_test.c | 113 ++++++ .../lwip/lwip_v2.1.3/src/core/dns.c | 4 + .../lwip/lwip_v2.1.3/src/core/init.c | 4 +- .../4g/cat1Service/Service/cat1_utils.c | 4 - .../zhihui/UI/producttest/include/testView.h | 2 +- .../zhihui/UI/producttest/src/testView.cpp | 7 +- 16 files changed, 563 insertions(+), 223 deletions(-) create mode 100644 code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/lwip_test.c create mode 100644 code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/freertos/src/test/socket_test.c create mode 100644 code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/lwip_test.c create mode 100644 code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/socket_test.c diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/include/PhoneDirView.h b/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/include/PhoneDirView.h index fbb3e2c24..49ec43eeb 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/include/PhoneDirView.h +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/include/PhoneDirView.h @@ -61,7 +61,6 @@ namespace OHOS bool get_container_one_page_is_Visible(); private: - UIView::OnDragListener *draglistener{nullptr}; PhoneDirView(PhoneDirView &&) = delete; PhoneDirView &operator=(PhoneDirView &&) = delete; UILabelExt *label[20] ={nullptr}; diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp index 3562d6e5a..5faaf060f 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/src/PhoneDirPresenter.cpp @@ -65,7 +65,6 @@ namespace OHOS } - UNUSED(view); return true; } diff --git a/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/src/PhoneDirView.cpp b/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/src/PhoneDirView.cpp index 2164f325c..1a253adbd 100644 --- a/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/src/PhoneDirView.cpp +++ b/code/sdk/application/wearable/n9/nativeapp/nativeui/phone/src/PhoneDirView.cpp @@ -18,7 +18,6 @@ namespace OHOS extern addressbook addressbook_t; PhoneDirView::PhoneDirView() { - g_pPhoneDirView = this; } @@ -32,7 +31,7 @@ namespace OHOS { return g_pPhoneDirView; } - static char *number_str[]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"}; + static char *number_str[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"}; UILabelButtonExt *PhoneDirView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener) { UILabelButtonExt *button = new UILabelButtonExt(); @@ -43,19 +42,19 @@ namespace OHOS } button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); button->SetViewId(buttonconfig.ViewId); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "----------%s ---",buttonconfig.ViewId); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "----------%s ---", buttonconfig.ViewId); button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - if(buttonconfig.ImageSrc) - button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc); + if (buttonconfig.ImageSrc) + button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc); - //button->SetStyleForState(STYLE_BORDER_COLOR, 0xff191919, UIButton::PRESSED); - if(clickListener!=NULL) - button->SetOnClickListener(clickListener); + // button->SetStyleForState(STYLE_BORDER_COLOR, 0xff191919, UIButton::PRESSED); + if (clickListener != NULL) + button->SetOnClickListener(clickListener); button->SetText(buttonconfig.str); button->SetAlign(TEXT_ALIGNMENT_LEFT); - button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y ); + button->SetLabelPosition(buttonconfig.label_x, buttonconfig.label_y); button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize); button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); @@ -63,8 +62,7 @@ namespace OHOS return button; } - - void PhoneDirView::initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc) + void PhoneDirView::initView_ext(int x, int y, int w, int h, int interval, const char *imagsrc) { /* -------------------------------------------------------------------------- */ UIView::OnClickListener *clickListener = static_cast(PhoneDirPresenter::GetInstance()); @@ -75,15 +73,15 @@ namespace OHOS buttonconfig.w = w; buttonconfig.h = h; - int len =addressbook_t.num; + int len = addressbook_t.num; - for(int i=0;iSetPosition(x+107, buttonconfig.y+33); // widget's left position and top position - label[i]->Resize(210, 35); // widget's width and height - label[i]->SetViewId("label1");// Set style + label[i]->SetPosition(x + 107, buttonconfig.y + 33); + label[i]->Resize(210, 35); + label[i]->SetViewId("label1"); label[i]->SetStyle(STYLE_TEXT_FONT, 30); // Set additional property @@ -94,84 +92,83 @@ namespace OHOS label[i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); label[i]->SetVisible(true); - //char buf[32]={0}; - //sprintf(buf,"1",i); - //buf[0]=i+48; - buttonconfig.ViewId =number_str[i]; - - buttonconfig.ImageSrc = addressbook_t.Contact_t[i].sex==1 ? PHONE_DIR_BOY:PHONE_DIR_GIRL; - buttonconfig.label_x=107; - buttonconfig.label_y=0; - buttonconfig.Fontsize=30; - buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT; + // char buf[32]={0}; + // sprintf(buf,"1",i); + // buf[0]=i+48; + buttonconfig.ViewId = number_str[i]; + + buttonconfig.ImageSrc = addressbook_t.Contact_t[i].sex == 1 ? PHONE_DIR_BOY : PHONE_DIR_GIRL; + buttonconfig.label_x = 107; + buttonconfig.label_y = 0; + buttonconfig.Fontsize = 30; + buttonconfig.ALIGN = TEXT_ALIGNMENT_LEFT; button[i] = SetTheButton_ext(buttonconfig, clickListener); - buttonconfig.y+=interval; + buttonconfig.y += interval; scrollview_->Add(button[i]); scrollview_->Add(label[i]); } onepage_address_init(); - /* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ } - void PhoneDirView :: onepage_address_init(void) + void PhoneDirView ::onepage_address_init(void) { - if (container_one_page == nullptr) { - container_one_page = new UIScrollView(); - container_one_page->SetPosition(0, 0,Screen::GetInstance().GetWidth(),Screen::GetInstance().GetHeight()); - //container_one_page->SetStyle(STYLE_BACKGROUND_OPA, 0); + if (container_one_page == nullptr) + { + container_one_page = new UIScrollView(); + if(container_one_page == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: container new fail!"); + return; + } + } + container_one_page->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); container_one_page->SetViewId("container_one_page"); container_one_page->SetScrollBlankSize(35); - //container_one_page->SetReboundSize(50); container_one_page->SetDirection(1); - } - - // Add Label to App - if (label1_phone_name == nullptr) { + container_one_page->SetOnDragListener(presenter_); + container_one_page->SetVisible(false); + container_one_page->SetDraggable(true); + container_one_page->SetTouchable(true); + AddViewToRootContainer(container_one_page); + /* -------------------------------------------------------------------------- */ + if (label1_phone_name == nullptr) + { label1_phone_name = new UILabelExt(); + if(label1_phone_name == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: label1_phone_name new fail!"); + return; + } } - label1_phone_name->SetPosition(128, 52); // widget's left position and top position - label1_phone_name->Resize(210, 30); // widget's width and height - label1_phone_name->SetViewId("label1");// Set style + label1_phone_name->SetPosition(128, 52); + label1_phone_name->Resize(210, 30); label1_phone_name->SetStyle(STYLE_TEXT_FONT, 30); - - // Set additional property label1_phone_name->SetText(addressbook_t.Contact_t[0].name); label1_phone_name->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); label1_phone_name->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); label1_phone_name->SetRollSpeed(23); label1_phone_name->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - // Add to rootView container_one_page->Add(label1_phone_name); label1_phone_name->SetVisible(true); - - // Add ImageView to App - if (phone_name == nullptr) { + /* -------------------------------------------------------------------------- */ + if (phone_name == nullptr) + { phone_name = new UIImageView(); + if(phone_name == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: phone_name new fail!"); + return; + } } - phone_name->SetPosition(158, 107); // widget's left position and top position - // phone_name->Resize(150, 150); // widget's width and height - phone_name->SetViewId("phone_sex");// Set style - + phone_name->SetPosition(158, 107); + phone_name->SetViewId("phone_sex"); + phone_name->SetVisible(true); image_boy = ImageCacheManager::GetInstance().LoadSingleRes(PHONE_DIR_BOY_1); - image_girl = ImageCacheManager::GetInstance().LoadSingleRes(PHONE_DIR_GIRL_1); - - phone_name->SetSrc(addressbook_t.Contact_t[0].sex ? image_boy:image_girl); - - - + phone_name->SetSrc(addressbook_t.Contact_t[0].sex ? image_boy : image_girl); container_one_page->Add(phone_name); - phone_name->SetVisible(true); - container_one_page->SetVisible(false); - container_one_page->SetDraggable(true); - container_one_page->SetTouchable(true); - - - - - UIView::OnClickListener *clickListener = static_cast(PhoneDirPresenter::GetInstance()); /* -------------------------------------------------------------------------- */ ButtonConfig_ext_t buttonconfig; buttonconfig.x = 43; @@ -179,44 +176,36 @@ namespace OHOS buttonconfig.w = 380; buttonconfig.h = 100; - int len =addressbook_t.Contact_t[0].phone_num; - - for(int i=0;i<2;i++) + int len = addressbook_t.Contact_t[0].phone_num; + for (int i = 0; i < 2; i++) { - buttonconfig.str=addressbook_t.Contact_t[0].phone_number_t[0].number; - buttonconfig.ViewId =addressbook_t.Contact_t[0].phone_number_t[0].number; - buttonconfig.ImageSrc=nullptr; - buttonconfig.label_x=50; - buttonconfig.label_y=0; - buttonconfig.Fontsize=30; - buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT; - number_button[i] = SetTheButton_ext(buttonconfig,clickListener); - buttonconfig.y+=120; + buttonconfig.str = addressbook_t.Contact_t[0].phone_number_t[0].number; + buttonconfig.ViewId = addressbook_t.Contact_t[0].phone_number_t[0].number; + buttonconfig.ImageSrc = nullptr; + buttonconfig.label_x = 50; + buttonconfig.label_y = 0; + buttonconfig.Fontsize = 30; + buttonconfig.ALIGN = TEXT_ALIGNMENT_LEFT; + number_button[i] = SetTheButton_ext(buttonconfig, presenter_); + buttonconfig.y += 120; container_one_page->Add(number_button[i]); } - - - UIView::OnDragListener *draglistener = static_cast(PhoneDirPresenter::GetInstance()); - if (draglistener == nullptr) + /* -------------------------------------------------------------------------- */ + if (phone_name_ == nullptr) { - return; - } - container_one_page->SetOnDragListener(draglistener); - - if (phone_name_ == nullptr) { phone_name_ = new UIImageView(); + if(phone_name_ == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirView::phone_name_ new fail"); + return; + } } - phone_name_->SetPosition(0, 520); // widget's left position and top position - phone_name_->Resize(466, 30); // widget's width and height - phone_name_->SetViewId("phone_sex");// Set style - - container_one_page->Add(phone_name_); - + phone_name_->SetPosition(0, 520); + phone_name_->Resize(466, 30); + phone_name_->SetViewId("phone_sex"); phone_name_->SetVisible(true); - - + container_one_page->Add(phone_name_); return; - } bool PhoneDirView::get_container_one_page_is_Visible() @@ -224,53 +213,49 @@ namespace OHOS return container_one_page->IsVisible(); } - void PhoneDirView::Set_onepage_address(const char *idstr) { - if(strcmp("container_one_page",idstr)==0) + if (strcmp("container_one_page", idstr) == 0) { scrollview_->SetVisible(true); container_one_page->SetVisible(false); return; - } container_one_page->ScrollBy(0, 100); scrollview_->SetVisible(false); container_one_page->SetVisible(true); - uint8_t id= atoi(idstr);//idstr[16]; - if(id>=20) + uint8_t id = atoi(idstr); // idstr[16]; + if (id >= 20) { return; } - if(addressbook_t.Contact_t[id].name) - label1_phone_name->SetText(addressbook_t.Contact_t[id].name); + if (addressbook_t.Contact_t[id].name) + label1_phone_name->SetText(addressbook_t.Contact_t[id].name); label1_phone_name->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - phone_name->SetSrc(addressbook_t.Contact_t[0].sex ? image_boy:image_girl); + phone_name->SetSrc(addressbook_t.Contact_t[0].sex ? image_boy : image_girl); - int len =addressbook_t.Contact_t[id].phone_num; + int len = addressbook_t.Contact_t[id].phone_num; - for(int i=0;iSetVisible(true); - if(addressbook_t.Contact_t[id].phone_number_t[i].number) + if (addressbook_t.Contact_t[id].phone_number_t[i].number) { number_button[i]->SetText(addressbook_t.Contact_t[id].phone_number_t[i].number); number_button[i]->SetViewId(addressbook_t.Contact_t[id].phone_number_t[i].number); } } - if(len<2) + if (len < 2) { number_button[1]->SetVisible(false); } - RootView::GetInstance()->Invalidate(); + RootView::GetInstance()->Invalidate(); return; } - - void PhoneDirView::DeInit() { @@ -280,99 +265,93 @@ namespace OHOS scrollview_->ClearFocus(); delete scrollview_; scrollview_ = nullptr; - - if(label1_) + + if (label1_) { delete label1_; label1_ = nullptr; } - for(int i=0;iRemoveAll(); delete container_one_page; container_one_page = nullptr; - if(phone_name) + if (phone_name) { delete phone_name; phone_name = nullptr; } - if(phone_name_) + if (phone_name_) { delete phone_name_; phone_name_ = nullptr; } - - ImageCacheManager::GetInstance().UnloadSingleRes(PHONE_DIR_BOY_1); - ImageCacheManager::GetInstance().UnloadSingleRes(PHONE_DIR_GIRL_1); - if(label1_phone_name) + if (label1_phone_name) { delete label1_phone_name; label1_phone_name = nullptr; } - for(int i=0;i<2;i++) - { - if( number_button[i]) + for (int i = 0; i < 2; i++) + { + if (number_button[i]) { - delete number_button[i]; + delete number_button[i]; number_button[i] = nullptr; } } - } - - if(label1_no) + + if (label1_no) { delete label1_no; - label1_no=nullptr; + label1_no = nullptr; } - if(label2_no) + if (label2_no) { delete label2_no; - label2_no=nullptr; + label2_no = nullptr; } - if(image1_no) + if (image1_no) { delete image1_no; - image1_no=nullptr; + image1_no = nullptr; } } } - UIView *PhoneDirView::GetView() { if (label1_no == nullptr) { label1_no = new UILabelExt(); } - label1_no->SetPosition(158, 52); // widget's left position and top position - label1_no->Resize(200, 60); // widget's width and height - label1_no->SetViewId("label1"); // Set style + label1_no->SetPosition(158, 52); + label1_no->Resize(200, 60); + label1_no->SetViewId("label1"); label1_no->SetStyle(STYLE_TEXT_FONT, 30); // Set additional property @@ -393,9 +372,9 @@ namespace OHOS { label2_no = new UILabelExt(); } - label2_no->SetPosition(76, 310); // widget's left position and top position - label2_no->Resize(312, 70); // widget's width and height - label2_no->SetViewId("label2"); // Set style + label2_no->SetPosition(76, 310); + label2_no->Resize(312, 70); + label2_no->SetViewId("label2"); label2_no->SetStyle(STYLE_TEXT_FONT, 26); // Set additional property @@ -416,9 +395,9 @@ namespace OHOS { image1_no = new UIImageView(); } - image1_no->SetPosition(158, 120); // widget's left position and top position - image1_no->Resize(150, 150); // widget's width and height - image1_no->SetViewId("image1"); // Set style + image1_no->SetPosition(158, 120); + image1_no->Resize(150, 150); + image1_no->SetViewId("image1"); // Set additional property @@ -433,80 +412,59 @@ namespace OHOS } void PhoneDirView::OnStart() { - scrollview_ = new UIScrollView(); - if (scrollview_ == nullptr) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirView::OnStart"); + if(scrollview_ == nullptr) { - return; + scrollview_ = new UIScrollView(); + if (scrollview_ == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirView::scrollview_ new fail"); + return; + } } scrollview_->SetPosition(0, 0); scrollview_->SetWidth(Screen::GetInstance().GetWidth()); scrollview_->SetHeight(Screen::GetInstance().GetHeight()); - scrollview_->SetScrollBlankSize(35); scrollview_->SetReboundSize(35); scrollview_->SetDirection(1); scrollview_->SetMaxScrollDistance(500); scrollview_->SetThrowDrag(true); scrollview_->RequestFocus(); - // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = static_cast(PhoneDirPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - scrollview_->SetOnDragListener(draglistener); - + scrollview_->SetOnDragListener(presenter_); scrollview_->SetTouchable(true); scrollview_->SetDraggable(true); - //read_addressbook_bin_file(); - + AddViewToRootContainer(scrollview_); - if (label1_ == nullptr) { - label1_ = new UILabelExt(); + if (label1_ == nullptr) + { + label1_ = new UILabelExt(); + if(label1_ == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PhoneDirView::label1_ new fail"); + return; + } } - label1_->SetPosition(0, 18); // widget's left position and top position - label1_->Resize(466, 88); // widget's width and height - label1_->SetViewId("label1");// Set style + label1_->SetPosition(0, 18); + label1_->Resize(466, 88); label1_->SetStyle(STYLE_TEXT_FONT, 30); - label1_->SetTextId(STR_FRE_CONTACT); label1_->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); label1_->SetTextId(STR_FAVORITE_CONTACTS); - //label1_->SetTextColor(Color::GetColorFromRGBA(0xac, 0xa4, 0xa4, 0xff)); label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); label1_->SetRollSpeed(0); label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); scrollview_->Add(label1_); - if(addressbook_t.num<=0 ||addressbook_t.num>20) + if (addressbook_t.num <= 0 || addressbook_t.num > 20) { GetView(); } else { - initView_ext(43,123,380,100,120,NULL); - } - - - - - AddViewToRootContainer(scrollview_); - if(container_one_page) - { - if (draglistener == nullptr) - { - return; - } - container_one_page->SetOnDragListener(draglistener); + initView_ext(43, 123, 380, 100, 120, NULL); } - AddViewToRootContainer(container_one_page); - - - - // 增加按键监听 - RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::PhoneDirPresenter::GetInstance(); - RootView::GetInstance()->SetOnKeyActListener(keyactListener); + RootView::GetInstance()->SetOnKeyActListener(presenter_); } - } diff --git a/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_recorder.a b/code/sdk/interim_binary/brandy/libs/media/evb_standard/libjs_audio_recorder.a index 5ccbce8e638f3d5c36e06ca011aea27a6ed626bc..515ce6543c889675761413defc81c0bc5a9040d0 100644 GIT binary patch delta 59 zcmZ2(?OTKxftYFg79r-^qfiOs?G`tfUrhu6 DJAD(1 delta 59 zcmZ2 +#include + +#define SERVER_IP "192.168.1.121" +#define SEND_PORT 5002 +#define BUFFER_SIZE 1024 + +void udp_client(void) { + int sockfd; + struct sockaddr_in server_addr; + char buffer[BUFFER_SIZE]; + + // 创建 UDP 套接字 + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd == -1) { + perror("Error creating socket"); + exit(EXIT_FAILURE); + } + + // 设置服务器地址信息 + memset(&server_addr, 0, sizeof(server_addr)); + server_addr.sin_family = AF_INET; + server_addr.sin_port = lwip_htons(SEND_PORT); + if (inet_aton(SERVER_IP, &server_addr.sin_addr) == 0) { + perror("Invalid server IP address"); + close(sockfd); + exit(EXIT_FAILURE); + } + + while (1) { + // 发送数据 + const char *message = "Hello, UDP Server!"; + int len = strlen(message); + printf("send message: \n"); + for (int i = 0; i < len; i++) { + printf(" %x ", message[i]); + } + printf("\n"); + if (sendto(sockfd, message, strlen(message), 0, (struct sockaddr *)&server_addr, sizeof(server_addr)) == -1) { + perror("Error sending data"); + close(sockfd); + exit(EXIT_FAILURE); + } + sleep(1); + } +} + +#define REV_PORT 5001 +#define BUFFER_SIZE 1024 + +void udp_server(void) +{ + int sockfd; + struct sockaddr_in server_addr; + char buffer[BUFFER_SIZE]; + + // 创建 UDP 套接字 + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd == -1) { + perror("Error creating socket"); + exit(EXIT_FAILURE); + } + + // 设置服务器地址信息 + memset(&server_addr, 0, sizeof(server_addr)); + server_addr.sin_family = AF_INET; + server_addr.sin_addr.s_addr = INADDR_ANY; + server_addr.sin_port = lwip_htons(REV_PORT); + + // 绑定套接字 + if (bind(sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr)) == -1) { + perror("Error binding socket"); + close(sockfd); + exit(EXIT_FAILURE); + } + + while (1) { + socklen_t client_len = sizeof(struct sockaddr_in); + struct sockaddr_in client_addr; + + // 接收数据 + ssize_t bytes_received = recvfrom(sockfd, buffer, BUFFER_SIZE, 0, (struct sockaddr *)&client_addr, &client_len); + if (bytes_received == -1) { + perror("Error receiving data"); + continue; + } + + // 打印接收到的数据 + printf("Received message from %s:%d\n", inet_ntoa(client_addr.sin_addr), lwip_ntohs(client_addr.sin_port)); + printf("Received message: %d %s\n", (int)bytes_received, buffer); + printf("message: "); + for (int i = 0; i < bytes_received; i++) { + printf(" %02x ", buffer[i]); + } + printf("\n"); + + // 清空缓冲区 + memset(buffer, 0, BUFFER_SIZE); + // break; + } + + close(sockfd); +} + +void client_init(void) { + printf("___enter client_init function___\n"); + sys_thread_new("server", udp_server, NULL, 4096, 4); + sys_thread_new("client", udp_client, NULL, 4096, 4); +} \ No newline at end of file diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/arch/sio.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/arch/sio.c index 3fb708d62..dc030fdb5 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/arch/sio.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/arch/sio.c @@ -641,9 +641,9 @@ errcode_t sio_interrupt_enable(void (*data_callback)(const uint8_t *data, uint32 - printf("[SIO] Allocated %d x %d bytes = %.2f KB total\n", - SIO_PING_PONG_BUFFER_COUNT, SIO_PING_PONG_BUFFER_SIZE, - (SIO_PING_PONG_BUFFER_COUNT * SIO_PING_PONG_BUFFER_SIZE) / 1024.0); + // uint32_t total_bytes = SIO_PING_PONG_BUFFER_COUNT * SIO_PING_PONG_BUFFER_SIZE; + // printf("[SIO] Allocated %d x %d bytes = %u KB total\n", + // SIO_PING_PONG_BUFFER_COUNT, SIO_PING_PONG_BUFFER_SIZE, total_bytes / 1024); // 2. 创建消息队列 int ret = osal_msg_queue_create( diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/include/lwip/lwipopts_default.h b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/include/lwip/lwipopts_default.h index 516f985b9..940098628 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/include/lwip/lwipopts_default.h +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/include/lwip/lwipopts_default.h @@ -785,11 +785,7 @@ extern "C" { #endif #ifndef TCP_WND -#define TCP_WND (TCP_SND_BUF * 2 / 6) //改善810的下载速度 -#endif - -#ifndef LWIP_IGMP -#define LWIP_IGMP 1 +#define TCP_WND (TCP_SND_BUF * 2 / 3) #endif #ifndef LWIP_DNS_REVERSE @@ -804,10 +800,6 @@ extern "C" { #define LWIP_SO_RCVBUF 0 #endif -#ifndef LWIP_IPV6_MLD -#define LWIP_IPV6_MLD 0 -#endif - #ifndef LWIP_IPV6_MLD_QUERIER #define LWIP_IPV6_MLD_QUERIER 0 #endif @@ -1970,8 +1962,6 @@ TCP sender buffer space (pbufs). This must be at least = 2 * #define LWIP_NETIF_LOOPBACK 0 #endif - - #if LWIP_SNTP #define LWIP_DHCP_MAX_NTP_SERVERS 1 diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/lwip_test.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/lwip_test.c new file mode 100644 index 000000000..99e96bdba --- /dev/null +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/lwip_test.c @@ -0,0 +1,63 @@ +#include "lwip_test.h" +#include "lwip/netif.h" +#include "lwip/netifapi.h" +#include "lwip/ethernetif.h" +#define IP_ADDR0 192 +#define IP_ADDR1 168 +#define IP_ADDR2 1 +#define IP_ADDR3 122 + +#define NETMASK_ADDR0 255 +#define NETMASK_ADDR1 255 +#define NETMASK_ADDR2 255 +#define NETMASK_ADDR3 0 + +#define GW_ADDR0 192 +#define GW_ADDR1 168 +#define GW_ADDR2 1 +#define GW_ADDR3 1 + +#define WIFI_DRIVER_IF 801 +#define HWADDR_LEN 6 + +struct netif g_netif; + +err_t my_hw_input(struct pbuf *p, struct netif *netif); + +err_t my_hw_input(struct pbuf *p, struct netif *netif) +{ + (void)p; + (void)netif; + printf("enter my_hw_input\n"); + return 0; +} + +void lwip_test_init(void) +{ + int ret = 0; + ip4_addr_t ip, gw, netmask; + + IP4_ADDR(&ip, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3); + IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3); + IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3); + + g_netif.hwaddr_len = HWADDR_LEN; + g_netif.hwaddr[0] = 0x00; + g_netif.hwaddr[1] = 0x11; + g_netif.hwaddr[2] = 0x22; + g_netif.hwaddr[3] = 0x33; + g_netif.hwaddr[4] = 0x44; + g_netif.hwaddr[5] = 0x55; + + g_netif.flags = 4; + g_netif.input = my_hw_input; + /* Initilialize the LwIP stack */ + /* add the network interface */ + netif_add(&g_netif, &ip, &netmask, &gw, NULL, ðernetif_init, tcpip_input); + /* Registers the default network interface */ + netif_set_default(&g_netif); + + netif_is_link_up(&g_netif); + /* When the netif is fully configured this function must be called */ + netif_set_up(&g_netif); +} diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/socket_test.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/socket_test.c new file mode 100644 index 000000000..2e8f48b01 --- /dev/null +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_adapter/liteos/src/test/socket_test.c @@ -0,0 +1,113 @@ +#include "socket_test.h" +#include "lwip/opt.h" +#include "lwip/sys.h" +#include "lwip/api.h" +#include +#include + +#define SERVER_IP "192.168.1.121" +#define SEND_PORT 5002 +#define BUFFER_SIZE 1024 + +void udp_client(void) { + int sockfd; + struct sockaddr_in server_addr; + char buffer[BUFFER_SIZE]; + + // 创建 UDP 套接字 + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd == -1) { + perror("Error creating socket"); + exit(EXIT_FAILURE); + } + + // 设置服务器地址信息 + memset(&server_addr, 0, sizeof(server_addr)); + server_addr.sin_family = AF_INET; + server_addr.sin_port = lwip_htons(SEND_PORT); + if (inet_aton(SERVER_IP, &server_addr.sin_addr) == 0) { + perror("Invalid server IP address"); + close(sockfd); + exit(EXIT_FAILURE); + } + + while (1) { + // 发送数据 + const char *message = "Hello, UDP Server!"; + int len = strlen(message); + printf("send message: \n"); + for (int i = 0; i < len; i++) { + printf(" %x ", message[i]); + } + printf("\n"); + if (sendto(sockfd, message, strlen(message), 0, (struct sockaddr *)&server_addr, sizeof(server_addr)) == -1) { + perror("Error sending data"); + close(sockfd); + exit(EXIT_FAILURE); + } + sleep(1); + } +} + +#define REV_PORT 5001 +#define BUFFER_SIZE 1024 + +void udp_server(void) +{ + int sockfd; + struct sockaddr_in server_addr; + char buffer[BUFFER_SIZE]; + + // 创建 UDP 套接字 + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd == -1) { + perror("Error creating socket"); + exit(EXIT_FAILURE); + } + + // 设置服务器地址信息 + memset(&server_addr, 0, sizeof(server_addr)); + server_addr.sin_family = AF_INET; + server_addr.sin_addr.s_addr = INADDR_ANY; + server_addr.sin_port = lwip_htons(REV_PORT); + + // 绑定套接字 + if (bind(sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr)) == -1) { + perror("Error binding socket"); + close(sockfd); + exit(EXIT_FAILURE); + } + + while (1) { + socklen_t client_len = sizeof(struct sockaddr_in); + struct sockaddr_in client_addr; + + // 接收数据 + ssize_t bytes_received = recvfrom(sockfd, buffer, BUFFER_SIZE, 0, (struct sockaddr *)&client_addr, &client_len); + if (bytes_received == -1) { + perror("Error receiving data"); + continue; + } + + // 打印接收到的数据 + printf("Received message from %s:%d\n", inet_ntoa(client_addr.sin_addr), lwip_ntohs(client_addr.sin_port)); + printf("Received message: %d %s\n", (int)bytes_received, buffer); + printf("message: "); + for (int i = 0; i < bytes_received; i++) { + printf(" %02x ", buffer[i]); + } + printf("\n"); + + // 清空缓冲区 + memset(buffer, 0, BUFFER_SIZE); + // break; + } + + close(sockfd); +} + +void client_init(void) { + printf("___enter client_init function___\n"); + sys_thread_new("server", udp_server, NULL, 512, 4); + sys_thread_new("client", udp_client, NULL, 512, 4); +} \ No newline at end of file diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/dns.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/dns.c index 5c6023898..ff4485842 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/dns.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/dns.c @@ -333,6 +333,10 @@ dns_init(void) for (n = 0; (n < LWIP_DHCP_MAX_DNS_SERVERS); n++) { dns_setserver(n, &dnsserver); } +#ifdef DNS_SERVER_ADDRESS_SECONDARY + DNS_SERVER_ADDRESS_SECONDARY(&dnsserver); + dns_setserver(1, &dnsserver); +#endif #endif /* DNS_SERVER_ADDRESS */ LWIP_ASSERT("sanity check SIZEOF_DNS_QUERY", diff --git a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/init.c b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/init.c index 067d51a05..ab25144b1 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/init.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/lwip_v2.1.3/src/core/init.c @@ -377,9 +377,7 @@ lwip_init(void) #endif /* LWIP_DNS */ #if LWIP_SLIP -#if 0 // 1201patch 为编译过屏蔽 - slip_test_init(); -#endif + // slip_test_init();暂时屏蔽 #endif /* LWIP_SLIP */ #if PPP_SUPPORT ppp_init(); diff --git a/code/sdk/zhihui/4g/cat1Service/Service/cat1_utils.c b/code/sdk/zhihui/4g/cat1Service/Service/cat1_utils.c index 0bc6dea87..f61a99fd4 100644 --- a/code/sdk/zhihui/4g/cat1Service/Service/cat1_utils.c +++ b/code/sdk/zhihui/4g/cat1Service/Service/cat1_utils.c @@ -384,12 +384,10 @@ errcode_t cat1_register_time_ctl_functions(time_ctl_funcs_t *funcs) void cat1_api_suspend_protocol(void) { - #if 0 // 1201patch 为编译过屏蔽 #ifdef SUPPORT_LWIP tcpip_thread_suspend(); slipif_loop_thread_suspend(); #endif - #endif } /** @@ -405,12 +403,10 @@ void cat1_api_suspend_protocol(void) */ void cat1_api_resume_protocol(void) { - #if 0 // 1201patch 为编译过屏蔽 #ifdef SUPPORT_LWIP tcpip_thread_resume(); slipif_loop_thread_resume(); #endif - #endif } /** diff --git a/code/sdk/zhihui/UI/producttest/include/testView.h b/code/sdk/zhihui/UI/producttest/include/testView.h index c62f886fa..1bed26ad5 100644 --- a/code/sdk/zhihui/UI/producttest/include/testView.h +++ b/code/sdk/zhihui/UI/producttest/include/testView.h @@ -168,7 +168,7 @@ namespace OHOS #ifdef SUPPORT_A5133_SERVICE testA5133View *test_A5133_view{nullptr}; #endif - UILabelButtonExt *button[30] = {NULL}; + UILabelButtonExt *button[30] = {nullptr}; bool initViewStatus{false}; // 添加成员变量来存储按钮viewId字符串,避免悬空指针问题 diff --git a/code/sdk/zhihui/UI/producttest/src/testView.cpp b/code/sdk/zhihui/UI/producttest/src/testView.cpp index 73399cc3f..0f6a2536b 100644 --- a/code/sdk/zhihui/UI/producttest/src/testView.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testView.cpp @@ -118,7 +118,7 @@ namespace OHOS if (button[i]) { delete button[i]; - button[i] = NULL; + button[i] = nullptr; } } } @@ -1117,7 +1117,10 @@ namespace OHOS int len = sizeof(Test_ViewMapper_t) / sizeof(Test_ViewMapper_t[0]); for (int i = 0; i < len; i++) { - SystemScrollView[TESTVIEW]->Add(button[i]); + if (button[i] != nullptr) + { + SystemScrollView[TESTVIEW]->Add(button[i]); + } } group->Add(SystemScrollView[TESTVIEW]); AddViewToRootContainer(group); -- 2.17.1