Merge #39 into xts_origin from refs/changes/39/head 41/target/1 42/target/1 43/target/1
author胡传军 <1224667075@qq.com>
Thu, 18 Apr 2024 04:04:53 +0000 (04:04 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Thu, 18 Apr 2024 04:04:53 +0000 (04:04 +0000)
Code review from 胡传军

* refs/changes/39/head: (6 commits squashed)

  - 多包数据发送修改及通讯录AT指令添加修改

  - 修改编译错误

  - Merge branch &#39;xts_origin&#39; of codeup.aliyun.com:64191456b9581d62e8f81ac0/FD230 into xts_origin

  - Merge branch &#39;xts_origin&#39; of codeup.aliyun.com:64191456b9581d62e8f81ac0/FD230 into xts_origin

  - Merge branch &#39;xts_origin&#39; of codeup.aliyun.com:64191456b9581d62e8f81ac0/FD230 into xts_origin

  - 蓝牙设置语言及关机重启

Signed-off-by: aliyun8003852482 <1224667075@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/39
code/sdk/application/wearable/service/ble_service/blemoder/bletest.h
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c
code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h
code/sdk/application/wearable/service/msg_center/include/notify/charge_notification.h
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp

index e5f4388..49bf3e6 100644 (file)
@@ -26,6 +26,15 @@ enum PAIRING
     REBOOT,
     SHUTDOWN
 };
+
+enum TRANING
+{
+    START=0,
+    STOP,
+    RECOVER,
+    END
+};
+
 void set_weather_now_data(int humidity, char* windScale, char* textNight,int uvIndex,int temp,int iconNight);
 
 void set_weather_address_data(int lat, char* atm, char* city,char* subLocality,int lon);
index b3fb0d9..c4e7ba1 100644 (file)
@@ -234,6 +234,7 @@ static cJSON *cjson_json_tmp = NULL;
 errcode_t sendBleData(uint8_t *buf,uint16_t len)\r
 {\r
     errcode_t ret = ERRCODE_FAIL;\r
+    printf("bigDataBufState:%d and  sendbigDataBufState %d\r\n",bigDataBufState,sendbigDataBufState);\r
     if(bigDataBufState == true || sendbigDataBufState == true)return ERRCODE_FAIL; //在手表发送分包数据时 手表不允许发指令给app\r
     for(uint16_t i = 0;i<len;i++)\r
     {   \r
@@ -246,10 +247,16 @@ errcode_t sendBleData(uint8_t *buf,uint16_t len)
     return ret;\r
     \r
 }\r
+\r
 void sendDataNow(uint8_t *buf,uint16_t len)\r
 {\r
     if(Bleconnect == true )\r
     {\r
+        for(uint16_t i = 0;i<len;i++)\r
+        {   \r
+            printf("%02x ",buf[i]);\r
+        }\r
+\r
         svr_ble_bt_gatts_noyify(buf,len);\r
     }\r
 }\r
@@ -3831,28 +3838,39 @@ void send_big_data(uint8_t flag,char *data,int datalen,int total,uint32_t Packet
     memcpy(buf+7,&total,4);\r
     memcpy(buf+11,&Packet_id,4);\r
     memcpy(buf+15,&datalen,2);\r
-    if(flag)\r
+    // if(flag)\r
+    // {\r
+    //     uint8_t crcvalue=Calculate_CRC_Big((uint8_t *)data,datalen);\r
+    //     // uint16_t t= ble_nus_max_data_len -17 -crcvalue;\r
+    //     // memcpy(buf+17,&t,2);\r
+    //     memcpy(buf+17,data,datalen);\r
+       \r
+    //     buf[17+datalen] = crcvalue;\r
+    //     sendDataNow(buf,17+datalen+1);\r
+\r
+    // }\r
+    // else\r
+    // {\r
+    if(data==NULL)\r
     {\r
-        uint16_t t=0x00;\r
-        memcpy(buf+17,&t,2);\r
-        memcpy(buf+19,data,datalen);\r
-        buf[19+datalen] = Calculate_CRC_Big((uint8_t *)data,datalen);\r
-        sendDataNow(buf,19+datalen+1);\r
+        buf[17+datalen] = Calculate_CRC_Big((uint8_t *)data,datalen);\r
+        sendDataNow(buf,17+datalen+1);\r
 \r
-    }\r
-    else\r
+    }else\r
     {\r
-       \r
         memcpy(buf+17,data,datalen);\r
         buf[17+datalen] = Calculate_CRC_Big((uint8_t *)data,datalen);\r
         printf("xxxxxxxxxxxxx\r\n");\r
         sendDataNow(buf,17+datalen+1);\r
 \r
     }\r
+    \r
+\r
+   // }\r
    \r
 }\r
 \r
