BlueTooth.c 5.75 KB
Newer Older
1
#include "Components.h"
2

3 4 5 6 7
uint8_t OTA_Update_Count_Open = 0;
uint8_t OTA_Update_Count_Close = 0;
uint8_t Update_Graphic_Count = 0;
uint8_t GetBlueToothVaild = 0;
uint8_t GetPhoneBookVaild = 0;
8
uint8_t TextInit = 0;
9
uint8_t SetUUIDTimes = 0;
10 11
_PICID_Struct PicObj;
_QRCODE_RECT QRCode_Rect;
12
const uint8_t HJBlueToothName[9]= {"HJ750"};
13 14
uint8_t UUIDConfigBuf[22] = {"800082024071700000001"};
// 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00
15

16 17 18

void TextService(void);

19 20
void BlueToothService()
{
21
    // SetUUIDTimes++;
22 23 24
    if(Get_Dis_Bluetooth_Open_Close() == 0)
    {
        if(GetBlueToothVaild == 0)
25
        {
26 27
            SetBluetoothTurnXX(1);
            GetBlueToothVaild = 1;
28
        }
29 30 31 32
    }
    else
    {
        if(GetBlueToothVaild == 1)
33
        {
34 35
            SetBluetoothTurnXX(0);
            GetBlueToothVaild = 0;
36
        }
37
    }
38

39 40 41 42 43 44 45 46 47
    if ((BlueToothPhoneData.BlueToothSignalSate == BlueTooth_Connection)&&(GetPhoneBookVaild == 0))
    {
        PackedTransfer_GetPhoneBookCmd();
        GetPhoneBookVaild = 1;
    }
    else if (BlueToothPhoneData.BlueToothSignalSate == BlueTooth_DisConnect)
    {
        GetPhoneBookVaild = 0;
    }
48

49 50 51 52
    if((BlueToothPhoneData.BlueToothPhoneSate == Phone_Outgoing) || (BlueToothPhoneData.BlueToothPhoneSate == Phone_Incoming) || (BlueToothPhoneData.BlueToothPhoneSate == Phone_Talking))
    {
        Menu_Change_Branch_To_Item(MENU_BRANCH_ANIMATION,MENU_ITEM_MAIN_ITEM);
    }
53
    SetUUIDData((char *)UUIDConfigBuf, 22);
54 55 56 57 58 59 60 61 62 63 64 65
    if (OTA_Update_Flag == 1) 
    {
        QRCode_Rect.x = 650;
        QRCode_Rect.y = 210;
    }
    else 
    {
        QRCode_Rect.x = QRCode_X;
        QRCode_Rect.y = QRCode_Y;
    }
    // QRCode_Rect.x = 650;
    // QRCode_Rect.y = 210;
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
    QRCode_Rect.height = 240;
    QRCode_Rect.width = 240;
    SetScreenType(QRCode_TYPE, QRCode_Rect);
    if(Menu_Get_Current_Cursor_Information() != MENU_ITEM_FAULT_INFORMATION)
    {
        OTA_Update_Flag = 0;
    }
    if(OTA_Update_Flag == 1)
    {
        if(OTA_Update_Count_Open < 5)
        {
            SetUpdateCtrl(1,QRCode_Rect);
            OTA_Update_Count_Open++;
        }  
        OTA_Update_Count_Close = 0;
    }
    else
    {
        if(OTA_Update_Count_Close < 5)
        {
            SetUpdateCtrl(0,QRCode_Rect);
            OTA_Update_Count_Close++;
        } 
        OTA_Update_Count_Open=0;
    }
91
    SetTaskbarHeight(150);
92
    SetBlueToothName((uint8_t *)HJBlueToothName, sizeof(HJBlueToothName));
93
    TextService();
94
    
95 96 97 98 99 100 101 102 103 104 105
    // BlueConnectStatus = GetBlueToothPowerSTATE();
    // juasfha = BlueToothPhoneData.BlueToothPhoneSate;
    // juasfha = BlueToothPhoneData.PhoneBookTotalCount;
    // for(i=0;i<20;i++)
    // {
    //     sjhja[i] = BlueToothPhoneData.PhoneNumber[i];
    // }
    // for(i=0;i<100;i++)
    // {
    //     PhoneName[i] = BlueToothPhoneData.BlueToothPhoneName[i];
    // }
106
    
107 108 109 110 111 112
    // _QRCODE_RECT QRCode_Rect;
    // QRCode_Rect.x = QRCode_X;
    // QRCode_Rect.y = QRCode_Y;
    // QRCode_Rect.height = QRCode_HEIGHT;
    // QRCode_Rect.width = QRCode_WIDTH;
    // SetScreenType(QRCode_TYPE, QRCode_Rect);
113 114
}

