150 lines
4.1 KiB
C
150 lines
4.1 KiB
C
#include "include.h"
|
|
#include "func.h"
|
|
#include "ble_protocol_msg.h"
|
|
#include "app_variable.h"
|
|
|
|
#if TRACE_EN
|
|
#define TRACE(...) printf(__VA_ARGS__)
|
|
#else
|
|
#define TRACE(...)
|
|
#endif
|
|
|
|
#define QR_CODE_MAX 120
|
|
|
|
#if(APP_CHOOSE==APP_CHOOSE_LEFUN)
|
|
#if defined(KEY_DEFINED_BY_XG_CUSTOM)
|
|
#define STR_URL_EN "http://app.waashine.com/Lefun/download.html"
|
|
#else
|
|
#define STR_URL_EN "http://dw.ss-tjd.com/download/en4.html"
|
|
#endif
|
|
#define STR_URL_CN "http://dw.ss-tjd.com/download/index4.html"
|
|
|
|
#elif(APP_CHOOSE==APP_CHOOSE_TFit)
|
|
#if defined(TJD_GUI_W17_SWATCH_MODIFY) && !defined(TJD_HUAYING_MODIFY)
|
|
#define STR_URL "http://download.microwear.com/mactiveapk.html"
|
|
#else
|
|
#define STR_URL "http://dw.ss-tjd.com/DownLoad/TFitzh.html"
|
|
#endif
|
|
#endif
|
|
|
|
typedef struct f_scan_t_ {
|
|
} f_scan_t;
|
|
|
|
void *barcode_creat(void *parent, char *str, int x, int y, int h, u8 length, bool dir);
|
|
|
|
static bool Refresh = false;
|
|
|
|
//创建扫一扫窗体
|
|
compo_form_t *func_scan_form_create(void)
|
|
{
|
|
u8 *p_qrCode = func_zalloc(120);
|
|
//新建窗体
|
|
compo_form_t *frm = compo_form_create(true);
|
|
//设置标题栏
|
|
compo_form_set_mode(frm, COMPO_FORM_MODE_SHOW_TITLE | COMPO_FORM_MODE_SHOW_TIME);
|
|
compo_form_set_title(frm, i18n[STR_SETTING_QR_CODE]);
|
|
|
|
//创建按键
|
|
//compo_button_t *btn = compo_button_create_by_image(frm, UI_BUF_ICON_SCAN_BIN);
|
|
//compo_button_set_pos(btn, 160, 180);
|
|
|
|
u8 mac_addr[20]={0};
|
|
u8 mac_buf[20]={0};
|
|
ble_get_local_bd_addr((void *)mac_addr);
|
|
sprintf((char*)mac_buf,"%02x%02x%02x%02x%02x%02x",mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
|
|
#if(APP_CHOOSE==APP_CHOOSE_LEFUN)
|
|
#if defined(__LANGUAGE_SM_CHINESE__)
|
|
if(SysVariable.deviceInfo.language==LANGUAGE_TYPE_Chinese){
|
|
sprintf((char*)p_qrCode,"%s?name=%s&mac=%s", STR_URL_CN, xcfg_cb.le_name, mac_buf);
|
|
}else
|
|
#endif
|
|
{
|
|
sprintf((char*)p_qrCode,"%s?name=%s&mac=%s", STR_URL_EN, xcfg_cb.le_name, mac_buf);
|
|
}
|
|
#elif(APP_CHOOSE==APP_CHOOSE_TFit)
|
|
#if defined(TJD_GUI_BASE_SW_BIULD)
|
|
sprintf((char*)p_qrCode,"%s?name=%s&mac=%s", STR_URL, ble_name, mac_buf);
|
|
#else
|
|
sprintf((char*)p_qrCode,"%s?name=%s&mac=%s", STR_URL, BLE_GAP_DEVICE_NAME, mac_buf);
|
|
#endif
|
|
#endif
|
|
compo_qrcodebox_t *qrbox = compo_qrcodebox_create(frm, QRCODE_TYPE_2D, QR_CODE_MAX);
|
|
compo_qrcodebox_set(qrbox, (const char*)p_qrCode);
|
|
compo_qrcodebox_set_bitwid_by_qrwid(qrbox, 80);
|
|
//barcode_creat(frm->page_body, "123896\0", GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y, 80, 6, false);
|
|
|
|
func_free(p_qrCode);
|
|
return frm;
|
|
}
|
|
|
|
//扫一扫功能事件处理
|
|
static void func_scan_process(void)
|
|
{
|
|
if (Refresh && !sco_is_connected()) {
|
|
Refresh = false;
|
|
|
|
compo_form_t *frm = func_cb.frm_main;
|
|
compo_form_destroy(frm);
|
|
func_cb.frm_main = func_scan_form_create();
|
|
}
|
|
|
|
func_process();
|
|
}
|
|
|
|
//扫一扫功能消息处理
|
|
static void func_scan_message(size_msg_t msg)
|
|
{
|
|
switch (msg) {
|
|
case MSG_CTP_CLICK:
|
|
break;
|
|
|
|
case MSG_CTP_SHORT_UP:
|
|
break;
|
|
|
|
case MSG_CTP_SHORT_DOWN:
|
|
break;
|
|
|
|
case MSG_CTP_LONG:
|
|
/* APP已连接下不允许进入工厂模式 */
|
|
if (!ble_is_connected()) {
|
|
func_switch_to_assign_screen(FUNC_FACTORY_TEST, false);
|
|
}
|
|
break;
|
|
|
|
default:
|
|
func_message(msg);
|
|
break;
|
|
}
|
|
}
|
|
|
|
//进入扫一扫功能
|
|
static void func_scan_enter(void)
|
|
{
|
|
if (sco_is_connected()) {
|
|
Refresh = true;
|
|
}
|
|
|
|
func_cb.f_cb = func_zalloc(sizeof(f_scan_t));
|
|
func_cb.frm_main = func_scan_form_create();
|
|
func_cb.enter_tick = tick_get();
|
|
}
|
|
|
|
//退出扫一扫功能
|
|
static void func_scan_exit(void)
|
|
{
|
|
Refresh = false;
|
|
func_cb.last = FUNC_SCAN;
|
|
}
|
|
|
|
//扫一扫功能
|
|
void func_scan(void)
|
|
{
|
|
printf("%s\n", __func__);
|
|
func_scan_enter();
|
|
while (func_cb.sta == FUNC_SCAN) {
|
|
func_scan_process();
|
|
func_scan_message(msg_dequeue());
|
|
}
|
|
func_scan_exit();
|
|
}
|