-void Read_spo2_file_buf_Data(uint8_t id)\r
+void Read_spo2_file_buf_Data(uint8_t num)\r
 {\r
     sendbigDataBufState = true;//分包同步数据不允许打断\r
     char *buf=(char *)malloc(sizeof(char)*512);\r
@@ -3861,6 +3879,7 @@ void Read_spo2_file_buf_Data(uint8_t id)
     FILE *fp= fopen(path,"r+");\r
     if(fp==NULL)\r
     {\r
+        send_big_data(0,NULL,0,0,1,1,0x40);\r
         printf("打开文件失败%s\r\n",path);\r
         return;\r
     }\r
@@ -3893,21 +3912,24 @@ void Read_spo2_file_buf_Data(uint8_t id)
     {\r
          packet_total=item_num/96+1;\r
     }\r
-    for(int i=0;i<item_num;i++)\r
+   for(int i=0;i<item_num;i++)\r
     {\r
         cJSON * heart_data_item=cJSON_GetArrayItem(heart_data_list,i);\r
         uint32 timestamp=cJSON_GetObjectItem(heart_data_item,"timestamp")->valueint;\r
-        uint8_t vale=cJSON_GetObjectItem(heart_data_item,"oxygen_value")->valueint;\r
+        uint8_t vale=cJSON_GetObjectItem(heart_data_item,"heart_value")->valueint;\r
+        printf("heart_value :%d\r\n",vale);\r
+        printf("timestamp :%d\r\n",timestamp);\r
         memcpy(send_buf+send_len,&timestamp,4);\r
         send_len+=4;\r
         memcpy(send_buf+send_len,&vale,1);\r
         send_len+=1;\r
         \r
-        if((i%96==0 && i!=0) || (item_num-1==i))\r
+        if(((i+1)%num==0 && i!=0) || (item_num-1==i))\r
         {\r
             //发送数据\r
             if(item_num-1==i)\r
             {\r
+                printf("sendbuf :%s sendbuf_len%d\r\n",send_buf,send_len);\r
                 send_big_data(0,send_buf,send_len,item_num*5,Packet_id,packet_total,0x40);\r
                 free(send_buf);\r
                 sendbigDataBufState=false;\r
@@ -3918,9 +3940,10 @@ void Read_spo2_file_buf_Data(uint8_t id)
                 free(send_buf);\r
                 send_buf=(char *)malloc(sizeof(char)*HEART_DATA_LEN);\r
                 send_len=0;\r
+                Packet_id++;\r
             }\r
         }\r
-        send_buf=realloc(send_buf,i*5+5);\r
+        send_buf=realloc(send_buf,i*5+10);\r
     }\r
     cJSON_free(heart_data);\r
     \r
@@ -3935,6 +3958,7 @@ void Read_heart_file_buf_Data(uint8_t num)
     FILE *fp= fopen(path,"r+");\r
     if(fp==NULL)\r
     {\r
+        send_big_data(0,NULL,0,0,1,1,0x40);\r
         return;\r
     }\r
     int ret=fread(buf,1,512,fp);\r
@@ -3994,6 +4018,7 @@ void Read_heart_file_buf_Data(uint8_t num)
                 free(send_buf);\r
                 send_buf=(char *)malloc(sizeof(char)*HEART_DATA_LEN);\r
                 send_len=0;\r
+                Packet_id++;\r
             }\r
         }\r
         send_buf=realloc(send_buf,i*5+10);\r
