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);
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
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
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
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
{\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,×tamp,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
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
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
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
{\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
#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,
TOPIC_EVENT_DEVICE_UNBIND,
TOPIC_EVENT_DEVICE_UNBINDING_REQUEST,
#endif
+
TOPIC_EVENT_FIND_WATCH, //查找手表
TOPIC_EVENT_CANCEL_FIND_WATCH,//取消查找
TOPIC_END_NUM = 20000,
// 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
{
#include "ConfigModel.h"
#include "power_display_service.h"
#include "bletest.h"
+//#include "TraingCardPresenter.h"
+
//#include "Systemupgrade.h"
namespace OHOS {
{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},
#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
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);
else
{
//电量过低,直接提醒关机
- set_lowpower_falg(true);
+ set_lowpower_falg(1);
if (NotificationManager::GetInstance()->hasNotifyShowing())
NotificationManager::GetInstance()->StopNotify();
NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
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;
//灰卡测试
display_api->turn_on_screen();
}
uint8_t* data=(uint8_t*)req->data;
+
if(data!=NULL && req->len>=2)
{
switch (data[0])
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:
{
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[] = {
{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},
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;
}
}
}
- 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);
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);
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后将自动关机");
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;
}
if(battery_falg)
{
osTimerStop(low_power_timer);
- low_power_paly(true);
+ low_power_paly();
}
else
{
//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)