#include "bleService.h"
#include "BluetoothModel.h"
#include "producttest/include/testView.h"
+#ifdef SUPPORT_A5133_SERVICE
+#include "service/a5133_service.h"
+#endif
+
#ifdef __cplusplus
#if __cplusplus
extern "C"
{
return g_ptestA5133View;
}
- static osTimerId_t BR_TEST_timer=NULL;
+ static osTimerId_t A5133_TEST_timer=NULL;
void testA5133View::ClearAll()
{
if(testa5133ScrollView)
testa5133ScrollView->RemoveAll();
- if (BR_TEST_timer != NULL) {
- osTimerStop(BR_TEST_timer);
- osTimerDelete(BR_TEST_timer);
- BR_TEST_timer = NULL;
+ if (A5133_TEST_timer != NULL) {
+ osTimerStop(A5133_TEST_timer);
+ osTimerDelete(A5133_TEST_timer);
+ A5133_TEST_timer = NULL;
return ;
}
- if(button)
+ if(button[0])
{
- delete button;
- button=nullptr;
+ delete button[0];
+ button[0]=nullptr;
+ }
+ if(button[1])
+ {
+ delete button[1];
+ button[1]=nullptr;
+ }
+ if(button[2])
+ {
+ delete button[2];
+ button[2]=nullptr;
+ }
+ if(button[3])
+ {
+ delete button[3];
+ button[3]=nullptr;
}
-
if(labelButton_next)
{
delete labelButton_next;
labelButton_next=nullptr;
}
-
if(Title)
{
delete Title;
// button->SetDraggable(false);
return button;
}
- static bool speakfalg=false;
-
- static bool discovery_falg=false;
-
- void testA5133View:: BT_discovery_callback( void)
+
+ static bool receive_flag=false;
+
+ static bool transmit_flag=false;
+
+ void testA5133View::a5133_send_data_callback(int cmd)
{
-
- bool reT_gap;
- if(discovery_falg==false)
+ uint8 send_data_1[64] = {"前方路段发生塌方,请紧急制动"};
+ uint8 send_data_2[64] = {"前方道路拥堵,请减速慢行,注意安全"};
+ errcode_t ret = 0;
+ if(cmd)
{
+ ret = uapi_a5133_set_send_data(send_data_1,64);
+ if(ret != ERRCODE_SUCC)
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_a5133_set_send_data_1 failed %d",ret);
+ }
+ else
+ {
+ ret = uapi_a5133_set_send_data(send_data_2,64);
+ if(ret != ERRCODE_SUCC)
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_a5133_set_send_data_2 failed %d",ret);
+ }
+ }
+
+ static uint8_t a1533_count = 0;
+
+ void testA5133View::a5133_transmit_callback( void)
+ {
+ int ret = 0;
+ if(transmit_flag==false)
+ {
+ uapi_set4GCapability(true);
+ send_a5133_cmd_msg(9);
+ button[1]->SetText("start transmit");
+ button[1]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full);
+ transmit_flag = true;
+ if(A5133_TEST_timer)
+ {
+ ret = osTimerStart(A5133_TEST_timer, 1000);
+ if(ret != 0)
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"osTimerStart A5133_TEST_timer failed %d",ret);
+ }
-
- button->SetText("scaning");
- button->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full);
- discovery_falg=true;
}
else
{
-
- button->SetText("discovery");
- button->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full);
+ button[1]->SetText("stop transmit");
+ button[1]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full);
+ transmit_flag = false;
+ if(A5133_TEST_timer)
+ {
+ ret = osTimerStop(A5133_TEST_timer);
+ if(ret != 0)
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"osTimerStop A5133_TEST_timer failed %d",ret);
+ a1533_count = 0;
+ }
+ }
+ }
+
+
+ void testA5133View::a5133_receive_callback( void)
+ {
+ if(receive_flag==false)
+ {
+ uapi_set4GCapability(true);
+ send_a5133_cmd_msg(10);
+ button[0]->SetText("start receive");
+ button[0]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full);
+ receive_flag = true;
- discovery_falg=false;
+ }
+ else
+ {
+ button[0]->SetText("stop receive");
+ button[0]->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full);
+
+ receive_flag = false;
+ for(int i = 0 ; i < 1; i++)
+ label_a5133_SCAN[i]->SetText("");
+
}
+ RootView::GetInstance()->Invalidate();
}
label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh); // 字体行高
label->SetText(labelConfig.text); // 内容
label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。
- label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP);
+ label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize);
label->SetAlign(TEXT_ALIGNMENT_LEFT);
+ label->SetStyle(STYLE_BORDER_COLOR, 0xff0176ff);
+ label->SetStyle(STYLE_BORDER_COLOR, 0xff0176ff);
return label;
}
free(device_name);
}
-
static void mgdataTimerCallBack(int data)
{
+ uint8_t rxdata[80] = {0};
+ uapi_get_a5133_rxdata(rxdata,80);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "rxdata:%s",rxdata);
+ testA5133View::GetInstance()->a5133_set_text(rxdata,0);
+ RootView::GetInstance()->Invalidate();
+ }
-
-
- }
-
- bool testA5133View::br_scan_set_text(unsigned char *name ,unsigned char *addr,int16_t rssi,int i)
+ bool testA5133View::a5133_set_text(uint8_t *databuf,int i)
{
- if(i>=5)
- {
- return false;
- }
- char buf[128]={0};
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rssi %d",rssi);
+
+ //unsigned char buf[80]= {0};
- sprintf_s(buf,128,"addr:%02X %02X %02X %02X %02X %02X\nRssi:%d",addr[0],addr[1],addr[2],addr[3],addr[4],addr[5],rssi);
- label_a5133_SCAN[i]->SetText(buf);
+ //sprintf_s(buf,128,"addr:%02X %02X %02X %02X %02X %02X\nRssi:%d",addr[0],addr[1],addr[2],addr[3],addr[4],addr[5],rssi);
+ label_a5133_SCAN[a1533_count]->SetText((char *)databuf);
RootView::GetInstance()->Invalidate();
return true;
testa5133ScrollView->SetDirection(1);
- LabelConfig Config = {
- .left = 33,
- .top = 80,
- .width = 400,
- .height = 44,
- .fontSize = 30,
- .lineHeigh = 0,
- .text = "",
- .lineBreakMode = UILabel::LINE_BREAK_WRAP,
- };
+ // if (label5_ == nullptr) {
+ // label5_ = new UILabel();
+ // }
+ //label5_->SetPosition(79, 203); // widget's left position and top position
+ // label5_->Resize(306, 49); // widget's width and height
+ // label5_->SetViewId("label5");// Set style
+ // label5_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff007dff);
+ // label5_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ // label5_->SetStyle(STYLE_BORDER_COLOR, 0xff0176ff);
+ // label5_->SetStyle(STYLE_TEXT_FONT, 30);
+
+ // // Set additional property
+ // label5_->SetText("28%");
+ // label5_->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ // label5_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ // label5_->SetRollSpeed(0);
+ // label5_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+
+ // Add ImageView to App
+ if (image3_ == nullptr) {
+ image3_ = new UIImageView();
+ }
+ image3_->SetPosition(40, 192); // widget's left position and top position
+ image3_->Resize(379, 100); // widget's width and height
+ image3_->SetViewId("image3");// Set style
+ image3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ image3_->SetStyle(STYLE_BORDER_WIDTH, 3);
+ image3_->SetStyle(STYLE_BORDER_COLOR, 0xffffffff);
+ // Set additional property
- for(int i=0 ;i<5;i++)
- {
- Config.top+=100;
- label_a5133_SCAN[i]= InitLabel(Config);
- testa5133ScrollView->Add(label_a5133_SCAN[i]);
+ // Add to rootView
+ testa5133ScrollView->Add(image3_);
+ image3_->SetVisible(true);
+
+ if (label_a5133_SCAN[0] == nullptr) {
+ label_a5133_SCAN[0] = new UILabel();
}
+ label_a5133_SCAN[0]->SetPosition(0, 193); // widget's left position and top position
+ label_a5133_SCAN[0]->Resize(466, 100); // widget's width and height
+ label_a5133_SCAN[0]->SetViewId("label5");// Set style
+ label_a5133_SCAN[0]->SetStyle(STYLE_TEXT_FONT, 25);
+
+ // Set additional property
+ label_a5133_SCAN[0]->SetText("default");
+ label_a5133_SCAN[0]->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ label_a5133_SCAN[0]->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ label_a5133_SCAN[0]->SetRollSpeed(0);
+ label_a5133_SCAN[0]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 25);
+
+ // Add to rootView
+ testa5133ScrollView->Add(label_a5133_SCAN[0]);
+ label_a5133_SCAN[0]->SetVisible(true);
+
+
+ // LabelConfig Config = {
+ // .left = 79,
+ // .top = 80,
+ // .width = 306,
+ // .height = 49,
+ // .fontSize = 30,
+ // .lineHeigh = 0,
+ // .text = "",
+ // .lineBreakMode = UILabel::LINE_BREAK_ELLIPSIS,
+ // };
+
+
+ // for(int i=0 ;i<5;i++)
+ // {
+ // Config.top+=100;
+ // label_a5133_SCAN[i]= InitLabel(Config);
+ // testa5133ScrollView->Add(label_a5133_SCAN[i]);
+ // }
+
ButtonConfig_ext_t buttonconfig;
buttonconfig.x = 55;
buttonconfig.label_x=40;
buttonconfig.label_y=0;
buttonconfig.Fontsize=30;
- buttonconfig.ViewId="discovery";
- buttonconfig.str="discovery";
+ buttonconfig.ViewId="receive";
+ buttonconfig.str="receive";
buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;
- button=SetTheButton_ext(buttonconfig);
- testa5133ScrollView->Add(button);
-
+ button[0]=SetTheButton_ext(buttonconfig);
+ testa5133ScrollView->Add(button[0]);
+
+
+ // buttonconfig.x = 55;
+ // buttonconfig.y = 200;
+ // buttonconfig.w = 180;
+ // buttonconfig.h = 88;
+ // buttonconfig.label_x=40;
+ // buttonconfig.label_y=0;
+ // buttonconfig.Fontsize=30;
+ // buttonconfig.ViewId="transmit";
+ // buttonconfig.str="transmit";
+ // buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;
+ // button[1]=SetTheButton_ext(buttonconfig);
+ // testa5133ScrollView->Add(button[1]);
+
+ // buttonconfig.x = 55;
+ // buttonconfig.y = 220;
+ // buttonconfig.w = 180;
+ // buttonconfig.h = 88;
+ // buttonconfig.label_x=40;
+ // buttonconfig.label_y=0;
+ // buttonconfig.Fontsize=30;
+ // buttonconfig.ViewId="send_data_1";
+ // buttonconfig.str="1";
+ // buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;
+ // button[2]=SetTheButton_ext(buttonconfig);
+ // testa5133ScrollView->Add(button[2]);
+
+ // buttonconfig.x = 55;
+ // buttonconfig.y = 280;
+ // buttonconfig.w = 180;
+ // buttonconfig.h = 88;
+ // buttonconfig.label_x=40;
+ // buttonconfig.label_y=0;
+ // buttonconfig.Fontsize=30;
+ // buttonconfig.ViewId="send_data_2";
+ // buttonconfig.str="2";
+ // buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;
+ // button[3]=SetTheButton_ext(buttonconfig);
+ // testa5133ScrollView->Add(button[3]);
+
+
UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(testPresenter::GetInstance());
if (draglistener == nullptr)
labelButton_next= testAboutView::GetInstance()->init_button_next(270,80,Test_ViewMapper_t[id].viewid_str_next);
testa5133ScrollView->Add(labelButton_next);
- Title= testAboutView::GetInstance()->init_title(165,45,"BT_TEST");
+ Title= testAboutView::GetInstance()->init_title(165,45,"A5133_TEST");
testa5133ScrollView->Add(Title);
testa5133ScrollView->SetDraggable(true);
uint32_t tick;
osStatus_t retTimer;
- BR_TEST_timer = osTimerNew((osTimerFunc_t)mgdataTimerCallBack, osTimerPeriodic, NULL, NULL);
- tick =5000;// osMs2Tick(1000);
- retTimer = osTimerStart(BR_TEST_timer, tick);
- if (retTimer != osOK && BR_TEST_timer != NULL) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer);
- osTimerDelete(BR_TEST_timer);
- BR_TEST_timer = NULL;
- return false;
- }
+ A5133_TEST_timer = osTimerNew((osTimerFunc_t)mgdataTimerCallBack, osTimerPeriodic, NULL, NULL);
+ if(A5133_TEST_timer)
+ osTimerStart(A5133_TEST_timer, 1000);
- discovery_falg=false;
+ receive_flag=false;
+ transmit_flag = false;
uint8_t cnt = pm_veto_get_id_cnt(PM_ID_P_TEST);
if (cnt == 0) {
uapi_pm_add_sleep_veto(PM_ID_P_TEST);