@@ -4013,7 +4038,9 @@ void readDevDataBle(uint8_t *crcnum,uint16_t len,uint8_t crcvalue)
         {\r
             case 0x40://同步心率历史数据\r
                 EACH_DATA_LEN = HEART_DATA_LEN;\r
-                Read_heart_file_buf_Data(3);\r
+                int num=(ble_nus_max_data_len-18)/HEART_DATA_LEN;\r
+                printf("同步心率数据,每包最多:%d 条数据\r\n",num);\r
+                Read_heart_file_buf_Data(num);\r
                 break;\r
             case 0x41://同步血氧历史数据\r
                 printf("同步血氧数据\r\n");\r
index 141ccf7..ac9ec75 100755 (executable)
@@ -48,6 +48,7 @@ typedef enum {
 #ifdef CYWEE_SPORT
     TOPIC_EVENT_ACTIVITY_UPDATE,
     TOPIC_EVENT_INACTIVITY_UPDATE,
+    TOPIC_EVENT_BLE_TRAINING,
 #endif
 #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION
     TOPIC_EVENT_CHARGE_PLUG,
@@ -78,6 +79,7 @@ typedef enum {
     TOPIC_EVENT_DEVICE_UNBIND,
     TOPIC_EVENT_DEVICE_UNBINDING_REQUEST,
 #endif
+  
     TOPIC_EVENT_FIND_WATCH, //查找手表
     TOPIC_EVENT_CANCEL_FIND_WATCH,//取消查找
     TOPIC_END_NUM = 20000,
index 357ed56..a270924 100644 (file)
@@ -8,9 +8,9 @@ namespace OHOS
     // UIView *view_ = nullptr;
 
     UIViewGroup* lowPowerShow(void);
-    void set_lowpower_falg(bool falg);
+    void set_lowpower_falg(uint8_t falg);
     void FreelowPower(void);
-    void low_power_paly(bool);
+    void low_power_paly();
      
     class lowppowrAnimatorStopListener :public OHOS::UIImageAnimatorView::AnimatorStopListener
     {
index feeab27..208226f 100755 (executable)
@@ -41,6 +41,8 @@
 #include "ConfigModel.h"
 #include "power_display_service.h"
 #include "bletest.h"
+//#include "TraingCardPresenter.h"
+
 //#include "Systemupgrade.h"
 namespace OHOS {
 
@@ -54,6 +56,7 @@ const PriorityMapper g_pri_mapper[] = {
     {TOPIC_EVENT_NEXTDAY_UPDATE, PRIORITY_TWO},
     {TOPIC_EVENT_ACTIVITY_UPDATE,PRIORITY_TWO},
     {TOPIC_EVENT_INACTIVITY_UPDATE,PRIORITY_TWO},
+    {TOPIC_EVENT_BLE_TRAINING,PRIORITY_TWO},
 #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION
     {TOPIC_EVENT_CHARGE_PLUG, PRIORITY_TWO},
     {TOPIC_EVENT_CHARGE_UNPLUG, PRIORITY_TWO},
@@ -124,6 +127,7 @@ void MsgCenterSubscribe()
 #ifdef CYWEE_SPORT
     MsgCenterSubscribeTopic(TOPIC_EVENT_ACTIVITY_UPDATE);
     MsgCenterSubscribeTopic(TOPIC_EVENT_INACTIVITY_UPDATE);
+    MsgCenterSubscribeTopic(TOPIC_EVENT_BLE_TRAINING);
 
 #endif
 #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION
@@ -279,12 +283,12 @@ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req)
     if(*x==3)
     {
         //倒计时结束后,直接执行关机动画
-        low_power_paly(true);
+        low_power_paly();
     }
     else if(*x==0)
     {
         //提醒低电充电
-        set_lowpower_falg(false);
+        set_lowpower_falg(0);
         if (NotificationManager::GetInstance()->hasNotifyShowing())
             NotificationManager::GetInstance()->StopNotify();
         NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
@@ -293,7 +297,7 @@ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req)
     else
     {
         //电量过低,直接提醒关机
-        set_lowpower_falg(true);
+        set_lowpower_falg(1);
         if (NotificationManager::GetInstance()->hasNotifyShowing())
             NotificationManager::GetInstance()->StopNotify();
         NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
@@ -363,54 +367,7 @@ void MsgCenterNotifyHfpWatchProc(const Topic topic, Request* req)
         NotificationManager::GetInstance()->ShowNotify(showCallingNotify, (uint16_t)topic, true);
     }
 }
-//一般模式
-void MsgCenterNotifyNormalProc(const Topic topic, Request* req)
-{
-    unused(topic);
-    unused(req);
-}
-//跑步机模式
-void MsgCenterNotifyTreadmillProc(const Topic topic, Request* req)
-{
-    unused(topic);
-    unused(req);
-}
-//户外跑步模式
-void MsgCenterNotifyOutdoorRunningProc(const Topic topic, Request* req)
-{
-    unused(topic);
-    unused(req);
-}
-//室内跑步模式
-void MsgCenterNotifyIndoorRunningProc(const Topic topic, Request* req)
-{
-    unused(topic);
-    unused(req);
-}
-//防误触计步
-void MsgCenterNotifyFitnessPedometerProc(const Topic topic, Request* req)
-{
-    unused(topic);
-    unused(req);
-}
-//自由运动模式
-void MsgCenterNotifyFreeTrainingProc(const Topic topic, Request* req)
-{
-    unused(topic);
-    unused(req);
-}
-//长时间动作侦测模式
-void MsgCenterNotifyArAlertProc(const Topic topic, Request* req)
-{
-    unused(topic);
-    unused(req);
-}
 
-void MsgCenterNotifyExtraInfoProc(const Topic topic, Request* req)
-{
-    unused(topic);
-    unused(req);
-}
 #ifdef SUPPORT_SPO2_NOTIFICATION_TEST
 uint32_t md = PPG_SERVICE_CMD_TYPE_DO_PPG_TEST;
 //灰卡测试
@@ -755,6 +712,7 @@ void MsgCenterNotifyDeviceBindProc(const Topic topic, Request* req)
         display_api->turn_on_screen();
     }
     uint8_t* data=(uint8_t*)req->data;
+
     if(data!=NULL && req->len>=2)
     {
         switch (data[0])
@@ -772,16 +730,24 @@ void MsgCenterNotifyDeviceBindProc(const Topic topic, Request* req)
             NotificationManager::GetInstance()->ShowNotify(showDeviceUnbindingRequestNotify, (uint16_t)topic, true);
             break;
         case SHUTDOWN:
-            set_lowpower_falg(true);
+            WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, " SHUTDOWN");
+            set_lowpower_falg(3);
+             if (NotificationManager::GetInstance()->hasNotifyShowing())
+            NotificationManager::GetInstance()->StopNotify();
+
             NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+
             NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
-            low_power_paly(true);
+            //low_power_paly(true);
             break;
         case REBOOT:
-            set_lowpower_falg(true);
+            set_lowpower_falg(4);
+            if (NotificationManager::GetInstance()->hasNotifyShowing())
+            NotificationManager::GetInstance()->StopNotify();
+
             NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
             NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
-            low_power_paly(false);
+            //low_power_paly(false);
             break;
 
         default:
@@ -854,6 +820,33 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request* req)
 {
     unused(topic);
     unused(req);
+} 
+//APP运动相关
+void MsgCenterNotifybleAPPtraining(const Topic topic, Request* req)
+{
+    unused(topic);
+     uint8_t* data=(uint8_t*)req->data;
+    if(data!=NULL && req->len>=2)
+    {
+        switch (data[1])
+        {
+            case START://运动开始
+
+            break;
+            case STOP://运动暂停
+
+            break;
+            case RECOVER://运动恢复
+
+            break;
+
+            case END://运动结束
+            break;
+        }
+    }
+
+    // unused(req);
+
 }
 /* 订阅事件通知逻辑可定制 */
 static msg_center_notify_table_t g_msg_center_notify_table[] = {
@@ -867,8 +860,11 @@ static msg_center_notify_table_t g_msg_center_notify_table[] = {
     {TOPIC_EVENT_HFP_PHONE_TO_WATCH, MsgCenterNotifyHfpWatchProc},
     {TOPIC_EVENT_FIND_WATCH,MsgCenterNotifyFindWatchProc},
     {TOPIC_EVENT_CANCEL_FIND_WATCH,MsgCenterNotifyCanCelFindWatchProc},
+ #ifdef CYWEE_SPORT   
     {TOPIC_EVENT_ACTIVITY_UPDATE,       MsgCenterNotifyActivityProc},
     {TOPIC_EVENT_INACTIVITY_UPDATE,       MsgCenterNotifyInactivityProc},
+    {TOPIC_EVENT_BLE_TRAINING,       MsgCenterNotifybleAPPtraining},
+#endif  
 #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION
     {TOPIC_EVENT_CHARGE_PLUG,        MsgCenterNotifyChargePlugProc},
     {TOPIC_EVENT_CHARGE_UNPLUG,      MsgCenterNotifyChargeUnPlugProc},
index f2c2a9b..c057d45 100644 (file)
@@ -110,8 +110,8 @@ namespace OHOS
         return group;
     }
 
-    static bool battery_falg=false;
-    void set_lowpower_falg(bool falg)
+    static uint8_t battery_falg=0;
+    void set_lowpower_falg(uint8_t falg)
     {
         battery_falg=falg;
     }
@@ -175,11 +175,12 @@ namespace OHOS
         }
         
     }
-    bool poweroff_flag=true;
-    void low_power_paly(bool falg)
+
+    void low_power_paly()
     {
         //uapi_poweroff_device(); // 关机
-        poweroff_flag=falg;
+       
+        //osTimerStop(low_power_timer);
         group->SetVisible(true);
         UIImageAnimatorView::AnimatorStopListener *stoplistener =  static_cast<UIImageAnimatorView::AnimatorStopListener *>(lowppowrAnimatorStopListener::GetInstance());
         ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener);
@@ -226,7 +227,7 @@ namespace OHOS
         alarm_UILabel->SetStyle(STYLE_TEXT_FONT, 33);
 
         // Set additional property
-        if(battery_falg==false)
+        if(battery_falg==0)
         {
             alarm_UILabel->SetText("请及时连接充电器");
             alarm_UILabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
@@ -235,7 +236,7 @@ namespace OHOS
             alarm_UILabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 33);
         }
         // Set additional property