115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
TEXT_STRUCT TextPara[TEXT_NUM_TOTAL] = 
{
    {TEXT_NUM_BLUETOOTH_NAME,           0x4005, 0},
    {TEXT_NUM_BLUETOOTH_PHONENAME,      0x4007, 0},
    {TEXT_NUM_PHONE_NUMBER,             0x4009, 0},
    {TEXT_NUM_PHONE_NUMBER_TOTAL,       0x4011, 0},
    {TEXT_NUM_INFORMATION_MCUVER,       0x4012, 0},
    {TEXT_NUM_INFORMATION_SWVERSION,    0x4013, 0},
    {TEXT_NUM_INFORMATION_HW,           0x4014, 0}, //23F 23E
    {TEXT_NUM_INFORMATION_OS,           0x4015, 0},
    {TEXT_NUM_INFORMATION_HMI,          0x4016, 0},
    {TEXT_NUM_ROAD_NAME,                0x4022, 0},

};

uint8_t PhoneNumber[40];
uint8_t LastPhoneNumber[20];
uint8_t LastBlueToothPhoneName[100];
uint8_t CurBlueToothPhoneName[100];

void TextService(void) 
{
    if(TextInit == 0)
    {
        TextInit = 1;
        memset(PhoneNumber, 0, sizeof(PhoneNumber));
        memset(LastPhoneNumber, 0, sizeof(LastPhoneNumber));
        memset(LastBlueToothPhoneName, 0, sizeof(LastBlueToothPhoneName));
        memset(CurBlueToothPhoneName, 0, sizeof(CurBlueToothPhoneName));
    }
    if (BlueToothPhoneData.BlueToothSignalSate == BlueTooth_Connection) 
    {
        if ((BlueToothPhoneData.BlueToothPhoneSate == Phone_Outgoing) || (BlueToothPhoneData.BlueToothPhoneSate == Phone_Incoming) || (BlueToothPhoneData.BlueToothPhoneSate == Phone_Talking)) {
            if ((memcmp(LastBlueToothPhoneName, BlueToothPhoneData.BlueToothPhoneName, sizeof(LastBlueToothPhoneName))) != 0) 
            {
                for (uint8_t i = 0; i < (sizeof(BlueToothPhoneData.BlueToothPhoneName) / 2); i++) 
                {
                    CurBlueToothPhoneName[i * 2] = BlueToothPhoneData.BlueToothPhoneName[(i * 2) + 1];
                    CurBlueToothPhoneName[(i * 2) + 1] = BlueToothPhoneData.BlueToothPhoneName[i * 2];
                }
                memcpy(LastBlueToothPhoneName, BlueToothPhoneData.BlueToothPhoneName, (sizeof(BlueToothPhoneData.BlueToothPhoneName) / sizeof(BlueToothPhoneData.BlueToothPhoneName[0])));
                TextPara[TEXT_NUM_BLUETOOTH_PHONENAME].Vaild = 0X01;
            }
            if ((memcmp(LastPhoneNumber, BlueToothPhoneData.PhoneNumber, sizeof(LastPhoneNumber))) != 0) 
            {
                for (uint8_t i = 0; i < sizeof(BlueToothPhoneData.PhoneNumber); i++) 
                {
                    PhoneNumber[i * 2] = (uint8_t)(BlueToothPhoneData.PhoneNumber[i]);
                    PhoneNumber[(i * 2) + 1] = 0X00;
                }
                memcpy(LastPhoneNumber, BlueToothPhoneData.PhoneNumber, (sizeof(BlueToothPhoneData.PhoneNumber) / sizeof(BlueToothPhoneData.PhoneNumber[0])));
                TextPara[TEXT_NUM_PHONE_NUMBER].Vaild = 0X01;
            }
        }
    }
}