-        if(battery_falg==true)
+        if(battery_falg==1)
         {
             alarm_UILabel->SetPosition(50, 215); 
             alarm_UILabel->SetText("电量过低5s后将自动关机");
@@ -288,6 +289,18 @@ namespace OHOS
         ShowUpShutDownAnimatorView();
         if(group)
         UIViewGroup_lowpower->Add(group);
+        if(battery_falg>=3)
+        {
+            group->SetVisible(true);
+            UIImageAnimatorView::AnimatorStopListener *stoplistener =  static_cast<UIImageAnimatorView::AnimatorStopListener *>(lowppowrAnimatorStopListener::GetInstance());
+            ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener);
+            if (stoplistener == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create stoplistener!!");
+                return NULL;
+            }
+            ShutDownImageAnimatorView->Start();
+        }
         return UIViewGroup_lowpower;
     }
 
@@ -315,7 +328,7 @@ namespace OHOS
             if(battery_falg)
             {
                 osTimerStop(low_power_timer);
-                low_power_paly(true);
+                low_power_paly();
 
             }
             else
@@ -332,10 +345,10 @@ namespace OHOS
     {
         //UNUSED(view);
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xxxxxxxxxxxxxxxxxxxxOnAnimatorStop");
-        if(poweroff_flag)
-        uapi_poweroff_device(); // 关机 
-        else
+        if(battery_falg==4)
         uapi_reboot_device();
+        else
+        uapi_poweroff_device(); // 关机 
         //NotificationManager::GetInstance()->StopNotify();
         //
         // if(strcmp(view.GetViewId(),LOW_POWER_BUTTON)!=0)