diff --git a/drivers/mtk/2K_XP_COM/usb2ser_2kXP.inf b/drivers/mtk/2K_XP_COM/usb2ser_2kXP.inf new file mode 100644 index 00000000..06733f6e --- /dev/null +++ b/drivers/mtk/2K_XP_COM/usb2ser_2kXP.inf @@ -0,0 +1,90 @@ +;/***************************************************************************** +;* Copyright Statement: +;* -------------------- +;* This software is protected by Copyright and the information contained +;* herein is confidential. The software may not be copied and the information +;* contained herein may not be used or disclosed except with the written +;* permission of MediaTek Inc. (C) 2010 +;* +;* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +;* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +;* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +;* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +;* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +;* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +;* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +;* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +;* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +;* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +;* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +;* +;* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +;* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +;* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +;* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +;* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +;* +;* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +;* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +;* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +;* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +;* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +;* +;*****************************************************************************/ +; +; usb2ser_2kXP.inf +; + +[Version] +Signature="$Windows NT$" +Class=Ports +ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} + +Provider=%MTK% +DriverVer=07/28/2010,1.1032.0 +CatalogFile=usb2ser_2kXP_Comp.cat + +[Manufacturer] +%MTK%=MTK + +[MTK] +%MTK6218%=Reader,USB\Vid_0e8d&Pid_0003 +%MTK_COM%=Reader,USB\Vid_0e8d&Pid_0023&MI_00 +%MTK_CAT%=Reader,USB\Vid_0e8d&Pid_0023&MI_02 + +[DestinationDirs] +DefaultDestDir=12 + +[Reader.NT] +include=mdmcpq.inf +AddReg=Reader.NT.AddReg +CopyFiles=FakeModemCopyFileSection + +[Reader.NT.AddReg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,usbser.sys +HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" + +[Reader.NT.Services] +AddService = usbser, 0x00000002, Service_Inst + +[Service_Inst] +DisplayName = %Serial.SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %12%\usbser.sys +LoadOrderGroup = Base + +[SourceDisksNames] + +[SourceDisksFiles] + + +[Strings] +MTK = "MediaTek Inc." +MTK6218 = "MTK USB Port" +MTK_COM = "MTK USB Modem Port" +MTK_CAT = "MTK USB Debug Port" +Serial.SvcDesc = "USB Serial emulation modem driver" \ No newline at end of file diff --git a/drivers/mtk/2K_XP_COM/usb2ser_2kxp_64.cat b/drivers/mtk/2K_XP_COM/usb2ser_2kxp_64.cat new file mode 100644 index 00000000..85be693d Binary files /dev/null and b/drivers/mtk/2K_XP_COM/usb2ser_2kxp_64.cat differ diff --git a/drivers/mtk/2K_XP_COM/usb2ser_2kxp_comp.cat b/drivers/mtk/2K_XP_COM/usb2ser_2kxp_comp.cat new file mode 100644 index 00000000..61264609 Binary files /dev/null and b/drivers/mtk/2K_XP_COM/usb2ser_2kxp_comp.cat differ diff --git a/drivers/mtk/2K_XP_COM/usb2ser_XP64.inf b/drivers/mtk/2K_XP_COM/usb2ser_XP64.inf new file mode 100644 index 00000000..fa212f4b --- /dev/null +++ b/drivers/mtk/2K_XP_COM/usb2ser_XP64.inf @@ -0,0 +1,89 @@ +;/***************************************************************************** +;* Copyright Statement: +;* -------------------- +;* This software is protected by Copyright and the information contained +;* herein is confidential. The software may not be copied and the information +;* contained herein may not be used or disclosed except with the written +;* permission of MediaTek Inc. (C) 2010 +;* +;* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +;* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +;* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +;* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +;* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +;* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +;* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +;* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +;* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +;* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +;* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +;* +;* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +;* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +;* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +;* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +;* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +;* +;* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +;* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +;* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +;* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +;* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +;* +;*****************************************************************************/ +; +; usb2ser_XP64.inf +; + +[Version] +Signature="$Windows NT$" +Class=Ports +ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} + +Provider=%MTK% +DriverVer=07/28/2010,1.1032.0 +CatalogFile=usb2ser_2kXP_64.cat + +[Manufacturer] +%MTK%=MTK,NTamd64 + +[MTK.NTamd64] +%MTK6218%=Reader,USB\Vid_0e8d&Pid_0003 +%MTK_COM%=Reader,USB\Vid_0e8d&Pid_0023&MI_00 +%MTK_CAT%=Reader,USB\Vid_0e8d&Pid_0023&MI_02 + +[DestinationDirs] +DefaultDestDir=12 + +[Reader.NTamd64] +include=mdmcpq.inf +AddReg=Reader.NTamd64.AddReg +CopyFiles=FakeModemCopyFileSection + +[Reader.NTamd64.AddReg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,usbser.sys +HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" + +[Reader.NTamd64.Services] +AddService = usbser, 0x00000002, Service_Inst + +[Service_Inst] +DisplayName = %Serial.SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %12%\usbser.sys +LoadOrderGroup = Base + +[SourceDisksNames] + +[SourceDisksFiles] + +[Strings] +MTK = "MediaTek Inc." +MTK6218 = "MTK USB Port" +MTK_COM = "MTK USB Modem Port" +MTK_CAT = "MTK USB Debug Port" +Serial.SvcDesc = "USB Serial emulation modem driver" diff --git a/drivers/mtk/98ME_COM/GPRS_USB_Modem.inf b/drivers/mtk/98ME_COM/GPRS_USB_Modem.inf new file mode 100644 index 00000000..7a70f575 --- /dev/null +++ b/drivers/mtk/98ME_COM/GPRS_USB_Modem.inf @@ -0,0 +1,357 @@ +[Version] +Signature="$CHICAGO$" +Class=Modem +Provider=%COMPANY% +ClassGUID={4D36E96D-E325-11CE-BFC1-08002BE10318} + +[Manufacturer] +%COMPANY% = Models + +[Models] +%Modem1%=Modem1, USB\MTKUSB + +[Modem1] +AddReg = All, MfgAddReg, Modem1.AddReg, USB + +[Strings] +Company ="MediaTek" +Modem1="MTK GPRS USB Modem" + +[All] +HKR,,FriendlyDriver,0,Unimodem.vxd +HKR,,DevLoader,0,*vcomm +HKR,,ConfigDialog,0,modemui.dll +HKR,,EnumPropPages,0,modemui.dll,EnumPropPages +HKR,,PortSubClass,1,02 + +[USB] +HKR,, DeviceType, 1, 01 +HKR,,PortDriver,,wdmmdmld.vxd +HKR,,Contention,0, + +[Modem1.AddReg] +HKR,, Properties, 1, 80,01,00,00, 00,00,00,00, 00,00,00,00, 00,00,00,00, 00,00,00,00, 10,01,00,00, 00,C2,01,00, 40,83,00,00 + +[MfgAddReg] +HKR, Init, 1,, "AT" +HKR, Init, 2,, "ATE0V1" + +HKR, Monitor, 1,, "ATS0=0" +HKR, Monitor, 2,, "None" +HKR, Answer, 1,, "ATA" +HKR, Hangup, 1,, "ATH" +HKR,, Reset,, "ATZ" + +HKR, Settings, Prefix,, "AT" +HKR, Settings, Terminator,, "" +HKR, Settings, DialPrefix,, "D" +HKR, Settings, Pulse,, "P" +HKR, Settings, Tone,, "T" + +HKR, Responses, "", 1, 01, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "", 1, 01, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "OK", 1, 00, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "RING", 1, 08, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "NO CARRIER", 1, 04, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "ERROR", 1, 03, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "NO DIALTONE", 1, 05, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "BUSY", 1, 06, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "NO ANSWER", 1, 07, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "CONNECT", 1, 02, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "0", 1, 00, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "2", 1, 08, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "3", 1, 04, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "4", 1, 03, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "6", 1, 05, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "7", 1, 06, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "8", 1, 07, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "OK", 1, 00, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "RING", 1, 08, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "NO CARRIER", 1, 04, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "ERROR", 1, 03, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "NO DIALTONE", 1, 05, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "NO DIAL TONE",1, 05, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "BUSY", 1, 06, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "NO ANSWER", 1, 07, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "FAX", 1, 03, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "DATA", 1, 03, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "VOICE", 1, 03, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "RINGING", 1, 01, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "DIALING", 1, 01, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "RRING", 1, 01, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "DELAYED", 1, 1d, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "BLACKLISTED", 1, 1c, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "+FCERROR", 1, 03, 00, 00,00,00,00, 00,00,00,00 + +HKR, Responses, "CONNECT", 1, 02, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "CONNECT/ARQ", 1, 02, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "CONNECT/REL", 1, 02, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "CONNECT/MNP", 1, 02, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "CONNECT/LAP-M", 1, 02, 02, 00,00,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT/V42BIS", 1, 02, 03, 00,00,00,00, 00,00,00,00 +HKR, Responses, "CONNECT/V42b", 1, 02, 03, 00,00,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 300", 1, 02, 00, 2C,01,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 300/ARQ", 1, 02, 02, 2C,01,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 300/REL", 1, 02, 02, 2C,01,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 300/MNP", 1, 02, 02, 2C,01,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 300/LAP-M", 1, 02, 02, 2C,01,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 300/V42BIS", 1, 02, 03, 2C,01,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 300/V42b", 1, 02, 03, 2C,01,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 600", 1, 02, 00, 58,02,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 600/ARQ", 1, 02, 02, 58,02,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 600/REL", 1, 02, 02, 58,02,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 600/MNP", 1, 02, 02, 58,02,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 600/LAP-M", 1, 02, 02, 58,02,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 600/V42BIS", 1, 02, 03, 58,02,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 600/V42b", 1, 02, 03, 58,02,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 0600", 1, 02, 00, 58,02,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 0600/ARQ", 1, 02, 02, 58,02,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 0600/REL", 1, 02, 02, 58,02,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 0600/MNP", 1, 02, 02, 58,02,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 0600/LAP-M", 1, 02, 02, 58,02,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 0600/V42BIS", 1, 02, 03, 58,02,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 0600/V42b", 1, 02, 03, 58,02,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200", 1, 02, 00, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200/ARQ", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200/REL", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200/MNP", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200/LAP-M", 1, 02, 02, B0,04,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 1200/V42BIS", 1, 02, 03, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200/V42b", 1, 02, 03, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200/75", 1, 02, 00, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200/75/ARQ", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200/75/REL", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200/75/MNP", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200/75/LAP-M", 1, 02, 02, B0,04,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 1200/75/V42BIS", 1, 02, 03, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200/75/V42b", 1, 02, 03, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200TX/75RX", 1, 02, 00, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200TX/75RX/ARQ", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200TX/75RX/REL", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200TX/75RX/MNP", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200TX/75RX/LAP-M", 1, 02, 02, B0,04,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 1200TX/75RX/V42BIS",1, 02, 03, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 1200TX/75RX/V42b", 1, 02, 03, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 75/1200", 1, 02, 00, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 75/1200/ARQ", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 75/1200/REL", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 75/1200/MNP", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 75/1200/LAP-M", 1, 02, 02, B0,04,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 75/1200/V42BIS", 1, 02, 03, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 75/1200/V42b", 1, 02, 03, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 75TX/1200RX", 1, 02, 00, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 75TX/1200RX/ARQ", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 75TX/1200RX/REL", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 75TX/1200RX/MNP", 1, 02, 02, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 75TX/1200RX/LAP-M", 1, 02, 02, B0,04,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 75TX/1200RX/V42BIS",1, 02, 03, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 75TX/1200RX/V42b", 1, 02, 03, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 2400", 1, 02, 00, 60,09,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 2400/ARQ", 1, 02, 02, 60,09,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 2400/REL", 1, 02, 02, 60,09,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 2400/MNP", 1, 02, 02, 60,09,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 2400/LAP-M", 1, 02, 02, 60,09,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 2400/V42BIS", 1, 02, 03, 60,09,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 2400/V42b", 1, 02, 03, 60,09,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 4800", 1, 02, 00, C0,12,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 4800/ARQ", 1, 02, 02, C0,12,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 4800/REL", 1, 02, 02, C0,12,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 4800/MNP", 1, 02, 02, C0,12,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 4800/LAP-M", 1, 02, 02, C0,12,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 4800/V42BIS", 1, 02, 03, C0,12,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 4800/V42b", 1, 02, 03, C0,12,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 7200", 1, 02, 00, 20,1C,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 7200/ARQ", 1, 02, 02, 20,1C,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 7200/REL", 1, 02, 02, 20,1C,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 7200/MNP", 1, 02, 02, 20,1C,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 7200/LAP-M", 1, 02, 02, 20,1C,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 7200/V42BIS", 1, 02, 03, 20,1C,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 7200/V42b", 1, 02, 03, 20,1C,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 9600", 1, 02, 00, 80,25,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 9600/ARQ", 1, 02, 02, 80,25,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 9600/REL", 1, 02, 02, 80,25,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 9600/MNP", 1, 02, 02, 80,25,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 9600/LAP-M", 1, 02, 02, 80,25,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 9600/V42BIS", 1, 02, 03, 80,25,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 9600/V42b", 1, 02, 03, 80,25,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 12000", 1, 02, 00, E0,2E,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 12000/ARQ", 1, 02, 02, E0,2E,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 12000/REL", 1, 02, 02, E0,2E,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 12000/MNP", 1, 02, 02, E0,2E,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 12000/LAP-M", 1, 02, 02, E0,2E,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 12000/V42BIS", 1, 02, 03, E0,2E,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 12000/V42b", 1, 02, 03, E0,2E,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 14400", 1, 02, 00, 40,38,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 14400/ARQ", 1, 02, 02, 40,38,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 14400/REL", 1, 02, 02, 40,38,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 14400/MNP", 1, 02, 02, 40,38,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 14400/LAP-M", 1, 02, 02, 40,38,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 14400/V42BIS", 1, 02, 03, 40,38,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 14400/V42b", 1, 02, 03, 40,38,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 16800", 1, 02, 00, A0,41,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 16800/ARQ", 1, 02, 02, A0,41,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 16800/REL", 1, 02, 02, A0,41,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 16800/MNP", 1, 02, 02, A0,41,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 16800/LAP-M", 1, 02, 02, A0,41,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 16800/V42BIS", 1, 02, 03, A0,41,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 16800/V42b", 1, 02, 03, A0,41,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 19200", 1, 02, 00, 00,4B,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 19200/ARQ", 1, 02, 02, 00,4B,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 19200/REL", 1, 02, 02, 00,4B,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 19200/MNP", 1, 02, 02, 00,4B,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 19200/LAP-M", 1, 02, 02, 00,4B,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 19200/V42BIS", 1, 02, 03, 00,4B,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 19200/V42b", 1, 02, 03, 00,4B,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 21600", 1, 02, 00, 60,54,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 21600/ARQ", 1, 02, 02, 60,54,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 21600/REL", 1, 02, 02, 60,54,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 21600/MNP", 1, 02, 02, 60,54,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 21600/LAP-M", 1, 02, 02, 60,54,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 21600/V42BIS", 1, 02, 03, 60,54,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 21600/V42b", 1, 02, 03, 60,54,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 24000", 1, 02, 00, C0,5D,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 24000/ARQ", 1, 02, 02, C0,5D,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 24000/REL", 1, 02, 02, C0,5D,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 24000/MNP", 1, 02, 02, C0,5D,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 24000/LAP-M", 1, 02, 02, C0,5D,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 24000/V42BIS", 1, 02, 03, C0,5D,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 24000/V42b", 1, 02, 03, C0,5D,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 26400", 1, 02, 00, 20,67,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 26400/ARQ", 1, 02, 02, 20,67,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 26400/REL", 1, 02, 02, 20,67,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 26400/MNP", 1, 02, 02, 20,67,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 26400/LAP-M", 1, 02, 02, 20,67,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 26400/V42BIS", 1, 02, 03, 20,67,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 26400/V42b", 1, 02, 03, 20,67,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 28800", 1, 02, 00, 80,70,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 28800/ARQ", 1, 02, 02, 80,70,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 28800/REL", 1, 02, 02, 80,70,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 28800/MNP", 1, 02, 02, 80,70,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 28800/LAP-M", 1, 02, 02, 80,70,00,00, 00,00,00,00 +;HKR, Responses, "CONNECT 28800/V42BIS", 1, 02, 03, 80,70,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 28800/V42b", 1, 02, 03, 80,70,00,00, 00,00,00,00 +HKR, Responses, "CONNECT 38400", 1, 02, 00, 00,00,00,00, 00,96,00,00 +HKR, Responses, "CONNECT 38400/ARQ", 1, 02, 02, 00,00,00,00, 00,96,00,00 +HKR, Responses, "CONNECT 38400/REL", 1, 02, 02, 00,00,00,00, 00,96,00,00 +HKR, Responses, "CONNECT 38400/MNP", 1, 02, 02, 00,00,00,00, 00,96,00,00 +HKR, Responses, "CONNECT 38400/LAP-M", 1, 02, 02, 00,00,00,00, 00,96,00,00 +;HKR, Responses, "CONNECT 38400/V42BIS", 1, 02, 03, 00,00,00,00, 00,96,00,00 +HKR, Responses, "CONNECT 38400/V42b", 1, 02, 03, 00,00,00,00, 00,96,00,00 +HKR, Responses, "CONNECT 57600", 1, 02, 00, 00,00,00,00, 00,E1,00,00 +HKR, Responses, "CONNECT 57600/ARQ", 1, 02, 02, 00,00,00,00, 00,E1,00,00 +HKR, Responses, "CONNECT 57600/REL", 1, 02, 02, 00,00,00,00, 00,E1,00,00 +HKR, Responses, "CONNECT 57600/MNP", 1, 02, 02, 00,00,00,00, 00,E1,00,00 +HKR, Responses, "CONNECT 57600/LAP-M", 1, 02, 02, 00,00,00,00, 00,E1,00,00 +;HKR, Responses, "CONNECT 57600/V42BIS", 1, 02, 03, 00,00,00,00, 00,E1,00,00 +HKR, Responses, "CONNECT 57600/V42b", 1, 02, 03, 00,00,00,00, 00,E1,00,00 +HKR, Responses, "CONNECT 115200", 1, 02, 00, 00,00,00,00, 00,C2,01,00 +HKR, Responses, "CONNECT 115200/ARQ", 1, 02, 02, 00,00,00,00, 00,C2,01,00 +HKR, Responses, "CONNECT 115200/REL", 1, 02, 02, 00,00,00,00, 00,C2,01,00 +HKR, Responses, "CONNECT 115200/MNP", 1, 02, 02, 00,00,00,00, 00,C2,01,00 +HKR, Responses, "CONNECT 115200/LAP-M", 1, 02, 02, 00,00,00,00, 00,C2,01,00 +;HKR, Responses, "CONNECT 115200/V42BIS", 1, 02, 03, 00,00,00,00, 00,C2,01,00 +HKR, Responses, "CONNECT 115200/V42b", 1, 02, 03, 00,00,00,00, 00,C2,01,00 +HKR, Responses, "CONNECT 115,200", 1, 02, 00, 00,00,00,00, 00,C2,01,00 +HKR, Responses, "CONNECT 115,200/ARQ", 1, 02, 02, 00,00,00,00, 00,C2,01,00 +HKR, Responses, "CONNECT 115,200/REL", 1, 02, 02, 00,00,00,00, 00,C2,01,00 +HKR, Responses, "CONNECT 115,200/MNP", 1, 02, 02, 00,00,00,00, 00,C2,01,00 +HKR, Responses, "CONNECT 115,200/LAP-M", 1, 02, 02, 00,00,00,00, 00,C2,01,00 +;HKR, Responses, "CONNECT 115,200/V42BIS", 1, 02, 03, 00,00,00,00, 00,C2,01,00 +HKR, Responses, "CONNECT 115,200/V42b", 1, 02, 03, 00,00,00,00, 00,C2,01,00 +HKR, Responses, "CONNECT 230400", 1, 02, 00, 00,00,00,00, 00,84,03,00 +HKR, Responses, "CONNECT 230400/ARQ", 1, 02, 02, 00,00,00,00, 00,84,03,00 +HKR, Responses, "CONNECT 230400/REL", 1, 02, 02, 00,00,00,00, 00,84,03,00 +HKR, Responses, "CONNECT 230400/MNP", 1, 02, 02, 00,00,00,00, 00,84,03,00 +HKR, Responses, "CONNECT 230400/LAP-M", 1, 02, 02, 00,00,00,00, 00,84,03,00 +;HKR, Responses, "CONNECT 230400/V42BIS", 1, 02, 03, 00,00,00,00, 00,84,03,00 +HKR, Responses, "CONNECT 230400/V42b", 1, 02, 03, 00,00,00,00, 00,84,03,00 +HKR, Responses, "CONNECT 31200 EC", 1,02,02,E0,79,00,0,0,0,0,0 +HKR, Responses, "CONNECT 31200 EC/V42", 1,02,02,E0,79,00,0,0,0,0,0 +;HKR, Responses, "CONNECT 31200 EC/V42BIS", 1,02,03,E0,79,00,0,0,0,0,0 +HKR, Responses, "CONNECT 31200 REL", 1,02,02,E0,79,00,0,0,0,0,0 +HKR, Responses, "CONNECT 31200 REL/MNP5", 1,02,03,E0,79,00,0,0,0,0,0 +HKR, Responses, "CONNECT 31200 REL/V42", 1,02,02,E0,79,00,0,0,0,0,0 +;HKR, Responses, "CONNECT 31200 REL/V42BIS", 1,02,03,E0,79,00,0,0,0,0,0 +HKR, Responses, "CONNECT 31200", 1,02,00,E0,79,00,0,0,0,0,0 +HKR, Responses, "CONNECT 31200/ARQ", 1,02,02,E0,79,00,0,0,0,0,0 +HKR, Responses, "CONNECT 31200/LAP-M", 1,02,02,E0,79,00,0,0,0,0,0 +HKR, Responses, "CONNECT 31200/MNP", 1,02,02,E0,79,00,0,0,0,0,0 +HKR, Responses, "CONNECT 31200/REL", 1,02,02,E0,79,00,0,0,0,0,0 +HKR, Responses, "CONNECT 31200/REL-LAPM V.42 BIS", 1,02,03,E0,79,00,0,0,0,0,0 +HKR, Responses, "CONNECT 31200/REL-LAPM", 1,02,02,E0,79,00,0,0,0,0,0 +HKR, Responses, "CONNECT 31200/V42B", 1,02,03,E0,79,00,0,0,0,0,0 +;HKR, Responses, "CONNECT 31200/V42BIS", 1,02,03,E0,79,00,0,0,0,0,0 +HKR, Responses, "CONNECT 33600 EC", 1,02,02,40,83,00,0,0,0,0,0 +HKR, Responses, "CONNECT 33600 EC/V42", 1,02,02,40,83,00,0,0,0,0,0 +;HKR, Responses, "CONNECT 33600 EC/V42BIS", 1,02,03,40,83,00,0,0,0,0,0 +HKR, Responses, "CONNECT 33600 REL", 1,02,02,40,83,00,0,0,0,0,0 +HKR, Responses, "CONNECT 33600 REL/MNP5", 1,02,03,40,83,00,0,0,0,0,0 +HKR, Responses, "CONNECT 33600 REL/V42", 1,02,02,40,83,00,0,0,0,0,0 +;HKR, Responses, "CONNECT 33600 REL/V42BIS", 1,02,03,40,83,00,0,0,0,0,0 +HKR, Responses, "CONNECT 33600", 1,02,00,40,83,00,0,0,0,0,0 +HKR, Responses, "CONNECT 33600/ARQ", 1,02,02,40,83,00,0,0,0,0,0 +HKR, Responses, "CONNECT 33600/LAP-M", 1,02,02,40,83,00,0,0,0,0,0 +HKR, Responses, "CONNECT 33600/MNP", 1,02,02,40,83,00,0,0,0,0,0 +HKR, Responses, "CONNECT 33600/REL", 1,02,02,40,83,00,0,0,0,0,0 +HKR, Responses, "CONNECT 33600/REL-LAPM V.42 BIS", 1,02,03,40,83,00,0,0,0,0,0 +HKR, Responses, "CONNECT 33600/REL-LAPM", 1,02,02,40,83,00,0,0,0,0,0 +HKR, Responses, "CONNECT 33600/V42B", 1,02,03,40,83,00,0,0,0,0,0 +;HKR, Responses, "CONNECT 33600/V42BIS", 1,02,03,40,83,00,0,0,0,0,0 +HKR, Responses, "CONNECT 31200/REL-MNP",1,02,02,E0,79,00,0,0,0,0,0 +HKR, Responses, "CONNECT 33600/REL-MNP",1,02,02,40,83,00,0,0,0,0,0 + +HKR, Responses, "CARRIER 300", 1, 01, 00, 2C,01,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 1200", 1, 01, 00, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 1200/75", 1, 01, 00, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 75/1200", 1, 01, 00, B0,04,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 2400", 1, 01, 00, 60,09,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 4800", 1, 01, 00, C0,12,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 7200", 1, 01, 00, 20,1C,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 9600", 1, 01, 00, 80,25,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 12000", 1, 01, 00, E0,2E,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 14400", 1, 01, 00, 40,38,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 16800", 1, 01, 00, A0,41,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 19200", 1, 01, 00, 00,4B,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 21600", 1, 01, 00, 60,54,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 24000", 1, 01, 00, C0,5D,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 26400", 1, 01, 00, 20,67,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 28800", 1, 01, 00, 80,70,00,00, 00,00,00,00 +HKR, Responses, "CARRIER 31200 V.23",1,01,00,E0,79,00,0,0,0,0,0 +HKR, Responses, "CARRIER 31200",1,01,00,E0,79,00,0,0,0,0,0 +HKR, Responses, "CARRIER 31200/VFC", 1,01,00,E0,79,00,0,0,0,0,0 +HKR, Responses, "CARRIER 33600 V.23",1,01,00,40,83,00,0,0,0,0,0 +HKR, Responses, "CARRIER 33600",1,01,00,40,83,00,0,0,0,0,0 +HKR, Responses, "CARRIER 33600/VFC", 1,01,00,40,83,00,0,0,0,0,0 + +HKR, Responses, "COMPRESSION: CLASS 5", 1, 01, 03, 00,00,00,00, 00,00,00,00 +HKR, Responses, "COMPRESSION: MNP5", 1, 01, 03, 00,00,00,00, 00,00,00,00 +;HKR, Responses, "COMPRESSION: V.42BIS", 1, 01, 03, 00,00,00,00, 00,00,00,00 +HKR, Responses, "COMPRESSION: V.42 BIS", 1, 01, 03, 00,00,00,00, 00,00,00,00 +;HKR, Responses, "COMPRESSION: V.42bis", 1, 01, 03, 00,00,00,00, 00,00,00,00 +HKR, Responses, "COMPRESSION: V.42 bis", 1, 01, 03, 00,00,00,00, 00,00,00,00 +HKR, Responses, "COMPRESSION: ADC", 1, 01, 01, 00,00,00,00, 00,00,00,00 +HKR, Responses, "COMPRESSION: NONE", 1, 01, 00, 00,00,00,00, 00,00,00,00 + +HKR, Responses, "AUTOSTREAM: LEVEL 1", 1, 01, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "AUTOSTREAM: LEVEL 2", 1, 01, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "AUTOSTREAM: LEVEL 3", 1, 01, 00, 00,00,00,00, 00,00,00,00 + +HKR, Responses, "PROTOCOL: NONE", 1, 01, 00, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: ERROR-CONTROL/LAPB", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: ERROR-CONTROL/LAPB/HDX", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: ERROR-CONTROL/LAPB/AFT", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: X.25/LAPB", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: X.25/LAPB/HDX", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: X.25/LAPB/AFT", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: LAPM", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: LAP-M", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: LAPM/HDX", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: LAP-M/HDX", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: LAPM/AFT", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: LAP-M/AFT", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: ALT", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: ALT-CELLULAR", 1, 01, 0A, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: MNP", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: MNP2", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: MNP3", 1, 01, 02, 00,00,00,00, 00,00,00,00 +HKR, Responses, "PROTOCOL: MNP4", 1, 01, 02, 00,00,00,00, 00,00,00,00 diff --git a/drivers/mtk/98ME_COM/USBCDC.INF b/drivers/mtk/98ME_COM/USBCDC.INF new file mode 100644 index 00000000..dd183b36 --- /dev/null +++ b/drivers/mtk/98ME_COM/USBCDC.INF @@ -0,0 +1,47 @@ +[Version] +CatalogFile=usbcdc.cat +Signature=$CHICAGO$ +Class=USB +Provider=%String0% +LayoutFile=layout.inf,layout1.inf,layout2.inf + +[DestinationDirs] +DefaultDestDir=10 +USB.Drvrs=10,SYSTEM32\DRIVERS +USB.VxD=11 + +[Manufacturer] +%String0%=Microsoft +%MTK%=MTK + +[MTK] +%String1%=MTKUSB,USB\VID_0E8D&PID_0003,USB\Vid_0e8d&Pid_0023&MI_00,USB\Vid_0e8d&Pid_0023&MI_02 + +[MTKUSB] +CopyFiles=USB.Drvrs,USB.VxD +AddReg=MTKUSB.AddReg + +[USB.Drvrs] +usbser.sys +ccport.sys + +[USB.VxD] +wdmmdmld.vxd + +[MTKUSB.AddReg] +HKR,,DevLoader,0,*ntkern +HKR,,NTMPDriver,,"usbser.sys,ccport.sys" + +[MTKUSB.HW] +AddReg=MTKAddReg.HW + +[MTKAddReg.HW] +HKR,,ChildID,2,"USB\MTKUSB" + +[PreCopySection] +HKR,,NoSetupUI,,1 + +[Strings] +String0 = "Microsoft Corporation" +String1 = "USB Serial" +MTK = "MediaTek Inc." diff --git a/drivers/mtk/98_Mass/MTKUMSS.INF b/drivers/mtk/98_Mass/MTKUMSS.INF new file mode 100644 index 00000000..21383d18 --- /dev/null +++ b/drivers/mtk/98_Mass/MTKUMSS.INF @@ -0,0 +1,77 @@ +[Version] +Signature="$CHICAGO$" +Class=HDC +provider=%MSFT% + +[Manufacturer] +%MTK%=MTK + +[MTK] +%USB\VID_054C&PID_0023.DeviceDesc%=MTK.install,USB\VID_0e8d&PID_0002 +%UMSS\DISK.DeviceDesc%=umsspdr.install,UMSS\DISK + +[PreCopySection] +HKR,,NoSetupUI,,1 + +[DestinationDirs] +; \\SYSTEM32\DRIVERS +umss.files = 10,System32\Drivers + +; \\SYSTEM\IOSUBSYS +umsspdr.files = 12 + +[MTK.install] +CopyFiles=umss.files, umsspdr.files +AddReg=umss.addreg + +[umss.addreg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,UMSS.SYS + + +; If the device does not correctly indicate which protocol it uses, +; one of the following sections should be added to indicate which protocol +; the driver should use. + +; Indicate that the device uses the C/B/I protocol +[cbi.addreg.HW] +HKR,,DeviceProtocol,0x10001,00 + +; Indicate that the device uses the C/B protocol +[cb.addreg.HW] +HKR,,DeviceProtocol,0x10001,01 + +; Indicate that the device uses the BULK ONLY protocol +[bulkonly.addreg.HW] +HKR,,DeviceProtocol,0x10001,50 + +; Install the port driver +[umsspdr.install] +AddReg=umsspdr.addreg + +[umsspdr.addreg] +HKR,,DevLoader,,*ios +HKR,,PortDriver,,umsspdr.pdr + + + +[umss.files] +umss.sys + +[umsspdr.files] +umsspdr.pdr + +[SourceDisksNames] +1000 = "USB Mass Storage Sample Driver Disk","",, + +[SourceDisksFiles] +UMSS.SYS = 1000 +UMSSPDR.PDR = 1000 + +;---------------------------------------------------------------; + +[Strings] +MSFT="Microsoft" +MTK="MediaTek Inc." +USB\VID_054C&PID_0023.DeviceDesc="USB Mass Storage Drive" +UMSS\DISK.DeviceDesc="USB Mass Storage Device" diff --git a/drivers/mtk/98_Mass/UMSS.sys b/drivers/mtk/98_Mass/UMSS.sys new file mode 100644 index 00000000..c1876ac6 Binary files /dev/null and b/drivers/mtk/98_Mass/UMSS.sys differ diff --git a/drivers/mtk/98_Mass/UMSSPDR.pdr b/drivers/mtk/98_Mass/UMSSPDR.pdr new file mode 100644 index 00000000..2ac2e3ab Binary files /dev/null and b/drivers/mtk/98_Mass/UMSSPDR.pdr differ diff --git a/drivers/mtk/InstallDriver.exe b/drivers/mtk/InstallDriver.exe new file mode 100644 index 00000000..5576ca42 Binary files /dev/null and b/drivers/mtk/InstallDriver.exe differ diff --git a/drivers/mtk/ReadMe.txt b/drivers/mtk/ReadMe.txt new file mode 100644 index 00000000..37f82da1 --- /dev/null +++ b/drivers/mtk/ReadMe.txt @@ -0,0 +1,63 @@ +ReadMe.txt + +This application will install USB com port driver for MediaTek's device those IDs are listed below: + +1."VID_0E8D&PID_0003" (MTK USB Port) +2."VID_0E8D&PID_0023&MI_00" (MTK USB Modem Port) +3."VID_0E8D&PID_0023&MI_02" (MTK USB Debug Port) + +And support the Windows 98SE/ME/2000/XP/Vist/Win7 platform. + +The application user must belong to Administrator group or have the privilege to install driver. + +the execution of the InstallDriver.exe will install the driver, and the UninstallDriver.exe is special for remove driver. +the InstallDriver.exe will remove the legacy version of driver before install current driver automatically. + +Notes: +1. "2K_XP_COM, Vista, 98_MASS, 98ME_COM, Win7" folder must be put in the same directory with InstallDriver.exe +2. Running InstallDriver with command "-a" will install driver silently (means without GUI Windows). And remove driver command is "-u". "-au" or "-ua" will remove driver silently. +3. Windows 2003 use the INF files which under the 2K_XP_COM +4. The device which generates two com ports (USB Modem Port Driver & USB Modem Debug Driver) only support Systems after Win XP sp3 version. If you want to support these devices in Win XP Sp2, add these patchs: +http://support.microsoft.com/kb/918365/ +http://support.microsoft.com/kb/935892/ + + +[v1.0812.0] + [New Feature] + 1.Pass WHQL certification for Windows XP 32 bit +[v1.0821.0] + [New Feature] + 1.Support Windows XP 64 bit +[v1.0830.0] + [Bug Fix] + 1.Remove the entry referring "V.42bis", since none of our modem supports this protocol +[v1.0845.0] + [New Feature] + 1. Pass WHQL certification for Windows Vista 32 bit + 2. Pass WHQL certification for Windows Vista 64 bit +[v1.0945.0] + [New Feature] + 1.Support Win 7 32 bit + 2.Support Win 7 64 bit + 3.Remove the Installer.dll +[v1.0948.0] + [New Feature] + 1.Support Windows 2003 +[v1.1023.0] + [New Feature] + 1.Support Device VID_0E8D&PID_0023&MI_00 + Support Device VID_0E8D&PID_0023&MI_02 + +[v1.1032.0] + [Bug Fix] +1. Add the usbser.sys reference in the *.inf file .Since in Clean OS will need this reference to reference the correct driver file. +[New Feature] +1. Add "Remove" command , User can remove the driver with command Ħ°-uĦħ , As Notes section described. +2. The "Remove" command support windows XP operating system and later versions. +[v1.1032.1] +1.Add Bat file to release remove feature + + + + + diff --git a/drivers/mtk/UninstallDriver.exe b/drivers/mtk/UninstallDriver.exe new file mode 100644 index 00000000..53f38692 Binary files /dev/null and b/drivers/mtk/UninstallDriver.exe differ diff --git a/drivers/mtk/Vista/usb2ser_Vista.inf b/drivers/mtk/Vista/usb2ser_Vista.inf new file mode 100644 index 00000000..cb46f439 --- /dev/null +++ b/drivers/mtk/Vista/usb2ser_Vista.inf @@ -0,0 +1,91 @@ +;/***************************************************************************** +;* Copyright Statement: +;* -------------------- +;* This software is protected by Copyright and the information contained +;* herein is confidential. The software may not be copied and the information +;* contained herein may not be used or disclosed except with the written +;* permission of MediaTek Inc. (C) 2010 +;* +;* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +;* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +;* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +;* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +;* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +;* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +;* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +;* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +;* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +;* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +;* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +;* +;* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +;* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +;* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +;* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +;* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +;* +;* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +;* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +;* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +;* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +;* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +;* +;*****************************************************************************/ +; +; usb2ser_Vista_Win7.inf +; +[Version] +Signature="$Windows NT$" +Class=Ports +ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} + +Provider=%MTK% +DriverVer=07/28/2010,1.1032.0 + +CatalogFile=usb2serVistaWin7_32_Comp.cat + +[Manufacturer] +%MTK%=MTK + +[MTK] +%MTK6218%=Reader,USB\Vid_0e8d&Pid_0003,USB\Vid_0e8d&Pid_1003 +%MTK_COM%=Reader,USB\Vid_0e8d&Pid_0023&MI_00 +%MTK_CAT%=Reader,USB\Vid_0e8d&Pid_0023&MI_02 + +[Reader_Install.NTx86] + +[DestinationDirs] +DefaultDestDir=12 + +[Reader.NT] +Include=mdmcpq.inf +AddReg=Reader.NT.AddReg +CopyFiles=FakeModemCopyFileSection + +[Reader.NT.AddReg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,usbser.sys +HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" + +[Reader.NT.Services] +AddService = usbser, 0x00000002, Service_Inst + +[Service_Inst] +DisplayName = %Serial.SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %12%\usbser.sys +LoadOrderGroup = Base + +[SourceDisksNames] + +[SourceDisksFiles] + +[Strings] +MTK = "MediaTek Inc." +MTK6218 = "MTK USB Port" +MTK_COM = "MTK USB Modem Port" +MTK_CAT = "MTK USB Debug Port" +Serial.SvcDesc = "USB Serial emulation modem driver" diff --git a/drivers/mtk/Vista/usb2ser_Vista64.inf b/drivers/mtk/Vista/usb2ser_Vista64.inf new file mode 100644 index 00000000..0b751c82 --- /dev/null +++ b/drivers/mtk/Vista/usb2ser_Vista64.inf @@ -0,0 +1,90 @@ +;/***************************************************************************** +;* Copyright Statement: +;* -------------------- +;* This software is protected by Copyright and the information contained +;* herein is confidential. The software may not be copied and the information +;* contained herein may not be used or disclosed except with the written +;* permission of MediaTek Inc. (C) 2010 +;* +;* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +;* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +;* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +;* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +;* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +;* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +;* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +;* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +;* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +;* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +;* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +;* +;* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +;* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +;* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +;* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +;* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +;* +;* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +;* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +;* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +;* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +;* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +;* +;*****************************************************************************/ +; +; usb2ser_Vista64_Win7.inf +; +[Version] +Signature="$Windows NT$" +Class=Ports +ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} + +Provider=%MTK% +DriverVer=07/28/2010,1.1032.0 + +CatalogFile=usb2serVistaWin7_64_Comp.cat + +[Manufacturer] +%MTK%=MTK,NTamd64 + +[MTK.NTamd64] +%MTK6218%=Reader,USB\Vid_0e8d&Pid_0003,USB\Vid_0e8d&Pid_1003 +%MTK_COM%=Reader,USB\Vid_0e8d&Pid_0023&MI_00 +%MTK_CAT%=Reader,USB\Vid_0e8d&Pid_0023&MI_02 + +[DestinationDirs] +DefaultDestDir=12 + +[Reader.NTamd64] +Include=mdmcpq.inf +AddReg=Reader.NTamd64.AddReg +CopyFiles=FakeModemCopyFileSection + +[Reader.NTamd64.AddReg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,usbser.sys +HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" + +[Reader.NTamd64.Services] +AddService = usbser, 0x00000002, Service_Inst + +[SourceDisksNames] + +[SourceDisksFiles] + + +[Service_Inst] +DisplayName = %Serial.SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %12%\usbser.sys +LoadOrderGroup = Base + +[Strings] +MTK = "MediaTek Inc." +MTK6218 = "MTK USB Port" +MTK_COM = "MTK USB Modem Port" +MTK_CAT = "MTK USB Debug Port" +Serial.SvcDesc = "USB Serial emulation modem driver" diff --git a/drivers/mtk/Vista/usb2servistawin7_32_comp.cat b/drivers/mtk/Vista/usb2servistawin7_32_comp.cat new file mode 100644 index 00000000..ec8a27e2 Binary files /dev/null and b/drivers/mtk/Vista/usb2servistawin7_32_comp.cat differ diff --git a/drivers/mtk/Vista/usb2servistawin7_64_comp.cat b/drivers/mtk/Vista/usb2servistawin7_64_comp.cat new file mode 100644 index 00000000..2a745b96 Binary files /dev/null and b/drivers/mtk/Vista/usb2servistawin7_64_comp.cat differ diff --git a/drivers/mtk/Win7/usb2ser_Win7.inf b/drivers/mtk/Win7/usb2ser_Win7.inf new file mode 100644 index 00000000..cb46f439 --- /dev/null +++ b/drivers/mtk/Win7/usb2ser_Win7.inf @@ -0,0 +1,91 @@ +;/***************************************************************************** +;* Copyright Statement: +;* -------------------- +;* This software is protected by Copyright and the information contained +;* herein is confidential. The software may not be copied and the information +;* contained herein may not be used or disclosed except with the written +;* permission of MediaTek Inc. (C) 2010 +;* +;* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +;* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +;* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +;* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +;* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +;* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +;* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +;* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +;* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +;* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +;* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +;* +;* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +;* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +;* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +;* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +;* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +;* +;* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +;* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +;* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +;* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +;* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +;* +;*****************************************************************************/ +; +; usb2ser_Vista_Win7.inf +; +[Version] +Signature="$Windows NT$" +Class=Ports +ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} + +Provider=%MTK% +DriverVer=07/28/2010,1.1032.0 + +CatalogFile=usb2serVistaWin7_32_Comp.cat + +[Manufacturer] +%MTK%=MTK + +[MTK] +%MTK6218%=Reader,USB\Vid_0e8d&Pid_0003,USB\Vid_0e8d&Pid_1003 +%MTK_COM%=Reader,USB\Vid_0e8d&Pid_0023&MI_00 +%MTK_CAT%=Reader,USB\Vid_0e8d&Pid_0023&MI_02 + +[Reader_Install.NTx86] + +[DestinationDirs] +DefaultDestDir=12 + +[Reader.NT] +Include=mdmcpq.inf +AddReg=Reader.NT.AddReg +CopyFiles=FakeModemCopyFileSection + +[Reader.NT.AddReg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,usbser.sys +HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" + +[Reader.NT.Services] +AddService = usbser, 0x00000002, Service_Inst + +[Service_Inst] +DisplayName = %Serial.SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %12%\usbser.sys +LoadOrderGroup = Base + +[SourceDisksNames] + +[SourceDisksFiles] + +[Strings] +MTK = "MediaTek Inc." +MTK6218 = "MTK USB Port" +MTK_COM = "MTK USB Modem Port" +MTK_CAT = "MTK USB Debug Port" +Serial.SvcDesc = "USB Serial emulation modem driver" diff --git a/drivers/mtk/Win7/usb2ser_Win764.inf b/drivers/mtk/Win7/usb2ser_Win764.inf new file mode 100644 index 00000000..0b751c82 --- /dev/null +++ b/drivers/mtk/Win7/usb2ser_Win764.inf @@ -0,0 +1,90 @@ +;/***************************************************************************** +;* Copyright Statement: +;* -------------------- +;* This software is protected by Copyright and the information contained +;* herein is confidential. The software may not be copied and the information +;* contained herein may not be used or disclosed except with the written +;* permission of MediaTek Inc. (C) 2010 +;* +;* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +;* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +;* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +;* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +;* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +;* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +;* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +;* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +;* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +;* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +;* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +;* +;* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +;* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +;* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +;* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +;* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +;* +;* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +;* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +;* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +;* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +;* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +;* +;*****************************************************************************/ +; +; usb2ser_Vista64_Win7.inf +; +[Version] +Signature="$Windows NT$" +Class=Ports +ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} + +Provider=%MTK% +DriverVer=07/28/2010,1.1032.0 + +CatalogFile=usb2serVistaWin7_64_Comp.cat + +[Manufacturer] +%MTK%=MTK,NTamd64 + +[MTK.NTamd64] +%MTK6218%=Reader,USB\Vid_0e8d&Pid_0003,USB\Vid_0e8d&Pid_1003 +%MTK_COM%=Reader,USB\Vid_0e8d&Pid_0023&MI_00 +%MTK_CAT%=Reader,USB\Vid_0e8d&Pid_0023&MI_02 + +[DestinationDirs] +DefaultDestDir=12 + +[Reader.NTamd64] +Include=mdmcpq.inf +AddReg=Reader.NTamd64.AddReg +CopyFiles=FakeModemCopyFileSection + +[Reader.NTamd64.AddReg] +HKR,,DevLoader,,*ntkern +HKR,,NTMPDriver,,usbser.sys +HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" + +[Reader.NTamd64.Services] +AddService = usbser, 0x00000002, Service_Inst + +[SourceDisksNames] + +[SourceDisksFiles] + + +[Service_Inst] +DisplayName = %Serial.SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %12%\usbser.sys +LoadOrderGroup = Base + +[Strings] +MTK = "MediaTek Inc." +MTK6218 = "MTK USB Port" +MTK_COM = "MTK USB Modem Port" +MTK_CAT = "MTK USB Debug Port" +Serial.SvcDesc = "USB Serial emulation modem driver" diff --git a/drivers/mtk/Win7/usb2servistawin7_32_comp.cat b/drivers/mtk/Win7/usb2servistawin7_32_comp.cat new file mode 100644 index 00000000..e959107d Binary files /dev/null and b/drivers/mtk/Win7/usb2servistawin7_32_comp.cat differ diff --git a/drivers/mtk/Win7/usb2servistawin7_64_comp.cat b/drivers/mtk/Win7/usb2servistawin7_64_comp.cat new file mode 100644 index 00000000..b369d44c Binary files /dev/null and b/drivers/mtk/Win7/usb2servistawin7_64_comp.cat differ diff --git a/drivers/mtk/x64/install64.exe b/drivers/mtk/x64/install64.exe new file mode 100644 index 00000000..a3836429 Binary files /dev/null and b/drivers/mtk/x64/install64.exe differ diff --git a/drivers/mtk/x86/install32.exe b/drivers/mtk/x86/install32.exe new file mode 100644 index 00000000..ea51980c Binary files /dev/null and b/drivers/mtk/x86/install32.exe differ diff --git a/hardware/arduino/mtk/boards.txt b/hardware/arduino/mtk/boards.txt new file mode 100644 index 00000000..99ce0382 --- /dev/null +++ b/hardware/arduino/mtk/boards.txt @@ -0,0 +1,44 @@ + +linkit_one.name=LinkIt ONE +linkit_one.vid.0=0x0E8D +linkit_one.pid.0=0x0023 +linkit_one.upload.tool=bossac +linkit_one.upload.protocol=mtk-one +linkit_one.upload.maximum_size=10485760 +linkit_one.upload.use_1200bps_touch=true +linkit_one.upload.wait_for_upload_port=true +linkit_one.upload.native_usb=true +linkit_one.build.mcu=arm7tdmi-s +linkit_one.build.f_cpu=84000000L +linkit_one.build.usb_product="LinkIt ONE" +linkit_one.build.board=MTK_ONE +linkit_one.build.core=arduino +linkit_one.build.extra_flags=-D__COMPILER_GCC__ -D__LINKIT_ONE__ -D__LINKIT_ONE_RELEASE__ -mthumb {build.usb_flags} +linkit_one.build.ldscript=linker_scripts/gcc/scat.ld +linkit_one.build.variant=linkit_one +linkit_one.build.variant_system_lib=libmtk.a +linkit_one.build.vid=0x0E8D +linkit_one.build.pid=0x0023 + + + +# linkit_one_dbg.name=LinkIt ONE (Debug) +# linkit_one_dbg.vid.0=0x0E8D +# linkit_one_dbg.pid.0=0x0023 +# linkit_one_dbg.upload.tool=bossac +# linkit_one_dbg.upload.protocol=mtk-one +# linkit_one_dbg.upload.maximum_size=10485760 +# linkit_one_dbg.upload.use_1200bps_touch=true +# linkit_one_dbg.upload.wait_for_upload_port=true +# linkit_one_dbg.upload.native_usb=true +# linkit_one_dbg.build.mcu=arm7tdmi-s +# linkit_one_dbg.build.f_cpu=84000000L +# linkit_one_dbg.build.usb_product="LinkIt ONE" +# linkit_one_dbg.build.board=MTK_ONE +# linkit_one_dbg.build.core=arduino +# linkit_one_dbg.build.extra_flags=-D__COMPILER_GCC__ -D__LINKIT_ONE__ -D__LINKIT_ONE_DEBUG__ -mthumb {build.usb_flags} +# linkit_one_dbg.build.ldscript=linker_scripts/gcc/scat.ld +# linkit_one_dbg.build.variant=linkit_one +# linkit_one_dbg.build.variant_system_lib=libmtk.a +# linkit_one_dbg.build.vid=0x0E8D +# linkit_one_dbg.build.pid=0x0023 diff --git a/hardware/arduino/mtk/cores/arduino/Arduino.h b/hardware/arduino/mtk/cores/arduino/Arduino.h new file mode 100644 index 00000000..a174456f --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/Arduino.h @@ -0,0 +1,126 @@ +/* + Arduino.h - Main include file for the Arduino SDK + Copyright (c) 2005-2013 Arduino Team. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include +#include + +// some libraries and sketches depend on this +// AVR stuff, assuming Arduino.h or WProgram.h +// automatically includes it... +#include + +#include "binary.h" +#include "itoa.h" +#include "vmdcl.h" + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +// Includes Atmel CMSIS +#include + +#include "wiring_constants.h" + +void yield(void); + +/* sketch */ +extern void setup( void ) ; +extern void loop( void ) ; +extern boolean changePinType(uint32_t ulPin, uint32_t ulPinType, VM_DCL_HANDLE* handle); +extern void spiPinsRest(void); +extern void setPinHandle(uint32_t ulPin, VM_DCL_HANDLE handle); + +typedef enum _EExt_Interrupts +{ + EXTERNAL_INT_0=0, + EXTERNAL_INT_1=1, + EXTERNAL_NUM_INTERRUPTS +} EExt_Interrupts ; + +typedef void (*voidFuncPtr)( void ) ; + +#define PIO_MAX_NUM 19 + +typedef enum _EPioType +{ + PIO_DIGITAL, + PIO_ANALOG, + PIO_EINT, + PIO_PWM, + PIO_SPI, + PIO_UART, + PIO_I2C, + PIO_END +} EPioType ; + +/* Types used for the tables below */ +typedef struct _PinDescription +{ + VM_DCL_HANDLE ulHandle; + uint32_t ulGpioId ; + EPioType ulPinType ; + uint32_t ulPupd; +} PinDescription ; + +/* Pins table to be instanciated into variant.cpp */ +extern PinDescription g_APinDescription[] ; + +#ifdef __cplusplus +} // extern "C" + +#include "WCharacter.h" +#include "WString.h" +#include "Tone.h" +#include "WMath.h" +#include "HardwareSerial.h" +#include "wiring_pulse.h" + +#endif // __cplusplus + +// Include board variant +#include "variant.h" + +#include "wiring.h" +#include "wiring_digital.h" +#include "wiring_analog.h" //jianying add +#include "wiring_shift.h" +#include "WInterrupts.h" + +#include "message.h" + +// USB Device +//#define USB_VID 0x2341 // arduino LLC vid +#define USB_PID_LEONARDO 0x0034 +#define USB_PID_MICRO 0x0035 +#define USB_PID_DUE 0x003E +//#include "USB/USBDesc.h" +//#include "USB/USBCore.h" +//#include "USB/USBAPI.h" + +boolean noStopInterrupts(void); +extern void spiPinsRest(void); +extern void setPinHandle(uint32_t ulPin, VM_DCL_HANDLE handle); + +#endif // Arduino_h diff --git a/hardware/arduino/mtk/cores/arduino/Client.h b/hardware/arduino/mtk/cores/arduino/Client.h new file mode 100644 index 00000000..b8e5d935 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/Client.h @@ -0,0 +1,45 @@ +/* + Client.h - Base class that provides Client + Copyright (c) 2011 Adrian McEwen. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef client_h +#define client_h +#include "Print.h" +#include "Stream.h" +#include "IPAddress.h" + +class Client : public Stream { + +public: + virtual int connect(IPAddress ip, uint16_t port) =0; + virtual int connect(const char *host, uint16_t port) =0; + virtual size_t write(uint8_t) =0; + virtual size_t write(const uint8_t *buf, size_t size) =0; + virtual int available() = 0; + virtual int read() = 0; + virtual int read(uint8_t *buf, size_t size) = 0; + virtual int peek() = 0; + virtual void flush() = 0; + virtual void stop() = 0; + virtual uint8_t connected() = 0; + virtual operator bool() = 0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/hardware/arduino/mtk/cores/arduino/HardwareSerial.h b/hardware/arduino/mtk/cores/arduino/HardwareSerial.h new file mode 100644 index 00000000..5674e57a --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/HardwareSerial.h @@ -0,0 +1,42 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef HardwareSerial_h +#define HardwareSerial_h + +#include + +#include "Stream.h" + +class HardwareSerial : public Stream +{ + public: + virtual void begin(unsigned long); + virtual void end(); + virtual int available(void) = 0; + virtual int peek(void) = 0; + virtual int read(void) = 0; + virtual void flush(void) = 0; + virtual size_t write(uint8_t) = 0; + using Print::write; // pull in write(str) and write(buf, size) from Print + virtual operator bool() = 0; +}; + +extern void serialEventRun(void) __attribute__((weak)); + +#endif diff --git a/hardware/arduino/mtk/cores/arduino/IPAddress.cpp b/hardware/arduino/mtk/cores/arduino/IPAddress.cpp new file mode 100644 index 00000000..22a0e427 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/IPAddress.cpp @@ -0,0 +1,74 @@ +/* + IPAddress.cpp - Base class that provides IPAddress + Copyright (c) 2011 Adrian McEwen. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include + +IPAddress::IPAddress() +{ + memset(_address, 0, sizeof(_address)); +} + +IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) +{ + _address[0] = first_octet; + _address[1] = second_octet; + _address[2] = third_octet; + _address[3] = fourth_octet; +} + +IPAddress::IPAddress(uint32_t address) +{ + memcpy(_address, &address, sizeof(_address)); +} + +IPAddress::IPAddress(const uint8_t *address) +{ + memcpy(_address, address, sizeof(_address)); +} + +IPAddress& IPAddress::operator=(const uint8_t *address) +{ + memcpy(_address, address, sizeof(_address)); + return *this; +} + +IPAddress& IPAddress::operator=(uint32_t address) +{ + memcpy(_address, (const uint8_t *)&address, sizeof(_address)); + return *this; +} + +bool IPAddress::operator==(const uint8_t* addr) const +{ + return memcmp(addr, _address, sizeof(_address)) == 0; +} + +size_t IPAddress::printTo(Print& p) const +{ + size_t n = 0; + for (int i =0; i < 3; i++) + { + n += p.print(_address[i], DEC); + n += p.print('.'); + } + n += p.print(_address[3], DEC); + return n; +} + diff --git a/hardware/arduino/mtk/cores/arduino/IPAddress.h b/hardware/arduino/mtk/cores/arduino/IPAddress.h new file mode 100644 index 00000000..622efb76 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/IPAddress.h @@ -0,0 +1,70 @@ +/* + IPAddress.h - Base class that provides IPAddress + Copyright (c) 2011 Adrian McEwen. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef IPAddress_h +#define IPAddress_h + +#include + +// A class to make it easier to handle and pass around IP addresses + +class IPAddress : public Printable { +private: + uint8_t _address[4]; // IPv4 address + // Access the raw byte array containing the address. Because this returns a pointer + // to the internal structure rather than a copy of the address this function should only + // be used when you know that the usage of the returned uint8_t* will be transient and not + // stored. + uint8_t* raw_address() { return _address; }; + +public: + // Constructors + IPAddress(); + IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet); + IPAddress(uint32_t address); + IPAddress(const uint8_t *address); + + // Overloaded cast operator to allow IPAddress objects to be used where a pointer + // to a four-byte uint8_t array is expected + operator uint32_t() const { return *((uint32_t*)_address); }; + bool operator==(const IPAddress& addr) const { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); }; + bool operator==(const uint8_t* addr) const; + + // Overloaded index operator to allow getting and setting individual octets of the address + uint8_t operator[](int index) const { return _address[index]; }; + uint8_t& operator[](int index) { return _address[index]; }; + + // Overloaded copy operators to allow initialisation of IPAddress objects from other types + IPAddress& operator=(const uint8_t *address); + IPAddress& operator=(uint32_t address); + + virtual size_t printTo(Print& p) const; + + friend class EthernetClass; + friend class UDP; + friend class Client; + friend class Server; + friend class DhcpClass; + friend class DNSClient; +}; + +const IPAddress INADDR_NONE(0,0,0,0); + + +#endif diff --git a/hardware/arduino/mtk/cores/arduino/LTask.cpp b/hardware/arduino/mtk/cores/arduino/LTask.cpp new file mode 100644 index 00000000..63d50e29 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/LTask.cpp @@ -0,0 +1,120 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "vmsys.h" +#include "vmthread.h" +#include "LTask.h" +#include "arduino.h" + + +_LTaskClass::_LTaskClass() +{ + m_handle = 0; + m_signal = 0; +} + +void _LTaskClass::begin(void) +{ + vm_mutex_create(&m_mutex); + m_handle = vm_thread_get_main_handle(); + m_signal = vm_signal_init(); +} + +void _LTaskClass::sendMsg(VMUINT32 msg_id, void* user_data) +{ + if(m_handle == 0) + { + begin(); + } + if(m_handle != 0) + { + vm_thread_send_msg(m_handle, msg_id, user_data); + } +} + +void _LTaskClass::stop(void) +{ + m_handle = 0; + vm_signal_clean(m_signal); + vm_signal_deinit(m_signal); + m_signal = 0; +} + +void _LTaskClass::mutexLock() +{ + if(m_handle == 0) + { + begin(); + } + + vm_mutex_lock(&m_mutex); +} + +void _LTaskClass::mutexUnlock() +{ + if(m_handle == 0) + { + begin(); + } + + vm_mutex_unlock(&m_mutex); +} + +void _LTaskClass::post_signal() +{ + if(m_handle == 0) + { + begin(); + } + + vm_signal_post(m_signal); +} + +void _LTaskClass::remoteCall(remote_call_ptr func, void* userdata) +{ + if(m_handle == 0) + { + begin(); + } + mutexLock(); + m_msg.remote_func = (remote_call_ptr)func; + m_msg.userdata = userdata; + m_msg.signal = m_signal; + sendMsg(VM_MSG_ARDUINO_CALL, &m_msg); + vm_signal_wait(m_signal); + mutexUnlock(); +} + +_LTaskClass LTask = _LTaskClass(); + diff --git a/hardware/arduino/mtk/cores/arduino/LTask.h b/hardware/arduino/mtk/cores/arduino/LTask.h new file mode 100644 index 00000000..550f3ebe --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/LTask.h @@ -0,0 +1,70 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + + +#ifndef _LTaskClass_h +#define _LTaskClass_h + +#include "vmsys.h" +#include "vmthread.h" +#include "message.h" + +class _LTaskClass +{ +private: + vm_thread_mutex_struct m_mutex; + msg_struct m_msg; + VM_THREAD_HANDLE m_handle; + VM_SIGNAL_ID m_signal; + void sendMsg(VMUINT32 msg_id, void* user_data); + +public: + _LTaskClass(); + + void begin(void); + void mutexLock(); + void mutexUnlock(); + void stop(void); + void remoteCall(remote_call_ptr func, void* userdata); + +public: + void post_signal(); + +}; + +extern _LTaskClass LTask; + +#endif + diff --git a/hardware/arduino/mtk/cores/arduino/LTcpClient.cpp b/hardware/arduino/mtk/cores/arduino/LTcpClient.cpp new file mode 100644 index 00000000..fa3e5625 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/LTcpClient.cpp @@ -0,0 +1,498 @@ +#include +#include "LTask.h" +#include "LTcpClient.h" +#include "vmconn.h" +#include "vmtcp.h" +#include "vmlog.h" + +#define APN_ID VM_TCP_APN_WIFI + +SharedHandle::SharedHandle(): + m_handle(INVALID_HANDLE), + m_serverHandle(INVALID_HANDLE), + m_pSharedCount(NULL) +{ +} + +SharedHandle::SharedHandle(VMINT handle): + m_handle(handle), + m_serverHandle(INVALID_HANDLE), + m_pSharedCount(new VMINT(1)) +{ + vm_log_info("SharedHandle create: c:%d, s:%d", m_handle, m_serverHandle); +} + +SharedHandle::SharedHandle(VMINT clientHandle, VMINT serverHandle): + m_handle(clientHandle), + m_serverHandle(serverHandle), + m_pSharedCount(new VMINT(1)) +{ + vm_log_info("SharedHandle create: c:%d, s:%d", m_handle, m_serverHandle); +} + +SharedHandle::SharedHandle(const SharedHandle& rhs): + m_handle(rhs.m_handle), + m_serverHandle(rhs.m_serverHandle), + m_pSharedCount(rhs.m_pSharedCount) +{ + incRef(); +} + +SharedHandle::~SharedHandle() +{ + decRef(); +} + +void SharedHandle::invalidateHandle() +{ + m_handle = INVALID_HANDLE; + m_serverHandle = INVALID_HANDLE; +} + +SharedHandle& SharedHandle::operator =(const SharedHandle& rhs) +{ + decRef(); + m_handle = rhs.m_handle; + m_serverHandle = rhs.m_serverHandle; + m_pSharedCount = rhs.m_pSharedCount; + incRef(); + + return *this; +} + +SharedHandle::operator bool() const +{ + return (m_handle != INVALID_HANDLE); +} + +boolean SharedHandle::releaseTcpHandle(void *userData) +{ + SharedHandle *pThis = (SharedHandle*)userData; + vm_log_info("SharedHandle release: c=%d, s=%d", pThis->m_handle, pThis->m_serverHandle); + if (pThis->m_serverHandle != -1) + { + VMINT ret = vm_soc_svr_close_client(pThis->m_handle); + } + else + { + vm_tcp_close(pThis->m_handle); + } + return true; +} + +void SharedHandle::releaseHandle() +{ + if(m_handle == INVALID_HANDLE) + { + invalidateHandle(); + return; + } + + LTask.remoteCall(&releaseTcpHandle, (void*)this); + invalidateHandle(); +} + +void SharedHandle::incRef() +{ + if(m_pSharedCount != NULL) + { + (*m_pSharedCount)++; + } +} + +void SharedHandle::decRef() +{ + if(m_pSharedCount == NULL) + { + return; + } + + if(*m_pSharedCount) + *m_pSharedCount -= 1; + + if(*m_pSharedCount <= 0) + { + releaseHandle(); + delete m_pSharedCount; + m_pSharedCount = NULL; + } +} + +LTcpClient::LTcpClient(): + m_handle(), + m_peekByte(-1), + m_apn(APN_ID), + m_peekBuffered(false) +{ + +} + +LTcpClient::LTcpClient(const LTcpClient &rhs): + m_handle(rhs.m_handle), + m_apn(rhs.m_apn), + m_peekByte(-1), + m_peekBuffered(false) +{ +} + +LTcpClient::LTcpClient(VMINT handle): + m_handle(handle), + m_peekByte(-1), + m_apn(APN_ID), + m_peekBuffered(false) +{ +} + +LTcpClient::LTcpClient(VMINT handle, VMINT serverHandle): + m_handle(handle, serverHandle), + m_peekByte(-1), + m_apn(APN_ID), + m_peekBuffered(false) +{ +} + +LTcpClient::~LTcpClient() +{ +} + +struct LTcpConnectContext +{ + const char *ipAddr; + VMINT port; + LTcpClient *pInstance; +}; + +void LTcpClient::connectCallback(VMINT handle, VMINT event, void *userData) +{ + LTcpClient *pThis = (LTcpClient*)userData; + vm_log_info("connectCallback handle=%d event=%d userData=%d", handle, event, userData); + switch(event) + { + case VM_TCP_EVT_CONNECTED: + pThis->m_handle = SharedHandle(handle); + LTask.post_signal(); + break; + case VM_TCP_EVT_CAN_WRITE: + break; + case VM_TCP_EVT_CAN_READ: + break; + case VM_TCP_EVT_PIPE_BROKEN: + pThis->m_handle.invalidateHandle(); + LTask.post_signal(); + break; + case VM_TCP_EVT_HOST_NOT_FOUND: + pThis->m_handle.invalidateHandle(); + LTask.post_signal(); + break; + case VM_TCP_EVT_PIPE_CLOSED: + pThis->m_handle.invalidateHandle(); + LTask.post_signal(); + break; + } + return; +} + +boolean LTcpClient::connectIP(void *userData) +{ + LTcpConnectContext *pContext = (LTcpConnectContext*)userData; + // async api + vm_log_info("connectIP, IP=%s, port=%d", pContext->ipAddr, pContext->port); + VMINT clientHandle = vm_tcp_connect_ex(pContext->ipAddr, + pContext->port, + pContext->pInstance->getAPN(), + pContext->pInstance, + &connectCallback); + vm_log_info("vm_tcp_connect returns %d", clientHandle); + return false; +} + +int LTcpClient::connect(IPAddress ip, uint16_t port) +{ + vm_log_info("connect(IPAddress)"); + char ipAddr[50] = {0}; + sprintf(ipAddr, + "%d.%d.%d.%d", + ip[0], + ip[1], + ip[2], + ip[3]); + vm_log_info("connect to %s", ipAddr); + return connect(ipAddr, port); +} + +int LTcpClient::connect(const char *host, uint16_t port) +{ + vm_log_info("LTcpClient::connect(char) to %s:%d", host, port); + + if(connected()) + { + vm_log_info("LTcpClient::connect() while already connected. stop() first."); + stop(); + } + + LTcpConnectContext context; + context.ipAddr = host; + context.port = port; + context.pInstance = this; + LTask.remoteCall(&connectIP, &context); + return connected(); +} + +struct LTcpReadWriteContext +{ + VMINT handle; + VMINT serverHandle; + void *buf; + VMINT len; + VMINT lenProcessed; // bytes read or written + LTcpClient *pInst; + + LTcpReadWriteContext(): + handle(-1), + serverHandle(-1), + buf(NULL), + len(0), + lenProcessed(0), + pInst(NULL) + { + + } +}; + +boolean LTcpClient::wifiWrite(void *userData) +{ + vm_log_info("wifiWrite"); + LTcpReadWriteContext *pContext = (LTcpReadWriteContext*)userData; + if (pContext->serverHandle != -1) + { + pContext->lenProcessed = vm_soc_svr_send(pContext->serverHandle, + pContext->handle, + pContext->buf, + pContext->len); + } + else + { + pContext->lenProcessed = vm_tcp_write(pContext->handle, + pContext->buf, + pContext->len); + } + + vm_log_info("wifiWrite wrote %d", pContext->lenProcessed); + return true; +} + +size_t LTcpClient::write(uint8_t b) +{ + vm_log_info("wifiWrite arduino (byte)"); + LTcpReadWriteContext c; + c.handle = m_handle.m_handle; + c.serverHandle = m_handle.m_serverHandle; + c.buf = &b; + c.len = 1; + c.pInst = this; + LTask.remoteCall(&wifiWrite, &c); + + vm_log_info("written %d bytes", c.lenProcessed); + return c.lenProcessed; +} + +size_t LTcpClient::write(const uint8_t *buf, size_t size) +{ + vm_log_info("wifiWrite arduino (buffered)"); + LTcpReadWriteContext c; + c.handle = m_handle.m_handle; + c.serverHandle = m_handle.m_serverHandle; + c.buf = (void*)buf; + c.len = size; + c.pInst = this; + LTask.remoteCall(&wifiWrite, &c); + + vm_log_info("written %d bytes", c.lenProcessed); + return c.lenProcessed; +} + +int LTcpClient::available() +{ + return (peek() == -1) ? 0 : 1; +} + +boolean LTcpClient::wifiRead(void *userData) +{ + LTcpReadWriteContext *pContext = (LTcpReadWriteContext*)userData; + LTcpClient *pThis = pContext->pInst; + + pContext->lenProcessed = 0; + + // parameter check + if(pContext->len <= 0) + { + return true; + } + + vm_log_info("wifiRead len=%d", pContext->len); + + // check peek state + if(pThis->m_peekBuffered) + { + // insert the peeked byte + *((VMINT8*)pContext->buf) = pThis->m_peekByte; + pContext->lenProcessed += 1; + pContext->len--; + // clear peek state + pThis->m_peekByte = -1; + pThis->m_peekBuffered = false; + } + + VMINT readResult = VM_TCP_READ_EOF; + + // actually read from TCP socket + if (pContext->serverHandle != -1) + { + readResult = vm_soc_svr_read(pContext->serverHandle, + pContext->handle, + pContext->buf, + pContext->len); + } + else + { + readResult = vm_tcp_read(pContext->handle, + pContext->buf, + pContext->len); + } + + if (readResult > 0) + { + pContext->lenProcessed += readResult; + } + + if (readResult == VM_TCP_READ_EOF) + { + // we may cache a peek byte even if the socket is disconnected + vm_log_info("wifiRead socket disconnected"); + } + + vm_log_info("wifiRead %d bytes", pContext->lenProcessed); + return true; +} + +int LTcpClient::read() +{ + // read a single byte + LTcpReadWriteContext c; + uint8_t ret = 0; + c.handle = m_handle.m_handle; + c.serverHandle = m_handle.m_serverHandle; + c.buf = &ret; + c.len = 1; + c.pInst = this; + LTask.remoteCall(&wifiRead, &c); + if(c.lenProcessed > 0) + { + return (int)ret; + } + else + { + // if no data available, return -1 + return -1; + } +} + +int LTcpClient::read(uint8_t *buf, size_t size) +{ + // read a single byte + LTcpReadWriteContext c; + uint8_t ret = 0; + c.handle = m_handle.m_handle; + c.serverHandle = m_handle.m_serverHandle; + c.buf = buf; + c.len = size; + c.pInst = this; + vm_log_info("wifiRead call with buf=%d, size=%d", c.buf, c.len); + LTask.remoteCall(&wifiRead, &c); + vm_log_info("LTcpClient::read return %d", c.lenProcessed); + return c.lenProcessed; +} + +boolean LTcpClient::wifiPeek(void *userData) +{ + LTcpClient *pThis = (LTcpClient*)userData; + + if(pThis->m_peekBuffered) + { + return true; + } + + // read and store the peeked byte + LTcpReadWriteContext cntx; + cntx.buf = &pThis->m_peekByte; + cntx.len = sizeof(pThis->m_peekByte); + cntx.handle = pThis->m_handle.m_handle; + cntx.serverHandle = pThis->m_handle.m_serverHandle; + cntx.lenProcessed = 0; + cntx.pInst = pThis; + if(!wifiRead(&cntx)) + { + vm_log_error("read fail in wifiPeek"); + } + + if (cntx.lenProcessed > 0) + { + pThis->m_peekBuffered = true; + } + else + { + pThis->m_peekBuffered = false; + } + + return true; +} + +int LTcpClient::peek() +{ + // peek() must return -1 when there is no data to read + if (m_handle == -1) + { + vm_log_info("peek() with invalid handle, return -1"); + return -1; + } + + LTask.remoteCall(&wifiPeek, this); + + if (m_peekBuffered) + { + return (int)m_peekByte; + } + else + { + return -1; + } +} + +void LTcpClient::stop() +{ + // release reference to handle + m_handle = SharedHandle(); +} + +uint8_t LTcpClient::connected() +{ + return bool(m_handle); +} + +LTcpClient::operator bool() +{ + return connected(); +} + +void LTcpClient::flush() +{ + // both read() and write() are inherently flush()ed. + // so we simply return here. + return; +} + +VMINT LTcpClient::getAPN() const +{ + return m_apn; +} + diff --git a/hardware/arduino/mtk/cores/arduino/LTcpClient.h b/hardware/arduino/mtk/cores/arduino/LTcpClient.h new file mode 100644 index 00000000..8fc87a49 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/LTcpClient.h @@ -0,0 +1,208 @@ +#ifndef LTcpClient_h +#define LTcpClient_h +#include "Arduino.h" +#include "Print.h" +#include "Client.h" +#include "IPAddress.h" + + +/* DOM-NOT_FOR_SDK-BEGIN */ +// partially mimic the behavior of std::shard_ptr +// since we don't have tr1/0x/11 support right now. +class SharedHandle +{ +public: + SharedHandle(); + explicit SharedHandle(VMINT handle); + SharedHandle(VMINT clientHandle, VMINT serverHandle); + SharedHandle(const SharedHandle& rhs); + ~SharedHandle(); + + void invalidateHandle(); + + SharedHandle& operator =(const SharedHandle& rhs); + operator bool() const; + + friend class LTcpClient; + +protected: + static const VMINT INVALID_HANDLE = -1; + void releaseHandle(); + void incRef(); + void decRef(); + static boolean releaseTcpHandle(void *userData); + +private: + VMINT m_handle; + VMINT m_serverHandle; + VMINT *m_pSharedCount; +}; +/* DOM-NOT_FOR_SDK-END */ + +//LTcpClient Class +class LTcpClient : public Client { + +public: + // DESCRIPTION + // Constructs a LTcpClient object which can be used to connect to the remote TCP server. + // + // + // PARAMETERS + // N/A + // + // RETURNS + // N/A + LTcpClient(); + + /* DOM-NOT_FOR_SDK-BEGIN */ + LTcpClient(const LTcpClient &rhs); + LTcpClient(VMINT handle); + LTcpClient(VMINT handle, VMINT serverHandle); + ~LTcpClient(); + /* DOM-NOT_FOR_SDK-END */ + + // DESCRIPTION + // Connects to a TCP server. + // + // PARAMETERS + // IPAddress: IPAddress object, e.g. IPAddress server (172, 21, 84, 11), that denotes server address + // port: TCP port to be connected + // + // RETURNS + // 1 if connected, 0 otherwise. + virtual int connect(IPAddress ip, uint16_t port); + + // DESCRIPTION + // Connects to a TCP server. + // + // PARAMETERS + // IPAddress: String, e.g. "172.21.84.11", that denotes server address + // port: TCP port to be connected + // + // RETURNS + // 1 if connected, 0 otherwise. + virtual int connect(const char *host, uint16_t port); + + // DESCRIPTION + // Writes data to server after connected to one. + // + // PARAMETERS + // byte: Single byte to be sent + // + // RETURNS + // Total written bytes. + virtual size_t write(uint8_t); + + + // DESCRIPTION + // Writes data to server after connected to one. + // + // PARAMETERS + // byteArray: byteArray to be sent + // size: Size of byteArray, in bytes + // + // RETURNS + // Total written bytes. + virtual size_t write(const uint8_t *buf, size_t size); + + // DESCRIPTION + // Queries if there are incoming data from server side and returns the number of byte available for read after connecting to a server. + // + // PARAMETERS + // N/A + // + // RETURNS + // 0: There is no data available for read + // >0: Size of the data available to read, in bytes + virtual int available(); + + // DESCRIPTION + // Reads the data sent from the server side and returns one single byte if there is no parameter given. If the buffer and buffer size are given, store the data in the buffer passed in. + // + // PARAMETERS + // N/A + // + // RETURNS + // The data byte + virtual int read(); + + // DESCRIPTION + // Reads the data sent from the server side and returns one single byte if there is no parameter given. If the buffer and buffer size are given, store the data in the buffer passed in. + // + // PARAMETERS + // buf: uint8_t buffer to store the incoming data + // size: Buffer size in bytes + // + // RETURNS + // The actual read data in bytes are returned. + // >0: Total bytes read + // 0: There are no data to read + virtual int read(uint8_t *buf, size_t size); + + // DESCRIPTION + // Queries the first unread byte sent from the connected server side. + // This byte is not considered as read; therefore this method will return the same byte until read() is called. + // + // PARAMETERS + // N/A + // + // RETURNS + // The first unread byte sent from server + virtual int peek(); + + // DESCRIPTION + // Drops all data sent from server side to this client object. + // + // PARAMETERS + // N/A + // + // RETURNS + // N/A + virtual void flush(); // flush is not currrently supported. + + // DESCRIPTION + // Disconnects from the connected TCP server. + // + // PARAMETERS + // N/A + // + // RETURNS + // N/A + virtual void stop(); + + // DESCRIPTION + // Queries if this client object has been connected to a TCP server. + // + // PARAMETERS + // N/A + // + // RETURNS + // 1: Currently connected to a server + // 0: Not connected to a server + virtual uint8_t connected(); + + /* DOM-NOT_FOR_SDK-BEGIN */ + virtual operator bool(); + /* DOM-NOT_FOR_SDK-END */ + +public: + friend class LTcpServer; + +protected: + /* DOM-NOT_FOR_SDK-BEGIN */ + SharedHandle m_handle; // Manages underlying TCP resource handles. Reference counted, copy-constructable. + VMINT m_apn; // APN id to use. Child class should change this. + VMINT8 m_peekByte; // buffer to store the peek byte + boolean m_peekBuffered; // is the buffer valid or not + + static boolean connectIP(void *userData); + static void connectCallback(VMINT handle, VMINT event, void *userData); + static boolean wifiRead(void *userData); + static boolean wifiWrite(void *userData); + static boolean wifiPeek(void *userData); + + VMINT getAPN() const; + /* DOM-NOT_FOR_SDK-END */ +}; + +#endif // LTcpClient_h \ No newline at end of file diff --git a/hardware/arduino/mtk/cores/arduino/LTcpServer.cpp b/hardware/arduino/mtk/cores/arduino/LTcpServer.cpp new file mode 100644 index 00000000..b94562ce --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/LTcpServer.cpp @@ -0,0 +1,203 @@ +#include "arduino.h" +#include "LTcpServer.h" +#include "LTcpClient.h" +#include "LTask.h" +#include "vmconn.h" +#include "vmtcp.h" +#include "vmlog.h" +#include "vmsock.h" +#include "vmnwsetting.h" + +LTcpServer::LTcpServer(uint16_t port): + m_port(port), + m_handle(-1), + m_apn(VM_TCP_APN_WIFI) +{ +} + +void LTcpServer::serverCallback(VMINT handle, VMINT event, VMINT param, void *user_data) +{ + LTcpServer *pThis = (LTcpServer*)user_data; + vm_log_info("serverCallback handle=%d, evt=%d, param=%d", handle, event, param); + switch(event) + { + case VM_SOC_SVR_EVT_ACTIVED: + // server ready + pThis->m_handle = handle; + LTask.post_signal(); + break; + case VM_SOC_SVR_EVT_DEACTIVATED: + pThis->m_handle = -1; + LTask.post_signal(); + break; + case VM_SOC_SVR_EVT_ACCEPT: + vm_log_info("new client handle=%d", param); + pThis->m_clients.push_back(param); + break; + case VM_SOC_SVR_EVT_READ: + break; + case VM_SOC_SVR_EVT_WRITE: + break; + case VM_SOC_SVR_EVT_CLOSED: + break; + case VM_SOC_SVR_EVT_FAILED: + vm_log_info("open server on port=%d failed param=%d", pThis->m_port, param); + pThis->m_handle = -1; + LTask.post_signal(); + break; + } + +} + +boolean LTcpServer::initServer(void *userData) +{ + LTcpServer* pThis = (LTcpServer*)userData; + pThis->m_handle = vm_soc_svr_init(pThis->getAPN(), pThis->m_port, pThis, &serverCallback); + vm_log_info("initServer on port=%d ret=%d", pThis->m_port, pThis->m_handle); + if (pThis->m_handle < 0 && pThis->m_handle != -8) + { + pThis->m_handle = -1; + return true; + } + return false; +} + +void LTcpServer::begin() +{ + LTask.remoteCall(initServer, this); + return; +} + +boolean LTcpServer::deinitServer(void *userData) +{ + LTcpServer* pThis = (LTcpServer*)userData; + if(pThis->m_handle > 0) + { + VMINT ret = vm_soc_svr_deinit(pThis->m_handle); + vm_log_info("vm_soc_svr_deinit on handle=%d ret=%d", pThis->m_handle, ret); + } + return false; +} + +void LTcpServer::end() +{ + LTask.remoteCall(deinitServer, this); + return; +} + +struct LTcpAcceptConnectionContext +{ + LTcpServer *pInst; + VMINT hClient; + VMINT status; +}; + +boolean LTcpServer::acceptConnection(void *userData) +{ + LTcpAcceptConnectionContext *pCntx = (LTcpAcceptConnectionContext*)userData; + vm_log_info("acceptConnection() client count=%d", pCntx->pInst->m_clients.size()); + if (pCntx->pInst->m_clients.size() > 0) + { + const VMINT hClient = pCntx->pInst->m_clients.back(); + pCntx->pInst->m_clients.pop_back(); + pCntx->hClient = hClient; + } + else + { + pCntx->hClient = -1; + } + return true; +} + +void LTcpServer::availableImpl(VMINT& hClient, VMINT& hServer) +{ + vm_log_info((char*)__FUNCTION__); + // use async to open server port + LTcpAcceptConnectionContext cntx; + cntx.pInst = this; + cntx.hClient = -1; + LTask.remoteCall(&acceptConnection, &cntx); + + hClient = cntx.hClient; + hServer = m_handle; + + return; +} + +size_t LTcpServer::write(uint8_t data) +{ + return write(&data, 1); +} + +struct LTcpServerWriteContext +{ + LTcpServer *pInst; + VMINT totalWritten; + const uint8_t *buf; + size_t size; +}; + +boolean LTcpServer::wifiServerWrite(void *userData) +{ + LTcpServerWriteContext *pCntx = (LTcpServerWriteContext*)userData; + LTcpServer *pThis = pCntx->pInst; + pCntx->totalWritten = 0; + for(int i = 0; i < pThis->m_clients.size(); ++i) + { + VMINT written = vm_tcp_write_sync(pThis->m_clients[i], (void*)pCntx->buf, (VMINT)pCntx->size); + if(written > 0) + { + pCntx->totalWritten += written; + } + } +} + +size_t LTcpServer::write(const uint8_t *buf, size_t size) +{ + LTcpServerWriteContext cntx; + cntx.pInst = this; + cntx.totalWritten = 0; + cntx.buf = buf; + cntx.size = size; + LTask.remoteCall(&wifiServerWrite, &cntx); + return cntx.totalWritten; +} + +struct LTcpServerIPContext +{ + VMINT handle; + IPAddress result; +}; + +boolean wifiServerIP(void *userData) +{ + LTcpServerIPContext *pCntx = (LTcpServerIPContext*)userData; + VMUINT8 ip[VM_WLAN_PROF_MAX_IP_ADDR_LEN] = {0}; + // note that vm_soc_get_account_localip() + // does not take "server handle" as input + // but take "socket ID" as input instead. + const VMINT sockID = vm_soc_svr_get_soc_id(pCntx->handle); + VMINT ret = vm_soc_get_account_localip(sockID, ip); + vm_log_info("get socket IP ret=%d", ret); + pCntx->result = IPAddress(ip); + return true; +} + +IPAddress LTcpServer::serverIP() +{ + if (-1 == m_handle) + { + return IPAddress(); + } + + LTcpServerIPContext cntx; + + cntx.handle = m_handle; + LTask.remoteCall(&wifiServerIP, &cntx); + return cntx.result; +} + +VMINT LTcpServer::getAPN() const +{ + return m_apn; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/cores/arduino/LTcpServer.h b/hardware/arduino/mtk/cores/arduino/LTcpServer.h new file mode 100644 index 00000000..16571dce --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/LTcpServer.h @@ -0,0 +1,119 @@ +#ifndef LTcpServer_h +#define LTcpServer_h +#include "Arduino.h" +#include "Print.h" +#include "Client.h" +#include "Server.h" +#include + +class LTcpClient; + +//LTcpServer Class +class LTcpServer : public Server { +public: + + /* DOM-NOT_FOR_SDK-BEGIN */ + VMINT m_port; // server port + VMINT m_handle; // server handle; + VMINT m_apn; // APN used. Child classes should properly set APN in the constructor. + /* DOM-NOT_FOR_SDK-END */ + +public: + + // DESCRIPTION + // Creates a TCP server port on the device that can be connected by remote TCP clients. + // Call LTcpServer.begin() to start the server port. + // + // PARAMETERS + // port: uint16_t port number. Click here to learn more about common TCP port definitions. + // + // RETURNS + // N/A + LTcpServer(uint16_t port); + + /* DOM-NOT_FOR_SDK-BEGIN */ + // DESCRIPTION + // Checks if there is a client connected. + // If there is one, an LTcpClient object will be returned to represent the connection between this server object and the remote client. Call LTcpClient.read()/LTcpClient.write() to exchange data with the connected client. + // + // PARAMETERS + // N/A + // + // RETURNS + // An pointer to LTcpClient object representing the connection between this server object and the remote client. + // This object will turn to false if there is no incoming connection. + void availableImpl(VMINT& hClient, VMINT& hServer); + /* DOM-NOT_FOR_SDK-END */ + + // DESCRIPTION + // Starts listening to a TCP port that accepts client connections. + // + // PARAMETERS + // N/A + // + // RETURNS + // N/A + void begin(); + + // DESCRIPTION + // Close all + // Stops listening to a TCP port that accepts client connections. + // + // PARAMETERS + // N/A + // + // RETURNS + // N/A + void end(); + + // DESCRIPTION + // Writes data to all clients connected to this server object. + // + // PARAMETERS + // byte: Write a single byte to all connected clients. + // + // RETURNS + // Actual written bytes. + // Since this counts all bytes written to all connected clients, this value can be bigger than the size parameter passed to this method. + virtual size_t write(uint8_t); + + // DESCRIPTION + // Writes data to all clients connected to this server object. + // + // PARAMETERS + // buf: Write an array of bytes to all connected clients. + // size: buf size in bytes + // + // RETURNS + // Actual written bytes. + // Since this counts all bytes written to all connected clients, this value can be bigger than the size parameter passed to this method. + virtual size_t write(const uint8_t *buf, size_t size); + + // DESCRIPTION + // returns the IP address of the server. An IP address is only valid after begin() is called. + // + // PARAMETERS + // N/A + // + // RETURNS + // IP address of the server + IPAddress serverIP(); + + using Print::write; + /* DOM-NOT_FOR_SDK-END */ + +protected: + /* DOM-NOT_FOR_SDK-BEGIN */ + VMINT getAPN() const; + + static boolean initServer(void *userData); + static boolean deinitServer(void *userData); + static boolean acceptConnection(void *userData); + static void serverCallback(VMINT handle, VMINT event, VMINT param, void *user_data); + static boolean wifiServerWrite(void *userData); + + std::vector m_clients; + /* DOM-NOT_FOR_SDK-END */ +}; + +#endif diff --git a/hardware/arduino/mtk/cores/arduino/LUdp.cpp b/hardware/arduino/mtk/cores/arduino/LUdp.cpp new file mode 100644 index 00000000..990d7fa9 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/LUdp.cpp @@ -0,0 +1,332 @@ +#include +#include "LTask.h" +#include "vmconn.h" +#include "vmtcp.h" +#include "vmlog.h" +#include "vmsim.h" +#include "vmudp.h" +#include "LUDP.h" + +LUDP::LUDP(): + m_port(-1), + m_sendToPort(-1), + m_serverHandle(-1), + m_sendToIP(INADDR_NONE), + m_recvIP(INADDR_NONE), + m_recvPort(-1), + m_writePos(0), + m_recvPos(0) +{ + +} + +void LUDP::udpCallback(VMINT hdl, VMINT event) +{ + switch(event) + { + case VM_UDP_EVT_WRITE: + break; + case VM_UDP_EVT_READ: + break; + case VM_UDP_EVT_PIPE_BROKEN: + case VM_UDP_EVT_PIPE_CLOSED: + vm_log_error("udpCallback error! evt=%d hdl=%d", event, hdl); + break; + } +} + +boolean LUDP::udpBegin(void* userdata) +{ + LUDP* pThis = (LUDP*)userdata; + + pThis->m_serverHandle = vm_udp_create(pThis->m_port, + pThis->getAPN(), + &udpCallback, + 0 // don't loopback + ); + + if(pThis->m_serverHandle < 0) + { + // fail immediately + pThis->m_serverHandle = -1; + return true; + } + else + { + // no need to wait for VM_UDP_EVT_WRITE??? + return true; + } +} + +uint8_t LUDP::begin(uint16_t port) +{ + m_port = port; + LTask.remoteCall(&udpBegin, this); + + if(m_serverHandle == -1) + { + // create failed. + return 0; + } + else + { + return 1; + } +} + +boolean LUDP::udpStop(void* userdata) +{ + LUDP* pThis = (LUDP*)userdata; + vm_udp_close(pThis->m_serverHandle); + pThis->m_serverHandle = -1; + return true; +} + +void LUDP::stop() +{ + if(m_serverHandle == -1) + return; + + LTask.remoteCall(&udpStop, this); + return; +} + +int LUDP::beginPacket(IPAddress ip, uint16_t port) +{ + m_sendToPort = port; + m_sendToIP = ip; + + m_writeBuffer.resize(INIT_WRITE_BUFFER_SIZE); + m_writePos = 0; + + vm_log_info("beginPacket(IP)"); + return 1; +} + +struct LUDPSendContext +{ + LUDP *pThis; + VMINT sentComplete; +}; + +boolean LUDP::udpSend(void* userdata) +{ + LUDPSendContext *pCntx = (LUDPSendContext*)userdata; + LUDP* pThis = pCntx->pThis; + VMINT remainBuffer = pThis->m_writePos; + VMUINT8 *pBuf = &pThis->m_writeBuffer[0]; + + vm_sockaddr_struct sendto = {0}; + sendto.addr[0] = pThis->m_sendToIP[0]; + sendto.addr[1] = pThis->m_sendToIP[1]; + sendto.addr[2] = pThis->m_sendToIP[2]; + sendto.addr[3] = pThis->m_sendToIP[3]; + sendto.addr_len = 4; + sendto.port = pThis->m_sendToPort; + + vm_log_info("send packet len:%d to %d.%d.%d.%d:%d", + remainBuffer, + sendto.addr[0], + sendto.addr[1], + sendto.addr[2], + sendto.addr[3], + sendto.port); + + while(remainBuffer > 0) + { + VMINT sentBytes = 0; + sentBytes = vm_udp_sendto(pThis->m_serverHandle, + pBuf, + remainBuffer, + &sendto); + + vm_log_info("vm_udp_sendto returns %d", sentBytes); + + + if(sentBytes <= 0) + { + vm_log_error("vm_udp_sendto sent no content"); + break; + } + + pBuf += sentBytes; + remainBuffer -= sentBytes; + } + + // check if buffer is completely sent + if(remainBuffer <= 0) + { + pCntx->sentComplete = 1; + } + else + { + pCntx->sentComplete = 0; + } + + return true; +} + +int LUDP::endPacket() +{ + vm_log_info("endPacket"); + LUDPSendContext cntx; + cntx.pThis = this; + cntx.sentComplete = 0; + LTask.remoteCall(&udpSend, &cntx); + + // release buffer + m_writePos = 0; + m_writeBuffer.clear(); + + // reset socket address + m_sendToIP = INADDR_NONE; + m_sendToPort = -1; + return cntx.sentComplete; +} + +size_t LUDP::LUDP::write(uint8_t byte) +{ + if(m_writePos >= m_writeBuffer.size()) + { + m_writeBuffer.resize(m_writeBuffer.size() + INIT_WRITE_BUFFER_SIZE); + } + m_writeBuffer[m_writePos] = byte; + m_writePos++; + + return 1; +} + +size_t LUDP::write(const uint8_t *buffer, size_t size) +{ + if((m_writePos + size) >= m_writeBuffer.size()) + { + m_writeBuffer.resize(m_writeBuffer.size() + size); + } + + for(size_t i = 0; i < size; ++i) + { + m_writeBuffer[m_writePos] = buffer[i]; + m_writePos++; + } + + return size; +} + +boolean LUDP::udpRecv(void* userdata) +{ + LUDP *pThis = (LUDP*)userdata; + vm_sockaddr_struct recvfrom = {0}; + + // allocate buffer for receiving + pThis->m_recvBuffer.resize(INIT_RECV_BUFFER_SIZE); + const VMINT receivedSize = vm_udp_recvfrom(pThis->m_serverHandle, + &pThis->m_recvBuffer[0], + pThis->m_recvBuffer.size(), + &recvfrom); + + if(receivedSize > 0) + { + // content retrieved + pThis->m_recvBuffer.resize(receivedSize); + pThis->m_recvIP = IPAddress(recvfrom.addr[0], + recvfrom.addr[1], + recvfrom.addr[2], + recvfrom.addr[3]); + pThis->m_recvPort = recvfrom.port; + pThis->m_recvPos = 0; + } + else + { + // nothing to read + pThis->m_recvBuffer.clear(); + } + + return true; +} + +int LUDP::parsePacket() +{ + if(m_serverHandle == -1) + { + return 0; + } + + // is the receiving buffer has content? + int remainBytes = available(); + if(remainBytes) + { + return remainBytes; + } + + // is incoming packet ready? + flush(); + LTask.remoteCall(&udpRecv, this); + return available(); +} + +void LUDP::flush() +{ + m_recvBuffer.clear(); + m_recvPos = 0; + m_recvIP = INADDR_NONE; + m_recvPort = -1; +} + +int LUDP::available() +{ + if(m_recvIP == INADDR_NONE) + return 0; + + if(m_recvBuffer.size() == 0) + return 0; + + const int remainBytes = m_recvBuffer.size() - m_recvPos; + + if(remainBytes > 0) + { + return remainBytes; + } + else + { + return 0; + } +} + +int LUDP::read() +{ + if(!available()) + { + return -1; + } + + VMUINT8 byte = m_recvBuffer[m_recvPos]; + m_recvPos++; + + return (int)byte; +} + +int LUDP::read(unsigned char* buffer, size_t len) +{ + if(!available() || len <= 0) + { + return -1; + } + + const size_t readLen = std::min(m_recvBuffer.size() - m_recvPos, len); + + memcpy(buffer, &m_recvBuffer[m_recvPos], readLen); + m_recvPos += readLen; + + return readLen; +} + +int LUDP::peek() +{ + if(!available()) + { + return -1; + } + + VMUINT8 byte = m_recvBuffer[m_recvPos]; + return (int)byte; +} diff --git a/hardware/arduino/mtk/cores/arduino/LUdp.h b/hardware/arduino/mtk/cores/arduino/LUdp.h new file mode 100644 index 00000000..6e402684 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/LUdp.h @@ -0,0 +1,84 @@ +#ifndef ludp_h +#define ludp_h + +#include +#include + +#define UDP_TX_PACKET_MAX_SIZE 24 + +class LUDP : public UDP { +protected: + uint16_t m_port; // local port to listen on + VMINT m_serverHandle; + + IPAddress m_sendToIP; // remote IP address for outgoing packet whilst it's being processed + uint16_t m_sendToPort; // remote port for the outgoing packet whilst it's being processed + std::vector m_writeBuffer; + VMINT m_writePos; + + IPAddress m_recvIP; // remote IP address for outgoing packet whilst it's being processed + uint16_t m_recvPort; // remote port for the outgoing packet whilst it's being processed + std::vector m_recvBuffer; + VMINT m_recvPos; + + static const VMINT INIT_WRITE_BUFFER_SIZE = 32; + static const VMINT INIT_RECV_BUFFER_SIZE = 1024; // typical MTU of web is 512 bytes, 1KB buffer should be sufficient + + static boolean udpBegin(void* userdata); + static boolean udpStop(void* userdata); + static boolean udpSend(void* userdata); + static boolean udpRecv(void* userdata); + static void udpCallback(VMINT hdl, VMINT event); + +protected: + // child class shoudl return proper APN enum + virtual VMINT getAPN() const = 0; + +public: + LUDP(); // Constructor + virtual uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual void stop(); // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port); + + // different DNS lookup should be defined by child classes + virtual int beginPacket(const char *host, uint16_t port) = 0; + + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket(); + // Write a single byte into the packet + virtual size_t write(uint8_t); + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size); + + using Print::write; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket(); + // Number of bytes remaining in the current packet + virtual int available(); + // Read a single byte from the current packet + virtual int read(); + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len); + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) { return read((unsigned char*)buffer, len); }; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek(); + virtual void flush(); // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() { return m_recvIP; }; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() { return m_recvPort; }; +}; + +#endif diff --git a/hardware/arduino/mtk/cores/arduino/Print.cpp b/hardware/arduino/mtk/cores/arduino/Print.cpp new file mode 100644 index 00000000..b3ae8046 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/Print.cpp @@ -0,0 +1,272 @@ +/* + Print.cpp - Base class that provides print() and println() + Copyright (c) 2008 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Modified 23 November 2006 by David A. Mellis + */ + +#include +#include +#include +#include +#include "Arduino.h" + +#include "Print.h" + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + n += write(*buffer++); + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + return print(reinterpret_cast(ifsh)); +} + +size_t Print::print(const String &s) +{ + return write(s.c_str(), s.length()); +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + size_t n = print('\r'); + n += print('\n'); + return n; +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + + +#include +size_t Print::printf(const char *fmt, ...) +{ + va_list args; + char buf[256] = {0}; + + va_start(args, fmt); + vsprintf(buf, fmt, args); + va_end(args); + + return write(buf, strlen(buf)); +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) { + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + unsigned long m = n; + n /= base; + char c = m - base * n; + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +size_t Print::printFloat(double number, uint8_t digits) +{ + size_t n = 0; + + if (isnan(number)) return print("nan"); + if (isinf(number)) return print("inf"); + if (number > 4294967040.0) return print ("ovf"); // constant determined empirically + if (number <-4294967040.0) return print ("ovf"); // constant determined empirically + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + int toPrint = int(remainder); + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} diff --git a/hardware/arduino/mtk/cores/arduino/Print.h b/hardware/arduino/mtk/cores/arduino/Print.h new file mode 100644 index 00000000..5a799a31 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/Print.h @@ -0,0 +1,86 @@ +/* + Print.h - Base class that provides print() and println() + Copyright (c) 2008 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Print_h +#define Print_h + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printFloat(double, uint8_t); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual size_t write(const uint8_t *buffer, size_t size); + size_t write(const char *buffer, size_t size) { + return write((const uint8_t *)buffer, size); + } + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); + /* format param */ + size_t printf(const char *fmt, ...); +}; + +#endif diff --git a/hardware/arduino/mtk/cores/arduino/Printable.h b/hardware/arduino/mtk/cores/arduino/Printable.h new file mode 100644 index 00000000..2a1b2e9f --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/Printable.h @@ -0,0 +1,40 @@ +/* + Printable.h - Interface class that allows printing of complex types + Copyright (c) 2011 Adrian McEwen. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Printable_h +#define Printable_h + +#include + +class Print; + +/** The Printable class provides a way for new classes to allow themselves to be printed. + By deriving from Printable and implementing the printTo method, it will then be possible + for users to print out instances of this class by passing them into the usual + Print::print and Print::println methods. +*/ + +class Printable +{ + public: + virtual size_t printTo(Print& p) const = 0; +}; + +#endif + diff --git a/hardware/arduino/mtk/cores/arduino/RingBuffer.cpp b/hardware/arduino/mtk/cores/arduino/RingBuffer.cpp new file mode 100644 index 00000000..f0b3ed1d --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/RingBuffer.cpp @@ -0,0 +1,43 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "RingBuffer.h" +#include + +RingBuffer::RingBuffer( void ) +{ + memset( _aucBuffer, 0, SERIAL_BUFFER_SIZE ) ; + _iHead=0 ; + _iTail=0 ; +} + +void RingBuffer::store_char( uint8_t c ) +{ + int i = (uint32_t)(_iHead + 1) % SERIAL_BUFFER_SIZE ; + + // if we should be storing the received character into the location + // just before the tail (meaning that the head would advance to the + // current location of the tail), we're about to overflow the buffer + // and so we don't write the character or advance the head. + if ( i != _iTail ) + { + _aucBuffer[_iHead] = c ; + _iHead = i ; + } +} + diff --git a/hardware/arduino/mtk/cores/arduino/RingBuffer.h b/hardware/arduino/mtk/cores/arduino/RingBuffer.h new file mode 100644 index 00000000..28309df4 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/RingBuffer.h @@ -0,0 +1,42 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _RING_BUFFER_ +#define _RING_BUFFER_ + +#include + +// Define constants and variables for buffering incoming serial data. We're +// using a ring buffer (I think), in which head is the index of the location +// to which to write the next incoming character and tail is the index of the +// location from which to read. +#define SERIAL_BUFFER_SIZE 64 + +class RingBuffer +{ + public: + uint8_t _aucBuffer[SERIAL_BUFFER_SIZE] ; + int _iHead ; + int _iTail ; + + public: + RingBuffer( void ) ; + void store_char( uint8_t c ) ; +} ; + +#endif /* _RING_BUFFER_ */ diff --git a/hardware/arduino/mtk/cores/arduino/Server.h b/hardware/arduino/mtk/cores/arduino/Server.h new file mode 100644 index 00000000..77c415cc --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/Server.h @@ -0,0 +1,28 @@ +/* + Server.h - Base class that provides Server + Copyright (c) 2011 Adrian McEwen. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef server_h +#define server_h + +class Server : public Print { +public: + virtual void begin() =0; +}; + +#endif diff --git a/hardware/arduino/mtk/cores/arduino/Stream.cpp b/hardware/arduino/mtk/cores/arduino/Stream.cpp new file mode 100644 index 00000000..aafb7fcf --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/Stream.cpp @@ -0,0 +1,270 @@ +/* + Stream.cpp - adds parsing methods to Stream class + Copyright (c) 2008 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Created July 2011 + parsing functions based on TextFinder library by Michael Margolis + */ + +#include "Arduino.h" +#include "Stream.h" + +#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait +#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field + +// private method to read stream with timeout +int Stream::timedRead() +{ + int c; + _startMillis = millis(); + do { + c = read(); + if (c >= 0) return c; + } while(millis() - _startMillis < _timeout); + return -1; // -1 indicates timeout +} + +// private method to peek stream with timeout +int Stream::timedPeek() +{ + int c; + _startMillis = millis(); + do { + c = peek(); + if (c >= 0) return c; + } while(millis() - _startMillis < _timeout); + return -1; // -1 indicates timeout +} + +// returns peek of the next digit in the stream or -1 if timeout +// discards non-numeric characters +int Stream::peekNextDigit() +{ + int c; + while (1) { + c = timedPeek(); + if (c < 0) return c; // timeout + if (c == '-') return c; + if (c >= '0' && c <= '9') return c; + read(); // discard non-numeric + } +} + +// Public Methods +////////////////////////////////////////////////////////////// + +void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait +{ + _timeout = timeout; +} + + // find returns true if the target string is found +bool Stream::find(char *target) +{ + return findUntil(target, NULL); +} + +// reads data from the stream until the target string of given length is found +// returns true if target string is found, false if timed out +bool Stream::find(char *target, size_t length) +{ + return findUntil(target, length, NULL, 0); +} + +// as find but search ends if the terminator string is found +bool Stream::findUntil(char *target, char *terminator) +{ + return findUntil(target, strlen(target), terminator, strlen(terminator)); +} + +// reads data from the stream until the target string of the given length is found +// search terminated if the terminator string is found +// returns true if target string is found, false if terminated or timed out +bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t termLen) +{ + size_t index = 0; // maximum target string length is 64k bytes! + size_t termIndex = 0; + int c; + + if( *target == 0) + return true; // return true if target is a null string + while( (c = timedRead()) > 0){ + + if(c != target[index]) + index = 0; // reset index if any char does not match + + if( c == target[index]){ + //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1); + if(++index >= targetLen){ // return true if all chars in the target match + return true; + } + } + + if(termLen > 0 && c == terminator[termIndex]){ + if(++termIndex >= termLen) + return false; // return false if terminate string found before target string + } + else + termIndex = 0; + } + return false; +} + + +// returns the first valid (long) integer value from the current position. +// initial characters that are not digits (or the minus sign) are skipped +// function is terminated by the first character that is not a digit. +long Stream::parseInt() +{ + return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout) +} + +// as above but a given skipChar is ignored +// this allows format characters (typically commas) in values to be ignored +long Stream::parseInt(char skipChar) +{ + boolean isNegative = false; + long value = 0; + int c; + + c = peekNextDigit(); + // ignore non numeric leading characters + if(c < 0) + return 0; // zero returned if timeout + + do{ + if(c == skipChar) + ; // ignore this charactor + else if(c == '-') + isNegative = true; + else if(c >= '0' && c <= '9') // is c a digit? + value = value * 10 + c - '0'; + read(); // consume the character we got with peek + c = timedPeek(); + } + while( (c >= '0' && c <= '9') || c == skipChar ); + + if(isNegative) + value = -value; + return value; +} + + +// as parseInt but returns a floating point value +float Stream::parseFloat() +{ + return parseFloat(NO_SKIP_CHAR); +} + +// as above but the given skipChar is ignored +// this allows format characters (typically commas) in values to be ignored +float Stream::parseFloat(char skipChar){ + boolean isNegative = false; + boolean isFraction = false; + long value = 0; + char c; + float fraction = 1.0; + + c = peekNextDigit(); + // ignore non numeric leading characters + if(c < 0) + return 0; // zero returned if timeout + + do{ + if(c == skipChar) + ; // ignore + else if(c == '-') + isNegative = true; + else if (c == '.') + isFraction = true; + else if(c >= '0' && c <= '9') { // is c a digit? + value = value * 10 + c - '0'; + if(isFraction) + fraction *= 0.1; + } + read(); // consume the character we got with peek + c = timedPeek(); + } + while( (c >= '0' && c <= '9') || c == '.' || c == skipChar ); + + if(isNegative) + value = -value; + if(isFraction) + return value * fraction; + else + return value; +} + +// read characters from stream into buffer +// terminates if length characters have been read, or timeout (see setTimeout) +// returns the number of characters placed in the buffer +// the buffer is NOT null terminated. +// +size_t Stream::readBytes(char *buffer, size_t length) +{ + size_t count = 0; + while (count < length) { + int c = timedRead(); + if (c < 0) break; + *buffer++ = (char)c; + count++; + } + return count; +} + + +// as readBytes with terminator character +// terminates if length characters have been read, timeout, or if the terminator character detected +// returns the number of characters placed in the buffer (0 means no valid data found) + +size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length) +{ + if (length < 1) return 0; + size_t index = 0; + while (index < length) { + int c = timedRead(); + if (c < 0 || c == terminator) break; + *buffer++ = (char)c; + index++; + } + return index; // return number of characters, not including null terminator +} + +String Stream::readString() +{ + String ret; + int c = timedRead(); + while (c >= 0) + { + ret += (char)c; + c = timedRead(); + } + return ret; +} + +String Stream::readStringUntil(char terminator) +{ + String ret; + int c = timedRead(); + while (c >= 0 && c != terminator) + { + ret += (char)c; + c = timedRead(); + } + return ret; +} + diff --git a/hardware/arduino/mtk/cores/arduino/Stream.h b/hardware/arduino/mtk/cores/arduino/Stream.h new file mode 100644 index 00000000..5cf5ddf0 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/Stream.h @@ -0,0 +1,102 @@ +/* + Stream.h - base class for character-based streams. + Copyright (c) 2010 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + parsing functions based on TextFinder library by Michael Margolis +*/ + +#ifndef Stream_h +#define Stream_h + +#include +#include "Print.h" + +// compatability macros for testing +/* +#define getInt() parseInt() +#define getInt(skipChar) parseInt(skipchar) +#define getFloat() parseFloat() +#define getFloat(skipChar) parseFloat(skipChar) +#define getString( pre_string, post_string, buffer, length) +readBytesBetween( pre_string, terminator, buffer, length) +*/ + +class Stream : public Print +{ + protected: + unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read + unsigned long _startMillis; // used for timeout measurement + int timedRead(); // private method to read stream with timeout + int timedPeek(); // private method to peek stream with timeout + int peekNextDigit(); // returns the next numeric digit in the stream or -1 if timeout + + public: + virtual int available() = 0; + virtual int read() = 0; + virtual int peek() = 0; + virtual void flush() = 0; + + Stream() {_timeout=1000;} + +// parsing methods + + void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second + + bool find(char *target); // reads data from the stream until the target string is found + bool find(uint8_t *target) { return find ((char *)target); } + // returns true if target string is found, false if timed out (see setTimeout) + + bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found + bool find(uint8_t *target, size_t length) { return find ((char *)target, length); } + // returns true if target string is found, false if timed out + + bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found + bool findUntil(uint8_t *target, char *terminator) { return findUntil((char *)target, terminator); } + + bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found + bool findUntil(uint8_t *target, size_t targetLen, char *terminate, size_t termLen) {return findUntil((char *)target, targetLen, terminate, termLen); } + + + long parseInt(); // returns the first valid (long) integer value from the current position. + // initial characters that are not digits (or the minus sign) are skipped + // integer is terminated by the first character that is not a digit. + + float parseFloat(); // float version of parseInt + + size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer + size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); } + // terminates if length characters have been read or timeout (see setTimeout) + // returns the number of characters placed in the buffer (0 means no valid data found) + + size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character + size_t readBytesUntil( char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); } + // terminates if length characters have been read, timeout, or if the terminator character detected + // returns the number of characters placed in the buffer (0 means no valid data found) + + // Arduino String functions to be added here + String readString(); + String readStringUntil(char terminator); + + protected: + long parseInt(char skipChar); // as above but the given skipChar is ignored + // as above but the given skipChar is ignored + // this allows format characters (typically commas) in values to be ignored + + float parseFloat(char skipChar); // as above but the given skipChar is ignored +}; + +#endif diff --git a/hardware/arduino/mtk/cores/arduino/Tone.h b/hardware/arduino/mtk/cores/arduino/Tone.h new file mode 100644 index 00000000..5789b082 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/Tone.h @@ -0,0 +1,23 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _WIRING_TONE_ +#define _WIRING_TONE_ + + +#endif /* _WIRING_TONE_ */ diff --git a/hardware/arduino/mtk/cores/arduino/UARTClass.cpp b/hardware/arduino/mtk/cores/arduino/UARTClass.cpp new file mode 100644 index 00000000..948abce1 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/UARTClass.cpp @@ -0,0 +1,221 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include +#include +#include "UARTClass.h" +#include "variant.h" +#include "vmlog.h" + +static VM_DCL_HANDLE usb_device_handle = -1; + +typedef struct +{ + VMINT result; +}vm_uart_ctrl_com_response; + +// Constructors //////////////////////////////////////////////////////////////// + +UARTClass::UARTClass( int usbNum, RingBuffer* pRx_buffer ) +{ + _rx_buffer = pRx_buffer ; + _usbNum = usbNum; + uart_handle = -1; +} + +void UartIrqHandler(void* parameter, VM_DCL_EVENT event, VM_DCL_HANDLE device_handle) +{ + if(event == VM_UART_READY_TO_READ) + { + char data[32]; + int i; + VM_DCL_STATUS status; + VM_DCL_BUFF_LEN returned_len; + + status = vm_dcl_read(device_handle,(VM_DCL_BUFF*)data,32,&returned_len,vm_dcl_get_ownerid()); + if(statusstore_char(data[i]); + //Serial._rx_buffer->store_char(data[i]); + } + } + else + { + for(i=0;istore_char(data[i]); + } + } + } + else + { + //vm_log_info((char*)"VM_UART_READY_TO_NO_EVENT"); + } +} +// Public Methods ////////////////////////////////////////////////////////////// + +void UARTClass::begin( const uint32_t dwBaudRate ) +{ + + vm_sio_ctrl_dcb_t data; + + if(_usbNum == 2) + { + if(!changePinType(0, PIO_UART, &uart_handle)) + return; + + if(uart_handle == VM_DCL_HANDLE_INVALID) + uart_handle = vm_dcl_open(vm_uart_port1,vm_dcl_get_ownerid()); + + } + else + { + uart_handle = vm_dcl_open(vm_usb_port1,vm_dcl_get_ownerid()); + } + + if(VM_DCL_HANDLE_INVALID==uart_handle) + { + vm_log_info((char*)"UARTClass failed"); + return; + } + + data.u4OwenrId = vm_dcl_get_ownerid(); + data.rUARTConfig.u4Baud = dwBaudRate; + data.rUARTConfig.u1DataBits = 8; + data.rUARTConfig.u1StopBits = 1; + data.rUARTConfig.u1Parity = 0; + data.rUARTConfig.u1FlowControl = 1; + data.rUARTConfig.ucXonChar = 0x11; + data.rUARTConfig.ucXoffChar = 0x13; + data.rUARTConfig.fgDSRCheck = 0; + vm_dcl_control(uart_handle,VM_SIO_CMD_SET_DCB_CONFIG,(void *)&data); + vm_dcl_registercallback(uart_handle,VM_UART_READY_TO_READ,(VM_DCL_CALLBACK)UartIrqHandler,(void*)NULL); + //vm_dcl_registercallback(uart_handle,VM_UART_READY_TO_WRITE ,(VM_DCL_CALLBACK)UartIrqHandler,(void *)NULL); + + if(_usbNum == 2) + { + setPinHandle(0, uart_handle); + } + else + { + usb_device_handle = uart_handle; + } + + //vm_log_info((char*)"UARTClass begin successful"); +} + +void UARTClass::end( void ) +{ + // clear any received data + _rx_buffer->_iHead = _rx_buffer->_iTail ; + vm_dcl_close(uart_handle); + + if(_usbNum == 2) + { + g_APinDescription[0].ulHandle = VM_DCL_HANDLE_INVALID; + g_APinDescription[0].ulPinType = PIO_DIGITAL; + } + else + { + usb_device_handle = -1; + } +} + +int UARTClass::available( void ) +{ + return (uint32_t)(SERIAL_BUFFER_SIZE + _rx_buffer->_iHead - _rx_buffer->_iTail) % SERIAL_BUFFER_SIZE ; +} + +int UARTClass::peek( void ) +{ + if ( _rx_buffer->_iHead == _rx_buffer->_iTail ) + return -1 ; + + return _rx_buffer->_aucBuffer[_rx_buffer->_iTail] ; +} + +int UARTClass::read( void ) +{ + // if the head isn't ahead of the tail, we don't have any characters + if ( _rx_buffer->_iHead == _rx_buffer->_iTail ) + return -1 ; + + uint8_t uc = _rx_buffer->_aucBuffer[_rx_buffer->_iTail] ; + _rx_buffer->_iTail = (unsigned int)(_rx_buffer->_iTail + 1) % SERIAL_BUFFER_SIZE ; + return uc ; +} + +void UARTClass::flush( void ) +{ + while(read()!=-1); +} + +size_t UARTClass::write( const uint8_t uc_data ) +{ + + VM_DCL_STATUS status; + VM_DCL_BUFF_LEN writen_len = 0; + int count = 0; + + if(uart_handle != -1) + { + status = vm_dcl_write(uart_handle,(VM_DCL_BUFF*)&uc_data,1,&writen_len,vm_dcl_get_ownerid()); + + while((status + +/***************************************************************************** + * Class UARTClass + ****************************************************************************/ +// UARTClass is designed for LinkIt One board connecte with other hardware device through UART +// EXAMPLE: +// +// #define SENSOR 0 +// int val = 0; +// void setup(){ +// Serial.begin(9600); +// } +// void loop(){ +// val = analogRead(SENSOR); +// Serial.println(val); +// delay(100); +// } +// +class UARTClass : public HardwareSerial +{ + protected: + RingBuffer *_rx_buffer ; + protected: + int _usbNum ; + VM_DCL_HANDLE uart_handle; + + public: +// Constructor / Destructor + UARTClass( int usbNum, RingBuffer* pRx_buffer ) ; + +// Method + public: + + // sets the data rate in bits per sencond for serial data transmission + // + // RETURNS + // none + // + // EXAMPLE + // + // void setup(){ + // Serial.begin(115200); + // } + // void loop(){} + // +void begin( const uint32_t dwBaudRate //[IN] in bits per sencond(baud rate) + ) ; + + // disables serial communication, allowing the RX and TX pins to be used for + // general input and output + // + // RETURNS + // none +void end( void ) ; + + // get the number of bytes(characters)avaiable for reading from the serial port. + // + // RETURNS + // the bumbers of bytes available to read + // + // EXAMPLE + // + // int numberscomingBytes = 0; + // void setup(){ + // Serial.begin(115200); + // } + // void loop(){ + // if(Serial.available()>0){ + // numberscomingBytes = Serial.read(); + // Serial.print(numberscomingBytes); + // } + // } + // +int available( void ) ; + + // returns the next byte of incoming serial data without removing it from the + // internal serial buffer + // + // RETURNS + // the first byte of incoming serial data available, -1 if no data is available +int peek( void ) ; + + // reads incoming serial data + // + // RETURNS + // the first byte of incoimng serial data avaiable, -a if no data is available + // + // EXAMPLE + // + // int incomingdata = 0; + // void setup() { + // Serial.begin(9600); + // } + // void loop() { + // if (Serial.available() > 0) { + // incomingdata = Serial.read(); + // Serial.print("received data: "); + // Serial.println(incomingdata, DEC); + // } + // } + // +int read( void ) ; + + // waits for the transmission of outgoing serial data to complete + // + // RETURNS none +void flush( void ) ; + +// write a char +// +// RETURNS +// the number of write +size_t write( const uint8_t c //[IN] input char + ) ; + + friend void UartIrqHandler(void* parameter, VM_DCL_EVENT event, VM_DCL_HANDLE device_handle); + + // pull in write(str) and write(buf, size) from Print + using Print::write ; + + // UART always active + operator bool(); +}; + +#endif // _UART_CLASS_ diff --git a/hardware/arduino/mtk/cores/arduino/Udp.h b/hardware/arduino/mtk/cores/arduino/Udp.h new file mode 100644 index 00000000..dc5644b9 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/Udp.h @@ -0,0 +1,88 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/hardware/arduino/mtk/cores/arduino/WCharacter.h b/hardware/arduino/mtk/cores/arduino/WCharacter.h new file mode 100644 index 00000000..e84b3485 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/WCharacter.h @@ -0,0 +1,180 @@ +/* + WCharacter.h - Character utility functions for Wiring & Arduino + Copyright (c) 2010 Hernando Barragan. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef Character_h +#define Character_h + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// WCharacter.h prototypes +#if defined ( __GNUC__ ) +inline boolean isAlphaNumeric(int c) __attribute__((always_inline)); +inline boolean isAlpha(int c) __attribute__((always_inline)); +inline boolean isAscii(int c) __attribute__((always_inline)); +inline boolean isWhitespace(int c) __attribute__((always_inline)); +inline boolean isControl(int c) __attribute__((always_inline)); +inline boolean isDigit(int c) __attribute__((always_inline)); +inline boolean isGraph(int c) __attribute__((always_inline)); +inline boolean isLowerCase(int c) __attribute__((always_inline)); +inline boolean isPrintable(int c) __attribute__((always_inline)); +inline boolean isPunct(int c) __attribute__((always_inline)); +inline boolean isSpace(int c) __attribute__((always_inline)); +inline boolean isUpperCase(int c) __attribute__((always_inline)); +inline boolean isHexadecimalDigit(int c) __attribute__((always_inline)); +inline int toAscii(int c) __attribute__((always_inline)); +inline int toLowerCase(int c) __attribute__((always_inline)); +inline int toUpperCase(int c)__attribute__((always_inline)); +#elif defined ( __ICCARM__ ) +#endif + +// Checks for an alphanumeric character. +// It is equivalent to (isalpha(c) || isdigit(c)). +inline boolean isAlphaNumeric(int c) +{ + return ( isalnum(c) == 0 ? false : true); +} + + +// Checks for an alphabetic character. +// It is equivalent to (isupper(c) || islower(c)). +inline boolean isAlpha(int c) +{ + return ( isalpha(c) == 0 ? false : true); +} + + +// Checks whether c is a 7-bit unsigned char value +// that fits into the ASCII character set. +inline boolean isAscii(int c) +{ +/* return ( isascii(c) == 0 ? false : true); */ + return ( (c & ~0x7f) != 0 ? false : true); +} + + +// Checks for a blank character, that is, a space or a tab. +inline boolean isWhitespace(int c) +{ + return ( isblank (c) == 0 ? false : true); +} + + +// Checks for a control character. +inline boolean isControl(int c) +{ + return ( iscntrl (c) == 0 ? false : true); +} + + +// Checks for a digit (0 through 9). +inline boolean isDigit(int c) +{ + return ( isdigit (c) == 0 ? false : true); +} + + +// Checks for any printable character except space. +inline boolean isGraph(int c) +{ + return ( isgraph (c) == 0 ? false : true); +} + + +// Checks for a lower-case character. +inline boolean isLowerCase(int c) +{ + return (islower (c) == 0 ? false : true); +} + + +// Checks for any printable character including space. +inline boolean isPrintable(int c) +{ + return ( isprint (c) == 0 ? false : true); +} + + +// Checks for any printable character which is not a space +// or an alphanumeric character. +inline boolean isPunct(int c) +{ + return ( ispunct (c) == 0 ? false : true); +} + + +// Checks for white-space characters. For the avr-libc library, +// these are: space, formfeed ('\f'), newline ('\n'), carriage +// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v'). +inline boolean isSpace(int c) +{ + return ( isspace (c) == 0 ? false : true); +} + + +// Checks for an uppercase letter. +inline boolean isUpperCase(int c) +{ + return ( isupper (c) == 0 ? false : true); +} + + +// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7 +// 8 9 a b c d e f A B C D E F. +inline boolean isHexadecimalDigit(int c) +{ + return ( isxdigit (c) == 0 ? false : true); +} + + +// Converts c to a 7-bit unsigned char value that fits into the +// ASCII character set, by clearing the high-order bits. +inline int toAscii(int c) +{ +/* return toascii (c); */ + return (c & 0x7f); +} + + +// Warning: +// Many people will be unhappy if you use this function. +// This function will convert accented letters into random +// characters. + +// Converts the letter c to lower case, if possible. +inline int toLowerCase(int c) +{ + return tolower (c); +} + + +// Converts the letter c to upper case, if possible. +inline int toUpperCase(int c) +{ + return toupper (c); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/hardware/arduino/mtk/cores/arduino/WInterrupts.c b/hardware/arduino/mtk/cores/arduino/WInterrupts.c new file mode 100644 index 00000000..e07afd67 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/WInterrupts.c @@ -0,0 +1,211 @@ +/* + Copyright (c) 2011-2012 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "vmdcl.h" +#include "vmdcl_gpio.h" +#include "vmdcl_eint.h" +#include "vmlog.h" +#include "WInterrupts.h" + +typedef struct _Exinterrupts_Struct +{ + VM_DCL_HANDLE handle; + uint32_t pin; + uint32_t eint; + uint32_t first; + voidFuncPtr cb; +}Exinterrupts_Struct; + + +static Exinterrupts_Struct gExinterruptsPio[EXTERNAL_NUM_INTERRUPTS] = { + {VM_DCL_HANDLE_INVALID, 2, 20, 0, NULL}, + {VM_DCL_HANDLE_INVALID, 3, 11, 0, NULL} +}; + +#ifdef __cplusplus +extern "C" { +#endif + +static void eint_callback(void* parameter, VM_DCL_EVENT event, VM_DCL_HANDLE device_handle) +{ + int i; + + for(i=0; i EXTERNAL_NUM_INTERRUPTS) + return ; + + if(!changePinType(gExinterruptsPio[pin].pin, PIO_EINT, &eint_handle)) + return; + + memset(&eint_config,0, sizeof(vm_eint_ctrl_config_t)); + memset(&sens_data,0, sizeof(vm_eint_ctrl_set_sensitivity_t)); + memset(&deboun_time,0, sizeof(vm_eint_ctrl_set_hw_deounce_t)); + + if(eint_handle == VM_DCL_HANDLE_INVALID) + eint_handle = vm_dcl_open(VM_DCL_EINT,gExinterruptsPio[pin].eint); + + if(VM_DCL_HANDLE_INVALID == eint_handle) + { + vm_log_info("open EINT error"); + return; + } + + setPinHandle(gExinterruptsPio[pin].pin, eint_handle); + gExinterruptsPio[pin].handle = eint_handle; + gExinterruptsPio[pin].cb = callback; + + status = vm_dcl_control(eint_handle ,VM_EINT_CMD_MASK,NULL); /* Usually, before we config eint, we mask it firstly. */ + if(status != VM_DCL_STATUS_OK) + { + vm_log_info("VM_EINT_CMD_MASK = %d", status); + } + + status = vm_dcl_registercallback(eint_handle , VM_EVENT_EINT_TRIGGER,(VM_DCL_CALLBACK)eint_callback,(void*)NULL ); /* register callback function,Note: the last paramter fill NULL */ + if(status != VM_DCL_STATUS_OK) + { + vm_log_info("VM_EVENT_EINT_TRIGGER = %d", status); + } + if(gExinterruptsPio[pin].first == 0) + { + + if (mode == CHANGE) + { + sens_data.sensitivity = 0; /* 1 means level sensitiv, 0 means edge sensitive. */ + eint_config.act_polarity = 0; /* 1 means positive active, 0 means negative active. */ + eint_config.auto_unmask = 1; /* 1 means unmask after callback, 0 means not unmask. user unmask it themselves. */ + } + else + { + // Select mode of operation + if (mode == LOW) + { + sens_data.sensitivity = 1; /* 1 means level sensitiv, 0 means edge sensitive. */ + eint_config.act_polarity = 0; /* 1 means positive active, 0 means negative active. */ + eint_config.auto_unmask = 0; /* 1 means unmask after callback, 0 means not unmask. user unmask it themselves. */ + + } + + if (mode == HIGH) + { + sens_data.sensitivity = 1; /* Not support use low */ + eint_config.act_polarity = 1; /* 1 means positive active, 0 means negative active. */ + eint_config.auto_unmask = 0; /* 1 means unmask after callback, 0 means not unmask. user unmask it themselves. */ + } + + if (mode == FALLING) + { + sens_data.sensitivity = 0; /* 1 means level sensitiv, 0 means edge sensitive. */ + eint_config.act_polarity = 0; /* 1 means positive active, 0 means negative active. */ + eint_config.auto_unmask = 1; /* 1 means unmask after callback, 0 means not unmask. user unmask it themselves. */ + } + + if (mode == RISING) + { + sens_data.sensitivity = 0; /* 1 means level sensitiv, 0 means edge sensitive. */ + eint_config.act_polarity = 1; /* 1 means positive active, 0 means negative active. */ + eint_config.auto_unmask = 1; /* 1 means unmask after callback, 0 means not unmask. user unmask it themselves. */ + } + } + + status = vm_dcl_control(eint_handle ,VM_EINT_CMD_SET_SENSITIVITY,(void *)&sens_data); /* set eint sensitivity */ + if(status != VM_DCL_STATUS_OK) + { + vm_log_info("VM_EINT_CMD_SET_SENSITIVITY = %d", status); + } + + deboun_time.debounce_time = 1; /* debounce time 1ms */ + status = vm_dcl_control(eint_handle ,VM_EINT_CMD_SET_HW_DEBOUNCE,(void *)&deboun_time); /* set debounce time */ + if(status != VM_DCL_STATUS_OK) + { + vm_log_info("VM_EINT_CMD_SET_HW_DEBOUNCE = %d", status); + } + + status = vm_dcl_control(eint_handle ,VM_EINT_CMD_MASK,NULL); /* Usually, before we config eint, we mask it firstly. */ + if(status != VM_DCL_STATUS_OK) + { + vm_log_info("VM_EINT_CMD_MASK = %d", status); + } + + eint_config.debounce_en = 1; /* 1 means enable hw debounce, 0 means disable. */ + + status = vm_dcl_control(eint_handle ,VM_EINT_CMD_CONFIG,(void *)&eint_config); /* Please call this api finally, because we will unmask eint in this command. */ + if(status != VM_DCL_STATUS_OK) + { + vm_log_info("VM_EINT_CMD_CONFIG = %d", status); + } + + if (mode == CHANGE) + { + eint_config.act_polarity = 1; /* 1 means positive active, 0 means negative active. */ + status = vm_dcl_control(eint_handle ,VM_EINT_CMD_CONFIG,(void *)&eint_config); /* Please call this api finally, because we will unmask eint in this command. */ + if(status != VM_DCL_STATUS_OK) + { + vm_log_info("VM_EINT_CMD_CONFIG chage= %d", status); + } + } + gExinterruptsPio[pin].first ++; + } + else + { + status = vm_dcl_control(eint_handle,VM_EINT_CMD_UNMASK,NULL); /* call this function to unmask this eint. */ + if(status != VM_DCL_STATUS_OK) + { + vm_log_info("VM_EINT_CMD_CONFIG = %d", status); + } + } +} + +void detachInterrupt(uint32_t pin) +{ + if(VM_DCL_HANDLE_INVALID != gExinterruptsPio[pin].handle) + { + vm_dcl_close(gExinterruptsPio[pin].handle); + } + gExinterruptsPio[pin].handle = VM_DCL_HANDLE_INVALID; + gExinterruptsPio[pin].cb = NULL; + + g_APinDescription[gExinterruptsPio[pin].pin].ulHandle = VM_DCL_HANDLE_INVALID; + g_APinDescription[gExinterruptsPio[pin].pin].ulPinType= PIO_DIGITAL; +} + + diff --git a/hardware/arduino/mtk/cores/arduino/WInterrupts.h b/hardware/arduino/mtk/cores/arduino/WInterrupts.h new file mode 100644 index 00000000..6fdca470 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/WInterrupts.h @@ -0,0 +1,139 @@ +/* + Copyright (c) 2011-2012 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _WIRING_INTERRUPTS_ +#define _WIRING_INTERRUPTS_ + +#include "Arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Definitions Interrupt callback type +typedef void (*callback_ptr)(void); + +/***************************************************************************** +* FUNCTION + * attachInterrupt + * DESCRIPTION + * Sets up Interrupt Service Routine (ISR). + * When an interrupt arrives, the ISR will be called automatically. This interrupt service cannot preempt execution. + * When the next interrupt arrives, it will wait for ISR to finish the previous interrupt before its execution starts. + * There are two external interrupts on LinkIt One development board, interrupt 0 (at pin 2) and interrupt 1 (at pin 3). + * PARAMETERS + * pin : [IN] Interrupt id, should be 0, and 1; 0 corresponds to pin2 (D2), 1 corresponds to pin3 (D3). + * callback : [IN] Interrupt callback + * mode : [IN] Interrupt trigger mode, it should be LOW/HIGH/RISING/FALLING/CHANGE + * RETURNS + * None + * RETURN VALUES + * None + * Example + * + * + * int pin = 13; + * volatile int state = LOW; + * + * void setup() + * { + * pinMode(pin, OUTPUT); + * attachInterrupt(0, blink, RISING); + * } + * + * void loop() + * { + * digitalWrite(pin, state); + * } + * + * void blink() + * { + * state = !state; + * } + * + * + *****************************************************************************/ +void attachInterrupt(uint32_t pin, callback_ptr callback, uint32_t mode); + +/***************************************************************************** +* FUNCTION + * detachInterrupt + * DESCRIPTION + * Disables ISR. + * PARAMETERS + * pin : [IN] Interrupt id, should be 0, and 1 + * RETURNS + * None + * RETURN VALUES + * None + *****************************************************************************/ +void detachInterrupt(uint32_t pin); + +/***************************************************************************** + * + * FUNCTION + * interrupts + * DESCRIPTION + * Enables interrupt (after it is disabled by noInterrupts()). + * By default, interrupts make some essential tasks executed in background. Disabling interrupts + * will make some communication functions unable to work normally and external interaction ignored. + * Therefore, please pay particular attention when using this function and enable the interrupt again as soon as possible + * PARAMETERS + * None + * RETURNS + * None + * RETURN VALUES + * None + * Example + * + * + * void setup() {} + * + * void loop() + * { + * noInterrupts(); + * // critical, time-sensitive code here + * interrupts(); + * // other code here + * } + * + * + *****************************************************************************/ +void interrupts(void); + + +/***************************************************************************** + * + * FUNCTION + * noInterrupts + * DESCRIPTION + * Disables interrupt (which can be enabled again by interrupts()). + * PARAMETERS + * None + * RETURNS + * None + * RETURN VALUES + * None + *****************************************************************************/ +void noInterrupts(void ); + +#ifdef __cplusplus +} +#endif + +#endif /* _WIRING_INTERRUPTS_ */ diff --git a/hardware/arduino/mtk/cores/arduino/WMath.cpp b/hardware/arduino/mtk/cores/arduino/WMath.cpp new file mode 100644 index 00000000..ec2e29b2 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/WMath.cpp @@ -0,0 +1,68 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +extern "C" { + #include "stdlib.h" + #include "stdint.h" +} +#include "WMath.h" + +extern void randomSeed( uint32_t dwSeed ) +{ + if ( dwSeed != 0 ) + { + srand( dwSeed ) ; + } +} + +extern long random( long howbig ) +{ + if ( howbig == 0 ) + { + return 0 ; + } + + return rand() % howbig; +} + +extern long random( long howsmall, long howbig ) +{ + if (howsmall >= howbig) + { + return howsmall; + } + + long diff = howbig - howsmall; + + return random(diff) + howsmall; +} + +extern long map(long x, long in_min, long in_max, long out_min, long out_max) +{ + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; +} + +extern uint16_t makeWord( uint16_t w ) +{ + return w ; +} + +extern uint16_t makeWord( uint8_t h, uint8_t l ) +{ + return (h << 8) | l ; +} diff --git a/hardware/arduino/mtk/cores/arduino/WMath.h b/hardware/arduino/mtk/cores/arduino/WMath.h new file mode 100644 index 00000000..7f7fd115 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/WMath.h @@ -0,0 +1,93 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _WIRING_MATH_ +#define _WIRING_MATH_ + +/***************************************************************************** + * + * FUNCTION + * map + * DESCRIPTION + * Re-maps a number from one range to another. + * That is, a value of fromLow would get mapped to toLow, a value of fromHigh to toHigh, values in-between to values in-between, etc. + * PARAMETERS + * value: the number to map + * fromLow: the lower bound of the value's current range + * fromHigh: the upper bound of the value's current range + * toLow: the lower bound of the value's target range + * toHigh: the upper bound of the value's target range + * RETURNS + * The mapped value. + * RETURN VALUES + * long + *****************************************************************************/ +extern long map(long value, long fromLow, long fromHigh, long toLow, long toHigh); + +/***************************************************************************** + * FUNCTION + * random + * DESCRIPTION + * The random function generates pseudo-random numbers. + * PARAMETERS + * max: upper bound of the random value, exclusive + * RETURNS + * a random number limit to max-1 (long) + * RETURN VALUES + * long + *****************************************************************************/ +extern long random(long max) ; + +/***************************************************************************** + * FUNCTION + * random + * DESCRIPTION + * The random function generates pseudo-random numbers. + * That is, a value of fromLow would get mapped to toLow, a value of fromHigh to toHigh, values in-between to values in-between, etc. + * PARAMETERS + * min: lower bound of the random value, inclusive (optional) + * max: upper bound of the random value, exclusive + * RETURNS + * a random number between min and max-1 (long) + * RETURN VALUES + * long + *****************************************************************************/ +extern long random(long min, long max) ; + +/***************************************************************************** + * FUNCTION + * randomSeed + * DESCRIPTION + * randomSeed() initializes the pseudo-random number generator, causing it to start at an arbitrary point in its random sequence. + * This sequence, while very long, and random, is always the same. + * PARAMETERS + * dwSeed: pass a number to generate the seed. + * RETURNS + * no returns + * RETURN VALUES + * long + *****************************************************************************/ +extern void randomSeed( uint32_t dwSeed ) ; + +extern uint16_t makeWord( uint16_t w ) ; +extern uint16_t makeWord( uint8_t h, uint8_t l ) ; + +#define word(...) makeWord(__VA_ARGS__) + + +#endif /* _WIRING_MATH_ */ diff --git a/hardware/arduino/mtk/cores/arduino/WString.cpp b/hardware/arduino/mtk/cores/arduino/WString.cpp new file mode 100644 index 00000000..939ca0e2 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/WString.cpp @@ -0,0 +1,746 @@ +/* + WString.cpp - String library for Wiring & Arduino + ...mostly rewritten by Paul Stoffregen... + Copyright (c) 2009-10 Hernando Barragan. All rights reserved. + Copyright 2011, Paul Stoffregen, paul@pjrc.com + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "WString.h" +#include "itoa.h" +#include "avr/dtostrf.h" + +/*********************************************/ +/* Constructors */ +/*********************************************/ + +String::String(const char *cstr) +{ + init(); + if (cstr) copy(cstr, strlen(cstr)); +} + +String::String(const String &value) +{ + init(); + *this = value; +} + +String::String(const __FlashStringHelper *pstr) +{ + init(); + *this = pstr; +} + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +String::String(String &&rval) +{ + init(); + move(rval); +} +String::String(StringSumHelper &&rval) +{ + init(); + move(rval); +} +#endif + +String::String(char c) +{ + init(); + char buf[2]; + buf[0] = c; + buf[1] = 0; + *this = buf; +} + +String::String(unsigned char value, unsigned char base) +{ + init(); + char buf[1 + 8 * sizeof(unsigned char)]; + utoa(value, buf, base); + *this = buf; +} + +String::String(int value, unsigned char base) +{ + init(); + char buf[2 + 8 * sizeof(int)]; + itoa(value, buf, base); + *this = buf; +} + +String::String(unsigned int value, unsigned char base) +{ + init(); + char buf[1 + 8 * sizeof(unsigned int)]; + utoa(value, buf, base); + *this = buf; +} + +String::String(long value, unsigned char base) +{ + init(); + char buf[2 + 8 * sizeof(long)]; + ltoa(value, buf, base); + *this = buf; +} + +String::String(unsigned long value, unsigned char base) +{ + init(); + char buf[1 + 8 * sizeof(unsigned long)]; + ultoa(value, buf, base); + *this = buf; +} + +String::String(float value, unsigned char decimalPlaces) +{ + init(); + char buf[33]; + *this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf); +} + +String::String(double value, unsigned char decimalPlaces) +{ + init(); + char buf[33]; + *this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf); +} + +String::~String() +{ + free(buffer); +} + +/*********************************************/ +/* Memory Management */ +/*********************************************/ + +inline void String::init(void) +{ + buffer = NULL; + capacity = 0; + len = 0; +} + +void String::invalidate(void) +{ + if (buffer) free(buffer); + buffer = NULL; + capacity = len = 0; +} + +unsigned char String::reserve(unsigned int size) +{ + if (buffer && capacity >= size) return 1; + if (changeBuffer(size)) { + if (len == 0) buffer[0] = 0; + return 1; + } + return 0; +} + +unsigned char String::changeBuffer(unsigned int maxStrLen) +{ + char *newbuffer = (char *)realloc(buffer, maxStrLen + 1); + if (newbuffer) { + buffer = newbuffer; + capacity = maxStrLen; + return 1; + } + return 0; +} + +/*********************************************/ +/* Copy and Move */ +/*********************************************/ + +String & String::copy(const char *cstr, unsigned int length) +{ + if (!reserve(length)) { + invalidate(); + return *this; + } + len = length; + strcpy(buffer, cstr); + return *this; +} + +String & String::copy(const __FlashStringHelper *pstr, unsigned int length) +{ + if (!reserve(length)) { + invalidate(); + return *this; + } + len = length; + strcpy_P(buffer, (PGM_P)pstr); + return *this; +} + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +void String::move(String &rhs) +{ + if (buffer) { + if (capacity >= rhs.len) { + strcpy(buffer, rhs.buffer); + len = rhs.len; + rhs.len = 0; + return; + } else { + free(buffer); + } + } + buffer = rhs.buffer; + capacity = rhs.capacity; + len = rhs.len; + rhs.buffer = NULL; + rhs.capacity = 0; + rhs.len = 0; +} +#endif + +String & String::operator = (const String &rhs) +{ + if (this == &rhs) return *this; + + if (rhs.buffer) copy(rhs.buffer, rhs.len); + else invalidate(); + + return *this; +} + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +String & String::operator = (String &&rval) +{ + if (this != &rval) move(rval); + return *this; +} + +String & String::operator = (StringSumHelper &&rval) +{ + if (this != &rval) move(rval); + return *this; +} +#endif + +String & String::operator = (const char *cstr) +{ + if (cstr) copy(cstr, strlen(cstr)); + else invalidate(); + + return *this; +} + +String & String::operator = (const __FlashStringHelper *pstr) +{ + if (pstr) copy(pstr, strlen_P((PGM_P)pstr)); + else invalidate(); + + return *this; +} + +/*********************************************/ +/* concat */ +/*********************************************/ + +unsigned char String::concat(const String &s) +{ + return concat(s.buffer, s.len); +} + +unsigned char String::concat(const char *cstr, unsigned int length) +{ + unsigned int newlen = len + length; + if (!cstr) return 0; + if (length == 0) return 1; + if (!reserve(newlen)) return 0; + strcpy(buffer + len, cstr); + len = newlen; + return 1; +} + +unsigned char String::concat(const char *cstr) +{ + if (!cstr) return 0; + return concat(cstr, strlen(cstr)); +} + +unsigned char String::concat(char c) +{ + char buf[2]; + buf[0] = c; + buf[1] = 0; + return concat(buf, 1); +} + +unsigned char String::concat(unsigned char num) +{ + char buf[1 + 3 * sizeof(unsigned char)]; + itoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +unsigned char String::concat(int num) +{ + char buf[2 + 3 * sizeof(int)]; + itoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +unsigned char String::concat(unsigned int num) +{ + char buf[1 + 3 * sizeof(unsigned int)]; + utoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +unsigned char String::concat(long num) +{ + char buf[2 + 3 * sizeof(long)]; + ltoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +unsigned char String::concat(unsigned long num) +{ + char buf[1 + 3 * sizeof(unsigned long)]; + ultoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +unsigned char String::concat(float num) +{ + char buf[20]; + char* string = dtostrf(num, 4, 2, buf); + return concat(string, strlen(string)); +} + +unsigned char String::concat(double num) +{ + char buf[20]; + char* string = dtostrf(num, 4, 2, buf); + return concat(string, strlen(string)); +} + +unsigned char String::concat(const __FlashStringHelper * str) +{ + if (!str) return 0; + int length = strlen_P((const char *) str); + if (length == 0) return 1; + unsigned int newlen = len + length; + if (!reserve(newlen)) return 0; + strcpy_P(buffer + len, (const char *) str); + len = newlen; + return 1; +} + +/*********************************************/ +/* Concatenate */ +/*********************************************/ + +StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(rhs.buffer, rhs.len)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr) +{ + StringSumHelper &a = const_cast(lhs); + if (!cstr || !a.concat(cstr, strlen(cstr))) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, char c) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(c)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, int num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, long num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, float num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, double num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(rhs)) a.invalidate(); + return a; +} + +/*********************************************/ +/* Comparison */ +/*********************************************/ + +int String::compareTo(const String &s) const +{ + if (!buffer || !s.buffer) { + if (s.buffer && s.len > 0) return 0 - *(unsigned char *)s.buffer; + if (buffer && len > 0) return *(unsigned char *)buffer; + return 0; + } + return strcmp(buffer, s.buffer); +} + +unsigned char String::equals(const String &s2) const +{ + return (len == s2.len && compareTo(s2) == 0); +} + +unsigned char String::equals(const char *cstr) const +{ + if (len == 0) return (cstr == NULL || *cstr == 0); + if (cstr == NULL) return buffer[0] == 0; + return strcmp(buffer, cstr) == 0; +} + +unsigned char String::operator<(const String &rhs) const +{ + return compareTo(rhs) < 0; +} + +unsigned char String::operator>(const String &rhs) const +{ + return compareTo(rhs) > 0; +} + +unsigned char String::operator<=(const String &rhs) const +{ + return compareTo(rhs) <= 0; +} + +unsigned char String::operator>=(const String &rhs) const +{ + return compareTo(rhs) >= 0; +} + +unsigned char String::equalsIgnoreCase( const String &s2 ) const +{ + if (this == &s2) return 1; + if (len != s2.len) return 0; + if (len == 0) return 1; + const char *p1 = buffer; + const char *p2 = s2.buffer; + while (*p1) { + if (tolower(*p1++) != tolower(*p2++)) return 0; + } + return 1; +} + +unsigned char String::startsWith( const String &s2 ) const +{ + if (len < s2.len) return 0; + return startsWith(s2, 0); +} + +unsigned char String::startsWith( const String &s2, unsigned int offset ) const +{ + if (offset > len - s2.len || !buffer || !s2.buffer) return 0; + return strncmp( &buffer[offset], s2.buffer, s2.len ) == 0; +} + +unsigned char String::endsWith( const String &s2 ) const +{ + if ( len < s2.len || !buffer || !s2.buffer) return 0; + return strcmp(&buffer[len - s2.len], s2.buffer) == 0; +} + +/*********************************************/ +/* Character Access */ +/*********************************************/ + +char String::charAt(unsigned int loc) const +{ + return operator[](loc); +} + +void String::setCharAt(unsigned int loc, char c) +{ + if (loc < len) buffer[loc] = c; +} + +char & String::operator[](unsigned int index) +{ + static char dummy_writable_char; + if (index >= len || !buffer) { + dummy_writable_char = 0; + return dummy_writable_char; + } + return buffer[index]; +} + +char String::operator[]( unsigned int index ) const +{ + if (index >= len || !buffer) return 0; + return buffer[index]; +} + +void String::getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index) const +{ + if (!bufsize || !buf) return; + if (index >= len) { + buf[0] = 0; + return; + } + unsigned int n = bufsize - 1; + if (n > len - index) n = len - index; + strncpy((char *)buf, buffer + index, n); + buf[n] = 0; +} + +/*********************************************/ +/* Search */ +/*********************************************/ + +int String::indexOf(char c) const +{ + return indexOf(c, 0); +} + +int String::indexOf( char ch, unsigned int fromIndex ) const +{ + if (fromIndex >= len) return -1; + const char* temp = strchr(buffer + fromIndex, ch); + if (temp == NULL) return -1; + return temp - buffer; +} + +int String::indexOf(const String &s2) const +{ + return indexOf(s2, 0); +} + +int String::indexOf(const String &s2, unsigned int fromIndex) const +{ + if (fromIndex >= len) return -1; + const char *found = strstr(buffer + fromIndex, s2.buffer); + if (found == NULL) return -1; + return found - buffer; +} + +int String::lastIndexOf( char theChar ) const +{ + return lastIndexOf(theChar, len - 1); +} + +int String::lastIndexOf(char ch, unsigned int fromIndex) const +{ + if (fromIndex >= len) return -1; + char tempchar = buffer[fromIndex + 1]; + buffer[fromIndex + 1] = '\0'; + char* temp = strrchr( buffer, ch ); + buffer[fromIndex + 1] = tempchar; + if (temp == NULL) return -1; + return temp - buffer; +} + +int String::lastIndexOf(const String &s2) const +{ + return lastIndexOf(s2, len - s2.len); +} + +int String::lastIndexOf(const String &s2, unsigned int fromIndex) const +{ + if (s2.len == 0 || len == 0 || s2.len > len) return -1; + if (fromIndex >= len) fromIndex = len - 1; + int found = -1; + for (char *p = buffer; p <= buffer + fromIndex; p++) { + p = strstr(p, s2.buffer); + if (!p) break; + if ((unsigned int)(p - buffer) <= fromIndex) found = p - buffer; + } + return found; +} + +String String::substring(unsigned int left, unsigned int right) const +{ + if (left > right) { + unsigned int temp = right; + right = left; + left = temp; + } + String out; + if (left > len) return out; + if (right > len) right = len; + char temp = buffer[right]; // save the replaced character + buffer[right] = '\0'; + out = buffer + left; // pointer arithmetic + buffer[right] = temp; //restore character + return out; +} + +/*********************************************/ +/* Modification */ +/*********************************************/ + +void String::replace(char find, char replace) +{ + if (!buffer) return; + for (char *p = buffer; *p; p++) { + if (*p == find) *p = replace; + } +} + +void String::replace(const String& find, const String& replace) +{ + if (len == 0 || find.len == 0) return; + int diff = replace.len - find.len; + char *readFrom = buffer; + char *foundAt; + if (diff == 0) { + while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { + memcpy(foundAt, replace.buffer, replace.len); + readFrom = foundAt + replace.len; + } + } else if (diff < 0) { + char *writeTo = buffer; + while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { + unsigned int n = foundAt - readFrom; + memcpy(writeTo, readFrom, n); + writeTo += n; + memcpy(writeTo, replace.buffer, replace.len); + writeTo += replace.len; + readFrom = foundAt + find.len; + len += diff; + } + strcpy(writeTo, readFrom); + } else { + unsigned int size = len; // compute size needed for result + while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { + readFrom = foundAt + find.len; + size += diff; + } + if (size == len) return; + if (size > capacity && !changeBuffer(size)) return; // XXX: tell user! + int index = len - 1; + while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) { + readFrom = buffer + index + find.len; + memmove(readFrom + diff, readFrom, len - (readFrom - buffer)); + len += diff; + buffer[len] = 0; + memcpy(buffer + index, replace.buffer, replace.len); + index--; + } + } +} + +void String::remove(unsigned int index){ + if (index >= len) { return; } + int count = len - index; + remove(index, count); +} + +void String::remove(unsigned int index, unsigned int count){ + if (index >= len) { return; } + if (count <= 0) { return; } + if (index + count > len) { count = len - index; } + char *writeTo = buffer + index; + len = len - count; + strncpy(writeTo, buffer + index + count,len - index); + buffer[len] = 0; +} + +void String::toLowerCase(void) +{ + if (!buffer) return; + for (char *p = buffer; *p; p++) { + *p = tolower(*p); + } +} + +void String::toUpperCase(void) +{ + if (!buffer) return; + for (char *p = buffer; *p; p++) { + *p = toupper(*p); + } +} + +void String::trim(void) +{ + if (!buffer || len == 0) return; + char *begin = buffer; + while (isspace(*begin)) begin++; + char *end = buffer + len - 1; + while (isspace(*end) && end >= begin) end--; + len = end + 1 - begin; + if (begin > buffer) memcpy(buffer, begin, len); + buffer[len] = 0; +} + +/*********************************************/ +/* Parsing / Conversion */ +/*********************************************/ + +long String::toInt(void) const +{ + if (buffer) return atol(buffer); + return 0; +} + +float String::toFloat(void) const +{ + if (buffer) return float(atof(buffer)); + return 0; +} diff --git a/hardware/arduino/mtk/cores/arduino/WString.h b/hardware/arduino/mtk/cores/arduino/WString.h new file mode 100644 index 00000000..74024309 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/WString.h @@ -0,0 +1,224 @@ +/* + WString.h - String library for Wiring & Arduino + ...mostly rewritten by Paul Stoffregen... + Copyright (c) 2009-10 Hernando Barragan. All right reserved. + Copyright 2011, Paul Stoffregen, paul@pjrc.com + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef String_class_h +#define String_class_h +#ifdef __cplusplus + +#include +#include +#include +#include + +// When compiling programs with this class, the following gcc parameters +// dramatically increase performance and memory (RAM) efficiency, typically +// with little or no increase in code size. +// -felide-constructors +// -std=c++0x + +class __FlashStringHelper; +#define F(string_literal) (reinterpret_cast(PSTR(string_literal))) + +// An inherited class for holding the result of a concatenation. These +// result objects are assumed to be writable by subsequent concatenations. +class StringSumHelper; + +// The string class +class String +{ + // use a function pointer to allow for "if (s)" without the + // complications of an operator bool(). for more information, see: + // http://www.artima.com/cppsource/safebool.html + typedef void (String::*StringIfHelperType)() const; + void StringIfHelper() const {} + +public: + // constructors + // creates a copy of the initial value. + // if the initial value is null or invalid, or if memory allocation + // fails, the string will be marked as invalid (i.e. "if (s)" will + // be false). + String(const char *cstr = ""); + String(const String &str); + String(const __FlashStringHelper *str); + #ifdef __GXX_EXPERIMENTAL_CXX0X__ + String(String &&rval); + String(StringSumHelper &&rval); + #endif + explicit String(char c); + explicit String(unsigned char, unsigned char base=10); + explicit String(int, unsigned char base=10); + explicit String(unsigned int, unsigned char base=10); + explicit String(long, unsigned char base=10); + explicit String(unsigned long, unsigned char base=10); + explicit String(float, unsigned char decimalPlaces=2); + explicit String(double, unsigned char decimalPlaces=2); + ~String(void); + + // memory management + // return true on success, false on failure (in which case, the string + // is left unchanged). reserve(0), if successful, will validate an + // invalid string (i.e., "if (s)" will be true afterwards) + unsigned char reserve(unsigned int size); + inline unsigned int length(void) const {return len;} + + // creates a copy of the assigned value. if the value is null or + // invalid, or if the memory allocation fails, the string will be + // marked as invalid ("if (s)" will be false). + String & operator = (const String &rhs); + String & operator = (const char *cstr); + String & operator = (const __FlashStringHelper *str); + #ifdef __GXX_EXPERIMENTAL_CXX0X__ + String & operator = (String &&rval); + String & operator = (StringSumHelper &&rval); + #endif + + // concatenate (works w/ built-in types) + + // returns true on success, false on failure (in which case, the string + // is left unchanged). if the argument is null or invalid, the + // concatenation is considered unsucessful. + unsigned char concat(const String &str); + unsigned char concat(const char *cstr); + unsigned char concat(char c); + unsigned char concat(unsigned char c); + unsigned char concat(int num); + unsigned char concat(unsigned int num); + unsigned char concat(long num); + unsigned char concat(unsigned long num); + unsigned char concat(float num); + unsigned char concat(double num); + unsigned char concat(const __FlashStringHelper * str); + + // if there's not enough memory for the concatenated value, the string + // will be left unchanged (but this isn't signalled in any way) + String & operator += (const String &rhs) {concat(rhs); return (*this);} + String & operator += (const char *cstr) {concat(cstr); return (*this);} + String & operator += (char c) {concat(c); return (*this);} + String & operator += (unsigned char num) {concat(num); return (*this);} + String & operator += (int num) {concat(num); return (*this);} + String & operator += (unsigned int num) {concat(num); return (*this);} + String & operator += (long num) {concat(num); return (*this);} + String & operator += (unsigned long num) {concat(num); return (*this);} + String & operator += (float num) {concat(num); return (*this);} + String & operator += (double num) {concat(num); return (*this);} + String & operator += (const __FlashStringHelper *str){concat(str); return (*this);} + + friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs); + friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr); + friend StringSumHelper & operator + (const StringSumHelper &lhs, char c); + friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, int num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, long num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, float num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, double num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs); + + // comparison (only works w/ Strings and "strings") + operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; } + int compareTo(const String &s) const; + unsigned char equals(const String &s) const; + unsigned char equals(const char *cstr) const; + unsigned char operator == (const String &rhs) const {return equals(rhs);} + unsigned char operator == (const char *cstr) const {return equals(cstr);} + unsigned char operator != (const String &rhs) const {return !equals(rhs);} + unsigned char operator != (const char *cstr) const {return !equals(cstr);} + unsigned char operator < (const String &rhs) const; + unsigned char operator > (const String &rhs) const; + unsigned char operator <= (const String &rhs) const; + unsigned char operator >= (const String &rhs) const; + unsigned char equalsIgnoreCase(const String &s) const; + unsigned char startsWith( const String &prefix) const; + unsigned char startsWith(const String &prefix, unsigned int offset) const; + unsigned char endsWith(const String &suffix) const; + + // character acccess + char charAt(unsigned int index) const; + void setCharAt(unsigned int index, char c); + char operator [] (unsigned int index) const; + char& operator [] (unsigned int index); + void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const; + void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const + {getBytes((unsigned char *)buf, bufsize, index);} + const char * c_str() const { return buffer; } + + // search + int indexOf( char ch ) const; + int indexOf( char ch, unsigned int fromIndex ) const; + int indexOf( const String &str ) const; + int indexOf( const String &str, unsigned int fromIndex ) const; + int lastIndexOf( char ch ) const; + int lastIndexOf( char ch, unsigned int fromIndex ) const; + int lastIndexOf( const String &str ) const; + int lastIndexOf( const String &str, unsigned int fromIndex ) const; + String substring( unsigned int beginIndex ) const { return substring(beginIndex, len); }; + String substring( unsigned int beginIndex, unsigned int endIndex ) const; + + // modification + void replace(char find, char replace); + void replace(const String& find, const String& replace); + void remove(unsigned int index); + void remove(unsigned int index, unsigned int count); + void toLowerCase(void); + void toUpperCase(void); + void trim(void); + + // parsing/conversion + long toInt(void) const; + float toFloat(void) const; + +protected: + char *buffer; // the actual char array + unsigned int capacity; // the array length minus one (for the '\0') + unsigned int len; // the String length (not counting the '\0') +protected: + void init(void); + void invalidate(void); + unsigned char changeBuffer(unsigned int maxStrLen); + unsigned char concat(const char *cstr, unsigned int length); + + // copy and move + String & copy(const char *cstr, unsigned int length); + String & copy(const __FlashStringHelper *pstr, unsigned int length); + #ifdef __GXX_EXPERIMENTAL_CXX0X__ + void move(String &rhs); + #endif +}; + +class StringSumHelper : public String +{ +public: + StringSumHelper(const String &s) : String(s) {} + StringSumHelper(const char *p) : String(p) {} + StringSumHelper(char c) : String(c) {} + StringSumHelper(unsigned char num) : String(num) {} + StringSumHelper(int num) : String(num) {} + StringSumHelper(unsigned int num) : String(num) {} + StringSumHelper(long num) : String(num) {} + StringSumHelper(unsigned long num) : String(num) {} + StringSumHelper(float num) : String(num) {} + StringSumHelper(double num) : String(num) {} +}; + +#endif // __cplusplus +#endif // String_class_h diff --git a/hardware/arduino/mtk/cores/arduino/avr/dtostrf.c b/hardware/arduino/mtk/cores/arduino/avr/dtostrf.c new file mode 100644 index 00000000..7f90154f --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/avr/dtostrf.c @@ -0,0 +1,29 @@ +/* + dtostrf - Emulation for dtostrf function from avr-libc + Copyright (c) 2013 Arduino. All rights reserved. + Written by Cristian Maglie + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include + +char *dtostrf (double val, signed char width, unsigned char prec, char *sout) { + char fmt[20]; + sprintf(fmt, "%%%d.%df", width, prec); + sprintf(sout, fmt, val); + return sout; +} + diff --git a/hardware/arduino/mtk/cores/arduino/avr/dtostrf.h b/hardware/arduino/mtk/cores/arduino/avr/dtostrf.h new file mode 100644 index 00000000..0bf9f57c --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/avr/dtostrf.h @@ -0,0 +1,29 @@ +/* + dtostrf - Emulation for dtostrf function from avr-libc + Copyright (c) 2013 Arduino. All rights reserved. + Written by Cristian Maglie + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +char *dtostrf (double val, signed char width, unsigned char prec, char *sout); + +#ifdef __cplusplus +} +#endif diff --git a/hardware/arduino/mtk/cores/arduino/avr/interrupt.h b/hardware/arduino/mtk/cores/arduino/avr/interrupt.h new file mode 100644 index 00000000..e69de29b diff --git a/hardware/arduino/mtk/cores/arduino/avr/pgmspace.h b/hardware/arduino/mtk/cores/arduino/avr/pgmspace.h new file mode 100644 index 00000000..9b344c9b --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/avr/pgmspace.h @@ -0,0 +1,44 @@ +#ifndef __PGMSPACE_H_ +#define __PGMSPACE_H_ 1 + +#include + +#define PROGMEM +#define PGM_P const char * +#define PSTR(str) (str) + +#define _SFR_BYTE(n) (n) + +typedef void prog_void; +typedef char prog_char; +typedef unsigned char prog_uchar; +typedef int8_t prog_int8_t; +typedef uint8_t prog_uint8_t; +typedef int16_t prog_int16_t; +typedef uint16_t prog_uint16_t; +typedef int32_t prog_int32_t; +typedef uint32_t prog_uint32_t; + +#define memcpy_P(dest, src, num) memcpy((dest), (src), (num)) +#define strcpy_P(dest, src) strcpy((dest), (src)) +#define strcat_P(dest, src) strcat((dest), (src)) +#define strcmp_P(a, b) strcmp((a), (b)) +#define strstr_P(a, b) strstr((a), (b)) +#define strlen_P(a) strlen((a)) +#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) + +#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) +#define pgm_read_word(addr) (*(const unsigned short *)(addr)) +#define pgm_read_dword(addr) (*(const unsigned long *)(addr)) +#define pgm_read_float(addr) (*(const float *)(addr)) + +#define pgm_read_byte_near(addr) pgm_read_byte(addr) +#define pgm_read_word_near(addr) pgm_read_word(addr) +#define pgm_read_dword_near(addr) pgm_read_dword(addr) +#define pgm_read_float_near(addr) pgm_read_float(addr) +#define pgm_read_byte_far(addr) pgm_read_byte(addr) +#define pgm_read_word_far(addr) pgm_read_word(addr) +#define pgm_read_dword_far(addr) pgm_read_dword(addr) +#define pgm_read_float_far(addr) pgm_read_float(addr) + +#endif diff --git a/hardware/arduino/mtk/cores/arduino/binary.h b/hardware/arduino/mtk/cores/arduino/binary.h new file mode 100644 index 00000000..aec4c733 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/binary.h @@ -0,0 +1,534 @@ +/* + binary.h - Definitions for binary constants + Copyright (c) 2006 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Binary_h +#define Binary_h + +#define B0 0 +#define B00 0 +#define B000 0 +#define B0000 0 +#define B00000 0 +#define B000000 0 +#define B0000000 0 +#define B00000000 0 +#define B1 1 +#define B01 1 +#define B001 1 +#define B0001 1 +#define B00001 1 +#define B000001 1 +#define B0000001 1 +#define B00000001 1 +#define B10 2 +#define B010 2 +#define B0010 2 +#define B00010 2 +#define B000010 2 +#define B0000010 2 +#define B00000010 2 +#define B11 3 +#define B011 3 +#define B0011 3 +#define B00011 3 +#define B000011 3 +#define B0000011 3 +#define B00000011 3 +#define B100 4 +#define B0100 4 +#define B00100 4 +#define B000100 4 +#define B0000100 4 +#define B00000100 4 +#define B101 5 +#define B0101 5 +#define B00101 5 +#define B000101 5 +#define B0000101 5 +#define B00000101 5 +#define B110 6 +#define B0110 6 +#define B00110 6 +#define B000110 6 +#define B0000110 6 +#define B00000110 6 +#define B111 7 +#define B0111 7 +#define B00111 7 +#define B000111 7 +#define B0000111 7 +#define B00000111 7 +#define B1000 8 +#define B01000 8 +#define B001000 8 +#define B0001000 8 +#define B00001000 8 +#define B1001 9 +#define B01001 9 +#define B001001 9 +#define B0001001 9 +#define B00001001 9 +#define B1010 10 +#define B01010 10 +#define B001010 10 +#define B0001010 10 +#define B00001010 10 +#define B1011 11 +#define B01011 11 +#define B001011 11 +#define B0001011 11 +#define B00001011 11 +#define B1100 12 +#define B01100 12 +#define B001100 12 +#define B0001100 12 +#define B00001100 12 +#define B1101 13 +#define B01101 13 +#define B001101 13 +#define B0001101 13 +#define B00001101 13 +#define B1110 14 +#define B01110 14 +#define B001110 14 +#define B0001110 14 +#define B00001110 14 +#define B1111 15 +#define B01111 15 +#define B001111 15 +#define B0001111 15 +#define B00001111 15 +#define B10000 16 +#define B010000 16 +#define B0010000 16 +#define B00010000 16 +#define B10001 17 +#define B010001 17 +#define B0010001 17 +#define B00010001 17 +#define B10010 18 +#define B010010 18 +#define B0010010 18 +#define B00010010 18 +#define B10011 19 +#define B010011 19 +#define B0010011 19 +#define B00010011 19 +#define B10100 20 +#define B010100 20 +#define B0010100 20 +#define B00010100 20 +#define B10101 21 +#define B010101 21 +#define B0010101 21 +#define B00010101 21 +#define B10110 22 +#define B010110 22 +#define B0010110 22 +#define B00010110 22 +#define B10111 23 +#define B010111 23 +#define B0010111 23 +#define B00010111 23 +#define B11000 24 +#define B011000 24 +#define B0011000 24 +#define B00011000 24 +#define B11001 25 +#define B011001 25 +#define B0011001 25 +#define B00011001 25 +#define B11010 26 +#define B011010 26 +#define B0011010 26 +#define B00011010 26 +#define B11011 27 +#define B011011 27 +#define B0011011 27 +#define B00011011 27 +#define B11100 28 +#define B011100 28 +#define B0011100 28 +#define B00011100 28 +#define B11101 29 +#define B011101 29 +#define B0011101 29 +#define B00011101 29 +#define B11110 30 +#define B011110 30 +#define B0011110 30 +#define B00011110 30 +#define B11111 31 +#define B011111 31 +#define B0011111 31 +#define B00011111 31 +#define B100000 32 +#define B0100000 32 +#define B00100000 32 +#define B100001 33 +#define B0100001 33 +#define B00100001 33 +#define B100010 34 +#define B0100010 34 +#define B00100010 34 +#define B100011 35 +#define B0100011 35 +#define B00100011 35 +#define B100100 36 +#define B0100100 36 +#define B00100100 36 +#define B100101 37 +#define B0100101 37 +#define B00100101 37 +#define B100110 38 +#define B0100110 38 +#define B00100110 38 +#define B100111 39 +#define B0100111 39 +#define B00100111 39 +#define B101000 40 +#define B0101000 40 +#define B00101000 40 +#define B101001 41 +#define B0101001 41 +#define B00101001 41 +#define B101010 42 +#define B0101010 42 +#define B00101010 42 +#define B101011 43 +#define B0101011 43 +#define B00101011 43 +#define B101100 44 +#define B0101100 44 +#define B00101100 44 +#define B101101 45 +#define B0101101 45 +#define B00101101 45 +#define B101110 46 +#define B0101110 46 +#define B00101110 46 +#define B101111 47 +#define B0101111 47 +#define B00101111 47 +#define B110000 48 +#define B0110000 48 +#define B00110000 48 +#define B110001 49 +#define B0110001 49 +#define B00110001 49 +#define B110010 50 +#define B0110010 50 +#define B00110010 50 +#define B110011 51 +#define B0110011 51 +#define B00110011 51 +#define B110100 52 +#define B0110100 52 +#define B00110100 52 +#define B110101 53 +#define B0110101 53 +#define B00110101 53 +#define B110110 54 +#define B0110110 54 +#define B00110110 54 +#define B110111 55 +#define B0110111 55 +#define B00110111 55 +#define B111000 56 +#define B0111000 56 +#define B00111000 56 +#define B111001 57 +#define B0111001 57 +#define B00111001 57 +#define B111010 58 +#define B0111010 58 +#define B00111010 58 +#define B111011 59 +#define B0111011 59 +#define B00111011 59 +#define B111100 60 +#define B0111100 60 +#define B00111100 60 +#define B111101 61 +#define B0111101 61 +#define B00111101 61 +#define B111110 62 +#define B0111110 62 +#define B00111110 62 +#define B111111 63 +#define B0111111 63 +#define B00111111 63 +#define B1000000 64 +#define B01000000 64 +#define B1000001 65 +#define B01000001 65 +#define B1000010 66 +#define B01000010 66 +#define B1000011 67 +#define B01000011 67 +#define B1000100 68 +#define B01000100 68 +#define B1000101 69 +#define B01000101 69 +#define B1000110 70 +#define B01000110 70 +#define B1000111 71 +#define B01000111 71 +#define B1001000 72 +#define B01001000 72 +#define B1001001 73 +#define B01001001 73 +#define B1001010 74 +#define B01001010 74 +#define B1001011 75 +#define B01001011 75 +#define B1001100 76 +#define B01001100 76 +#define B1001101 77 +#define B01001101 77 +#define B1001110 78 +#define B01001110 78 +#define B1001111 79 +#define B01001111 79 +#define B1010000 80 +#define B01010000 80 +#define B1010001 81 +#define B01010001 81 +#define B1010010 82 +#define B01010010 82 +#define B1010011 83 +#define B01010011 83 +#define B1010100 84 +#define B01010100 84 +#define B1010101 85 +#define B01010101 85 +#define B1010110 86 +#define B01010110 86 +#define B1010111 87 +#define B01010111 87 +#define B1011000 88 +#define B01011000 88 +#define B1011001 89 +#define B01011001 89 +#define B1011010 90 +#define B01011010 90 +#define B1011011 91 +#define B01011011 91 +#define B1011100 92 +#define B01011100 92 +#define B1011101 93 +#define B01011101 93 +#define B1011110 94 +#define B01011110 94 +#define B1011111 95 +#define B01011111 95 +#define B1100000 96 +#define B01100000 96 +#define B1100001 97 +#define B01100001 97 +#define B1100010 98 +#define B01100010 98 +#define B1100011 99 +#define B01100011 99 +#define B1100100 100 +#define B01100100 100 +#define B1100101 101 +#define B01100101 101 +#define B1100110 102 +#define B01100110 102 +#define B1100111 103 +#define B01100111 103 +#define B1101000 104 +#define B01101000 104 +#define B1101001 105 +#define B01101001 105 +#define B1101010 106 +#define B01101010 106 +#define B1101011 107 +#define B01101011 107 +#define B1101100 108 +#define B01101100 108 +#define B1101101 109 +#define B01101101 109 +#define B1101110 110 +#define B01101110 110 +#define B1101111 111 +#define B01101111 111 +#define B1110000 112 +#define B01110000 112 +#define B1110001 113 +#define B01110001 113 +#define B1110010 114 +#define B01110010 114 +#define B1110011 115 +#define B01110011 115 +#define B1110100 116 +#define B01110100 116 +#define B1110101 117 +#define B01110101 117 +#define B1110110 118 +#define B01110110 118 +#define B1110111 119 +#define B01110111 119 +#define B1111000 120 +#define B01111000 120 +#define B1111001 121 +#define B01111001 121 +#define B1111010 122 +#define B01111010 122 +#define B1111011 123 +#define B01111011 123 +#define B1111100 124 +#define B01111100 124 +#define B1111101 125 +#define B01111101 125 +#define B1111110 126 +#define B01111110 126 +#define B1111111 127 +#define B01111111 127 +#define B10000000 128 +#define B10000001 129 +#define B10000010 130 +#define B10000011 131 +#define B10000100 132 +#define B10000101 133 +#define B10000110 134 +#define B10000111 135 +#define B10001000 136 +#define B10001001 137 +#define B10001010 138 +#define B10001011 139 +#define B10001100 140 +#define B10001101 141 +#define B10001110 142 +#define B10001111 143 +#define B10010000 144 +#define B10010001 145 +#define B10010010 146 +#define B10010011 147 +#define B10010100 148 +#define B10010101 149 +#define B10010110 150 +#define B10010111 151 +#define B10011000 152 +#define B10011001 153 +#define B10011010 154 +#define B10011011 155 +#define B10011100 156 +#define B10011101 157 +#define B10011110 158 +#define B10011111 159 +#define B10100000 160 +#define B10100001 161 +#define B10100010 162 +#define B10100011 163 +#define B10100100 164 +#define B10100101 165 +#define B10100110 166 +#define B10100111 167 +#define B10101000 168 +#define B10101001 169 +#define B10101010 170 +#define B10101011 171 +#define B10101100 172 +#define B10101101 173 +#define B10101110 174 +#define B10101111 175 +#define B10110000 176 +#define B10110001 177 +#define B10110010 178 +#define B10110011 179 +#define B10110100 180 +#define B10110101 181 +#define B10110110 182 +#define B10110111 183 +#define B10111000 184 +#define B10111001 185 +#define B10111010 186 +#define B10111011 187 +#define B10111100 188 +#define B10111101 189 +#define B10111110 190 +#define B10111111 191 +#define B11000000 192 +#define B11000001 193 +#define B11000010 194 +#define B11000011 195 +#define B11000100 196 +#define B11000101 197 +#define B11000110 198 +#define B11000111 199 +#define B11001000 200 +#define B11001001 201 +#define B11001010 202 +#define B11001011 203 +#define B11001100 204 +#define B11001101 205 +#define B11001110 206 +#define B11001111 207 +#define B11010000 208 +#define B11010001 209 +#define B11010010 210 +#define B11010011 211 +#define B11010100 212 +#define B11010101 213 +#define B11010110 214 +#define B11010111 215 +#define B11011000 216 +#define B11011001 217 +#define B11011010 218 +#define B11011011 219 +#define B11011100 220 +#define B11011101 221 +#define B11011110 222 +#define B11011111 223 +#define B11100000 224 +#define B11100001 225 +#define B11100010 226 +#define B11100011 227 +#define B11100100 228 +#define B11100101 229 +#define B11100110 230 +#define B11100111 231 +#define B11101000 232 +#define B11101001 233 +#define B11101010 234 +#define B11101011 235 +#define B11101100 236 +#define B11101101 237 +#define B11101110 238 +#define B11101111 239 +#define B11110000 240 +#define B11110001 241 +#define B11110010 242 +#define B11110011 243 +#define B11110100 244 +#define B11110101 245 +#define B11110110 246 +#define B11110111 247 +#define B11111000 248 +#define B11111001 249 +#define B11111010 250 +#define B11111011 251 +#define B11111100 252 +#define B11111101 253 +#define B11111110 254 +#define B11111111 255 + +#endif diff --git a/hardware/arduino/mtk/cores/arduino/cxxabi-compat.cpp b/hardware/arduino/mtk/cores/arduino/cxxabi-compat.cpp new file mode 100644 index 00000000..7370b0be --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/cxxabi-compat.cpp @@ -0,0 +1,26 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +extern "C" void __cxa_pure_virtual(void) ; + +/* We compile with nodefaultlibs, so we need to provide an error + * handler for an empty pure virtual function */ +extern "C" void __cxa_pure_virtual(void) { + while(1) + ; +} diff --git a/hardware/arduino/mtk/cores/arduino/itoa.c b/hardware/arduino/mtk/cores/arduino/itoa.c new file mode 100644 index 00000000..fc357660 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/itoa.c @@ -0,0 +1,170 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "itoa.h" +#include + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +#if 0 +/* reverse: reverse string s in place */ +static void reverse( char s[] ) +{ + int i, j ; + char c ; + + for ( i = 0, j = strlen(s)-1 ; i < j ; i++, j-- ) + { + c = s[i] ; + s[i] = s[j] ; + s[j] = c ; + } +} + +/* itoa: convert n to characters in s */ +extern void itoa( int n, char s[] ) +{ + int i, sign ; + + if ( (sign = n) < 0 ) /* record sign */ + { + n = -n; /* make n positive */ + } + + i = 0; + do + { /* generate digits in reverse order */ + s[i++] = n % 10 + '0'; /* get next digit */ + } while ((n /= 10) > 0) ; /* delete it */ + + if (sign < 0 ) + { + s[i++] = '-'; + } + + s[i] = '\0'; + + reverse( s ) ; +} + +#else + +extern char* itoa( int value, char *string, int radix ) +{ + return ltoa( value, string, radix ) ; +} + +extern char* ltoa( long value, char *string, int radix ) +{ + char tmp[33]; + char *tp = tmp; + long i; + unsigned long v; + int sign; + char *sp; + + if ( string == NULL ) + { + return 0 ; + } + + if (radix > 36 || radix <= 1) + { + return 0 ; + } + + sign = (radix == 10 && value < 0); + if (sign) + { + v = -value; + } + else + { + v = (unsigned long)value; + } + + while (v || tp == tmp) + { + i = v % radix; + v = v / radix; + if (i < 10) + *tp++ = i+'0'; + else + *tp++ = i + 'a' - 10; + } + + sp = string; + + if (sign) + *sp++ = '-'; + while (tp > tmp) + *sp++ = *--tp; + *sp = 0; + + return string; +} + +extern char* utoa( unsigned long value, char *string, int radix ) +{ + return ultoa( value, string, radix ) ; +} + +extern char* ultoa( unsigned long value, char *string, int radix ) +{ + char tmp[33]; + char *tp = tmp; + long i; + unsigned long v = value; + char *sp; + + if ( string == NULL ) + { + return 0; + } + + if (radix > 36 || radix <= 1) + { + return 0; + } + + while (v || tp == tmp) + { + i = v % radix; + v = v / radix; + if (i < 10) + *tp++ = i+'0'; + else + *tp++ = i + 'a' - 10; + } + + sp = string; + + + while (tp > tmp) + *sp++ = *--tp; + *sp = 0; + + return string; +} +#endif /* 0 */ + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/hardware/arduino/mtk/cores/arduino/itoa.h b/hardware/arduino/mtk/cores/arduino/itoa.h new file mode 100644 index 00000000..59af1094 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/itoa.h @@ -0,0 +1,42 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _ITOA_ +#define _ITOA_ + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +#if 0 + +extern void itoa( int n, char s[] ) ; + +#else + +extern char* itoa( int value, char *string, int radix ) ; +extern char* ltoa( long value, char *string, int radix ) ; +extern char* utoa( unsigned long value, char *string, int radix ) ; +extern char* ultoa( unsigned long value, char *string, int radix ) ; +#endif /* 0 */ + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // _ITOA_ diff --git a/hardware/arduino/mtk/cores/arduino/main.cpp b/hardware/arduino/mtk/cores/arduino/main.cpp new file mode 100644 index 00000000..2691f7e8 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/main.cpp @@ -0,0 +1,95 @@ +/* + main.cpp - Main loop for Arduino sketches + Copyright (c) 2005-2013 Arduino Team. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#define ARDUINO_MAIN +#include "Arduino.h" +#include "vmsys.h" +#include "vmthread.h" +#include "vmpromng.h" +#include "vmlog.h" +#include "vmtel.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +extern "C" void vm_thread_change_priority(VM_THREAD_HANDLE thread_handle, VMUINT32 new_priority); + +unsigned char* spi_w_data = NULL; +unsigned char* spi_r_data= NULL; +unsigned char* spi_data_memory= NULL; +vm_call_listener_func g_call_status_callback = NULL; + +void __handle_sysevt(VMINT message, VMINT param) +{ + //vm_log_info("receive msg = %d", message); + if(message == VM_MSG_ARDUINO_CALL) + { + msg_struct* pMsg = (msg_struct*)param; + if(pMsg->remote_func(pMsg->userdata)) + { + //vm_log_info("post signal"); + vm_signal_post(pMsg->signal); + } + return ; + } +} + +void __call_listener_func(vm_call_listener_data* data) +{ + if(g_call_status_callback) + { + g_call_status_callback(data); + } +} + +VMINT32 __arduino_thread(VM_THREAD_HANDLE thread_handle, void* user_data) +{ + init(); + + delay(1); + + //#if defined(USBCON) + // USBDevice.attach(); + //#endif + + setup(); + + for (;;) + { + loop(); + if (serialEventRun) serialEventRun(); + } +} + +/* + * \brief Main entry point of Arduino application + */ +void vm_main( void ) +{ + VM_THREAD_HANDLE handle; + spi_w_data = (unsigned char*)vm_malloc_nc(2); + spi_r_data = (unsigned char*)vm_malloc_nc(2); + spi_data_memory = (unsigned char*)vm_malloc_nc(64*1024); + memset(spi_data_memory,0, 64*1024); + vm_reg_sysevt_callback(__handle_sysevt); + vm_call_reg_listener(__call_listener_func); + handle = vm_thread_create(__arduino_thread, NULL, 0); + vm_thread_change_priority(handle, 245); +} + diff --git a/hardware/arduino/mtk/cores/arduino/message.h b/hardware/arduino/mtk/cores/arduino/message.h new file mode 100644 index 00000000..2e3cf153 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/message.h @@ -0,0 +1,44 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _MESSAGE_ +#define _MESSAGE_ +#include "arduino.h" +#include "vmsys.h" +#include "vmthread.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define VM_MSG_ARDUINO_CALL 3000 + +typedef boolean (*remote_call_ptr)(void* user_data); + +typedef struct _msg_struct +{ + VM_SIGNAL_ID signal; + remote_call_ptr remote_func; + void* userdata; +}msg_struct; + +#ifdef __cplusplus +} +#endif + +#endif /* _MESSAGE_ */ diff --git a/hardware/arduino/mtk/cores/arduino/syscalls.h b/hardware/arduino/mtk/cores/arduino/syscalls.h new file mode 100644 index 00000000..845b4b5d --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/syscalls.h @@ -0,0 +1,60 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/** + * \file syscalls.h + * + * Implementation of newlib syscall. + * + */ + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ +#include +#include +#include +#include + +/*---------------------------------------------------------------------------- + * Exported functions + *----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" { +#endif + +extern caddr_t _sbrk( int incr ) ; + +extern int link( char *cOld, char *cNew ) ; + +extern int _close( int file ) ; + +extern int _fstat( int file, struct stat *st ) ; + +extern int _isatty( int file ) ; + +extern int _lseek( int file, int ptr, int dir ) ; + +extern int _read(int file, char *ptr, int len) ; + +extern int _write( int file, char *ptr, int len ) ; + +#ifdef __cplusplus +} +#endif + diff --git a/hardware/arduino/mtk/cores/arduino/syscalls_mtk.c b/hardware/arduino/mtk/cores/arduino/syscalls_mtk.c new file mode 100644 index 00000000..72d9d9e7 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/syscalls_mtk.c @@ -0,0 +1,222 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/** + * \file syscalls_mtk.c + * + * Implementation of newlib syscall. + * + */ + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + + +#include "syscalls.h" + +#include +#include +//#include "sam.h" +#if defined ( __GNUC__ ) /* GCC CS3 */ + #include + #include +#endif + +#include "vmsys.h" +#include "vmlog.h" +#include "vmdatetime.h" + +/*---------------------------------------------------------------------------- + * Exported variables + *----------------------------------------------------------------------------*/ + +#undef errno +extern int errno ; +extern int _end ; + +unsigned int g_size = 1024*200; +unsigned char * base_address = NULL; + +#define RESERVED_MEMORY_SIZE 270*1024 + +/*---------------------------------------------------------------------------- + * Exported functions + *----------------------------------------------------------------------------*/ +extern void _exit( int status ) ; +extern void _kill( int pid, int sig ) ; +extern int _getpid ( void ) ; + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_get_total_heap_size_t)(void); +_vm_get_total_heap_size_t _vm_get_total_heap_size = NULL; +VMUINT vm_get_total_heap_size(void) +{ + if (NULL == _vm_get_total_heap_size) + _vm_get_total_heap_size = (_vm_get_total_heap_size_t)vm_get_sym_entry((char*)"vm_get_total_heap_size"); + + if (NULL != _vm_get_total_heap_size) + return _vm_get_total_heap_size(); + return 0; +} + +typedef VMINT (*_vm_set_time_t)(vm_time_t* time); +_vm_set_time_t _vm_set_time = NULL; + +VMINT vm_set_time(vm_time_t* time) +{ + if (NULL == _vm_set_time) + _vm_set_time = (_vm_set_time_t)vm_get_sym_entry("vm_set_time"); + + if (NULL != _vm_set_time) + return _vm_set_time(time); + + return (VMINT )-1; +} + +extern caddr_t _sbrk ( int incr ) +{ + static unsigned char *heap = NULL ; + static unsigned char *base = NULL ; + unsigned char *prev_heap ; + + if ( heap == NULL ) + { + base = (unsigned char *)base_address; + if(base == NULL) + { + vm_log_fatal("malloc failed"); + } + else + { + heap = base; + vm_log_info("init memory success"); + } + } + + if (heap + incr > base + g_size) { + vm_log_fatal("memory not enough"); + } + + prev_heap = heap; + + heap += incr ; + + return (caddr_t) prev_heap ; +} + + +extern int link( char *cOld, char *cNew ) +{ + return -1 ; +} + +extern int _close( int file ) +{ + return -1 ; +} + +extern int _fstat( int file, struct stat *st ) +{ + st->st_mode = S_IFCHR ; + + return 0 ; +} + +extern int _isatty( int file ) +{ + return 1 ; +} + +extern int _lseek( int file, int ptr, int dir ) +{ + return 0 ; +} + +extern int _read(int file, char *ptr, int len) +{ + return 0 ; +} + +extern int _write( int file, char *ptr, int len ) +{ + return len ; +} + +extern void _exit( int status ) +{ + for ( ; ; ) ; +} + +extern void _kill( int pid, int sig ) +{ + return ; +} + +extern int _getpid ( void ) +{ + return -1 ; +} + +int __cxa_guard_acquire(int *g) {return !*(char *)(g);}; +void __cxa_guard_release (int *g) {*(char *)g = 1;}; + +typedef void (**__init_array) (void); + +void __libc_init_array(void); + +void gcc_entry(unsigned int entry, unsigned int init_array_start, unsigned int count) +{ + __init_array ptr; + int i; + VMUINT size = 0; + + vm_get_sym_entry = (vm_get_sym_entry_t)entry; + + size = vm_get_total_heap_size(); + + if(size == 0) + { + base_address = vm_malloc(g_size); + vm_log_info("defalut heap size = %d", g_size); + } + else + { + if(size > RESERVED_MEMORY_SIZE) + size -= RESERVED_MEMORY_SIZE; + + base_address = vm_malloc(size); + vm_log_info("heap size = %d", size); + g_size = size; +} + + vm_log_info("init lib arrays"); + + __libc_init_array(); + + ptr = (__init_array)init_array_start; + + for (i = 1; i < count; i++) + { + ptr[i](); + } + vm_main(); +} + diff --git a/hardware/arduino/mtk/cores/arduino/wiring.c b/hardware/arduino/mtk/cores/arduino/wiring.c new file mode 100644 index 00000000..ea6ca00c --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/wiring.c @@ -0,0 +1,92 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "Arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + +boolean no_interrupt = 1; + +uint32_t millis( void ) +{ +// todo: ensure no interrupts + return vm_get_tick_count() ; +} + +// Interrupt-compatible version of micros +// Theory: repeatedly take readings of SysTick counter, millis counter and SysTick interrupt pending flag. +// When it appears that millis counter and pending is stable and SysTick hasn't rolled over, use these +// values to calculate micros. If there is a pending SysTick, add one to the millis counter in the calculation. +uint32_t micros( void ) +{ + return vm_ust_get_current_time(); +} + +// original function: +// uint32_t micros( void ) +// { +// uint32_t ticks ; +// uint32_t count ; +// +// SysTick->CTRL; +// do { +// ticks = SysTick->VAL; +// count = GetTickCount(); +// } while (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk); +// +// return count * 1000 + (SysTick->LOAD + 1 - ticks) / (SystemCoreClock/1000000) ; +// } + + +void delay( uint32_t ms ) +{ + vm_thread_sleep(ms); +} + +void delayMicroseconds(uint32_t usec){ + VMUINT32 timeStop; + VMUINT32 timeStart; + VMUINT32 Freq = 0; + + timeStart = vm_ust_get_current_time(); + while( Freq < usec) + { + timeStop = vm_ust_get_current_time(); + Freq = timeStop - timeStart + 1; + } +} +void interrupts(void) +{ + no_interrupt = 0; +} + +void noInterrupts(void ) +{ + no_interrupt = 1; +} + +boolean noStopInterrupts(void) +{ + return no_interrupt; +} + +#ifdef __cplusplus +} +#endif diff --git a/hardware/arduino/mtk/cores/arduino/wiring.h b/hardware/arduino/mtk/cores/arduino/wiring.h new file mode 100644 index 00000000..e3a573bb --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/wiring.h @@ -0,0 +1,139 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _WIRING_ +#define _WIRING_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * + */ +extern void init( void ) ; + +/***************************************************************************** + * FUNCTION + * millis + * DESCRIPTION + * Time from returning to LinkIt to enable the current program to the present(unit:ms). + * PARAMETERS + * none + * RETURNS + * uint32_t:Time from LinkIt enabling the current program to the present in ms. + * EXAMPLE + * + * uint32_t t; + * void setup() + * { + * + * } + * void loop() + * { + * t = millis(); + * delay(2000); + * } + * +*****************************************************************************/ +extern uint32_t millis( void ) ; + +/***************************************************************************** + * FUNCTION + * micros + * DESCRIPTION + * Time from returning to LinkIt to enable the current program to the present(unit:us) + * PARAMETERS + * none + * RETURNS + * uint32_t:Time from LinkIt enabling the current program to the present in us. + * EXAMPLE + * + * uint32_t t; + * void setup() + * { + * + * } + * void loop() + * { + * t = micros(); + * delay(2000); + * } + * +*****************************************************************************/ +extern uint32_t micros( void ) ; + +/***************************************************************************** + * FUNCTION + * delay + * DESCRIPTION + * Pauses the program by setting up parameter to designate time to pause(unit:ms) + * PARAMETERS + * dwMs: Time to pause in ms + * RETURNS + * none + * EXAMPLE + * + * int led = 13; + * void setup() + * { + * pinMode(led,OUTPUT); + * } + * void loop() + * { + * digitalWrite(led,HIGH); + * delay(1000); + * digitalWrite(led,LOW); + * delay(1000); + * } + * +*****************************************************************************/ +extern void delay( uint32_t dwMs ) ; + +/***************************************************************************** + * FUNCTION + * delayMicroseconds + * DESCRIPTION + * Pauses the program by setting up parameter to designate time to pause(unit:us) + * PARAMETERS + * usec: Time to pause in us + * RETURNS + * none + * EXAMPLE + * + * int led = 13; + * void setup() + * { + * pinMode(led,OUTPUT); + * } + * void loop() + * { + * digitalWrite(led,HIGH); + * delayMicroseconds(1000); + * digitalWrite(led,LOW); + * delayMicroseconds(1000); + * } + * +*****************************************************************************/ +void delayMicroseconds(uint32_t usec); + +#ifdef __cplusplus +} +#endif + +#endif /* _WIRING_ */ diff --git a/hardware/arduino/mtk/cores/arduino/wiring_analog.c b/hardware/arduino/mtk/cores/arduino/wiring_analog.c new file mode 100644 index 00000000..6b608169 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/wiring_analog.c @@ -0,0 +1,304 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "Arduino.h" +#include "vmdcl.h" +#include "vmlog.h" +#include "vmdcl_adc.h" +#include "vmdcl_pwm.h" +#include "vmdcl_gpio.h" +#include "vmthread.h" +#include "vmsys.h" + +#ifdef __cplusplus +extern "C" { +#endif + +static int _readResolution = 10; +static int _writeResolution = 8; + +static VM_SIGNAL_ID signalid = 0; +static uint32_t adc_result = 0; + +#define PWM_RESOLUTION 8 + +#ifdef __LINKIT_V1__ +#define ADC_PIN_NUM 4 +#else +#define ADC_PIN_NUM 3 +#endif + +typedef struct _ADCPinDescription +{ + uint32_t ulPin; + uint32_t channel; +}ADCPinDescription; + +ADCPinDescription g_ADCPinArray[ADC_PIN_NUM] = +{ + { 14, 12 }, + { 15, 15 }, +#ifdef __LINKIT_V1__ + { 16, 13 }, + { 17, 14 } +#else + { 16, 13 } +#endif +}; + +/**/ +void analogReadResolution(int res) { + _readResolution = res; +} + +void analogWriteResolution(int res) { + _writeResolution = res; +} + +static inline uint32_t mapResolution(uint32_t value, uint32_t from, uint32_t to) { + if (from == to) + return value; + if (from > to) + return value >> (from-to); + else + return value << (to-from); +} + +long mapVolt(long x, long in_min, long in_max, long out_min, long out_max) +{ + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; +} + +eAnalogReference analog_reference = AR_DEFAULT; + +void analogReference(eAnalogReference ulMode) +{ + analog_reference = ulMode;//only for compatiable, nouse. +} + +void adcCallback(void* parameter, VM_DCL_EVENT event, VM_DCL_HANDLE device_handle) +{ + VM_DCL_CB_ILM_DATA_T *data; + vm_bmt_adc_measure_done_conf_struct * result; + + if(parameter!=NULL) + { + data = (VM_DCL_CB_ILM_DATA_T*)parameter; + result = (vm_bmt_adc_measure_done_conf_struct *)(data->vm_local_para_ptr); + + if( result != NULL ) + { + double *p; + + p =(double*)&(result->adc_value); + + adc_result = (unsigned int)*p; + //vm_log_info("analogRead_callback:the result is:adc_result=%d;",adc_result); + } + } + + vm_signal_post(signalid); + +} + +uint32_t findADCChannel(uint32_t ulPin) +{ + int i; + + for(i = 0; i906) + adc_result = 906; + + adc_result = mapVolt(adc_result, 0, 906, 0, 1023); + + return adc_result; + +} + +void analogOutputInit(void) { + return; +} + +void analogWrite(uint32_t ulPin, uint32_t ulValue) { + + VM_DCL_HANDLE pwm_handle; + + if(ulPin == 9) + { + VM_PWM_SET_CLOCK_T pwm_clock; + VM_PWM_SET_COUNTER_THRESHOLD_T pwm_config_adv; + + if(!changePinType(ulPin, PIO_PWM, &pwm_handle)) + return; + + if(pwm_handle == VM_DCL_HANDLE_INVALID) + { + pwm_handle = vm_dcl_open(VM_DCL_PWM4,vm_dcl_get_ownerid()); + vm_dcl_control(pwm_handle,VM_PWM_CMD_START,0); + setPinHandle(ulPin, pwm_handle); + } + + pwm_config_adv.counter = 1022; + pwm_config_adv.threshold = ulValue; + pwm_clock.source_clk = 1; + pwm_clock.source_clk_div =1; + vm_dcl_control(pwm_handle,VM_PWM_CMD_SET_CLK,(void *)(&pwm_clock)); + vm_dcl_control(pwm_handle,VM_PWM_CMD_SET_COUNTER_AND_THRESHOLD,(void *)(&pwm_config_adv)); + } + else if(ulPin == 3) + { + VM_PWM_SET_CLOCK_T pwm_clock; + VM_PWM_SET_COUNTER_THRESHOLD_T pwm_config_adv; + + if(!changePinType(ulPin, PIO_PWM, &pwm_handle)) + return; + + if(pwm_handle == VM_DCL_HANDLE_INVALID) + { + pwm_handle = vm_dcl_open(VM_DCL_PWM1,vm_dcl_get_ownerid()); + vm_dcl_control(pwm_handle,VM_PWM_CMD_START,0); + setPinHandle(ulPin, pwm_handle); + } + + pwm_config_adv.counter = 1022; + pwm_config_adv.threshold = ulValue; + pwm_clock.source_clk = 1; + pwm_clock.source_clk_div =1; + vm_dcl_control(pwm_handle,VM_PWM_CMD_SET_CLK,(void *)(&pwm_clock)); + vm_dcl_control(pwm_handle,VM_PWM_CMD_SET_COUNTER_AND_THRESHOLD,(void *)(&pwm_config_adv)); + } + else + { + pinMode(ulPin, OUTPUT); + + if (ulValue < 128) + digitalWrite(ulPin, LOW); + else + digitalWrite(ulPin, HIGH); + } + +} + + +void analogWriteAdvance(uint32_t ulPin, uint32_t ulClock, uint32_t ulDiv, uint32_t ulCycle, uint32_t ulDuty ) +{ + VM_DCL_HANDLE pwm_handle; + + if(ulPin == 9) + { + VM_PWM_SET_CLOCK_T pwm_clock; + VM_PWM_SET_COUNTER_THRESHOLD_T pwm_config_adv; + + if(!changePinType(ulPin, PIO_PWM, &pwm_handle)) + return; + + if(pwm_handle == VM_DCL_HANDLE_INVALID) + { + pwm_handle = vm_dcl_open(VM_DCL_PWM4,vm_dcl_get_ownerid()); + vm_dcl_control(pwm_handle,VM_PWM_CMD_START,0); + setPinHandle(ulPin, pwm_handle); + } + + pwm_clock.source_clk = ulClock; + pwm_clock.source_clk_div = ulDiv; + pwm_config_adv.counter = ulCycle; + pwm_config_adv.threshold = ulDuty; + vm_dcl_control(pwm_handle,VM_PWM_CMD_SET_CLK,(void *)(&pwm_clock)); + vm_dcl_control(pwm_handle,VM_PWM_CMD_SET_COUNTER_AND_THRESHOLD,(void *)(&pwm_config_adv)); + } + if(ulPin == 3) + { + VM_PWM_SET_CLOCK_T pwm_clock; + VM_PWM_SET_COUNTER_THRESHOLD_T pwm_config_adv; + + if(!changePinType(ulPin, PIO_PWM, &pwm_handle)) + return; + + if(pwm_handle == VM_DCL_HANDLE_INVALID) + { + pwm_handle = vm_dcl_open(VM_DCL_PWM1,vm_dcl_get_ownerid()); + vm_dcl_control(pwm_handle,VM_PWM_CMD_START,0); + setPinHandle(ulPin, pwm_handle); + } + + pwm_clock.source_clk = ulClock; + pwm_clock.source_clk_div = ulDiv; + pwm_config_adv.counter = ulCycle; + pwm_config_adv.threshold = ulDuty; + vm_dcl_control(pwm_handle,VM_PWM_CMD_SET_CLK,(void *)(&pwm_clock)); + vm_dcl_control(pwm_handle,VM_PWM_CMD_SET_COUNTER_AND_THRESHOLD,(void *)(&pwm_config_adv)); + } +} + +#ifdef __cplusplus +} +#endif diff --git a/hardware/arduino/mtk/cores/arduino/wiring_analog.h b/hardware/arduino/mtk/cores/arduino/wiring_analog.h new file mode 100644 index 00000000..6c7112d4 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/wiring_analog.h @@ -0,0 +1,171 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _WIRING_ANALOG_ +#define _WIRING_ANALOG_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* DOM-NOT_FOR_SDK-BEGIN */ +/* + * \brief SAM3 products have only one reference for ADC + */ +typedef enum _eAnalogReference +{ + AR_DEFAULT, +} eAnalogReference ; + +#define PWM_SOURCE_CLOCK_13MHZ 0x00 +#define PWM_SOURCE_CLOCK_32KHZ 0x01 + +#define PWM_CLOCK_DIV1 0x00 +#define PWM_CLOCK_DIV2 0x01 +#define PWM_CLOCK_DIV4 0x02 +#define PWM_CLOCK_DIV8 0x03 + +/* + * \brief Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). + * This function is kept only for compatibility with existing AVR based API. + * + * \param ulMmode Should be set to AR_DEFAULT. + */ +extern void analogReference( eAnalogReference ulMode ) ; + +/* + * \brief Set the resolution of analogRead return values. Default is 10 bits (range from 0 to 1023). + * + * \param res + */ +extern void analogReadResolution(int res); + +/* + * \brief Set the resolution of analogWrite parameters. Default is 8 bits (range from 0 to 255). + * + * \param res + */ +extern void analogWriteResolution(int res); + +extern void analogOutputInit( void ) ; +/* DOM-NOT_FOR_SDK-END */ + + /***************************************************************************** + * FUNCTION + * analogWrite + * DESCRIPTION + * Outputs analog value(PWM wave)to the assigned analog output pin. + * PARAMETERS + * ulPin : [IN] Analog output pin number; 8, 9 + * ulValue : [IN] duty cycle,0~1023 + * RETURNS + * void + * EXAMPLE + * + * uint32_t analogPin = 9; + * void setup() + * {} + * void loop() + * { + * analogWrite(analogPin,128); + * } + * +*****************************************************************************/ +extern void analogWrite( uint32_t ulPin, uint32_t ulValue ); + + /***************************************************************************** + * FUNCTION + * analogWriteAdvance + * DESCRIPTION + * Outputs analog value (PWM wave) to the assigned analog output pin. + * Note: Only the analog output pins D8 and D9 support analog output. + * You can define your own PWM output wave accuracy (max. 13-bit) and frequency in this function. + * PARAMETERS + * ulPin : [IN] analog output pin number; 8, 9 + * ulClock : [IN] define base clock frequency, can be PWM_SOURCE_CLOCK_13MHZ or PWM_SOURCE_CLOCK_32KHZ + * ulDiv : [IN] define clock frequency divider, can be PWM_CLOCK_DIV1, PWM_CLOCK_DIV2, PWM_CLOCK_DIV4 or PWM_CLOCK_DIV8 + * ulCycle : [IN] the cycle, between 0 and 8191 + * ulDuty : [IN] the duty cycle,between 0 and 8191, but must be smaller than cycle + * RETURNS + * void + * EXAMPLE + * + * uint32_t pwmPin = 9; // use Digital pin D9 + * + * int cycle = 9; // Divide output into 9+1 = 10 portions + * int sourceClock = PWM_SOURCE_CLOCK_13MHZ; // + * int divider = PWM_CLOCK_DIV8; // The PWM frequency will be 13MHz / 8 / 10 = 162.5KHz + * + * int duty = 0; + * int offset = 1; + * + * void setup() + * { + * pinMode(pwmPin, OUTPUT); + * } + * + * void loop() + * { + * analogWriteAdvance(pwmPin, sourceClock, divider, cycle, duty); + * + * duty += offset; + * if (duty == cycle) + * { + * offset = -1; + * } + * else if(duty == 0) + * { + * offset = 1; + * } + * delay(1000); + * } + * +*****************************************************************************/ +extern void analogWriteAdvance(uint32_t pin, uint32_t sourceClock, uint32_t clockDivider, uint32_t cycle, uint32_t dutyCycle); + +/***************************************************************************** + * FUNCTION + * analogRead + * DESCRIPTION + * Reads the value of an assigned analog input pin. + * PARAMETERS + * ulPin : [IN] Analog input pin number to be read;A0,A1,A2 or A3 + * RETURNS + * uint32_t:0 to 1023 + * EXAMPLE + * + * uint32_t analogPin = A0; + * uint32_t readVal = 0; + * void setup() + * { + * Serial.begin(9600); + * } + * void loop() + * { + * readVal = analogRead(analogPin); + * Serial.println(readVal); + * } + * +*****************************************************************************/ +extern uint32_t analogRead( uint32_t ulPin ) ; + +#ifdef __cplusplus +} +#endif + +#endif /* _WIRING_ANALOG_ */ diff --git a/hardware/arduino/mtk/cores/arduino/wiring_constants.h b/hardware/arduino/mtk/cores/arduino/wiring_constants.h new file mode 100644 index 00000000..8ec9f6c0 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/wiring_constants.h @@ -0,0 +1,275 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _WIRING_CONSTANTS_ +#define _WIRING_CONSTANTS_ + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +/* DOM-NOT_FOR_SDK-BEGIN */ +#define HIGH 0x1 +#define LOW 0x0 + +#define INPUT 0x0 +#define OUTPUT 0x1 +#define INPUT_PULLUP 0x2 + +#define true 0x1 +#define false 0x0 + +#define PI 3.1415926535897932384626433832795 +#define HALF_PI 1.5707963267948966192313216916398 +#define TWO_PI 6.283185307179586476925286766559 +#define DEG_TO_RAD 0.017453292519943295769236907684886 //ğĦĥÈת½ÇĥÈ +#define RAD_TO_DEG 57.295779513082320876798154814105 //½ÇĥÈתğĦĥÈ +#define EULER 2.718281828459045235360287471352 + +#define SERIAL 0x0 +#define DISPLAY 0x1 + +enum BitOrder { + LSBFIRST = 0, + MSBFIRST = 1 +}; + +// LOW 0 +// HIGH 1 +#define CHANGE 2 +#define FALLING 3 +#define RISING 4 + +#define DEFAULT 1 +#define EXTERNAL 0 + +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif // abs +/* DOM-NOT_FOR_SDK-END */ + +#ifndef min +/***************************************************************************** + * + * FUNCTION + * min + * DESCRIPTION + * Calculates the minimum of two numbers. + * PARAMETERS + * x: the first number, any data type + * y: the second number, any data type + * RETURNS + * The smaller of the two numbers. + * RETURN VALUES + * depend on input value + *****************************************************************************/ +#define min(a,b) ((a)<(b)?(a):(b)) +#endif // min + +#ifndef max +/***************************************************************************** + * + * FUNCTION + * max + * DESCRIPTION + * Calculates the maximum of two numbers. + * PARAMETERS + * x: the first number, any data type + * y: the second number, any data type + * RETURNS + * The larger of the two numbers. + * RETURN VALUES + * depend on input value + *****************************************************************************/ +#define max(a,b) ((a)>(b)?(a):(b)) +#endif // max + +/***************************************************************************** + * + * FUNCTION + * abs + * DESCRIPTION + * Computes the absolute value of a number. + * PARAMETERS + * x: the number + * RETURNS + * x: if x is greater than or equal to 0. + * -x: if x is less than 0. + * RETURN VALUES + * depend on input value + *****************************************************************************/ +#define abs(x) ((x)>0?(x):-(x)) + +/***************************************************************************** + * + * FUNCTION + * constrain + * DESCRIPTION + * Constrains a number to be within a range. + * PARAMETERS + * x: the number to constrain, all data types + * a: the lower end of the range, all data types + * b: the upper end of the range, all data types + * RETURNS + * x: if x is between a and b + * a: if x is less than a + * b: if x is greater than b + * RETURN VALUES + * depend on input value + *****************************************************************************/ +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) + +/* DOM-NOT_FOR_SDK-BEGIN */ +#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) //ËÄÉáÎċÈë +#define radians(deg) ((deg)*DEG_TO_RAD) // ½ÇĥÈתğĦĥÈ +#define degrees(rad) ((rad)*RAD_TO_DEG) //ğĦĥÈת½ÇĥÈ +#define sq(x) ((x)*(x)) //Ĉ½·½ +/* DOM-NOT_FOR_SDK-END */ + +/***************************************************************************** + * FUNCTION + * lowByte + * DESCRIPTION + * Extracts the high-order (leftmost) byte of a word (or the second lowest byte of a larger data type). + * PARAMETERS + * x: a value of any type + * RETURNS + * byte + * RETURN VALUES + * depend on input value + *****************************************************************************/ +#define lowByte(w) ((uint8_t) ((w) & 0xff)) + +/***************************************************************************** + * FUNCTION + * highByte + * DESCRIPTION + * Extracts the high-order (leftmost) byte of a word (or the second lowest byte of a larger data type). + * PARAMETERS + * x: a value of any type + * RETURNS + * byte + * RETURN VALUES + * depend on input value + *****************************************************************************/ +#define highByte(w) ((uint8_t) ((w) >> 8)) + +/***************************************************************************** + * FUNCTION + * bitRead + * DESCRIPTION + * Reads a bit of a number. + * PARAMETERS + * x: the number from which to read + * n: which bit to read, starting at 0 for the least-significant (rightmost) bit + * RETURNS + * the value of the bit (0 or 1). + * RETURN VALUES + * depend on input value + *****************************************************************************/ +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) + +/***************************************************************************** + * FUNCTION + * bitSet + * DESCRIPTION + * Sets (writes a 1 to) a bit of a numeric variable. + * PARAMETERS + * x: the numeric variable whose bit to set + * n: which bit to set, starting at 0 for the least-significant (rightmost) bit + * RETURNS + * none + *****************************************************************************/ +#define bitSet(value, bit) ((value) |= (1UL << (bit))) + +/***************************************************************************** + * FUNCTION + * bitClear + * DESCRIPTION + * Clears (writes a 0 to) a bit of a numeric variable. + * PARAMETERS + * x: the numeric variable whose bit to clear + * n: which bit to clear, starting at 0 for the least-significant (rightmost) bit + * RETURNS + * none + *****************************************************************************/ +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) + +/***************************************************************************** + * FUNCTION + * bitWrite + * DESCRIPTION + * Writes a bit of a numeric variable. + * PARAMETERS + * x: the numeric variable to which to write + * n: which bit of the number to write, starting at 0 for the least-significant (rightmost) bit + * b: the value to write to the bit (0 or 1) + * RETURNS + * the value of the bit + * RETURN VALUES + * depend on input value + *****************************************************************************/ +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) + +/* DOM-NOT_FOR_SDK-BEGIN */ +typedef unsigned int word; +/* DOM-NOT_FOR_SDK-END */ + +/***************************************************************************** + * FUNCTION + * bit + * DESCRIPTION + * Computes the value of the specified bit (bit 0 is 1, bit 1 is 2, bit 2 is 4, etc.). + * PARAMETERS + * b: the bit whose value to compute + * RETURNS + * the value of the bit + * RETURN VALUES + * depend on input value + *****************************************************************************/ +#define bit(b) (1UL << (b)) + +/***************************************************************************** + * FUNCTION + * _BV + * DESCRIPTION + * Converts a bit number into a byte value, same with bit. + * he bit shift is performed by the compiler which then inserts the + * result into the code. Thus, there is no run-time overhead when using + * PARAMETERS + * bit: the bit whose value to compute + * RETURNS + * the value of the bit + * RETURN VALUES + * depend on input value + *****************************************************************************/ +#define _BV(bit) (1 << (bit)) + +/* DOM-NOT_FOR_SDK-BEGIN */ +// TODO: to be checked +typedef uint8_t boolean ; +typedef uint8_t byte ; +/* DOM-NOT_FOR_SDK-END */ + + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif /* _WIRING_CONSTANTS_ */ diff --git a/hardware/arduino/mtk/cores/arduino/wiring_digital.c b/hardware/arduino/mtk/cores/arduino/wiring_digital.c new file mode 100644 index 00000000..2c9562b7 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/wiring_digital.c @@ -0,0 +1,149 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "Arduino.h" +#include "vmdcl.h" +#include "vmdcl_gpio.h" +#include "Vmlog.h" + +#ifdef __cplusplus + extern "C" { +#endif + +extern void pinMode( uint32_t ulPin, uint32_t ulMode ) +{ + VM_DCL_HANDLE gpio_handle; + vm_gpio_ctrl_set_pupd_r0_r1_t pupd; + //vm_log_info("pinMode(): pin = %d , pin_internal = %d, mode = %d", ulPin, g_APinDescription[ulPin].ulGpioId, ulMode); + + if(!changePinType(ulPin, PIO_DIGITAL, &gpio_handle)) + return; + + if(gpio_handle == VM_DCL_HANDLE_INVALID) + gpio_handle = vm_dcl_open(VM_DCL_GPIO, g_APinDescription[ulPin].ulGpioId); + + // set PIN direction + switch ( ulMode ) + { + case INPUT: + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_DIR_IN, NULL); + + if( g_APinDescription[ulPin].ulPupd) + { + pupd.fgSetPupd = 0; + pupd.fgSetR0 = 1; + pupd.fgSetR1 = 0; + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_PUPD_R0_R1, &pupd); + } + else + { + vm_dcl_control(gpio_handle,VM_GPIO_CMD_ENABLE_PULL, NULL); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_PULL_LOW, NULL); + } + break ; + + case INPUT_PULLUP: + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_DIR_IN, NULL); + + if( g_APinDescription[ulPin].ulPupd) + { + pupd.fgSetPupd = 1; + pupd.fgSetR0 = 1; + pupd.fgSetR1 = 0; + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_PUPD_R0_R1, &pupd); + } + else + { + vm_dcl_control(gpio_handle,VM_GPIO_CMD_ENABLE_PULL, NULL); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_PULL_HIGH, NULL); + } + break ; + + case OUTPUT: + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_DIR_OUT, NULL); + break ; + + default: + break ; + } + + g_APinDescription[ulPin].ulHandle = gpio_handle; + +} + +extern void digitalWrite( uint32_t ulPin, uint32_t ulVal ) +{ + //vm_log_info("digitalWrite(): pin = %d , value = %d", ulPin, ulVal); + + if (ulPin > PIO_MAX_NUM ) + { + return; + } + + // write PIN + switch (ulVal) + { + case HIGH: + vm_dcl_control(g_APinDescription[ulPin].ulHandle,VM_GPIO_CMD_WRITE_HIGH, NULL); + break; + + case LOW: + vm_dcl_control(g_APinDescription[ulPin].ulHandle,VM_GPIO_CMD_WRITE_LOW, NULL); + break; + + default: + break; + } + +} + +extern int digitalRead( uint32_t ulPin ) +{ + vm_gpio_ctrl_read_t data; + + //vm_log_info("digitalRead(): pin = %d", ulPin); + + if (ulPin > PIO_MAX_NUM ) + { + //vm_log_info("digitalRead(): pin mapping failed, return LOW as default."); + return LOW; + } + + vm_dcl_control(g_APinDescription[ulPin].ulHandle, VM_GPIO_CMD_READ,(void *)&data); + + if ( data.u1IOData == VM_GPIO_IO_LOW ) + { + //vm_log_info("digitalRead(): result = LOW"); + return LOW ; + } + else if ( data.u1IOData == VM_GPIO_IO_HIGH ) + { + //vm_log_info("digitalRead(): result = HIGH"); + return HIGH ; + } + else + { + //vm_log_info("digitalRead(): read failed, return LOW as default."); + return LOW ; + } +} + +#ifdef __cplusplus +} +#endif + diff --git a/hardware/arduino/mtk/cores/arduino/wiring_digital.h b/hardware/arduino/mtk/cores/arduino/wiring_digital.h new file mode 100644 index 00000000..95715cb8 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/wiring_digital.h @@ -0,0 +1,116 @@ +/* + * digital I/O for Arduino Due + * Copyright (c) 2011 Cristian Maglie . + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef _WIRING_DIGITAL_ +#define _WIRING_DIGITAL_ + +#ifdef __cplusplus + extern "C" { +#endif + + // DESCRIPTION + // Sets up modes for assigned pins. + // LinkIt One supports 3 pin modes: + // INPUT: Used for reading voltage (HIGH or LOW) or sensor. In INPUT mode when the circuit is at high impedance, similar to serially connecting a big resistance in the circuit, the pin can read accurate voltage value. However, this pin may not have enough voltage to activate peripheral devices, e.g. LED. + // INPUT_PULLUP: Similar to INPUT mode, used for reading voltage of sensor. However in this mode, the pin is often at high voltage when the sensor is disabled and turns to low voltage when the sensor is enabled, which is opposite to its behavior in INPUT mode. + // OUTPUT: Used for controlling peripheral devices. In OUTPUT mode when the circuit is at low impedance, the pin has enough voltage to activate or control other devices but cannot read the voltage of sensor. + // RETURNS + // N/A + // EXAMPLE + // + // #define LED 13 + // void setup() + // { + // pinMode(LED, OUTPUT); + // } + // void loop() + // { + // digitalWrite(LED, HIGH); + // delay(3000); + // digitalWrite(LED, LOW); + // delay(3000); + // } + // +extern void pinMode( + uint32_t dwPin, // [IN] Pin number that needs to be set with a mode + uint32_t dwMode // [IN] Mode of pin (INPUT, INPUT_PULLUP or OUTPUT) + ) ; + + // DESCRIPTION + // Sets assigned pins to high voltage (3.3V) or low voltage (0V). + // RETURNS + // N/A + // EXAMPLE + // + // #define LED 13 + // void setup() + // { + // pinMode(LED, OUTPUT); + // } + // void loop() + // { + // digitalWrite(LED, HIGH); + // delay(3000); + // digitalWrite(LED, LOW); + // delay(3000); + // } + // +extern void digitalWrite( + uint32_t dwPin, // [IN] Pin number that needs to be set with a value + uint32_t dwVal // [IN] HIGH or LOW + ) ; + + // DESCRIPTION + // Reads voltage of assigned pin, HIGH or LOW. + // RETURNS + // HIGH or LOW + // EXAMPLE + // + // #define LED 13 + // #define BUTTON 16 + // void setup() + // { + // pinMode(LED, OUTPUT); + // pinMode(BUTTON, INPUT); + // } + // void loop() + // { + // int result = 0; + // int n= digitalRead(BUTTON); + // if (n == HIGH) + // { + // digitalWrite(LED, LOW); + // delay(2000); + // } + // else + // { + // digitalWrite(LED, HIGH); + // delay(2000); + // } + // } + // +extern int digitalRead( + uint32_t ulPin // [IN] Pin number that needs to read voltage + ) ; + +#ifdef __cplusplus +} +#endif + +#endif /* _WIRING_DIGITAL_ */ diff --git a/hardware/arduino/mtk/cores/arduino/wiring_private.h b/hardware/arduino/mtk/cores/arduino/wiring_private.h new file mode 100644 index 00000000..573da03d --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/wiring_private.h @@ -0,0 +1,42 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef WiringPrivate_h +#define WiringPrivate_h + +#include +#include +#include + +#ifdef __cplusplus +extern "C"{ +#endif + +// Includes Atmel CMSIS +#include + +#include "wiring_constants.h" + +#ifdef __cplusplus +} // extern "C" + +#include "HardwareSerial.h" + +#endif + +#endif diff --git a/hardware/arduino/mtk/cores/arduino/wiring_pulse.cpp b/hardware/arduino/mtk/cores/arduino/wiring_pulse.cpp new file mode 100644 index 00000000..89b80175 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/wiring_pulse.cpp @@ -0,0 +1,67 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "Arduino.h" +#include "wiring_private.h" +#include "Vmlog.h" + +/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH + * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds + * to 3 minutes in length, but must be called at least a few dozen microseconds + * before the start of the pulse. */ +uint32_t pulseIn( uint32_t pin, uint32_t state, uint32_t timeout ) +{ + uint32_t init_time = micros(); + uint32_t curr_time = init_time; + uint32_t max_time = init_time + timeout; + int pin_state = 0; + + /* read GPIO info */ + pin_state = digitalRead(pin); + + // wait for any previous pulse to end + while ((pin_state == state) && (curr_time < max_time)) + { + curr_time = micros(); + pin_state = digitalRead(pin); + } + + // wait for the pulse to start + while ((pin_state != state) && (curr_time < max_time)) + { + curr_time = micros(); + init_time = curr_time; + pin_state = digitalRead(pin); + } + + // wait for the pulse to stop + while ((pin_state == state) && (curr_time < max_time)) + { + curr_time = micros(); + pin_state = digitalRead(pin); + } + + if (curr_time < max_time) + { + return (curr_time - init_time); + } + else + { + return 0; + } +} diff --git a/hardware/arduino/mtk/cores/arduino/wiring_pulse.h b/hardware/arduino/mtk/cores/arduino/wiring_pulse.h new file mode 100644 index 00000000..e2cfae84 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/wiring_pulse.h @@ -0,0 +1,56 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _WIRING_PULSE_ +#define _WIRING_PULSE_ + +#ifdef __cplusplus + extern "C" { +#endif + +#include + +// DESCRIPTION +// Duration of acquiring voltage (HIGH or LOW) of a pin. The accuracy is us; range is approx. 10us to 3 mins. +// RETURNS +// N/A +// EXAMPLE +// +// #define BUTTON 13 +// unsigned long duration; +// void setup() +// { +// pinMode(BUTTON, INPUT); +// } +// void loop() +// { +// duration = pulseIn(BUTTON, HIGH); +// } +// +uint32_t pulseIn( + uint32_t ulPin, // [IN] Pin number measured + uint32_t ulState, // [IN] Voltage type measured (HIGH or LOW) + uint32_t ulTimeout = 1000000L // [IN] The longest time allowed by the function before the measurement starts; unit: us (If not set, default will be 1s.) + ) ; + + +#ifdef __cplusplus +} +#endif + +#endif /* _WIRING_PULSE_ */ diff --git a/hardware/arduino/mtk/cores/arduino/wiring_shift.c b/hardware/arduino/mtk/cores/arduino/wiring_shift.c new file mode 100644 index 00000000..670fd246 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/wiring_shift.c @@ -0,0 +1,71 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "Arduino.h" + +#ifdef __cplusplus +extern "C"{ +#endif + +uint32_t shiftIn( uint32_t ulDataPin, uint32_t ulClockPin, uint32_t ulBitOrder ) +{ + uint8_t value = 0 ; + uint8_t i ; + + for ( i = 0 ; i < 8 ; ++i ) + { + digitalWrite( ulClockPin, HIGH); + + if ( ulBitOrder == LSBFIRST ) + { + value |= digitalRead( ulDataPin ) << i; + } + else + { + value |= digitalRead( ulDataPin ) << (7 - i); + } + + digitalWrite( ulClockPin, LOW ) ; + } + + return value ; +} + +void shiftOut( uint32_t ulDataPin, uint32_t ulClockPin, uint32_t ulBitOrder, uint32_t ulVal ) +{ + uint8_t i ; + + for ( i=0 ; i < 8 ; i++ ) + { + if ( ulBitOrder == LSBFIRST ) + { + digitalWrite( ulDataPin, !!(ulVal & (1 << i)) ) ; + } + else + { + digitalWrite( ulDataPin, !!(ulVal & (1 << (7 - i))) ) ; + } + + digitalWrite( ulClockPin, HIGH ) ; + digitalWrite( ulClockPin, LOW ) ; + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/hardware/arduino/mtk/cores/arduino/wiring_shift.h b/hardware/arduino/mtk/cores/arduino/wiring_shift.h new file mode 100644 index 00000000..a48aae90 --- /dev/null +++ b/hardware/arduino/mtk/cores/arduino/wiring_shift.h @@ -0,0 +1,90 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _WIRING_SHIFT_ +#define _WIRING_SHIFT_ + +#ifdef __cplusplus + extern "C" { +#endif + +// DESCRIPTION +// Reads data of a byte by bits on the assigned pin. +// Every bit of data is read from the data pin. +// You can select to combine the read 8-bit data into a byte from MSB or LSB. +// Every clock cycle (meaning the clock goes through a complete high voltage and low voltage) reads a bit of data; every bit of data is read when the clock signal is at high voltage. +// RETURNS +// Data read (one byte) +// EXAMPLE +// +// #define DATA 13 +// #define CLOCK 15 +// void setup() +// { +// pinMode(DATA, INPUT); +// pinMode(CLOCK, OUTPUT); +// } +// void loop() +// { +// byte data; +// data = shiftIn(DATA, CLOCK, LSBFIRST); +// delay(1000); +// } +// +extern uint32_t shiftIn( + uint32_t ulDataPin, // [IN] Data input pin, for reading every bit of data + uint32_t ulClockPin, // [IN] Clock pin. Periodically switches between high voltage and low voltage when dataPin outputs data + uint32_t ulBitOrder // [IN] Data input order. Can be MSBFIRST (MSB first) or LSBFIRST (LSB first) + ) ; + + +// DESCRIPTION +// Outputs a byte of data by bits on the assigned pin. +// Every bit of data is outputted from the data pin. +// You can select to start output from MSB or LSB of the data. +// Every clock cycle (meaning the clock goes through a complete high voltage and low voltage) outputs a bit of data. +// RETURNS +// N/A +// EXAMPLE +// +// #define DATA 13 +// #define CLOCK 15 +// void setup() +// { +// pinMode(DATA, INPUT); +// pinMode(CLOCK, OUTPUT); +// } +// void loop() +// { +// shiftOut(DATA, CLOCK, LSBFIRST, 100); +// delay(1000); +// } +// +extern void shiftOut( + uint32_t ulDataPin, // [IN] Data output pin, for outputting every bit of data + uint32_t ulClockPin, // [IN] Clock pin. Periodically switches between high voltage and low voltage when dataPin outputs data + uint32_t ulBitOrder, // [IN] Data output order. Can be MSBFIRST (MSB first) or LSBFIRST (LSB first) + uint32_t ulVal // [IN] Value to be outputted by bits (one byte) + ) ; + + +#ifdef __cplusplus +} +#endif + +#endif /* _WIRING_SHIFT_ */ diff --git a/hardware/arduino/mtk/libraries/LAudio/LAudio.cpp b/hardware/arduino/mtk/libraries/LAudio/LAudio.cpp new file mode 100644 index 00000000..310ead31 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LAudio/LAudio.cpp @@ -0,0 +1,111 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include +#include +#include "vmsys.h" +#include "vmmm.h" +#include "vmchset.h" +#include "vmstdlib.h" +#include "LAudio.h" +#include "audio.h" + +static int status_result = 0 ; + +void LAudioClass::onCallback(int result) { + status_result = result; +} + +void LAudioClass::playFile(StorageEnum drv, char *songName) +{ + strcpy((char*)m_path, songName); + m_drv = drv; + m_type = true; + remoteCall(audioPlay, (void*)this->onCallback); +} + +void LAudioClass::playFile(StorageEnum drv, wchar_t* songName) +{ + wcscpy((wchar_t*)m_path, songName); + m_drv = drv; + m_type = false; + remoteCall(audioPlay, (void*)this->onCallback); +} + +void LAudioClass::setVolume(unsigned char volume){ + m_volume = volume; + remoteCall(audioSetVolume, NULL); +} + +void LAudioClass::pause(){ + remoteCall(audioPause, NULL); +} + +void LAudioClass::resume(){ + remoteCall(audioResume, NULL); +} + +void LAudioClass::stop(){ + remoteCall(audioStop, NULL); +} + +AudioStatus LAudioClass::getStatus(){ + AudioStatus status = (AudioStatus)status_result; + status_result = 0; + return status; +} + +VMSTR LAudioClass::getFile(){ + return m_path; +} + +unsigned char LAudioClass::getVolume(){ + return m_volume; +} + +char LAudioClass::getDriver() +{ + return m_drv; +} + +boolean LAudioClass::getType() +{ + return m_type; +} + +//void setPlayMode(playMode_t playmode) { _playmode = playmode;} + + +LAudioClass LAudio; + diff --git a/hardware/arduino/mtk/libraries/LAudio/LAudio.h b/hardware/arduino/mtk/libraries/LAudio/LAudio.h new file mode 100644 index 00000000..d6151116 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LAudio/LAudio.h @@ -0,0 +1,154 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef _LAUDIO_H +#define _LAUDIO_H + +#include "chip.h" +#include "vmsys.h" +#include "LTask.h" +#include "arduino.h" + +// playing status +typedef enum +{ + AudioCommonFailed = -1, // Playback fails (e.g. the audio file is corrupted). + AudioStop = 1, // Playback is stopped. + AudioPause = 2, // Playback is paused (and can resume). + AudioResume = 3, // Playback resumes + AudioEndOfFile = 5 // Playback is finished. +}AudioStatus; + +// storage location +typedef enum +{ + storageFlash, // Flash + storageSD // SD +}StorageEnum; + +// LAudio class interface +class LAudioClass : public _LTaskClass { + +// Constructor / Destructor +public: + LAudioClass() { }; + +public: + // DESCRIPTION + // Plays an audio file on SD card or flash storage. + // RETURNS + // N/A + // EXAMPLE + // + // #include + // void setup() + // { + // LAudio.begin(); + // LAudio.playFile(storageFlash, (char*)"sample.mp3"); + // LAudio.setVolume(2); + // delay(2000); + // LAudio.pause(); + // delay(2000); + // LAudio.resume(); + // delay(2000); + // LAudio.stop(); + // } + // + void playFile( + StorageEnum drv, // [IN] Storage, can be storageSD (SD card) or storageFlash (flash storage) + char *songName // [IN] Path of audio file in ascii (char*) + ); + + // DESCRIPTION + // Plays an audio file on SD card or flash storage. + // RETURNS + // N/A + void playFile( + StorageEnum drv, // [IN] Storage, can be storageSD (SD card) or storageFlash (flash storage) + wchar_t* songName // [IN] Path of audio file in unicode (wchar_t*) encoding + ); + + // DESCRIPTION + // Adjusts the playback volume; range is from 0 (silent) to 6 (max). + // RETURNS + // N/A + void setVolume( + unsigned char volume // [IN] Volume level, can be 0 to 6; 0 as silent and 6 as max volume + ); + + // DESCRIPTION + // Pauses the playback. It only works when there is an active playback ongoing (by playFile()). + // RETURNS + // N/A + void pause(void); + + // DESCRIPTION + // Resumes playback. It only works when the playback has been paused. + // RETURNS + // N/A + void resume(void); + + // DESCRIPTION + // Stops playback. + // RETURNS + // N/A + void stop(void); + + // DESCRIPTION + // Queries the current playback status. + // RETURNS + // AudioStatus: Playback status, can be: + // AudioStop: Playback is stopped. + // AudioPause: Playback is paused (and can resume). + // AudioResume: Playback resumes + // AudioEndOfFile: Playback is finished. + // AudioCommonFailed: Playback fails (e.g. the audio file is corrupted). + AudioStatus getStatus(void); + +public: + VMSTR getFile(); + char getDriver(); + boolean getType(); + unsigned char getVolume(); + static void onCallback(int result); +private: + char m_path[256]; + unsigned char m_volume; + char m_drv; + boolean m_type; +}; + +extern LAudioClass LAudio; + +#endif diff --git a/hardware/arduino/mtk/libraries/LAudio/examples/AudioPlayer/AudioPlayer.ino b/hardware/arduino/mtk/libraries/LAudio/examples/AudioPlayer/AudioPlayer.ino new file mode 100644 index 00000000..6e6fffe8 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LAudio/examples/AudioPlayer/AudioPlayer.ino @@ -0,0 +1,90 @@ +#include + +#define KEY 5 +char buff[120]; +unsigned char KEY_NUM = 0; + +enum{Play,SetVolume,Pause,Resume,Stop}; + +unsigned char Status_Value = Play; + +void Scan_KEY() +{ + if( digitalRead(KEY) == 0 ) + { + delay(20); //ċğĥĉ—ĥ20msïĵŒċŽğĉŠ–ċŠ¨ + if( digitalRead(KEY) == 0 ) //ĉŸçœ‹ĉŒ‰é”ĉ˜ŻċĤĉŒ‰ä¸‹ + { + KEY_NUM = 1; + while(digitalRead(KEY) == 0); //ĉĉ‰‹ĉ£€ĉµ‹ + } + } +} + +void setup() +{ + LAudio.begin(); + pinMode(KEY,INPUT_PULLUP); + Serial.begin(115200); + Change_Status(Play); + pinMode(8, OUTPUT); + +} + +void Change_Status(unsigned char status) +{ + switch(status) + { + case Play: + LAudio.playFile( storageFlash,(char*)"LS8Mo.wav"); + LAudio.setVolume(2); + Serial.println("playOne"); + break; + case SetVolume: + LAudio.setVolume(6); + Serial.println("setVolume"); + break; + case Pause: + LAudio.pause(); + Serial.println("pause"); + break; + case Resume: + LAudio.resume(); + Serial.println("resume"); + break; + case Stop: + LAudio.stop(); + Serial.println("stop"); + break; + default: + break; + } +} + +void loop() +{ + //digitalWrite(8, HIGH); + //digitalWrite(8,LOW); + + AudioStatus status; + Scan_KEY(); + status = LAudio.getStatus(); + if(status == AudioEndOfFile) + { + Status_Value = Play; + Change_Status(Status_Value); + } + if(KEY_NUM == 1) + { + KEY_NUM = 0; + Change_Status(Status_Value); + Status_Value++; + if(Status_Value == Stop+1) + { + Status_Value = Play; + } + } + + delay(1000); +} + diff --git a/hardware/arduino/mtk/libraries/LAudio/keywords.txt b/hardware/arduino/mtk/libraries/LAudio/keywords.txt new file mode 100644 index 00000000..4990c67a --- /dev/null +++ b/hardware/arduino/mtk/libraries/LAudio/keywords.txt @@ -0,0 +1,31 @@ +####################################### +# Syntax Coloring Map For LAudioClass +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +LAudio KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +begin KEYWORD2 +playFile KEYWORD2 +setVolume KEYWORD2 +pause KEYWORD2 +resume KEYWORD2 +stop KEYWORD2 +getStatus KEYWORD2 + +####################################### +# Object (KEYWORD3) +####################################### +LAudio KEYWORD3 + +####################################### +# Constants (LITERAL1) +####################################### + diff --git a/hardware/arduino/mtk/libraries/LAudio/utility/Audio.cpp b/hardware/arduino/mtk/libraries/LAudio/utility/Audio.cpp new file mode 100644 index 00000000..395d4e1a --- /dev/null +++ b/hardware/arduino/mtk/libraries/LAudio/utility/Audio.cpp @@ -0,0 +1,126 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#include "vmsys.h" +#include "vmmm.h" +#include "vmchset.h" +#include "LAudio.h" +#include "Audio.h" +#include "vmlog.h" +#include "vmio.h" +#include "vmstdlib.h" + +typedef void (*call_func_ptr)(int result); +call_func_ptr g_callback = NULL; + + +void audio_callback(VMINT result) +{ + if(g_callback) + g_callback(result); + return; +} + +boolean audioPlay(void* user_data) +{ + VMWCHAR path[256]; + VMCHAR path_a[256]; + + VMINT drv ; + VMCHAR driver_str[2] = {0}; + + if(LAudio.getDriver() ==0) + { + drv = vm_get_system_driver(); + } + else + { + drv = vm_get_removable_driver(); + } + + if(drv >=0) + { + + if( LAudio.getType()) + { + sprintf(path_a,"%c:\\%s", drv, LAudio.getFile()); + vm_ascii_to_ucs2(path, 256, path_a); + } + else + { + sprintf(path_a,"%c:\\", drv); + vm_ascii_to_ucs2(path, 256, path_a); + vm_wstrcat(path, (VMWSTR)LAudio.getFile()); + } + } + else + { + vm_log_info("AudioPlay get driver error"); + return true; + } + + + + g_callback = (call_func_ptr)user_data; + vm_audio_play_file(path, audio_callback); + vm_set_volume(LAudio.getVolume()); + return true; +} + +boolean audioPause(void* user_data) +{ + vm_audio_pause(audio_callback); + return true; +} + +boolean audioResume(void* user_data) +{ + vm_audio_resume(audio_callback); + return true; +} + +boolean audioStop(void* user_data) +{ + vm_audio_stop(audio_callback); + return true; +} + +boolean audioSetVolume(void* user_data) +{ + vm_set_volume(LAudio.getVolume()); + return true; +} + + diff --git a/hardware/arduino/mtk/libraries/LAudio/utility/Audio.h b/hardware/arduino/mtk/libraries/LAudio/utility/Audio.h new file mode 100644 index 00000000..efe6ee5c --- /dev/null +++ b/hardware/arduino/mtk/libraries/LAudio/utility/Audio.h @@ -0,0 +1,56 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef _VMAUDIO_H +#define _VMAUDIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "chip.h" +#include "LAudio.h" + +boolean audioPlay(void* user_data); +boolean audioPause(void* user_data); +boolean audioResume(void* user_data); +boolean audioSetVolume(void* user_data); +boolean audioStop(void* user_data); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/hardware/arduino/mtk/libraries/LBT/LBT.cpp b/hardware/arduino/mtk/libraries/LBT/LBT.cpp new file mode 100644 index 00000000..3f404d9a --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBT/LBT.cpp @@ -0,0 +1,23 @@ +#include +#include "LBT.h" +LBTRingBuffer::LBTRingBuffer( void ) +{ + memset( _aucBuffer, 0, LBT_SERIAL_BUFFER_SIZE ) ; + _iHead=0 ; + _iTail=0 ; +} + +void LBTRingBuffer::store_char( uint8_t c ) +{ + int i = (uint32_t)(_iHead + 1) % LBT_SERIAL_BUFFER_SIZE ; + + // if we should be storing the received character into the location + // just before the tail (meaning that the head would advance to the + // current location of the tail), we're about to overflow the buffer + // and so we don't write the character or advance the head. + if ( i != _iTail ) + { + _aucBuffer[_iHead] = c ; + _iHead = i ; + } +} diff --git a/hardware/arduino/mtk/libraries/LBT/LBT.h b/hardware/arduino/mtk/libraries/LBT/LBT.h new file mode 100644 index 00000000..2989249c --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBT/LBT.h @@ -0,0 +1,88 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef LBT_H +#define LBT_H + +#if defined(__LINKIT_ONE_DEBUG__) +#define LBT_DEBUG +#endif + +#include +#include "LTask.h" +#include "Vmbtcm.h" +#include + +#define LBT_DEVICE_NAME_LENGTH 56 + +#define LBT_PIN_CODE_BUFFER_SIZE (20) + +struct BTBase +{ + _LTaskClass *ptr; +}; + +struct LBTAddress +{ + uint8_t lap[3]; + uint8_t uap; + uint8_t nap[2]; +}; + +typedef struct +{ + LBTAddress address; + char name[56]; +} LBTDeviceInfo; + + + +// Define constants and variables for buffering incoming serial data. We're +// using a ring buffer (I think), in which head is the index of the location +// to which to write the next incoming character and tail is the index of the +// location from which to read. +#define LBT_SERIAL_BUFFER_SIZE (1024*6) + +class LBTRingBuffer +{ + public: + uint8_t _aucBuffer[LBT_SERIAL_BUFFER_SIZE] ; + int _iHead ; + int _iTail ; + + public: + LBTRingBuffer( void ) ; + void store_char( uint8_t c ) ; +} ; +#endif //#ifndef LBT_H diff --git a/hardware/arduino/mtk/libraries/LBT/LBTClient.cpp b/hardware/arduino/mtk/libraries/LBT/LBTClient.cpp new file mode 100644 index 00000000..8008b128 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBT/LBTClient.cpp @@ -0,0 +1,241 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "arduino.h" +#include "vmlog.h" +#include "BTClient.h" +#include "LBTClient.h" +#include "vmthread.h" +#include "LBT.h" +extern int addrStr2Mac(const char *MACAddr, LBTAddress &address); +extern void app_log_file(char *fmt, ...); +#ifdef LBT_DEBUG +#define APP_LOG(...) app_log_file(__VA_ARGS__); \ + vm_log_info(__VA_ARGS__) +#else +#define APP_LOG(...) +#endif + +vm_thread_mutex_struct client_mutex = {0}; +LBTClientClass::LBTClientClass(LBTRingBuffer* pRx_buffer) : m_post_write(0), m_post_read(0) +{ + _rx_buffer = pRx_buffer; +} + +boolean LBTClientClass::begin(const uint8_t* pinCode) +{ + _LTaskClass::begin(); + + m_signal_write = vm_signal_init(); + m_signal_read = vm_signal_init(); + + LBTClientBeginContext c; + c.ptr = this; + c.result = false; + c.is_set_pin = false; + //boolean result = true; + //APP_LOG("begin"); + if(pinCode!= NULL) + { + int len = strlen((char*)pinCode); + if(len > LBT_PIN_CODE_BUFFER_SIZE - 1) + { + len = LBT_PIN_CODE_BUFFER_SIZE - 1; + } + c.is_set_pin = true; + memcpy(_pincode_buffer, pinCode, len+1); + } + + + remoteCall(btClientBegin, &c); + + //APP_LOG("begin = %d", result); + + return c.result; +} + +void LBTClientClass::end(void) +{ + _LTaskClass::stop(); + vm_signal_clean(m_signal_write); + vm_signal_deinit(m_signal_write); + vm_signal_clean(m_signal_read); + vm_signal_deinit(m_signal_read); + remoteCall(btClientEnd, (void*)NULL); +} + +boolean LBTClientClass::connect(const char *MACAddr) +{ + LBTClientConnectContext c; + + LBTAddress addr = {0}; + c.address = &addr; + if (0 > addrStr2Mac(MACAddr, *(c.address))) + return false; + + remoteCall(btClientConnect, (void*)&c); + + return c.result; +} + + +boolean LBTClientClass::connect(LBTAddress &address) +{ + LBTClientConnectContext c; + c.address = &address; + remoteCall(btClientConnect, (void*)&c); + + return c.result; +} + +boolean LBTClientClass::connected(void) +{ + boolean result = true; + remoteCall(btClientConnected, &result); + + return result; +} + +int LBTClientClass::scan(size_t time_out) +{ + LBTClientScanContext c; + c.time_out= time_out; + remoteCall(btClientScan, (void*)&c); + + return c.number; +} + +boolean LBTClientClass::getDeviceInfo(size_t index, LBTDeviceInfo* device_info) +{ + LBTClientGetDeviceInfoContext c; + c.index = index; + c.device_info = device_info; + remoteCall(btClientGetDeviceInfo, (void*)&c); + + return c.result; +} + +size_t LBTClientClass::write(const uint8_t *buf, size_t size) +{ + LBTClientReadWriteContext c; + c.buf = (void*)buf; + c.len = size; + + if (!m_post_write) + { + APP_LOG((char*)"LBTClientClass::write wait"); + vm_signal_wait(m_signal_write); // wait for VM_SRV_SPP_EVENT_READY_TO_WRITE + APP_LOG((char*)"LBTClientClass::write wait ok"); + } + m_post_write = 0; + vm_signal_clean(m_signal_write); + + remoteCall(btClientWrite, (void*)&c); + m_post_write = 1; + + return c.lenProcessed; +} + +void LBTClientClass::post_signal_write() +{ + APP_LOG((char*)"LBTClientClass::post_signal_write"); + vm_signal_post(m_signal_write); + m_post_write = 1; +} + +void LBTClientClass::post_signal_read() +{ + APP_LOG((char*)"LBTClientClass::post_signal_read"); + vm_signal_post(m_signal_read); + m_post_read = 1; +} + +int LBTClientClass::available(void) +{ + return (uint32_t)(LBT_SERIAL_BUFFER_SIZE + _rx_buffer->_iHead - _rx_buffer->_iTail) % LBT_SERIAL_BUFFER_SIZE; +} + +int LBTClientClass::peek(void) +{ + if(_rx_buffer->_iHead == _rx_buffer->_iTail) + return -1; + return _rx_buffer->_aucBuffer[_rx_buffer->_iTail]; +} + +int LBTClientClass::read(void) +{ + + if(_rx_buffer->_iHead == _rx_buffer->_iTail) + return -1; + if(client_mutex.guard == 0) + { + vm_mutex_create(&client_mutex); + } + vm_mutex_lock(&client_mutex); + uint8_t uc = _rx_buffer->_aucBuffer[_rx_buffer->_iTail]; + _rx_buffer->_iTail = (unsigned int)(_rx_buffer->_iTail + 1) % LBT_SERIAL_BUFFER_SIZE; + vm_mutex_unlock(&client_mutex); + return uc; +} + +void LBTClientClass::flush(void) +{ + while(read()!=-1); +} + +size_t LBTClientClass::write(const uint8_t data) +{ + LBTClientReadWriteContext c; + c.buf = (void*)&data; + c.len = 1; + + if (!m_post_write) + { + APP_LOG((char*)"LBTClientClass::write wait"); + vm_signal_wait(m_signal_write); // wait for VM_SRV_SPP_EVENT_READY_TO_WRITE + APP_LOG((char*)"LBTClientClass::write wait ok"); + } + m_post_write = 0; + vm_signal_clean(m_signal_write); + + remoteCall(btClientWrite, (void*)&c); + m_post_write = 1; + + return c.lenProcessed; +} + +LBTRingBuffer LBTClient_rx_buffer; +LBTClientClass LBTClient(&LBTClient_rx_buffer); + + diff --git a/hardware/arduino/mtk/libraries/LBT/LBTClient.h b/hardware/arduino/mtk/libraries/LBT/LBTClient.h new file mode 100644 index 00000000..21515be6 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBT/LBTClient.h @@ -0,0 +1,591 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef LBTCLIENT_H +#define LBTCLIENT_H + +#include "LTask.h" +#include "LBT.h" + +struct LBTClientBeginContext : BTBase +{ + void* name; + boolean result; + boolean is_set_pin; + LBTClientBeginContext(): + name(NULL), + result(false) + { + + } +}; + +struct LBTClientConnectContext : BTBase +{ + LBTAddress* address; + boolean result; + + LBTClientConnectContext(): + address(NULL), + result(false) + { + + } +}; + +struct LBTClientScanContext : BTBase +{ + size_t time_out; + size_t number; + + LBTClientScanContext(): + time_out(20), + number(0) + { + + } +}; + +struct LBTClientGetDeviceInfoContext : BTBase +{ + size_t index; + LBTDeviceInfo* device_info; + boolean result; + + LBTClientGetDeviceInfoContext(): + index(0), + device_info(NULL), + result(false) + { + + } +}; + +struct LBTClientReadWriteContext : BTBase +{ + void *buf; + VMUINT len; + VMINT lenProcessed; // bytes read or written + + LBTClientReadWriteContext(): + buf(NULL), + len(1), + lenProcessed(0) + { + + } +}; + + +// LBTClient class interface +class LBTClientClass : public _LTaskClass, public Stream { + +public: + LBTRingBuffer *_rx_buffer; + uint8_t _pincode_buffer[LBT_PIN_CODE_BUFFER_SIZE]; +// Constructor +public: + LBTClientClass(LBTRingBuffer* pRx_buffer); + +// Method +public: + + // DESCRIPTION + // init BT module and setup a SPP client instance + // RETURNS + // true: success + // false: fail + // EXAMPLE + // + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTClient.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Client successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Client begin successfully"); + // } + // } + // + // void loop() + // { + // + // } + // + boolean begin(const uint8_t* pinCode = NULL); + + // DESCRIPTION + // close corresponding SPP client instance and end BT module + // RETURNS + // None + // EXAMPLE + // + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTClient.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Client successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Client begin successfully"); + // } + // + // LBTClient.end(); + // } + // + // void loop() + // { + // + // } + // + void end(void); + + // DESCRIPTION + // connect SPP server with BT address + // RETURNS + // true: success + // false: fail + // EXAMPLE + // + // #include + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTClient.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Client successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Client begin successfully"); + // // start scan, at most scan 15 seconds + // int num = LBTClient.scan(15); + // + // if(num > 0) + // { + // LBTDeviceInfo info = {0}; + // if( LBTClient.getDeviceInfo(0, &info) ) + // { + // bool conn_result = LBTClient.connect(info.address); + // if( !conn_result ) + // { + // Serial.println("Cannot connect to Spp Server successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Connect to Spp Server successfully"); + // } + // } + // else + // { + // Serial.println("Device index not correct"); + // // don't do anything else + // while(true); + // } + // } + // } + // } + // + boolean connect( + LBTAddress &address //[IN] BT address to connect + ); + + // DESCRIPTION + // connect SPP server with BT address + // RETURNS + // true: success + // false: fail + // EXAMPLE + // + // #include + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTClient.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Client successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Client begin successfully"); + // // start scan, at most scan 15 seconds + // int num = LBTClient.scan(15); + // + // if(num > 0) + // { + // LBTDeviceInfo info = {0}; + // bool conn_result = LBTClient.connect("1234:56:abcdef"); + // if( !conn_result ) + // { + // Serial.println("Cannot connect to Spp Server successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Connect to Spp Server successfully"); + // } + // } + // } + // } + // + boolean connect( + const char *MACAddr //[IN] BT address to connect + ); + // DESCRIPTION + // check if any SPP server is conneccted + // RETURNS + // true: yes + // false: no + // EXAMPLE + // + // #include + // #include + // + // LBTDeviceInfo info = {0}; + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTClient.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Client successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Client begin successfully"); + // // start scan, at most scanned 15 seconds + // int num = LBTClient.scan(15); + // + // if(num > 0) + // { + // if( LBTClient.getDeviceInfo(0, &info) ) + // { + // Serial.println("Get device info of interested server"); + // } + // else + // { + // Serial.println("Device index not correct"); + // // don't do anything else + // while(true); + // } + // } + // } + // } + // + boolean connected(void); + + // DESCRIPTION + // scan BT devices around, at most scanned 10 devices + // RETURNS + // number of devices scanned + // EXAMPLE + // + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTClient.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Client successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Client begin successfully"); + // // start scan, at most scanned 15 seconds + // int num = LBTClient.scan(15); + // Serial.print("Scaned Device number:"); + // Serial.println(num); + // } + // } + // + // void loop() + // { + // + // } + // + int scan( + size_t time_out = 20 // [IN] time out duration in seconds of the scan process + ); + + // DESCRIPTION + // get scanned device information + // RETURNS + // true: success + // false : fail. Possible reasons are index not reasonable or never scanned before + // EXAMPLE + // + // #include + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTClient.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Client successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Client begin successfully"); + // // start scan, at most scanned 15 seconds + // int num = LBTClient.scan(15); + // Serial.print("Scaned Device number:"); + // Serial.println(num); + // + // for(int i = 0; i < num; ++i) + // { + // LBTDeviceInfo info = {0}; + // bool success = LBTClient.getDeviceInfo(i, &info); + // if( success ) + // { + // Serial.print("Device"); + // Serial.println(i); + // Serial.print(" name:"); + // Serial.println(info.name); + // } + // } + // } + // } + // + // void loop() + // { + // + // } + // + boolean getDeviceInfo( + size_t index, // [IN] device index of the scanned result + LBTDeviceInfo* dev_info // [OUT] device info acquired + ); + + // DESCRIPTION + // read data from SPP server + // RETURNS + // number of bytes read + // 0 for no data to read + // EXAMPLE + // + // #include + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTClient.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Client successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Client begin successfully"); + // // start scan, at most scanned 15 seconds + // int num = LBTClient.scan(15); + // + // if(num > 0) + // { + // LBTDeviceInfo info = {0}; + // if( LBTClient.getDeviceInfo(0, &info) ) + // { + // bool conn_result = LBTClient.connect(info.address); + // if( !conn_result ) + // { + // Serial.println("Cannot connect to Spp Server successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Connect to Spp Server successfully"); + // } + // } + // else + // { + // Serial.println("Device index not correct"); + // // don't do anything else + // while(true); + // } + // } + // } + // } + // + // void loop() + // { + // char buffer[10]; + // int read_size = LBTClient.read((uint8_t*)buffer, 10); + // if(read_size > 0) + // { + // Serial.print("size read: "); + // Serial.println(read_size); + // Serial.println(buffer); + // } + // } + // + + int read(void); + + // DESCRIPTION + // write data to SPP server + // RETURNS + // number of bytes written + // 0 for no buffer to write + // EXAMPLE + // + // #include + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTClient.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Client successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Client begin successfully"); + // // start scan, at most scanned 15 seconds + // int num = LBTClient.scan(15); + // + // if(num > 0) + // { + // LBTDeviceInfo info = {0}; + // if( LBTClient.getDeviceInfo(0, &info) ) + // { + // bool conn_result = LBTClient.connect(info.address); + // if( !conn_result ) + // { + // Serial.println("Cannot connect to Spp Server successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Connect to Spp Server successfully"); + // } + // } + // else + // { + // Serial.println("Device index not correct"); + // // don't do anything else + // while(true); + // } + // } + // } + // } + // + // void loop() + // { + // char* buffer = "LinkIt BT Client"; + // int write_size = LBTClient.write((uint8_t*)buffer, strlen(write_buf)); + // if(write_size > 0) + // { + // Serial.print("write read: "); + // Serial.println(write_size); + // } + //} + // + + size_t write( + const uint8_t* buf, // [IN] daat to write + size_t size = 1 // [IN] size of the buffer + ); + + // get the number of bytes(characters)avaiable for reading from the serial port. + // + // RETURNS + // the bumbers of bytes available to read + int available(void); + + // returns the next byte of incoming serial data without removing it from the + // internal serial buffer + // + // RETURNS + // the first byte of incoming serial data available, -1 if no data is available + int peek(void); + + // waits for the transmission of outgoing serial data to complete + // + // RETURNS none + void flush(void); + +// write a char +// +// RETURNS +// the number of write + size_t write(const uint8_t data //[IN] input char + ); + + using Print::write; + + void post_signal_write(); + void post_signal_read(); + +private: + int m_post_write; + VM_SIGNAL_ID m_signal_write; + int m_post_read; + VM_SIGNAL_ID m_signal_read; + +}; + +extern LBTClientClass LBTClient; + +#endif //#ifndef LBTCLIENT_H diff --git a/hardware/arduino/mtk/libraries/LBT/LBTServer.cpp b/hardware/arduino/mtk/libraries/LBT/LBTServer.cpp new file mode 100644 index 00000000..abb5f380 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBT/LBTServer.cpp @@ -0,0 +1,318 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "arduino.h" +#include "BTServer.h" +#include "LBTServer.h" +#include "vmlog.h" +#include "vmthread.h" +#include "LBT.h" +extern int addrStr2Mac(const char *MACAddr, LBTAddress &address); +extern void app_log_file(char *fmt, ...); +#ifdef LBT_DEBUG +#define APP_LOG(...) app_log_file(__VA_ARGS__); \ + vm_log_info(__VA_ARGS__) +#else +#define APP_LOG(...) +#endif + +vm_thread_mutex_struct server_mutex = {0}; +LBTServerClass::LBTServerClass(LBTRingBuffer* pRx_buffer) : m_post_write(0), m_post_read(0) +{ + _rx_buffer = pRx_buffer; +} + + +boolean LBTServerClass::begin(const uint8_t* buf, const uint8_t* pinCode) +{ + APP_LOG((char*)"LBTServerClass::begin"); + _LTaskClass::begin(); + LBTServerBeginContext c; + c.is_set_pin = false; + if(pinCode!= NULL) + { + int len = strlen((char*)pinCode); + if(len > LBT_PIN_CODE_BUFFER_SIZE - 1) + { + len = LBT_PIN_CODE_BUFFER_SIZE - 1; + } + c.is_set_pin = true; + memcpy(_pincode_buffer, pinCode, len+1); + } + + m_signal_write = vm_signal_init(); + m_signal_read = vm_signal_init(); + + + c.name = (void*)buf; + c.ptr = this; + remoteCall(btServerBegin, &c); + return c.result; +} + +void LBTServerClass::end(void) +{ + _LTaskClass::stop(); + + vm_signal_clean(m_signal_write); + vm_signal_deinit(m_signal_write); + vm_signal_clean(m_signal_read); + vm_signal_deinit(m_signal_read); + remoteCall(btServerEnd, (void*)NULL); +} + +boolean LBTServerClass::accept(size_t time_out) +{ + LBTServerAcceptContext c; + c.time_out = time_out; + c.address = NULL; + remoteCall(btServerAccept, (void*)&c); + + return c.result; +} + + +boolean LBTServerClass::accept(size_t time_out, const char *MACAddr) +{ + LBTServerAcceptContext c; + c.time_out = time_out; + LBTAddress addr = {0}; + c.address = &addr; + if (0 > addrStr2Mac(MACAddr, *(c.address))) + return false; + remoteCall(btServerAccept, (void*)&c); + + return c.result; +} + +boolean LBTServerClass::connected(void) +{ + boolean result = true; + remoteCall(btServerConnected, &result); + + return result; + +} + +boolean LBTServerClass::getHostDeviceInfo(LBTDeviceInfo* device_info) +{ + LBTServerGetHostDeviceInfoContext c; + c.device_info = device_info; + remoteCall(btServerGetHostDeviceInfo, (void*)&c); + + return c.result; +} + +size_t LBTServerClass::write(const uint8_t *buf, size_t size) +{ + LBTServerReadWriteContext c; + c.buf = (void*)buf; + c.len = size; + + if (!m_post_write) + { + APP_LOG((char*)"LBTServerClass::write wait"); + vm_signal_wait(m_signal_write); // wait for VM_SRV_SPP_EVENT_READY_TO_WRITE + APP_LOG((char*)"LBTServerClass::write wait ok"); + } + vm_signal_clean(m_signal_write); + m_post_write = 0; + + remoteCall(btServerWrite, (void*)&c); + m_post_write = 1; + + return c.lenProcessed; +} + +void LBTServerClass::post_signal_write() +{ + APP_LOG((char*)"LBTServerClass::post_signal_write"); + vm_signal_post(m_signal_write); + m_post_write = 1; +} + +void LBTServerClass::post_signal_read() +{ + APP_LOG((char*)"LBTServerClass::post_signal_read"); + vm_signal_post(m_signal_read); + m_post_read = 1; +} + +uint8_t a2x(char ch) +{ + + switch(ch) + { + case '0': + return 0; + case '1': + return 1; + case '2': + return 2; + case '3': + return 3; + case '4': + return 4; + case '5': + return 5; + case '6': + return 6; + case '7': + return 7; + case '8': + return 8; + case '9': + return 9; + case 'A': + case 'a': + return 10; + case 'B': + case 'b': + return 11; + case 'C': + case 'c': + return 12; + case 'D': + case 'd': + return 13; + case 'E': + case 'e': + return 14; + case 'F': + case 'f': + return 15; + default: + break;; + } + + + return -1; + +} + +int addrStr2Mac(const char *MACAddr, LBTAddress &address) +{ + if (14 != strlen(MACAddr)) + { + return -1; + } + + if (MACAddr[4] != ':' || MACAddr[7] != ':') + { + return -2; + } + + char tmp[13] = {0}; + strncpy(tmp, MACAddr, 4); + strncpy(tmp + 4, MACAddr + 5, 2); + strncpy(tmp + 6, MACAddr + 8, 6); + + for (int i = 0; i < 12; ++i) + { + if (0 > a2x(tmp[i])) + return -3; + } + + address.nap[1] = a2x(tmp[0])*16 + a2x(tmp[1]); + address.nap[0] = a2x(tmp[2])*16 + a2x(tmp[3]); + address.uap = a2x(tmp[4])*16 + a2x(tmp[5]); + address.lap[2] = a2x(tmp[6])*16 + a2x(tmp[7]); + address.lap[1] = a2x(tmp[8])*16 + a2x(tmp[9]); + address.lap[0] = a2x(tmp[10])*16 + a2x(tmp[11]); + + return 0; +} + + +int LBTServerClass::available(void) +{ + return (uint32_t)(LBT_SERIAL_BUFFER_SIZE + _rx_buffer->_iHead - _rx_buffer->_iTail) % LBT_SERIAL_BUFFER_SIZE; +} + +int LBTServerClass::peek(void) +{ + if(_rx_buffer->_iHead == _rx_buffer->_iTail) + return -1; + return _rx_buffer->_aucBuffer[_rx_buffer->_iTail]; +} + +int LBTServerClass::read(void) +{ + + if(_rx_buffer->_iHead == _rx_buffer->_iTail) + { + return -1; + } + if(server_mutex.guard == 0) + { + vm_mutex_create(&server_mutex); + } + vm_mutex_lock(&server_mutex); + uint8_t uc = _rx_buffer->_aucBuffer[_rx_buffer->_iTail]; + _rx_buffer->_iTail = (unsigned int)(_rx_buffer->_iTail + 1) % LBT_SERIAL_BUFFER_SIZE; + vm_mutex_unlock(&server_mutex); + return uc; + +} + +void LBTServerClass::flush(void) +{ + while(read()!=-1); +} + +size_t LBTServerClass::write(const uint8_t data) +{ + LBTServerReadWriteContext c; + c.buf = (void*)&data; + c.len = 1; + + if (!m_post_write) + { + APP_LOG((char*)"LBTServerClass::write wait"); + vm_signal_wait(m_signal_write); // wait for VM_SRV_SPP_EVENT_READY_TO_WRITE + APP_LOG((char*)"LBTServerClass::write wait ok"); + } + vm_signal_clean(m_signal_write); + m_post_write = 0; + + remoteCall(btServerWrite, (void*)&c); + m_post_write = 1; + + return c.lenProcessed; +} + + +LBTRingBuffer LBTServer_rx_buffer; +LBTServerClass LBTServer(&LBTServer_rx_buffer); + diff --git a/hardware/arduino/mtk/libraries/LBT/LBTServer.h b/hardware/arduino/mtk/libraries/LBT/LBTServer.h new file mode 100644 index 00000000..01ae1ea9 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBT/LBTServer.h @@ -0,0 +1,599 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef LBTSERVER_H +#define LBTSERVER_H + +#include "LTask.h" +#include "LBT.h" + + + +struct LBTServerBeginContext : BTBase +{ + void* name; + boolean result; + boolean is_set_pin; + LBTServerBeginContext(): + name(NULL), + result(false) + { + + } +}; + +struct LBTServerAcceptContext : BTBase +{ + size_t time_out; + boolean result; + LBTAddress *address; + + LBTServerAcceptContext(): + time_out(20), + result(false), + address(NULL) + { + + } +}; + +struct LBTServerGetHostDeviceInfoContext : BTBase +{ + LBTDeviceInfo* device_info; + boolean result; + + LBTServerGetHostDeviceInfoContext(): + device_info(NULL), + result(false) + { + + } +}; + +struct LBTServerReadWriteContext : BTBase +{ + void *buf; + VMINT len; + VMINT lenProcessed; // bytes read or written + + LBTServerReadWriteContext(): + buf(NULL), + len(1), + lenProcessed(0) + { + + } +}; + + +// LBTServer class interface +class LBTServerClass : public _LTaskClass,public Stream{ +public: + LBTRingBuffer *_rx_buffer; + uint8_t _pincode_buffer[LBT_PIN_CODE_BUFFER_SIZE]; +// Constructor +public: + LBTServerClass(LBTRingBuffer* pRx_buffer); + +// Method +public: + + // DESCRIPTION + // init BT module and setup a SPP server instance + // RETURNS + // true: success + // false: fail + // EXAMPLE + // + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTServer.begin("LBTServer"); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Server successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Server begin successfully"); + // } + // } + // + // void loop() + // { + // + // } + // + // connected + // #include + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTServer.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Server successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Server begin successfully"); + // } + // + // } + // + // void loop() + // { + // ĦĦĦĦ if(!LBTServer.connected()) + // { + // // waiting for Spp Client to connect + // bool connected = LBTServer.accept(20); + // + // if( !connected ) + // { + // Serial.println("No connection request yet"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Connected"); + // } + // } + // else + // { + // char buffer[10]; + // int read_size = LBTServer.read((uint8_t*)buffer, 10); + // if(read_size > 0) + // { + // Serial.print("size read: "); + // Serial.println(read_size); + // Serial.println(buffer); + // } + // } + // } + // + boolean begin( + const uint8_t* name = NULL, //[IN] device name to set + const uint8_t* pinCode = NULL + ); + + // DESCRIPTION + // close corresponding SPP server instance and end BT module + // RETURNS + // None + // EXAMPLE + // + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTServer.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Server successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Server begin successfully"); + // } + // + // LBTServer.end(); + // } + // + // void loop() + // { + // + // } + // + // getHostDeviceInfo + // #include + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTServer.begin("LBTServer"); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Server successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Server begin successfully"); + // LBTDeviceInfo info = {0}; + // bool success = LBTServer.getHostDeviceInfo(i, &info); + // if( success ) + // { + // Serial.print("Device name:" ); + // Serial.println(info.name); + // } + // } + // } + // + // void loop() + // { + // + // } + // + void end(void); + + // DESCRIPTION + // accept SPP client's connection request. + // returns as long as the connection is made or timeout + // RETURNS + // true: success + // false: fail + // EXAMPLE + // + // #include + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTServer.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Server successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Server begin successfully"); + // } + // + // // waiting for Spp Client to connect + // bool connected = LBTServer.accept(20); + // + // if( !connected ) + // { + // Serial.println("No connection request yet"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Connected"); + // } + // } + // + // void loop() + // { + // + // } + // + boolean accept( + size_t time_out = 20 //[IN] time out duration while waiting for SPP client's connection request + ); + + // DESCRIPTION + // accept SPP client's connection request. + // returns as long as the connection is made or timeout + // RETURNS + // true: success + // false: fail + // EXAMPLE + // + // #include + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTServer.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Server successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Server begin successfully"); + // } + // + // // waiting for Spp Client to connect + // bool connected = LBTServer.accept(20, "1234:56:abcdef"); + // + // if( !connected ) + // { + // Serial.println("No connection request yet"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Connected"); + // } + // } + // + // void loop() + // { + // + // } + // + boolean accept( + size_t time_out, //[IN] time out duration while waiting for SPP client's connection request + const char *MACAddr); + + // DESCRIPTION + // check if any SPP client is conneccted + // RETURNS + // true: yes + // false: no + // EXAMPLE + // + // #include + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTServer.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Server successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Server begin successfully"); + // } + // + // } + // + // void loop() + // { + // ĦĦĦĦ if(!LBTServer.connected()) + // { + // // waiting for Spp Client to connect + // bool connected = LBTServer.accept(20); + // + // if( !connected ) + // { + // Serial.println("No connection request yet"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Connected"); + // } + // } + // else + // { + // char buffer[10]; + // int read_size = LBTServer.read((uint8_t*)buffer, 10); + // if(read_size > 0) + // { + // Serial.print("size read: "); + // Serial.println(read_size); + // Serial.println(buffer); + // } + // } + // } + // + boolean connected(void); + + // DESCRIPTION + // get scanned device information + // RETURNS + // true: success + // false : fail. Possible reasons are index not reasonable or never scanned before + // EXAMPLE + // + // #include + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTServer.begin("LBTServer"); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Server successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Server begin successfully"); + // LBTDeviceInfo info = {0}; + // bool success = LBTServer.getHostDeviceInfo(i, &info); + // if( success ) + // { + // Serial.print("Device name:" ); + // Serial.println(info.name); + // } + // } + // } + // + // void loop() + // { + // + // } + // + boolean getHostDeviceInfo( + LBTDeviceInfo* dev_info // [OUT] device info acquired + ); + + // DESCRIPTION + // read data from SPP client + // RETURNS + // number of bytes read + // 0 for no data to read + // EXAMPLE + // + // #include + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTServer.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Server successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Server begin successfully"); + // } + // + // // waiting for Spp Client to connect + // bool connected = LBTServer.accept(20); + // + // if( !connected ) + // { + // Serial.println("No connection request yet"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Connected"); + // } + // } + // + // void loop() + // { + // char buffer[10]; + // int read_size = LBTServer.read((uint8_t*)buffer, 10); + // if(read_size > 0) + // { + // Serial.print("size read: "); + // Serial.println(read_size); + // Serial.println(buffer); + // } + // } + // + + int read(void); + + // DESCRIPTION + // write data to SPP client + // RETURNS + // number of bytes written + // 0 for write fail + // EXAMPLE + // + // #include + // #include + // + // void setup() + // { + // Serial.begin(9600); + // bool success = LBTServer.begin(); + // if( !success ) + // { + // Serial.println("Cannot begin Bluetooth Server successfully"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Bluetooth Server begin successfully"); + // } + // + // // waiting for Spp Client to connect + // bool connected = LBTServer.accept(20); + // + // if( !connected ) + // { + // Serial.println("No connection request yet"); + // // don't do anything else + // while(true); + // } + // else + // { + // Serial.println("Connected"); + // } + // } + // + // void loop() + // { + // char* buffer = "LinkIt BT Server"; + // int write_size = LBTServer.write((uint8_t*)buffer, strlen(buffer)); + // if(write_size > 0) + // { + // Serial.print("Size written: "); + // Serial.println(write_size); + // } + // } + // + size_t write( + const uint8_t* buf, // [IN] daat to write + size_t size = 1 // [IN] size of the buffer + ); + + // get the number of bytes(characters)avaiable for reading from the serial port. + // + // RETURNS + // the bumbers of bytes available to read + int available(void); + + // returns the next byte of incoming serial data without removing it from the + // internal serial buffer + // + // RETURNS + // the first byte of incoming serial data available, -1 if no data is available + int peek(void); + + // waits for the transmission of outgoing serial data to complete + // + // RETURNS none + void flush(void); + +// write a char +// +// RETURNS +// the number of write + size_t write(const uint8_t data //[IN] input char + ); + + using Print::write; + + void post_signal_write(); + void post_signal_read(); +private: + int m_post_write; + VM_SIGNAL_ID m_signal_write; + int m_post_read; + VM_SIGNAL_ID m_signal_read; +}; + +extern LBTServerClass LBTServer; + +#endif //#ifndef LBTSERVER_H diff --git a/hardware/arduino/mtk/libraries/LBT/examples/BTSPP/BTClient/BTClient.ino b/hardware/arduino/mtk/libraries/LBT/examples/BTSPP/BTClient/BTClient.ino new file mode 100644 index 00000000..898add31 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBT/examples/BTSPP/BTClient/BTClient.ino @@ -0,0 +1,96 @@ +#include +#include + + +static LBTDeviceInfo info = {0}; +boolean find = 0; +#define SPP_SVR "ARD_SPP" // it should be the prefer server's name, customize it yourself. +#define ard_log Serial.printf +int read_size = 0; +void setup() +{ + Serial.begin(9600); + ard_log("LBT start"); + // begin BT + bool success = LBTClient.begin(); + if( !success ) + { + ard_log("Cannot begin Bluetooth Client successfully"); + delay(0xffffffff); + } + else + { + ard_log("Bluetooth Client begin successfully"); + // scan the devices around + int num = LBTClient.scan(30); + ard_log("scanned device number [%d]", num); + for (int i = 0; i < num; i++) + { + memset(&info, 0, sizeof(info)); + // to check the prefer master(server)'s name + if (!LBTClient.getDeviceInfo(i, &info)) + { + continue; + } + ard_log("getDeviceInfo [%02x:%02x:%02x:%02x:%02x:%02x][%s]", + info.address.nap[1], info.address.nap[0], info.address.uap, info.address.lap[2], info.address.lap[1], info.address.lap[0], + info.name); + if (0 == strcmp(info.name, SPP_SVR)) + { + find = 1; + ard_log("found"); + break; + } + } + + } +} + +void loop() +{ + + // to check if the connection is ready + if(find && !LBTClient.connected()) + { + ard_log("Diconnected, try to connect"); + // do connect + bool conn_result = LBTClient.connect(info.address); + ard_log("connect result [%d]", conn_result); + + if( !conn_result ) + { + ard_log("Cannot connect to SPP Server successfully"); + delay(0xffffffff); + } + else + { + ard_log("Connect to SPP Server successfully"); + } + + char buffer[32] = {0}; + int write_size = LBTClient.write((uint8_t*)"123456789012", 12); + ard_log("client first spec write_size [%d]", write_size); + + // to read the data from master(server) + while(1) + { + if(LBTClient.available()) + { + read_size = LBTClient.readBytes(buffer,32); + break; + } + delay(100); + } + ard_log("read size [%d][%s]", read_size, buffer); + + + write_size = LBTClient.write((uint8_t*)"LinkIt BT Client", 16); + ard_log("write_size [%d]", write_size); + + + find = 0; + } + ard_log("loop client"); + delay(2000); + +} diff --git a/hardware/arduino/mtk/libraries/LBT/examples/BTSPP/BTServer/BTServer.ino b/hardware/arduino/mtk/libraries/LBT/examples/BTSPP/BTServer/BTServer.ino new file mode 100644 index 00000000..d210fb8d --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBT/examples/BTSPP/BTServer/BTServer.ino @@ -0,0 +1,92 @@ +#include +#include +#define SPP_SVR "ARD_SPP" // it is the server's visible name, customize it yourself. +#define ard_log Serial.printf + +int read_size = 0; +void setup() { + // put your setup code here, to run once: + Serial.begin(9600); + ard_log("start BTS"); + + bool success = LBTServer.begin((uint8_t*)SPP_SVR); + if( !success ) + { + ard_log("Cannot begin Bluetooth Server successfully"); + // don't do anything else + delay(0xffffffff); + } + else + { + LBTDeviceInfo info; + if (LBTServer.getHostDeviceInfo(&info)) + { + ard_log("LBTServer.getHostDeviceInfo [%02x:%02x:%02x:%02x:%02x:%02x]", + info.address.nap[1], info.address.nap[0], info.address.uap, info.address.lap[2], info.address.lap[1], info.address.lap[0]); + } + else + { + ard_log("LBTServer.getHostDeviceInfo failed"); + } + ard_log("Bluetooth Server begin successfully"); + } + + // waiting for Spp Client to connect + bool connected = LBTServer.accept(1800); + + if( !connected ) + { + ard_log("No connection request yet"); + // don't do anything else + delay(0xffffffff); + } + else + { + ard_log("Connected"); + } +} + +int sent = 0; +void loop() { + // put your main code here, to run repeatedly: + if (!sent) + { + char buffer[32] = {0}; + //int read_size = LBTServer.read((uint8_t*)buffer, 32); + //vm_log_info("spec read size [%d][%s]", read_size); + + char* buffer_w = "LinkIt BT Server"; + int write_size = LBTServer.write((uint8_t*)buffer_w, strlen(buffer_w)); + ard_log("write_size [%d]", write_size); + + + memset(buffer, 0, sizeof(buffer)); + while(1) + { + if(LBTServer.available()) + { + read_size = LBTServer.readBytes((uint8_t*)buffer, 32); + break; + } + delay(100); + } + ard_log("read size [%d][%s]", read_size, buffer); + + memset(buffer, 0, sizeof(buffer)); + while(1) + { + if(LBTServer.available()) + { + read_size = LBTServer.readBytes((uint8_t*)buffer, 32); + break; + } + delay(100); + } + ard_log("read size [%d][%s]", read_size, buffer); + + + sent = 1; + } + ard_log("loop server"); + delay(2000); +} diff --git a/hardware/arduino/mtk/libraries/LBT/utility/BTClient.cpp b/hardware/arduino/mtk/libraries/LBT/utility/BTClient.cpp new file mode 100644 index 00000000..0d5a6ca7 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBT/utility/BTClient.cpp @@ -0,0 +1,916 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "arduino.h" +#include "LBT.h" +#include "Vmbtcm.h" +#include "Vmbtspp.h" +#include "vmlog.h" +#include "BTClient.h" +#include "LBTClient.h" +#include "vmtimer.h" +#include "vmstdlib.h" +#include "vmio.h" +#include "vmchset.h" +#include "vmlog.h" +#include "vmthread.h" + +#define BT_NAME "SPP" +#define LOG_BUF_SIZE 96 +#define FILE_PATH_SIZE 16 +#define SPP_DATA "Hello SPP!" +#ifdef LBT_DEBUG +#define APP_LOG(...) app_log_file(__VA_ARGS__); \ + vm_log_info(__VA_ARGS__) +#else +#define APP_LOG(...) +#endif +static VMINT flag_delete_log; +extern vm_thread_mutex_struct client_mutex; + +void app_log_file(char *fmt, ...) +{ + va_list args; + VMINT drv, hdl; + VMUINT written; + VMINT ret; + vm_time_t time = {0}; + char buf[LOG_BUF_SIZE] = {0}; + VMWCHAR wpath[FILE_PATH_SIZE] = {0}; + VMCHAR path[FILE_PATH_SIZE] = {0}; + + buf[LOG_BUF_SIZE - 2] = '\r'; + buf[LOG_BUF_SIZE - 1] = '\n'; + + va_start( args, fmt ); + vm_get_time(&time); + //ret = va_arg(args, int); + vm_sprintf(buf+strlen(buf), "[%02d:%02d:%02d]", time.hour, time.min, time.sec); + vm_vsprintf(buf+strlen(buf), fmt, args); + + drv = vm_get_removable_driver() > 0 ? vm_get_removeable_driver() : vm_get_system_driver(); + vm_sprintf(path, "%c:\\%s", drv, BT_NAME".log"); + + //vm_log_debug(path); + vm_gb2312_to_ucs2(wpath, sizeof(wpath), path); + //file[0] = (VMWCHAR)drv; + //vm_wsprintf(file, FILE_PATH_SIZE, L"%c:\\%s", + //vm_wstrcat(&file[1], (VMWSTR)L":\\spp_svr.log"); + hdl = vm_file_open(wpath, MODE_APPEND, 0); + if (hdl < 0) + hdl = vm_file_open(wpath, MODE_CREATE_ALWAYS_WRITE, 0); + else + { + if (!flag_delete_log) + { + vm_file_close(hdl); + vm_file_delete(wpath); + flag_delete_log = 1; + hdl = vm_file_open(wpath, MODE_CREATE_ALWAYS_WRITE, 0); + //return; + } + } + //vm_file_seek(hdl, 0, BASE_END); + vm_file_write(hdl, buf, LOG_BUF_SIZE, &written); + vm_file_close(hdl); + + va_end( args ); +} + + +//APP_LOG("receive msg = %d", message); +//APP_LOG((char*)"open failed"); + +#define SPP_UUID 0x1101 +#define MAX_DEVICE_SCANNED 10 + +typedef enum{ + BT_CLIENT_IDLE = 0, + BT_CLIENT_BEGINING = 1, // not even power on, need to power on first + BT_CLIENT_POWERING_ON = 2, // waiting for power on to process + BT_CLIENT_READY = 3, // power on and init done + BT_CLIENT_ENDING = 4, // not event powr off, need to power off first + BT_CLIENT_POWERING_OFF = 5 // waiting for power off to process +}bt_client_status; + +class btClientContext +{ + public: + LBTClientClass *ptr; + VMINT search_tid; + VMINT btcm_hdl; + VMINT btspp_hdl; + VMINT btspp_buf_size; + void* btspp_buf; + + bt_client_status client_status; + size_t scan_number; + VMINT conn_id; + boolean* waiting_result_p; + size_t* scan_number_p; + + btClientContext(int x, int y); +}; + +btClientContext::btClientContext(int x, int y) +{ + btcm_hdl = x; // -1 + btspp_hdl = -1; + btspp_buf_size = -0; + btspp_buf = NULL; + //client_status(BT_CLIENT_IDLE), + scan_number = 0; + conn_id = -1; + waiting_result_p = NULL; + scan_number_p = NULL; + client_status = (bt_client_status)y; // BT_CLIENT_IDLE; + APP_LOG("btClientContext::btClientContext, [%d,%d] [%d,%d]", x, y, btcm_hdl, client_status); +} + + +btClientContext g_clientContext(-1, 0); + +static VMINT bt_client_init_spp(); +static boolean bt_client_end_spp(); + +static void bt_client_btcm_cb(VMUINT evt, void * param, void * user_data) +{ + + APP_LOG("[BTC]bt_client_btcm_cb, evt = %d, client_status = %d", evt, g_clientContext.client_status); + + switch (evt) + { + case VM_SRV_BT_CM_EVENT_ACTIVATE: + { + // waiting for power on to process + if (g_clientContext.client_status == BT_CLIENT_POWERING_ON) + { + VMINT ret = bt_client_init_spp(); + + if(ret<0) + { + *(g_clientContext.waiting_result_p) = false; + g_clientContext.waiting_result_p = NULL; + + if(bt_client_end_spp()) + { + + //LTask.post_signal(); + g_clientContext.ptr->post_signal(); + + } + } + else + { + *(g_clientContext.waiting_result_p) = true; + g_clientContext.waiting_result_p = NULL; + + //LTask.post_signal(); + g_clientContext.ptr->post_signal(); + + } + + } + else if (g_clientContext.client_status == BT_CLIENT_ENDING) + { + VMINT ret = vm_btcm_switch_off(); + + if(VM_SRV_BT_CM_RESULT_SUCCESS == ret) + { + //wait for callback to process + g_clientContext.client_status = BT_CLIENT_POWERING_OFF; + } + else + { + if(g_clientContext.btcm_hdl >= 0) + { + vm_btcm_exit(g_clientContext.btcm_hdl); + g_clientContext.btcm_hdl = -1; + } + + g_clientContext.client_status = BT_CLIENT_IDLE; + + //LTask.post_signal(); + g_clientContext.ptr->post_signal(); + + } + } + + break; + } + + case VM_SRV_BT_CM_EVENT_DEACTIVATE: + { + if (g_clientContext.client_status == BT_CLIENT_BEGINING) + { + VMINT ret = vm_btcm_switch_on(); + + if(VM_SRV_BT_CM_RESULT_SUCCESS == ret) + { + //wait for callback to process + g_clientContext.client_status = BT_CLIENT_POWERING_ON; + } + else + { + *(g_clientContext.waiting_result_p) = false; + g_clientContext.waiting_result_p = NULL; + + if(bt_client_end_spp()) + { + + //LTask.post_signal(); + g_clientContext.ptr->post_signal(); + + } + } + } + else if(g_clientContext.client_status == BT_CLIENT_POWERING_OFF) + { + if(g_clientContext.btcm_hdl >= 0) + { + vm_btcm_exit(g_clientContext.btcm_hdl); + g_clientContext.btcm_hdl = -1; + } + + g_clientContext.client_status = BT_CLIENT_IDLE; + + //LTask.post_signal(); + g_clientContext.ptr->post_signal(); + + } + + break; + } + + case VM_SRV_BT_CM_EVENT_INQUIRY_IND: + { + vm_srv_bt_cm_inquiry_indication_struct *ind = (vm_srv_bt_cm_inquiry_indication_struct *)param; + + if (ind->discovered_dev_num > 0) + { + g_clientContext.scan_number = ind->discovered_dev_num; + } + + + APP_LOG("[BTC]bt_client_btcm_cb, scan_number = %d, discovered_dev_num = %d", g_clientContext.scan_number, ind->discovered_dev_num); + vm_srv_bt_cm_dev_struct dev_info ; + *(g_clientContext.scan_number_p) = g_clientContext.scan_number; + for (int i = 0; i < ind->discovered_dev_num; i++) + { + if( VM_BT_CM_ERR_SUCCESS == vm_btcm_get_dev_info_by_index(i, VM_SRV_BT_CM_DISCOVERED_DEV, &dev_info) ) + { + LBTAddress addr; + addr.nap[0] = (dev_info.bd_addr.nap & 0x00ff); + addr.nap[1] = (dev_info.bd_addr.nap & 0xff00) >> 8; + addr.uap = dev_info.bd_addr.uap; + addr.lap[0] = (dev_info.bd_addr.lap & 0x0000ff); + addr.lap[1] = (dev_info.bd_addr.lap & 0x00ff00) >> 8; + addr.lap[2] = (dev_info.bd_addr.lap & 0xff0000) >> 16; + + APP_LOG("[BTC]VM_SRV_BT_CM_EVENT_INQUIRY_IND, name: %s", dev_info.name); + + + APP_LOG("[BTC]VM_SRV_BT_CM_EVENT_INQUIRY_IND, address: %02x:%02x:%02x:%02x:%02x:%02x:", + addr.nap[1], + addr.nap[0], + addr.uap, + addr.lap[2], + addr.lap[1], + addr.lap[0]); + + } + } + /*if (10 == g_clientContext.scan_number) + { + vm_btcm_search_abort(); + g_clientContext.ptr->post_signal(); + }*/ + + break; + } + + case VM_SRV_BT_CM_EVENT_INQUIRY_COMPLETE: + { + vm_srv_bt_cm_inquiry_complete_struct *cmpl = (vm_srv_bt_cm_inquiry_complete_struct *)param; + + *(g_clientContext.scan_number_p) = g_clientContext.scan_number; + + //LTask.post_signal(); + g_clientContext.ptr->post_signal(); + + break; + } + + case VM_SRV_BT_CM_EVENT_PAIR_IND: + { + vm_srv_bt_cm_pair_ind_struct *event = (vm_srv_bt_cm_pair_ind_struct *)param; + vm_bt_cm_send_passkey(&event->dev_addr, (VMUINT8*)LBTClient._pincode_buffer, VM_TRUE); + break; + } + + default: + { + break; + } + } + + +} + +static int bt_client_spp_read(void* data) +{ + //char readdata[LBT_SERIAL_BUFFER_SIZE]; + VMINT ret = 0; + VMINT i = 0; + if(g_clientContext.conn_id < 0) + { + //not connected yet + + APP_LOG((char*)"[BTC]bt_client_spp_read : not connected yet"); + + return true; + } + char *readdata = new char[LBT_SERIAL_BUFFER_SIZE]; + if(readdata == NULL) + { + APP_LOG((char*)"[BTC]bt_client_spp_read : allocate memory fail"); + return false; + } + ret = vm_btspp_read(g_clientContext.conn_id, (void*)readdata, LBT_SERIAL_BUFFER_SIZE); + + APP_LOG("[BTC]bt_client_spp_read, ret: %d", ret); + + if (ret < 0) + { + APP_LOG((char*)"[BTC]bt_client_spp_read : read data fail"); + + } + else + { + if(client_mutex.guard == 0) + { + vm_mutex_create(&client_mutex); + } + vm_mutex_lock(&client_mutex); + for(i=0;istore_char(readdata[i]); + } + vm_mutex_unlock(&client_mutex); + APP_LOG((char*)"[BTC]bt_client_spp_read : read data success"); + } + delete[] readdata; + return ret; +} + +static void bt_client_spp_cb(VMUINT evt, void * param, void * user_data) +{ + vm_srv_spp_event_cntx* cntx = (vm_srv_spp_event_cntx*)param; + + switch(evt) + { + case VM_SRV_SPP_EVENT_CONNECT: + { + if (cntx->ret) + { + //connect successfully + if(g_clientContext.waiting_result_p != NULL) + { + *(g_clientContext.waiting_result_p) = true; + } + g_clientContext.conn_id = cntx->conn_id; + } + else + { + //connnet fail + if(g_clientContext.waiting_result_p != NULL) + { + *(g_clientContext.waiting_result_p) = false; + } + } + + if(g_clientContext.waiting_result_p != NULL) + { + g_clientContext.waiting_result_p = NULL; + + //LTask.post_signal(); + g_clientContext.ptr->post_signal(); + + } + else + { + // reconnection + } + break; + } + + case VM_SRV_SPP_EVENT_DISCONNECT: + { + g_clientContext.conn_id = -1; + break; + } + + case VM_SRV_SPP_EVENT_READY_TO_WRITE: + { + g_clientContext.ptr->post_signal_write(); + break; + } + + case VM_SRV_SPP_EVENT_READY_TO_READ: + { + bt_client_spp_read(NULL); + +#if(0) + g_clientContext.ptr->post_signal_read(); +#endif + break; + } + + } + +} + +static VMINT bt_client_init_spp() +{ + VMUINT evt_mask = VM_SRV_SPP_EVENT_CONNECT | + VM_SRV_SPP_EVENT_READY_TO_WRITE | + VM_SRV_SPP_EVENT_READY_TO_READ | + VM_SRV_SPP_EVENT_DISCONNECT; + + g_clientContext.btspp_hdl = vm_btspp_open(evt_mask,bt_client_spp_cb,NULL); + + if(g_clientContext.btspp_hdl < 0) + { + APP_LOG((char*)"[BTC]bt_client_init_spp fail : btspp_open"); + + return g_clientContext.btspp_hdl; + } + + vm_btspp_set_security_level(g_clientContext.btspp_hdl,VM_SRV_SPP_SEC_NAN); + + VMINT min_buf_size = vm_btspp_get_min_buf_size(); + g_clientContext.btspp_buf = vm_calloc(min_buf_size); + g_clientContext.btspp_buf_size = min_buf_size; + + if(g_clientContext.btspp_buf == NULL) + { + APP_LOG((char*)"[BTC]bt_client_init_spp fail : alloc buffer"); + + return -1; + } + + APP_LOG("[BTC]bt_client_init_spp done, btspp_hdl=%d", g_clientContext.btspp_hdl); + + return 0; + +} + +static boolean bt_client_end_spp() +{ + if(g_clientContext.btspp_hdl >= 0) + { + vm_btspp_close(g_clientContext.btspp_hdl); + g_clientContext.btspp_hdl = -1; + } + + if(g_clientContext.btspp_buf != NULL) + { + vm_free(g_clientContext.btspp_buf); + g_clientContext.btspp_buf = NULL; + } + + if(g_clientContext.conn_id >= 0) + { + g_clientContext.conn_id = -1; + } + + VMINT ret = vm_btcm_get_power_status(); + + APP_LOG("[BTC]bt_client_end_spp, power status = %d", ret); + + if (VM_SRV_BT_CM_POWER_ON == ret) + { + VMINT ret = vm_btcm_switch_off(); + + if(VM_SRV_BT_CM_RESULT_SUCCESS == ret) + { + //wait for callback to process + g_clientContext.client_status = BT_CLIENT_POWERING_OFF; + + APP_LOG("[BTC]bt_client_end_spp, wait for power off bt 1"); + + return false; + } + } + else if (VM_SRV_BT_CM_POWER_SWITCHING_ON == ret) + { + g_clientContext.client_status = BT_CLIENT_ENDING; + + APP_LOG("[BTC]bt_client_end_spp, wait for power on bt"); + + return false; + } + else if (VM_SRV_BT_CM_POWER_SWITCHING_OFF == ret) + { + g_clientContext.client_status = BT_CLIENT_POWERING_OFF; + + APP_LOG("[BTC]bt_client_end_spp, wait for power off bt 2"); + + return false; + } + + // VM_SRV_BT_CM_POWER_OFF + if(g_clientContext.btcm_hdl >= 0) + { + vm_btcm_exit(g_clientContext.btcm_hdl); + g_clientContext.btcm_hdl = -1; + } + + g_clientContext.client_status = BT_CLIENT_IDLE; + + APP_LOG("[BTC]bt_client_end_spp, done"); + + return true; + +} + +boolean btClientBegin(void *userData) +{ + + APP_LOG("[Kinse][BTC]btClientBegin, 1"); + + APP_LOG("[Kinse][BTC]btClientBegin = %d, status[%d]" , g_clientContext.btcm_hdl, g_clientContext.client_status); + + LBTClientBeginContext* c = (LBTClientBeginContext*) userData; + g_clientContext.ptr = (LBTClientClass*)c->ptr; + if(c->is_set_pin == true) + { + vm_custom_set_bt_pairing_method(VM_PIN_AND_SSP); + } + if(g_clientContext.btcm_hdl >= 0) + { + //already inited + c->result = false; + APP_LOG((char*)"[BTC]btClientBegin fail : already inited"); + return true; + } + + g_clientContext.btcm_hdl = vm_btcm_init( + bt_client_btcm_cb, + VM_SRV_BT_CM_EVENT_ACTIVATE | + VM_SRV_BT_CM_EVENT_DEACTIVATE | + VM_SRV_BT_CM_EVENT_INQUIRY_IND | + VM_SRV_BT_CM_EVENT_PAIR_IND | + VM_SRV_BT_CM_EVENT_SECURITY_USER_CONFIRM | + VM_SRV_BT_CM_EVENT_INQUIRY_COMPLETE, + NULL); + + APP_LOG("[Kinse][BTC]btClientBegin, 2 = %d" ,g_clientContext.btcm_hdl); + + if(g_clientContext.btcm_hdl < 0) + { + //init btcm fail + c->result = false; + APP_LOG((char*)"[BTC]btClientBegin fail : btcm_init fail"); + return true; + } + + //return true; + + VMINT ret = vm_btcm_get_power_status(); + + APP_LOG("[BTC]btClientBegin, power status = %d", ret); + + if (VM_SRV_BT_CM_POWER_OFF == ret) + { + ret = vm_btcm_switch_on(); + + if(VM_SRV_BT_CM_RESULT_SUCCESS == ret) + { + //wait for callback to process + g_clientContext.client_status = BT_CLIENT_POWERING_ON; + g_clientContext.waiting_result_p = &(c->result); + + APP_LOG("[BTC]btClientBegin, wait for power on bt 1, btcm_hdl=%d", g_clientContext.btcm_hdl); + + return false; + } + } + else if (VM_SRV_BT_CM_POWER_SWITCHING_OFF == ret) + { + g_clientContext.client_status = BT_CLIENT_BEGINING; + g_clientContext.waiting_result_p = &(c->result); + + APP_LOG("[BTC]btClientBegin, wait for power off bt, btcm_hdl=%d", g_clientContext.btcm_hdl); + + return false; + } + else if (VM_SRV_BT_CM_POWER_SWITCHING_ON == ret) + { + g_clientContext.client_status = BT_CLIENT_POWERING_ON; + g_clientContext.waiting_result_p = &(c->result); + + APP_LOG("[BTC]btClientBegin, wait for power on bt 2, btcm_hdl=%d", g_clientContext.btcm_hdl); + + return false; + } + else if (VM_SRV_BT_CM_POWER_ON == ret) + { + ret = bt_client_init_spp(); + } + + if(ret<0) + { + c->result = false; + APP_LOG((char*)"[BTC]btClientBegin fail : init app fail"); + return bt_client_end_spp(); + } + + //success + g_clientContext.client_status = BT_CLIENT_READY; + c->result = true; + + APP_LOG("[BTC]btClientBegin done, btcm_hdl=%d", g_clientContext.btcm_hdl); + + return true; + +} + + +boolean btClientEnd(void *userData) +{ + APP_LOG("[BTC]btClientEnd"); + + return bt_client_end_spp();; +} + +boolean btClientConnect(void *userData) +{ + LBTClientConnectContext* pContext = (LBTClientConnectContext*)userData ; + + if(g_clientContext.conn_id != -1) + { + //someone connected + APP_LOG((char*)"[BTC]btClientConnect fail : already connected = %d", g_clientContext.conn_id); + + pContext->result = false; + return true; + } + + vm_srv_bt_cm_bt_addr btspp_addr = {0}; + btspp_addr.lap = ((0x000000ff & (VMUINT)pContext->address->lap[2]) << 16) | + ((0x000000ff & (VMUINT)pContext->address->lap[1]) << 8) | + (0x000000ff & (VMUINT)pContext->address->lap[0]); + btspp_addr.uap = pContext->address->uap; + btspp_addr.nap = ((0x00ff & (VMUINT16)pContext->address->nap[1]) << 8) | (0x00ff & (VMUINT16)pContext->address->nap[0]); + VMUINT8 *tmp = (VMUINT8*)&btspp_addr.nap; + APP_LOG("[BTC]btClientConnect nap 0x%x, 0x%x", tmp[1], tmp[0]); + APP_LOG("[BTC]btClientConnect nap:%x, uap:%x, lap:%x", btspp_addr.nap, btspp_addr.uap, btspp_addr.lap); + + VMINT ret = vm_btspp_connect( + g_clientContext.btspp_hdl, + &btspp_addr, + g_clientContext.btspp_buf, + g_clientContext.btspp_buf_size/2, + g_clientContext.btspp_buf_size/2, + SPP_UUID); + + //LBTAddress tmp_addr = {0}; + + //memcpy(&tmp_addr, &btspp_addr, sizeof(LBTAddress)); + + APP_LOG("[BTC]btClientConnect ret[%d], address: %02x:%02x:%02x:%02x:%02x:%02x:", + ret, + pContext->address->nap[1], + pContext->address->nap[0], + pContext->address->uap, + pContext->address->lap[2], + pContext->address->lap[1], + pContext->address->lap[0]); + + + if( ret < 0) + { + //connect fail + pContext->result = false; + return true; + } + + // wait for connect result + g_clientContext.waiting_result_p = &(pContext->result); + return false; +} + +boolean btClientConnected(void *userData) +{ + boolean* result = (boolean*) userData; + + APP_LOG("[BTC]btClientConnected, conn_id = %d", g_clientContext.conn_id); + + if(g_clientContext.conn_id != -1) + { + //connected + *result = true; + } + else + { + //not connected yet + *result = false; + } + + return true; +} + +static void bt_client_timeout_cb(VMINT tid) +{ + APP_LOG("[BTC]bt_client_timeout_cb %d", tid); + if (tid == g_clientContext.search_tid) + { + vm_btcm_search_abort(); + vm_delete_timer(g_clientContext.search_tid); + g_clientContext.search_tid = 0; + //g_clientContext.ptr->post_signal(); + } +} +boolean btClientScan(void *userData) +{ + LBTClientScanContext* pContext = (LBTClientScanContext*)userData ; + + g_clientContext.scan_number = 0; + + APP_LOG("[BTC]btClientScan, time_out = %d", pContext->time_out); + + if(pContext->time_out == 0) + { + pContext->number = g_clientContext.scan_number; + return true ; + } + + VMINT ret = vm_btcm_search(MAX_DEVICE_SCANNED, pContext->time_out, 0xFFFFFFFF, 1); + + if (ret < 0) + { + pContext->number = g_clientContext.scan_number; + + APP_LOG((char*)"[BTC]btClientScan fail : btcm_search fail"); + + return true; + } + + g_clientContext.search_tid = vm_create_timer(pContext->time_out*1000, bt_client_timeout_cb); + APP_LOG("[BTC]search_tid = %d, timeout = %d", g_clientContext.search_tid, pContext->time_out*1000); + g_clientContext.scan_number_p = &(pContext->number); + return false; +} + +boolean btClientGetDeviceInfo(void *userData) +{ + + LBTClientGetDeviceInfoContext* pContext = (LBTClientGetDeviceInfoContext*)userData; + + if(pContext->index < 0 || pContext->index >= g_clientContext.scan_number) + { + //invalid range + + APP_LOG((char*)"[BTC]btClientGetDeviceInfo : invalid range = %d", pContext->index); + + pContext->result = false; + return true; + } + + vm_srv_bt_cm_dev_struct dev_info ; + + if( VM_BT_CM_ERR_SUCCESS == vm_btcm_get_dev_info_by_index(pContext->index, VM_SRV_BT_CM_DISCOVERED_DEV, &dev_info) ) + { + pContext->device_info->address.nap[0] = (dev_info.bd_addr.nap & 0x00ff); + pContext->device_info->address.nap[1] = (dev_info.bd_addr.nap & 0xff00) >> 8; + pContext->device_info->address.uap = dev_info.bd_addr.uap; + pContext->device_info->address.lap[0] = (dev_info.bd_addr.lap & 0x0000ff); + pContext->device_info->address.lap[1] = (dev_info.bd_addr.lap & 0x00ff00) >> 8; + pContext->device_info->address.lap[2] = (dev_info.bd_addr.lap & 0xff0000) >> 16; + + strcpy(pContext->device_info->name, (const char*)dev_info.name); + + APP_LOG("[BTC]btClientGetDeviceInfo, name: %s", dev_info.name); + + APP_LOG("[BTC]btClientGetDeviceInfo, bd_addr: nap:%x, uap:%x, lap:%x", + dev_info.bd_addr.nap, + dev_info.bd_addr.uap, + dev_info.bd_addr.lap); + + + APP_LOG("[BTC]btClientGetDeviceInfo, address: %02x:%02x:%02x:%02x:%02x:%02x:", + pContext->device_info->address.nap[1], + pContext->device_info->address.nap[0], + pContext->device_info->address.uap, + pContext->device_info->address.lap[2], + pContext->device_info->address.lap[1], + pContext->device_info->address.lap[0]); + + pContext->result = true; + } + else + { + // fail to get the device info + APP_LOG((char*)"[BTC]btClientGetDeviceInfo : get_dev_info_by_index fail"); + pContext->result = false; + } + + return true; + +} + +boolean btClientRead(void *userData) +{ + + LBTClientReadWriteContext* pContext = (LBTClientReadWriteContext*)userData; + + if(g_clientContext.conn_id < 0) + { + //not connected yet + + APP_LOG((char*)"[BTC]btClientRead : not connected yet"); + + pContext->lenProcessed = 0; + return true; + } + + VMINT ret = vm_btspp_read(g_clientContext.conn_id, pContext->buf, pContext->len); + + APP_LOG("[BTC]btClientRead, ret: %d", ret); + + if (ret < 0) + { + //read fail + pContext->lenProcessed = 0; + } + else + { + pContext->lenProcessed = ret; + } + + return true; +} + +boolean btClientWrite(void *userData) +{ + LBTClientReadWriteContext* pContext = (LBTClientReadWriteContext*)userData; + + if(g_clientContext.conn_id < 0) + { + //not connected yet + + APP_LOG((char*)"[BTC]btClientWrite : not connected yet"); + + pContext->lenProcessed = 0; + return true; + } + + VMINT ret = vm_btspp_write(g_clientContext.conn_id, pContext->buf, pContext->len); + + APP_LOG("[BTC]btClientWrite, ret: %d", ret); + + if (ret < 0) + { + //read fail + pContext->lenProcessed = 0; + } + else + { + pContext->lenProcessed = ret; + } + + return true; +} + diff --git a/hardware/arduino/mtk/libraries/LBT/utility/BTClient.h b/hardware/arduino/mtk/libraries/LBT/utility/BTClient.h new file mode 100644 index 00000000..fad22c87 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBT/utility/BTClient.h @@ -0,0 +1,55 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef BT_CLIENT_H +#define BT_CLIENT_H + +#ifdef __cplusplus +extern "C" { +#endif + +boolean btClientBegin(void *userData); +boolean btClientEnd(void *userData); +boolean btClientConnect(void *userData); +boolean btClientConnected(void *userData); +boolean btClientScan(void *userData); +boolean btClientGetDeviceInfo(void *userData); +boolean btClientRead(void *userData); +boolean btClientWrite(void *userData); + +#ifdef __cplusplus +} +#endif + +#endif //#ifndef BT_CLIENT_H \ No newline at end of file diff --git a/hardware/arduino/mtk/libraries/LBT/utility/BTServer.cpp b/hardware/arduino/mtk/libraries/LBT/utility/BTServer.cpp new file mode 100644 index 00000000..142cf807 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBT/utility/BTServer.cpp @@ -0,0 +1,784 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "arduino.h" +#include "LBT.h" +#include "Vmbtcm.h" +#include "Vmtimer.h" +#include "Vmbtspp.h" +#include "vmlog.h" +#include "BTServer.h" +#include "LBTServer.h" +#include "vmthread.h" +#include "vmstdlib.h" +#include "vmio.h" +#include "vmchset.h" + +#define BT_NAME "SPP" +#define LOG_BUF_SIZE 96 +#define FILE_PATH_SIZE 16 +#define SPP_DATA "Hello SPP!" +#ifdef LBT_DEBUG +#define APP_LOG(...) app_log_file(__VA_ARGS__); \ + vm_log_info(__VA_ARGS__) +#else +#define APP_LOG(...) +#endif +static VMINT flag_delete_log; +extern vm_thread_mutex_struct server_mutex; + +extern void app_log_file(char *fmt, ...); + + + +//vm_log_info("receive msg = %d", message); +//vm_log_warn((char*)"open failed"); + +#define SPP_UUID 0x1101 + +typedef enum +{ + BT_SERVER_IDLE = 0, + BT_SERVER_BEGINING = 1, // not even power on, need to power on first + BT_SERVER_POWERING_ON = 2, // waiting for power on to process + BT_SERVER_READY = 3, // power on and init done + BT_SERVER_ENDING = 4, // not event powr off, need to power off first + BT_SERVER_POWERING_OFF = 5 // waiting for power off to process +}bt_server_status; + +struct btServerContext +{ + LBTServerClass *ptr; + VMINT btcm_hdl; + VMINT btspp_hdl; + VMINT btspp_buf_size; + void* btspp_buf; + VMINT accept_tid; + + bt_server_status server_status; + VMINT conn_id; + boolean waiting_for_accept; + boolean* waiting_result_p; + void* device_name_p; + LBTAddress address; + boolean mac_only; + + btServerContext(): + btcm_hdl(-1), + btspp_hdl(-1), + btspp_buf_size(0), + btspp_buf(NULL), + accept_tid(-1), + server_status(BT_SERVER_IDLE), + conn_id(-1), + waiting_for_accept(false), + waiting_result_p(NULL), + device_name_p(NULL) + { + APP_LOG("[BTC]btServerContext, server_status[%d]", server_status); + } + +}; + +btServerContext g_serverContext; + +static VMINT bt_server_init_spp(uint8_t* name); +static boolean bt_server_end_spp(); + +static void bt_server_btcm_cb(VMUINT evt, void * param, void * user_data) +{ + + APP_LOG("[BTC]bt_server_btcm_cb, evt = %d, client_status = %d", evt, g_serverContext.server_status); + + switch (evt) + { + case VM_SRV_BT_CM_EVENT_ACTIVATE: + { + // waiting for power on to process + if (g_serverContext.server_status == BT_SERVER_POWERING_ON) + { + VMINT ret = bt_server_init_spp((uint8_t*)g_serverContext.device_name_p); + APP_LOG("[BTC]bt_server_init_spp[%d]", ret); + + if(ret<0) + { + *(g_serverContext.waiting_result_p) = false; + g_serverContext.waiting_result_p = NULL; + + if(bt_server_end_spp()) + { + //LTask.post_signal(); + g_serverContext.ptr->post_signal(); + } + } + else if (ret == 0) + { + *(g_serverContext.waiting_result_p) = true; + g_serverContext.waiting_result_p = NULL; + //LTask.post_signal(); + g_serverContext.ptr->post_signal(); + } + + } + else if (g_serverContext.server_status == BT_SERVER_ENDING) + { + VMINT ret = vm_btcm_switch_off(); + + if(VM_SRV_BT_CM_RESULT_SUCCESS == ret) + { + //wait for callback to process + g_serverContext.server_status = BT_SERVER_POWERING_OFF; + } + else + { + if(g_serverContext.btcm_hdl >= 0) + { + vm_btcm_exit(g_serverContext.btcm_hdl); + g_serverContext.btcm_hdl = -1; + } + + g_serverContext.server_status = BT_SERVER_IDLE; + //LTask.post_signal(); + g_serverContext.ptr->post_signal(); + } + } + + break; + } + + case VM_SRV_BT_CM_EVENT_DEACTIVATE: + { + if (g_serverContext.server_status == BT_SERVER_BEGINING) + { + VMINT ret = vm_btcm_switch_on(); + + if(VM_SRV_BT_CM_RESULT_SUCCESS == ret) + { + //wait for callback to process + g_serverContext.server_status = BT_SERVER_POWERING_ON; + } + else + { + *(g_serverContext.waiting_result_p) = false; + g_serverContext.waiting_result_p = NULL; + + if(bt_server_end_spp()) + { + //LTask.post_signal(); + g_serverContext.ptr->post_signal(); + } + } + } + else if(g_serverContext.server_status == BT_SERVER_POWERING_OFF) + { + if(g_serverContext.btcm_hdl >= 0) + { + vm_btcm_exit(g_serverContext.btcm_hdl); + g_serverContext.btcm_hdl = -1; + } + + g_serverContext.server_status = BT_SERVER_IDLE; + //LTask.post_signal(); + g_serverContext.ptr->post_signal(); + } + + break; + } + + case VM_SRV_BT_CM_EVENT_SET_VISIBILITY: + { + APP_LOG("[BTC] VM_SRV_BT_CM_EVENT_SET_VISIBILITY"); + //LTask.post_signal(); + g_serverContext.ptr->post_signal(); + break; + } + + case VM_SRV_BT_CM_EVENT_SET_NAME: + { + break; + } + + case VM_SRV_BT_CM_EVENT_PAIR_IND: + { + vm_srv_bt_cm_pair_ind_struct *event = (vm_srv_bt_cm_pair_ind_struct *)param; + vm_bt_cm_send_passkey(&event->dev_addr, (VMUINT8*)LBTServer._pincode_buffer, VM_TRUE); + break; + } + default: + { + break; + } + } + + +} + +static void bt_server_accept_timeout_cb(VMINT tid) +{ + APP_LOG("bt_server_accept_timeout_cb tid[%d][%d]", tid, g_serverContext.accept_tid); + if (tid == g_serverContext.accept_tid && g_serverContext.waiting_for_accept) + { + g_serverContext.waiting_for_accept = false; + vm_delete_timer(g_serverContext.accept_tid); + g_serverContext.accept_tid = -1; + + *(g_serverContext.waiting_result_p) = false; + g_serverContext.waiting_result_p = NULL; + + //LTask.post_signal(); + g_serverContext.ptr->post_signal(); + } +} + +static int bt_server_spp_read(void* data) +{ + + VMINT ret = 0; + VMINT i = 0; + if(g_serverContext.conn_id < 0) + { + //not connected yet + + APP_LOG((char*)"[BTC]bt_server_spp_read : not connected yet"); + + return true; + } + char *readdata = new char[LBT_SERIAL_BUFFER_SIZE]; + if(readdata == NULL) + { + APP_LOG((char*)"[BTC]bt_server_spp_read : allocate memory fail"); + return false; + } + ret = vm_btspp_read(g_serverContext.conn_id, (void*)readdata, LBT_SERIAL_BUFFER_SIZE); + + APP_LOG("[BTC]bt_server_spp_read, ret: %d", ret); + + if (ret < 0) + { + APP_LOG((char*)"[BTC]bt_server_spp_read : read data fail"); + + } + else + { + + if(server_mutex.guard == 0) + { + vm_mutex_create(&server_mutex); + } + vm_mutex_lock(&server_mutex); + for(i=0;istore_char(readdata[i]); + } + vm_mutex_unlock(&server_mutex); + + APP_LOG((char*)"[BTC]btServerRead : read data success"); + } + delete[] readdata; + return ret; +} + +static void bt_server_spp_cb(VMUINT evt, void * param, void * user_data) +{ + vm_srv_spp_event_cntx* cntx = (vm_srv_spp_event_cntx*)param; + + switch(evt) + { + case VM_SRV_SPP_EVENT_CONNECT: + { + if (cntx->ret) + { + //connect successfully + if(g_serverContext.waiting_result_p != NULL) + { + *(g_serverContext.waiting_result_p) = true; + } + g_serverContext.conn_id = cntx->conn_id; + } + else + { + //connnet fail + if(g_serverContext.waiting_result_p != NULL) + { + *(g_serverContext.waiting_result_p) = false; + } + } + + if(g_serverContext.waiting_result_p != NULL) + { + g_serverContext.waiting_result_p = NULL; + //LTask.post_signal(); + g_serverContext.ptr->post_signal(); + bt_server_accept_timeout_cb(g_serverContext.accept_tid); + } + else + { + // reconnection + } + + break; + } + + case VM_SRV_SPP_EVENT_DISCONNECT: + { + g_serverContext.conn_id = -1; + APP_LOG((char*)"[BTS]VM_SRV_SPP_EVENT_DISCONNECT"); + break; + } + + case VM_SRV_SPP_EVENT_AUTHORIZE: + { + if (g_serverContext.mac_only) + { + vm_srv_bt_cm_bt_addr curr_addr = {0}; + vm_srv_bt_cm_bt_addr tmp = {0}; + vm_btspp_get_dev_addr(cntx->conn_id, &curr_addr); + tmp.nap = (VMUINT16)((g_serverContext.address.nap[1] << 8) | g_serverContext.address.nap[0]); + tmp.uap = (VMUINT8)g_serverContext.address.uap; + tmp.lap = (VMUINT)((g_serverContext.address.lap[2] << 16) | (g_serverContext.address.lap[1] << 8) | g_serverContext.address.lap[0]); + APP_LOG("[BTS AUTH] tmp addr: nap:%x, uap:%x, lap:%x", + tmp.nap, + tmp.uap, + tmp.lap); + APP_LOG("[BTS AUTH] curr_addr: nap:%x, uap:%x, lap:%x", + curr_addr.nap, + curr_addr.uap, + curr_addr.lap); + //if (0 != memcmp(&tmp, &curr_addr, sizeof(vm_srv_bt_cm_bt_addr))) + if ((tmp.nap != curr_addr.nap) || + (tmp.uap != curr_addr.uap) || + (tmp.lap != curr_addr.lap)) + { + vm_btspp_reject(cntx->conn_id); + break; + } + } + + if(g_serverContext.waiting_for_accept) + { + VMINT ret = vm_btspp_accept(cntx->conn_id, g_serverContext.btspp_buf, g_serverContext.btspp_buf_size, g_serverContext.btspp_buf_size); + g_serverContext.waiting_for_accept = false; + vm_delete_timer(g_serverContext.accept_tid); + g_serverContext.accept_tid = -1; + } + else + { + vm_btspp_reject(cntx->conn_id); + } + + + + break; + } + + case VM_SRV_SPP_EVENT_BIND_FAIL: + { + break; + } + + case VM_SRV_SPP_EVENT_READY_TO_WRITE: + { + //g_serverContext.ptr->post_signal(); + g_serverContext.ptr->post_signal_write(); + break; + } + + case VM_SRV_SPP_EVENT_READY_TO_READ: + { + bt_server_spp_read(NULL); + #if(0) + g_serverContext.ptr->post_signal_read(); + #endif + break; + } + + + } + +} + +static VMINT bt_server_init_spp(uint8_t* name) +{ + + VMUINT evt_mask = VM_SRV_SPP_EVENT_BIND_FAIL | + VM_SRV_SPP_EVENT_AUTHORIZE | + VM_SRV_SPP_EVENT_CONNECT | + VM_SRV_SPP_EVENT_READY_TO_WRITE | + VM_SRV_SPP_EVENT_READY_TO_READ | + VM_SRV_SPP_EVENT_DISCONNECT; + + + g_serverContext.btspp_hdl = vm_btspp_open(evt_mask,bt_server_spp_cb,NULL); + + if(g_serverContext.btspp_hdl < 0) + { + APP_LOG((char*)"[BTC]bt_server_init_spp hdl[%d]", g_serverContext.btspp_hdl); + return g_serverContext.btspp_hdl; + } + vm_btspp_set_security_level(g_serverContext.btspp_hdl,VM_SRV_SPP_SEC_NAN); + + VMINT min_buf_size = vm_btspp_get_min_buf_size(); + g_serverContext.btspp_buf = vm_calloc(min_buf_size); + g_serverContext.btspp_buf_size = min_buf_size / 2; + + if(g_serverContext.btspp_buf == NULL) + { + APP_LOG((char*)"[BTC]bt_server_init_spp fail : alloc buffer"); + return -1; + } + + VMINT ret = vm_btspp_bind(g_serverContext.btspp_hdl, SPP_UUID); + + if(ret < 0) + { + APP_LOG((char*)"[BTC]bt_server_init_spp fail : btspp_bind"); + return -1; + } + + if(name != NULL) + { + ret = vm_btcm_set_host_name((VMUINT8*)name); + } + + if(ret < 0) + { + APP_LOG((char*)"[BTC]bt_server_init_spp fail : btcm_set_host_name"); + return -1; + } + + if (VM_SRV_BT_CM_VISIBILITY_ON == vm_btcm_srv_get_visibility()) + { + ret = 0; + } + else + { + ret = vm_btcm_srv_set_visibility(VM_SRV_BT_CM_VISIBILITY_ON); + if (VM_SRV_BT_CM_RESULT_SUCCESS == ret) + { + ret = 1; + } + } + APP_LOG("[BTC]bt_server_init_spp ret[%d], btspp_hdl=%d", ret, g_serverContext.btspp_hdl); + return ret; + +} + +static boolean bt_server_end_spp() +{ + if(g_serverContext.btspp_hdl >= 0) + { + vm_btspp_close(g_serverContext.btspp_hdl); + g_serverContext.btspp_hdl = -1; + } + + if(g_serverContext.btspp_buf != NULL) + { + vm_free(g_serverContext.btspp_buf); + g_serverContext.btspp_buf = NULL; + } + + if(g_serverContext.conn_id >= 0) + { + g_serverContext.conn_id = -1; + } + + VMINT ret = vm_btcm_get_power_status(); + + if (VM_SRV_BT_CM_POWER_ON == ret) + { + VMINT ret = vm_btcm_switch_off(); + + if(VM_SRV_BT_CM_RESULT_SUCCESS == ret) + { + //wait for callback to process + g_serverContext.server_status = BT_SERVER_POWERING_OFF; + return false; + } + } + else if (VM_SRV_BT_CM_POWER_SWITCHING_ON == ret) + { + g_serverContext.server_status = BT_SERVER_ENDING; + return false; + } + else if (VM_SRV_BT_CM_POWER_SWITCHING_OFF == ret) + { + g_serverContext.server_status = BT_SERVER_POWERING_OFF; + return false; + } + + // VM_SRV_BT_CM_POWER_OFF + if(g_serverContext.btcm_hdl >= 0) + { + vm_btcm_exit(g_serverContext.btcm_hdl); + g_serverContext.btcm_hdl = -1; + } + + g_serverContext.server_status = BT_SERVER_IDLE; + + return true; + +} + +boolean btServerBegin(void *userData) +{ + LBTServerBeginContext* pContext = (LBTServerBeginContext*)userData ; + + boolean* result = (boolean*) userData; + APP_LOG("btServerBegin 1"); + + g_serverContext.ptr = (LBTServerClass*)pContext->ptr; + if(pContext->is_set_pin == true) + { + vm_custom_set_bt_pairing_method(VM_PIN_AND_SSP); + } + if(g_serverContext.btcm_hdl >= 0) + { + //already inited + pContext->result = false; + APP_LOG("btServerBegin 2"); + return true; + } + + g_serverContext.btcm_hdl = vm_btcm_init( + bt_server_btcm_cb, + VM_SRV_BT_CM_EVENT_ACTIVATE | + VM_SRV_BT_CM_EVENT_DEACTIVATE | + VM_SRV_BT_CM_EVENT_SET_VISIBILITY | + VM_SRV_BT_CM_EVENT_PAIR_IND | + VM_SRV_BT_CM_EVENT_SECURITY_USER_CONFIRM | + VM_SRV_BT_CM_EVENT_SET_NAME, + NULL); + + if(g_serverContext.btcm_hdl < 0) + { + //init btcm fail + pContext->result = false; + APP_LOG("btServerBegin 3 hdl[%d]", g_serverContext.btcm_hdl); + return true; + } + + VMINT ret = vm_btcm_get_power_status(); + + if (VM_SRV_BT_CM_POWER_OFF == ret) + { + ret = vm_btcm_switch_on(); + + if(VM_SRV_BT_CM_RESULT_SUCCESS == ret) + { + //wait for callback to process + g_serverContext.server_status = BT_SERVER_POWERING_ON; + g_serverContext.waiting_result_p = &(pContext->result); + g_serverContext.device_name_p = pContext->name; + APP_LOG("btServerBegin 4"); + return false; + } + } + else if (VM_SRV_BT_CM_POWER_SWITCHING_OFF == ret) + { + g_serverContext.server_status = BT_SERVER_BEGINING; + g_serverContext.waiting_result_p = &(pContext->result); + g_serverContext.device_name_p = pContext->name; + APP_LOG("btServerBegin 5"); + return false; + } + else if (VM_SRV_BT_CM_POWER_SWITCHING_ON == ret) + { + g_serverContext.server_status = BT_SERVER_POWERING_ON; + g_serverContext.waiting_result_p = &(pContext->result); + g_serverContext.device_name_p = pContext->name; + APP_LOG("btServerBegin 6"); + return false; + } + else if (VM_SRV_BT_CM_POWER_ON == ret) + { + ret = bt_server_init_spp((uint8_t*)pContext->name); + if (ret > 0) + { + return false; + } + } + + if(ret<0) + { + pContext->result = false; + APP_LOG("btServerBegin 7 ret[%d]", ret); + return bt_server_end_spp(); + } + + //success + g_serverContext.server_status = BT_SERVER_READY; + pContext->result = true; + + APP_LOG("btServerBegin 8"); + return true; +} + + +boolean btServerEnd(void *userData) +{ + return bt_server_end_spp(); +} + +boolean btServerAccept(void *userData) +{ + LBTServerAcceptContext* pContext = (LBTServerAcceptContext*)userData ; + + if(g_serverContext.conn_id != -1) + { + //someone connected + pContext->result = false; + return true; + } + + if (pContext->address) + { + g_serverContext.mac_only = true; + memcpy(&(g_serverContext.address), pContext->address, sizeof(LBTAddress)); + APP_LOG("pContext->address [%02x:%02x:%02x:%02x:%02x:%02x]", + g_serverContext.address.nap[1], g_serverContext.address.nap[0], + g_serverContext.address.uap, + g_serverContext.address.lap[2], g_serverContext.address.lap[1], g_serverContext.address.lap[0]); + } + + g_serverContext.waiting_for_accept = true; + g_serverContext.waiting_result_p = &(pContext->result); + + g_serverContext.accept_tid = vm_create_timer(pContext->time_out*1000, bt_server_accept_timeout_cb); + APP_LOG("vm_create_timer [%d] timeout[%d]", g_serverContext.accept_tid, pContext->time_out*1000); + + return false; +} + +boolean btServerConnected(void *userData) +{ + boolean* result = (boolean*) userData; + + if(g_serverContext.conn_id != -1) + { + //connected + *result = true; + } + else + { + //not connected yet + *result = false; + } + + return true; +} + +boolean btServerGetHostDeviceInfo(void *userData) +{ + + LBTServerGetHostDeviceInfoContext* pContext = (LBTServerGetHostDeviceInfoContext*)userData; + + vm_srv_bt_cm_dev_struct dev_info ; + + if( VM_BT_CM_ERR_SUCCESS == vm_btcm_get_host_dev_info(&dev_info) ) + { + pContext->device_info->address.nap[0] = (dev_info.bd_addr.nap & 0x00ff); + pContext->device_info->address.nap[1] = (dev_info.bd_addr.nap & 0xff00) >> 8; + pContext->device_info->address.uap = dev_info.bd_addr.uap; + pContext->device_info->address.lap[0] = (dev_info.bd_addr.lap & 0x0000ff); + pContext->device_info->address.lap[1] = (dev_info.bd_addr.lap & 0x00ff00) >> 8; + pContext->device_info->address.lap[2] = (dev_info.bd_addr.lap & 0xff0000) >> 16; + + strcpy(pContext->device_info->name, (const char*)dev_info.name); + + pContext->result = true; + } + else + { + // fail to get the device info + pContext->result = false; + } + + return true; + +} + +boolean btServerRead(void *userData) +{ + + LBTServerReadWriteContext* pContext = (LBTServerReadWriteContext*)userData; + + if(g_serverContext.conn_id < 0) + { + //not connected yet + pContext->lenProcessed = 0; + return true; + } + + VMINT ret = vm_btspp_read(g_serverContext.conn_id, pContext->buf, pContext->len); + + if (ret < 0) + { + //read fail + pContext->lenProcessed = 0; + } + else + { + pContext->lenProcessed = ret; + } + + return true; +} + +boolean btServerWrite(void *userData) +{ + LBTServerReadWriteContext* pContext = (LBTServerReadWriteContext*)userData; + + if(g_serverContext.conn_id < 0) + { + //not connected yet + pContext->lenProcessed = 0; + return true; + } + + VMINT ret = vm_btspp_write(g_serverContext.conn_id, pContext->buf, pContext->len); + APP_LOG("vm_btspp_write ret[%d] [%s]", ret, pContext->buf); + + if (ret < 0) + { + //read fail + pContext->lenProcessed = 0; + } + else + { + pContext->lenProcessed = ret; + } + + return true; +} + diff --git a/hardware/arduino/mtk/libraries/LBT/utility/BTServer.h b/hardware/arduino/mtk/libraries/LBT/utility/BTServer.h new file mode 100644 index 00000000..625f42e1 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBT/utility/BTServer.h @@ -0,0 +1,55 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef BT_SERVER_H +#define BT_SERVER_H + +#ifdef __cplusplus +extern "C" { +#endif + + +boolean btServerBegin(void *userData); +boolean btServerEnd(void *userData); +boolean btServerAccept(void *userData); +boolean btServerConnected(void *userData); +boolean btServerGetHostDeviceInfo(void *userData); +boolean btServerRead(void *userData); +boolean btServerWrite(void *userData); + +#ifdef __cplusplus +} +#endif + +#endif //#ifndef BT_SERVER_H \ No newline at end of file diff --git a/hardware/arduino/mtk/libraries/LBattery/LBattery.cpp b/hardware/arduino/mtk/libraries/LBattery/LBattery.cpp new file mode 100644 index 00000000..68093ccc --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBattery/LBattery.cpp @@ -0,0 +1,52 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "arduino.h" +#include "Battery.h" +#include "LBattery.h" + +int LBatteryClass::level(void) +{ + remoteCall(batteryLevel, (void*)&m_level); + return m_level; +} + +boolean LBatteryClass::isCharging(void) +{ + remoteCall(batteryIsCharging, (void*)&m_charging); + return m_charging; +} + +LBatteryClass LBattery; + diff --git a/hardware/arduino/mtk/libraries/LBattery/LBattery.h b/hardware/arduino/mtk/libraries/LBattery/LBattery.h new file mode 100644 index 00000000..c6af13c4 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBattery/LBattery.h @@ -0,0 +1,69 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef _LBATTERY_H +#define _LBATTERY_H + +#include "LTask.h" + + +// LBattery class interface, With this library, you can get battery infomation like charging status and battery level +class LBatteryClass : public _LTaskClass { + +// Constructor / Destructor +public: + LBatteryClass() { }; + +// Method +public: + // DESCRIPTION + // Get the battery level of the board. + // RETURNS + // battery level, return value maybe one of 0,33,66,100 + int level(); + + // DESCRIPTION + // Charging or not. + // RETURNS + // true means current is charging, false means not charging + boolean isCharging(); + +private: + int m_level; + boolean m_charging; +}; + +extern LBatteryClass LBattery; + +#endif diff --git a/hardware/arduino/mtk/libraries/LBattery/examples/Battery/Battery.ino b/hardware/arduino/mtk/libraries/LBattery/examples/Battery/Battery.ino new file mode 100644 index 00000000..815a40cb --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBattery/examples/Battery/Battery.ino @@ -0,0 +1,18 @@ +#include + +char buff[256]; + +void setup() { + // put your setup code here, to run once: + Serial.begin(115200); +} + +void loop() { + // put your main code here, to run repeatedly: + sprintf(buff,"battery level = %d", LBattery.level() ); + Serial.println(buff); + sprintf(buff,"is charging = %d",LBattery.isCharging() ); + Serial.println(buff); + delay(1000); +} + diff --git a/hardware/arduino/mtk/libraries/LBattery/keywords.txt b/hardware/arduino/mtk/libraries/LBattery/keywords.txt new file mode 100644 index 00000000..f3eccecc --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBattery/keywords.txt @@ -0,0 +1,26 @@ +####################################### +# Syntax Coloring Map For LBatteryClass +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +LBattery KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +level KEYWORD2 +isCharging KEYWORD2 + +####################################### +# Object (KEYWORD3) +####################################### +LBattery KEYWORD3 + +####################################### +# Constants (LITERAL1) +####################################### + diff --git a/hardware/arduino/mtk/libraries/LBattery/utility/Battery.cpp b/hardware/arduino/mtk/libraries/LBattery/utility/Battery.cpp new file mode 100644 index 00000000..246712e0 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBattery/utility/Battery.cpp @@ -0,0 +1,51 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "arduino.h" +#include "vmpwr.h" +#include "Battery.h" + +boolean batteryLevel(void* user_data) +{ + int level = vm_get_battery_level(); + *(int*)user_data = level; + return true; +} + +boolean batteryIsCharging(void* user_data) +{ + VMBOOL charging = vm_charbat_is_charging(); + *(boolean*)user_data = charging; + return true; +} diff --git a/hardware/arduino/mtk/libraries/LBattery/utility/Battery.h b/hardware/arduino/mtk/libraries/LBattery/utility/Battery.h new file mode 100644 index 00000000..922dd617 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LBattery/utility/Battery.h @@ -0,0 +1,50 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef _BATTERY_H +#define _BATTERY_H + +#ifdef __cplusplus +extern "C" { +#endif + +boolean batteryIsCharging(void* user_data); +boolean batteryLevel(void* user_data); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/hardware/arduino/mtk/libraries/LDateTime/LDateTime.cpp b/hardware/arduino/mtk/libraries/LDateTime/LDateTime.cpp new file mode 100644 index 00000000..68ed6c80 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LDateTime/LDateTime.cpp @@ -0,0 +1,57 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "vmsys.h" +#include "LDatetime.h" + +LDateTimeClass::LDateTimeClass() +{ +} + +int LDateTimeClass::getTime(datetimeInfo *time) +{ + return vm_get_time((vm_time_t *)time);//return value:-1:failed, time is null; 0:success +} + +int LDateTimeClass::setTime(datetimeInfo *time) +{ + return vm_set_time((vm_time_t *)time); +} + +int LDateTimeClass::getRtc(unsigned int *rtc) +{ + return vm_get_rtc(rtc);//return value:-2:failed, rtc is null; 0:success +} + +LDateTimeClass LDateTime; \ No newline at end of file diff --git a/hardware/arduino/mtk/libraries/LDateTime/LDateTime.h b/hardware/arduino/mtk/libraries/LDateTime/LDateTime.h new file mode 100644 index 00000000..a02a93f4 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LDateTime/LDateTime.h @@ -0,0 +1,141 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + + +#ifndef _LINKITDateTime_h +#define _LINKITDateTime_h + +//datetimeInfo struct +typedef struct +{ + int year;//year + int mon;//month,begin from 1 + int day;//day,begin from 1 + int hour;//hour,24-hour + int min;//minute + int sec;//second +}datetimeInfo; + +// LDatetimeClass is designed to get system time related function +class LDateTimeClass +{ + +// Constructor / Destructor +public: + LDateTimeClass(); + +// Method +public: + + // Return current system time + // + // RETURNS + // if succeed, return 0, otherwise return -1 + // + // EXAMPLE + // + // #include + // datetimeInfo t; + // unsigned int rtc; + // void setup() + // { + // + // } + // void loop() + // { + // LDateTime.getTime(&t); + // LDateTime.getRtc(&rtc); + // delay(1000); + // } + // + int getTime( + datetimeInfo *time // [OUT] vm_time_t structure + ); + + // Set system time + // + // RETURNS + // if succeed, return 0, otherwise return -1 + // + // EXAMPLE + // + // #include + // datetimeInfo t; + // void setup() + // { + // + // } + // void loop() + // { + // LDateTime.getTime(&t); + // delay(1000); + // } + // + int setTime( + datetimeInfo *time // [OUT] vm_time_t structure + ); + + // Get the time since the Epoch (00:00:00 UTC, January 1, 1970), + // measured in seconds. + // + // RETURNS + // if succeed, return 0, otherwise failure. + // + // EXAMPLE + // + // #include + // datetimeInfo t; + // unsigned int rtc; + // void setup() + // { + // + // } + // void loop() + // { + // LDateTime.getTime(&t); + // LDateTime.getRtc(&rtc); + // delay(1000); + // } + // + int getRtc( + unsigned int *rtc // [OUT] point to the time in seconds. + ); +}; + +//LDateTime object +extern LDateTimeClass LDateTime; + +#endif + diff --git a/hardware/arduino/mtk/libraries/LDateTime/examples/DateTime/LDateTime/LDateTime.ino b/hardware/arduino/mtk/libraries/LDateTime/examples/DateTime/LDateTime/LDateTime.ino new file mode 100644 index 00000000..b264f7ef --- /dev/null +++ b/hardware/arduino/mtk/libraries/LDateTime/examples/DateTime/LDateTime/LDateTime.ino @@ -0,0 +1,15 @@ +#include + +datetimeInfo t; +unsigned int rtc; + +void setup() { + // put your setup code here, to run once: +} + +void loop() { + // put your main code here, to run repeatedly: + LDateTime.getTime(&t); + LDateTime.getRtc(&rtc); + delay(1000); +} diff --git a/hardware/arduino/mtk/libraries/LDateTime/keywords.txt b/hardware/arduino/mtk/libraries/LDateTime/keywords.txt new file mode 100644 index 00000000..50ec5afa --- /dev/null +++ b/hardware/arduino/mtk/libraries/LDateTime/keywords.txt @@ -0,0 +1,24 @@ +####################################### +# Syntax Coloring Map For LDateTime +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### +datetimeInfo KEYWORD1 +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +getTime KEYWORD2 +getRtc KEYWORD2 + +####################################### +# Object (KEYWORD3) +####################################### +LDateTime KEYWORD3 + +####################################### +# Constants (LITERAL1) +####################################### + diff --git a/hardware/arduino/mtk/libraries/LEEPROM/LEEPROM.cpp b/hardware/arduino/mtk/libraries/LEEPROM/LEEPROM.cpp new file mode 100644 index 00000000..26f08d11 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LEEPROM/LEEPROM.cpp @@ -0,0 +1,111 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "vmsys.h" +#include "LEEPROM.h" +#include "sysfile.h" +#include "vmlog.h" +#define APP_LOG(...) vm_log_info(__VA_ARGS__); \ + Serial.println(__VA_ARGS__) + +//extern void app_log_file(char *fmt, ...); + + +LEEPROMClass::LEEPROMClass(int init) : _LTaskClass(), m_init(init) +{ + //Serial.println("LEEPROMClass::LEEPROMClass"); + //APP_LOG((char*)"LEEPROMClass::LEEPROMClass"); + //_LTaskClass::begin(); + //APP_LOG((char*)"LEEPROMClass::LEEPROMClass"); +} + +/* + +LEEPROMClass::~LEEPROMClass() +{ + //APP_LOG((char*)"LEEPROMClass::~LEEPROMClass"); + //_LTaskClass::stop(); + //APP_LOG((char*)"LEEPROMClass::~LEEPROMClass"); +} +*/ +VMUINT8 LEEPROMClass::read(int addr) +{ + APP_LOG((char*)"LEEPROMClass::read [%d]", addr); + if (!m_init) + { + _LTaskClass::begin(); + m_init = 1; + } + + if (0 > addr || 1024 <= addr) + { + APP_LOG((char*)"LEEPROMClass::read e1"); + return 0; + } + g_fs_data.addr = addr; + APP_LOG((char*)"remoteCall onRead s"); + remoteCall(onRead, (void*)NULL); + APP_LOG((char*)"remoteCall onRead e"); + return getReadData(); +} + +void LEEPROMClass::write(int addr, uint8_t value) +{ + APP_LOG((char*)"LEEPROMClass::write @[%d] value[%d]", addr, value); + if (!m_init) + { + _LTaskClass::begin(); + m_init = 1; + } + + if (0 > addr || 1024 <= addr) + { + APP_LOG((char*)"LEEPROMClass::write e1"); + return; + } + g_fs_data.addr = addr; + g_fs_data.value = value; + APP_LOG((char*)"remoteCall onWrite s"); + remoteCall(onWrite, (void*)NULL); + APP_LOG((char*)"remoteCall onWrite e"); + //return 0; +} + +LEEPROMClass & getEEPROM(void) +{ + + static LEEPROMClass EEPROM_internal(0); + return EEPROM_internal; +} + diff --git a/hardware/arduino/mtk/libraries/LEEPROM/LEEPROM.h b/hardware/arduino/mtk/libraries/LEEPROM/LEEPROM.h new file mode 100644 index 00000000..52cfc5b7 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LEEPROM/LEEPROM.h @@ -0,0 +1,119 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _LINKITEEPROM_H +#define _LINKITEEPROM_H + +#include "LTask.h" + +//#include "vmsys.h" +/***************************************************************************** + * Class LEEPROMClass + ****************************************************************************/ +// LEEPROMClass is reading and writing to "permanent" storage +// +// EXAMPLE: +// +// #include +// void setup() { +// // put your setup code here, to run once: +// +// } +// +// void loop() { +// // put your main code here, to run repeatedly: +// byte a = 1; +// EEPROM.write(0, a); +// byte b = EEPROM.read(0); +// if (a == b) +// { +// // do something. +// delay(2000); +// } +// } +// +class LEEPROMClass : public _LTaskClass +{ +private: + int m_init; + +// Method +public: + LEEPROMClass(int init); + //~LEEPROMClass(); + // DESCRIPTION + //Write a byte to the EEPROM. + // RETURNS + // VMUINT8 + // EXAMPLE + // + // #include + // int a = 0; + // int value; + // void setup() + // { + // Serial.begin(9600); + // } + // void loop() + // { + // value = EEPROM.read(a); + // + // Serial.print(a); + // Serial.print("\t"); + // Serial.print(value); + // Serial.println(); + // a = a + 1; + // if (a == 512) + // a = 0; + // delay(500); + // } + // + VMUINT8 read( + int addr // addr:the location to read from, starting from 0 (int) + ); + + // DESCRIPTION + //Write a byte to the EEPROM. + // RETURNS + // VMUINT8 + // EXAMPLE + // + // #include + // + // void setup() + // { + // for (int i = 0; i < 512; i++) + // EEPROM.write(i, i); + // } + // + // void loop() + // { + // } + // + void write( + int addr, // addr:the location to write to, starting from 0 (int) + uint8_t value // value:the value to write, from 0 to 255 (byte) + ); +}; + +//extern LEEPROMClass EEPROM; +extern LEEPROMClass & getEEPROM(void); +#define EEPROM getEEPROM() + +#endif + diff --git a/hardware/arduino/mtk/libraries/LEEPROM/examples/LEEPROM_RW/LEEPROM_RW.ino b/hardware/arduino/mtk/libraries/LEEPROM/examples/LEEPROM_RW/LEEPROM_RW.ino new file mode 100644 index 00000000..7e9f1a00 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LEEPROM/examples/LEEPROM_RW/LEEPROM_RW.ino @@ -0,0 +1,35 @@ +#include + +#define ard_log Serial.printf + +void setup() { + // put your setup code here, to run once: + + Serial.begin(9600); + ard_log("setup"); + delay(5000); +} + +void loop() { + // put your main code here, to run repeatedly: + ard_log("loop"); + delay(2000); + + byte a = 1; + + + EEPROM.write(0, a); + ard_log("written"); + delay(1000); + byte b = EEPROM.read(0); + ard_log("read [%d]", b); + if (a == b) + { + // do something. + delay(1000); + } + + + + +} diff --git a/hardware/arduino/mtk/libraries/LEEPROM/utility/sysfile.cpp b/hardware/arduino/mtk/libraries/LEEPROM/utility/sysfile.cpp new file mode 100644 index 00000000..c5751d9f --- /dev/null +++ b/hardware/arduino/mtk/libraries/LEEPROM/utility/sysfile.cpp @@ -0,0 +1,137 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "arduino.h" +#include "vmio.h" +#include "vmlog.h" +#include "sysfile.h" +#include "LEEPROM.h" + +#define APP_LOG(...) vm_log_info(__VA_ARGS__); \ + Serial.println(__VA_ARGS__) +fs_data_t g_fs_data; + + +boolean onRead(void* user_data) +{ + VMINT hdl, ret; + fs_data_t *tmp_fs_data = (fs_data_t*)&g_fs_data; + VMUINT read = 0; + + APP_LOG((char*)"EEPROM onRead -s"); + if (0 > tmp_fs_data->addr) + { + setReadData(0); + APP_LOG((char*)"EEPROM fs_data->addr[%d] -e1", tmp_fs_data->addr); + return true; + } + + hdl = vm_sys_file_open(MODE_READ, 1); + if (0 > hdl) + { + setReadData(0); + APP_LOG((char*)"EEPROM hdl[%d] -e2", hdl); + return true; + } + + ret = vm_sys_file_seek(hdl, tmp_fs_data->addr, BASE_BEGIN); + APP_LOG((char*)"EEPROM vm_sys_file_seek [%d][%d]", tmp_fs_data->addr, ret); + + ret = vm_sys_file_read(hdl, &(tmp_fs_data->value), 1, &read); + APP_LOG((char*)"EEPROM vm_sys_file_read [%d][%d] v[%d]", read, ret, tmp_fs_data->value); + + setReadData(tmp_fs_data->value); + + vm_sys_file_close(hdl); + + APP_LOG((char*)"EEPROM onRead -e"); + return true; +} +boolean onWrite(void* user_data) +{ + VMINT hdl, ret; + fs_data_t *tmp_fs_data = (fs_data_t*)&g_fs_data; + VMUINT written = 0; + + APP_LOG((char*)"EEPROM onWrite -s"); + if (0 > tmp_fs_data->addr) + { + setReadData(0); + APP_LOG((char*)"EEPROM fs_data->addr[%d] -e1", tmp_fs_data->addr); + return true; + } + + hdl = vm_sys_file_open(MODE_WRITE, 1); + if (0 > hdl) + { + hdl = vm_sys_file_open(MODE_CREATE_ALWAYS_WRITE, 1); + if (0 > hdl) + { + APP_LOG((char*)"EEPROM MODE_CREATE_ALWAYS_WRITE FAILED"); + return true; + } + APP_LOG((char*)"EEPROM MODE_CREATE_ALWAYS_WRITE OK"); + } + + APP_LOG((char*)"EEPROM vm_sys_file_open [%d]", hdl); + + ret = vm_sys_file_seek(hdl, tmp_fs_data->addr, BASE_BEGIN); + APP_LOG((char*)"EEPROM vm_sys_file_seek [%d][%d]", tmp_fs_data->addr, ret); + + ret = vm_sys_file_write(hdl, &(tmp_fs_data->value), 1, &written); + APP_LOG((char*)"EEPROM vm_sys_file_write [%d][%d] v[%d]", written, ret, tmp_fs_data->value); + + setReadData(tmp_fs_data->value); + + vm_sys_file_close(hdl); + + APP_LOG((char*)"EEPROM onWrite -e"); + return true; +} + +// be called in arduino task. +VMUINT8 getReadData() +{ + APP_LOG((char*)"getReadData [%d]", g_fs_data.value); + return g_fs_data.value; +} + +// mmi task set data +void setReadData(VMUINT8 data_read) +{ + g_fs_data.value = data_read; + APP_LOG((char*)"setReadData [%d]", data_read); +} + + diff --git a/hardware/arduino/mtk/libraries/LEEPROM/utility/sysfile.h b/hardware/arduino/mtk/libraries/LEEPROM/utility/sysfile.h new file mode 100644 index 00000000..36827198 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LEEPROM/utility/sysfile.h @@ -0,0 +1,61 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef _SYSFILE_H +#define _SYSFILE_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct +{ + VMINT addr; + VMUINT8 value; +}fs_data_t; + +extern fs_data_t g_fs_data; + +boolean onRead(void* user_data); +boolean onWrite(void* user_data); + +VMUINT8 getReadData(); +void setReadData(VMUINT8 data_read); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/hardware/arduino/mtk/libraries/LGPRS/LGPRS.cpp b/hardware/arduino/mtk/libraries/LGPRS/LGPRS.cpp new file mode 100644 index 00000000..0e61039b --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPRS/LGPRS.cpp @@ -0,0 +1,353 @@ +#include +#include "LTask.h" +#include "LGPRS.h" +#include "IPAddress.h" +#include "vmnwsetting.h" +#include "vmconn.h" +#include "vmsim.h" +#include "vmcell.h" +#include "vmlog.h" +#include "vmtcp.h" +#include "vmsettings.h" + +class LGPRSConnectContext; + +LGPRSClass::LGPRSClass(): + m_simCardReady(0) +{ + +} + +static void gprsSettingCallback(VMINT32 result, void *user_data) +{ + vm_log_info("gprsSettingCallback result=%d", result); + + // Is there GSM? + VMINT protocol = vm_srv_nw_info_get_protocol(VM_SIM_SIM1); + vm_log_info("SIM protocol=%d", protocol); + + // Is there GPRS? + // VMINT networkReady = vm_srv_nw_info_channel_supports(VM_SIM_SIM1, VM_GPRS); + //vm_log_info("SIM GPRS ready? %d", networkReady); + + // get APN info + vm_apn_info_ext apnInfo; + VMINT apnRet = vm_get_apn_info(&apnInfo); + vm_log_info("vm_get_apn_info = %d", apnRet); + vm_log_info("operator ID= %s", apnInfo.operator_id); + vm_log_info("operator Name= %s", apnInfo.operator_name); + + // retrieve cell info + VMINT openResult = vm_cell_open(); + vm_log_info("open cell = %d", openResult); + vm_cell_info_struct *pCell = vm_cell_get_cur_cell_info(); + if (pCell) + { + vm_log_info("cell rxlev=%d", pCell->rxlev); + vm_log_info("cell arfcn=%d", pCell->arfcn); + vm_log_info("cell bsic=%d", pCell->bsic); + vm_log_info("cell mcc=%d", pCell->mcc); + vm_log_info("cell mnc=%d", pCell->mnc); + vm_log_info("cell lac=%d", pCell->lac); + vm_log_info("cell ci=%d", pCell->ci); + } + else + { + vm_log_info("no cell info"); + } + + vm_cell_close(); + + // release blocking signal + LTask.post_signal(); +} + + +boolean LGPRSClass::gprsCheckSIM(void *userData) +{ + LGPRSClass *pThis =(LGPRSClass*)userData; + vm_log_info("Has SIM? %d", vm_has_sim_card()); + vm_log_info("SIM count? %d", vm_sim_card_count()); + vm_log_info("IMEI=%s", vm_get_imei()); + + // Is there SIM card ready? + VMINT simCardCount = vm_sim_card_count(); + if (simCardCount > 0) + { + pThis->m_simCardReady = 1; + } + + vm_set_active_sim_card(VM_SIM_SIM1); + + VMINT simStatus = vm_get_sim_card_status(VM_SIM_SIM1); + vm_log_info("SIM card state=%d", simStatus); + + + // Let's enable GPRS + VMINT32 result = vm_setting_srv_command(VM_SETTING_CELLULAR_GPRS_SERVICE, + VM_OPERATION_GPRS_SERVICE_ON, + NULL, + NULL, + NULL, + NULL); + if (result == VM_SETTING_RESULT_OK) + { + vm_log_info("vm_setting_srv_command OK"); + } + else if (result == VM_SETTING_RESULT_INVALID) + { + vm_log_info("vm_setting_srv_command INVALID"); + } + else + { + vm_log_info("vm_setting_srv_command failed."); + } + + // Is there GSM? + VMINT protocol = vm_srv_nw_info_get_protocol(VM_SIM_SIM1); + vm_log_info("SIM protocol=%d", protocol); + + // Is there GPRS? + // VMINT networkReady = vm_srv_nw_info_channel_supports(VM_SIM_SIM1, VM_GPRS); + //vm_log_info("SIM GPRS ready? %d", networkReady); + + // get APN info + vm_apn_info_ext apnInfo; + VMINT apnRet = vm_get_apn_info(&apnInfo); + vm_log_info("vm_get_apn_info = %d", apnRet); + vm_log_info("operator ID= %s", apnInfo.operator_id); + vm_log_info("operator Name= %s", apnInfo.operator_name); + + // retrieve cell info + VMINT openResult = vm_cell_open(); + vm_log_info("open cell = %d", openResult); + vm_cell_info_struct *pCell = vm_cell_get_cur_cell_info(); + if (pCell) + { + vm_log_info("cell rxlev=%d", pCell->rxlev); + vm_log_info("cell arfcn=%d", pCell->arfcn); + vm_log_info("cell bsic=%d", pCell->bsic); + vm_log_info("cell mcc=%d", pCell->mcc); + vm_log_info("cell mnc=%d", pCell->mnc); + vm_log_info("cell lac=%d", pCell->lac); + vm_log_info("cell ci=%d", pCell->ci); + } + else + { + vm_log_info("no cell info"); + } + + vm_cell_close(); + + + return true; +} + +struct LGPRSAttachContext +{ + vm_dtcnt_info_t info; + VMINT result; + VMUINT32 dataAccount; +}; + +boolean gprsSetCustomAPN(void *userData) +{ + LGPRSAttachContext *pCntx = (LGPRSAttachContext*)userData; + VMUINT32 dtacct = 0; + VMINT ret = 0; + #if 0 + ret = vm_set_cust_apn_info(&pCntx->info, &dtacct); + #endif + + if(0 != ret) + { + vm_log_error("vm_set_cust_apn_info fails with %d", ret); + pCntx->result = ret; + return true; + } + + // we have only 1 SIM card + ret = vm_dtacct_set(VM_SIM_SIM1, dtacct); + if(0 != ret) + { + vm_log_error("vm_dtacct_set fails with %d", ret); + pCntx->result = ret; + return true; + } + + pCntx->result = 0; + return true; +} + +int LGPRSClass::attachGPRS(const char *apn, const char *username, const char *password) +{ + LTask.remoteCall(&gprsCheckSIM, this); + if(!m_simCardReady) + { + return m_simCardReady; + } + + // setup custom APN + LGPRSAttachContext cntx; + memset(&cntx, 0, sizeof(cntx)); + strncpy((char*)cntx.info.APN, apn, VM_SRV_DTCNT_PROF_MAX); + strncpy((char*)cntx.info.UserName, username, VM_SRV_DTCNT_PROF_MAX); + strncpy((char*)cntx.info.Passwd, password,VM_SRV_DTCNT_PROF_MAX); + + // currently we don't configure proxy and DNS + + LTask.remoteCall(&gprsSetCustomAPN, &cntx); + + if(cntx.result == 0) + { + m_customAPN = true; + return 1; + } + else + { + m_customAPN = false; + return 0; + } +} + +int LGPRSClass::attachGPRS() +{ + m_customAPN = false; + LTask.remoteCall(&gprsCheckSIM, this); + return m_simCardReady; +} + +VMINT LGPRSClass::getAPN() const +{ + if(m_customAPN) + { + return VM_APN_USER_DEFINE; + } + else + { + return VM_TCP_APN_CMNET; + } +} + +struct LGPRSResolveContext +{ + const char *domainName; + vm_soc_dns_result dns; + VMINT resolveState; + + LGPRSResolveContext(): + domainName(NULL), + resolveState(VM_E_SOC_INVAL) + { + memset(&dns, 0, sizeof(dns)); + } + + ~LGPRSResolveContext() + { + } +}; + +static VMINT gprsResolveCallback(VMINT jobId, vm_soc_dns_result *pDNS, void *userData) +{ + vm_log_info("gprsResolveCallback"); + LGPRSResolveContext *pContext = (LGPRSResolveContext*)userData; + unsigned char* ipArray = (unsigned char*)&pDNS->address[0]; + vm_log_info("DNS resolve callback, cause=%d, num=%d, address=%d.%d.%d.%d", + pDNS->error_cause, + pDNS->num, + ipArray[0], + ipArray[1], + ipArray[2], + ipArray[3]); + + // TODO: since we don't know the definition of error_cause yet, + // treat all as OK. + if(pDNS && pDNS != &pContext->dns) + { + vm_log_info("pDNS != pContext->dns"); + pContext->dns = *pDNS; + } + pContext->resolveState = VM_E_SOC_SUCCESS; + LTask.post_signal(); +} + + +static boolean gprsResolveDomainName(void *userData) +{ + LGPRSResolveContext *pContext = (LGPRSResolveContext*)userData; + + vm_log_info("vm_soc_get_host_by_name_ex: %s", pContext->domainName); + pContext->resolveState = vm_soc_get_host_by_name_ex(VM_TCP_APN_CMNET, + pContext->domainName, + &pContext->dns, + &gprsResolveCallback, + pContext); + vm_log_info("vm_soc_get_host_by_name_ex ret = %d", pContext->resolveState); + + if (pContext->resolveState > 0) + { + // not done yet + return false; + } + + switch(pContext->resolveState) + { + case VM_E_SOC_SUCCESS: // Get IP address successfully, result is filled. + return true; + case VM_E_SOC_WOULDBLOCK: // wait response from network, result could be gotten from callback. + // need to wait, return directly + // so MMI message loop may continue. + return false; + case VM_E_SOC_INVAL: // invalid arguments: null domain_name, etc. + case VM_E_SOC_ERROR: // unspecified error + case VM_E_SOC_LIMIT_RESOURCE: // socket resources not available + case VM_E_SOC_INVALID_ACCOUNT: // invalid data account id + return true; + } +} + + +int LGPRSClass::hostByName(const char* aHostname, IPAddress& aResult) +{ + vm_log_info("hostByName"); + LGPRSResolveContext context; + // no memory copy since we're blocking call + context.domainName = aHostname; + LTask.remoteCall(&gprsResolveDomainName, (void*)&context); + + vm_log_info("context.resolveState = %d", context.resolveState); + unsigned char* ipArray = (unsigned char*)&context.dns.address[0]; + vm_log_info("Arduino DNS resolve callback, cause=%d, num=%d, address=%d.%d.%d.%d", + context.dns.error_cause, + context.dns.num, + ipArray[0], + ipArray[1], + ipArray[2], + ipArray[3]); + // parse result + if (VM_E_SOC_SUCCESS == context.resolveState) + { + // TODO: why are there multiple ip addresses? + + aResult = context.dns.address[0]; + + vm_log_info("get IP=%d.%d.%d.%d", + aResult[0], + aResult[1], + aResult[2], + aResult[3]); + return 1; + } + else + { + return 0; + } +} + + +IPAddress LGPRSClass::localIP() +{ +} + +LGPRSClass LGPRS; + diff --git a/hardware/arduino/mtk/libraries/LGPRS/LGPRS.h b/hardware/arduino/mtk/libraries/LGPRS/LGPRS.h new file mode 100644 index 00000000..0a9d2a33 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPRS/LGPRS.h @@ -0,0 +1,80 @@ +#ifndef LGPRS_h +#define LGPRS_h + +#include "Arduino.h" +#include "IPAddress.h" +#include "vmnwsetting.h" +#include "vmconn.h" + +class LGPRSConnectContext; + +//LGPRS Class +class LGPRSClass +{ +public: + + /* DOM-NOT_FOR_SDK-BEGIN */ + LGPRSClass(); + /* DOM-NOT_FOR_SDK-END */ + + // DESCRIPTION + // Sets up the Access Point Name (APN) information used to connect to GPRS network. Use the data provided by your telecom operator to set it up + // + // PARAMETERS + // APNName: char array, Access Point Name (APN) provided by the telecom operator + // userName: char array, user name, provided by the telecom operator. Pass NULL if the telecom operator does not provide the username information. + // password: char array, password provided by the telecom operator. Pass NULL if the telecom operator does not provide the password information. + // + // RETURN + // 1: APN setup succeeded + // 0: Otherwise + int attachGPRS(const char *apn, const char *username, const char *password); + + // DESCRIPTION + // Automatically detect Access Point Name (APN) information from SIM card and use it to connect to GPRS network. + // + // PARAMETERS + // APNName: char array, Access Point Name (APN) provided by the telecom operator + // userName: char array, user name, provided by the telecom operator. Pass NULL if the telecom operator does not provide the username information. + // password: char array, password provided by the telecom operator. Pass NULL if the telecom operator does not provide the password information. + // + // RETURN + // 1: APN setup succeeded + // 0: Otherwise + int attachGPRS(); + + // DESCRIPTION + // Queries the IP address of the LinkIt device after connecting to GPRS network through LGPRS.attachGPRS(). + // + // PARAMETERS + // N/A + // + // RETURN + // The IP address dispatched by the GPRS network. The value is meaningless before LGPRS.attachGPRS() succeeds. + IPAddress localIP(); + + // DESCRIPTION + // Resolve the given hostname to an IP address. + // + // PARAMETERS + // param aHostname: Name to be resolved + // param aResult: IPAddress structure to store the returned IP address + // + // RETURNS + // 1 if aIPAddrString was successfully converted to an IP address, + // else error code + int hostByName(const char* aHostname, IPAddress& aResult); + + VMINT getAPN() const; + friend class LGPRSServer; + friend class LGPRSClient; + +private: + boolean m_simCardReady; + boolean m_customAPN; + static boolean gprsCheckSIM(void *userData); +}; + +extern LGPRSClass LGPRS; + +#endif // #ifndef LGPRS_h \ No newline at end of file diff --git a/hardware/arduino/mtk/libraries/LGPRS/LGPRSClient.cpp b/hardware/arduino/mtk/libraries/LGPRS/LGPRSClient.cpp new file mode 100644 index 00000000..69fdea9b --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPRS/LGPRSClient.cpp @@ -0,0 +1,28 @@ +#include "LGPRSClient.h" +#include +#include +#include "LGPRS.h" + +LGPRSClient::LGPRSClient(): + LTcpClient() +{ + m_apn = LGPRS.getAPN(); +} + +LGPRSClient::LGPRSClient(const LTcpClient &rhs): + LTcpClient(rhs) +{ + m_apn = LGPRS.getAPN(); +} + +LGPRSClient::LGPRSClient(VMINT handle): + LTcpClient(handle) +{ + m_apn = LGPRS.getAPN(); +} + +LGPRSClient::LGPRSClient(VMINT handle, VMINT serverHandle): + LTcpClient(handle, serverHandle) +{ + m_apn = LGPRS.getAPN(); +} \ No newline at end of file diff --git a/hardware/arduino/mtk/libraries/LGPRS/LGPRSClient.h b/hardware/arduino/mtk/libraries/LGPRS/LGPRSClient.h new file mode 100644 index 00000000..d8ca9275 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPRS/LGPRSClient.h @@ -0,0 +1,20 @@ +#ifndef LGPRSClient_h +#define LGPRSClient_h +#include "Arduino.h" +#include +#include +#include + +//LGPRSClient Class +class LGPRSClient : public LTcpClient { +public: + LGPRSClient(); + + /* DOM-NOT_FOR_SDK-BEGIN */ + LGPRSClient(const LTcpClient &rhs); + LGPRSClient(VMINT handle); + LGPRSClient(VMINT handle, VMINT serverHandle); + /* DOM-NOT_FOR_SDK-END */ +}; + +#endif // LGPRSClient_h \ No newline at end of file diff --git a/hardware/arduino/mtk/libraries/LGPRS/LGPRSServer.cpp b/hardware/arduino/mtk/libraries/LGPRS/LGPRSServer.cpp new file mode 100644 index 00000000..698ec6ea --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPRS/LGPRSServer.cpp @@ -0,0 +1,21 @@ +#include "LGPRSServer.h" +#include +#include +#include "LGPRS.h" + +LGPRSServer::LGPRSServer(uint16_t port): + LTcpServer(port) +{ + m_apn = LGPRS.getAPN(); +} + +LGPRSClient LGPRSServer::available() +{ + VMINT hClient = -1; + VMINT hServer = -1; + availableImpl(hClient, hServer); + // return a special client object that has server handle + // Note that we rely on move-constructor optimization + // to prevent temp object destructor, which stop() the connection. + return LGPRSClient(hClient, hServer); +} \ No newline at end of file diff --git a/hardware/arduino/mtk/libraries/LGPRS/LGPRSServer.h b/hardware/arduino/mtk/libraries/LGPRS/LGPRSServer.h new file mode 100644 index 00000000..d8a73081 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPRS/LGPRSServer.h @@ -0,0 +1,14 @@ +#ifndef LGPRSServer_h +#define LGPRSServer_h +#include +#include +#include "LGPRSClient.h" + +//LGPRSServer Class +class LGPRSServer : public LTcpServer { +public: + LGPRSServer(uint16_t port); + LGPRSClient available(); +}; + +#endif \ No newline at end of file diff --git a/hardware/arduino/mtk/libraries/LGPRS/LGPRSUdp.cpp b/hardware/arduino/mtk/libraries/LGPRS/LGPRSUdp.cpp new file mode 100644 index 00000000..d7314bb2 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPRS/LGPRSUdp.cpp @@ -0,0 +1,24 @@ +#include +#include "LGPRSUdp.h" +#include "LGPRS.h" +#include "vmtcp.h" + +VMINT LGPRSUDP::getAPN() const +{ + return VM_TCP_APN_CMNET; +} + +int LGPRSUDP::beginPacket(const char *host, uint16_t port) +{ + // DNS loopup and bypass to IP version + int ret = LGPRS.hostByName(host, m_sendToIP); + if(ret) + { + return beginPacket(m_sendToIP, port); + } + else + { + return 0; + } +} + diff --git a/hardware/arduino/mtk/libraries/LGPRS/LGPRSUdp.h b/hardware/arduino/mtk/libraries/LGPRS/LGPRSUdp.h new file mode 100644 index 00000000..c3170349 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPRS/LGPRSUdp.h @@ -0,0 +1,16 @@ +#ifndef lgprsudp_h +#define lgprsudp_h + +#include +#include + +class LGPRSUDP : public LUDP { +public: + virtual int beginPacket(const char *host, uint16_t port); + using LUDP::beginPacket; + +protected: + virtual VMINT getAPN() const; +}; + +#endif diff --git a/hardware/arduino/mtk/libraries/LGPRS/examples/GPRSUdpNtpClient/GPRSUdpNtpClient.ino b/hardware/arduino/mtk/libraries/LGPRS/examples/GPRSUdpNtpClient/GPRSUdpNtpClient.ino new file mode 100644 index 00000000..b2c13b1e --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPRS/examples/GPRSUdpNtpClient/GPRSUdpNtpClient.ino @@ -0,0 +1,155 @@ +#include +#include + +/* + + Udp NTP Client + + Get the time from a Network Time Protocol (NTP) time server + Demonstrates use of UDP sendPacket and ReceivePacket + For more on NTP time servers and the messages needed to communicate with them, + see http://en.wikipedia.org/wiki/Network_Time_Protocol + + created 4 Sep 2010 + by Michael Margolis + modified 9 Apr 2012 + by Tom Igoe + + modified 14 Aug 2014 + by Pablo Sun + for LinkIt LGPRS UDP example + + This code is in the public domain. + + */ +unsigned int localPort = 2390; // local port to listen for UDP packets + +#define TIME_SERVER "time-c.nist.gov" // a list of NTP servers: http://tf.nist.gov/tf-cgi/servers.cgi + +const int NTP_PACKET_SIZE = 48; // NTP time stamp is in the first 48 bytes of the message + +byte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets + +// A LGPRSUDP instance to let us send and receive packets over UDP with LinkIt +LGPRSUDP Udp; + +void setup() +{ + // Open serial communications and wait for port to open: + Serial.begin(115200); + + Serial.println("setup()"); + + // attempt to connect to Wifi network: + while(!LGPRS.attachGPRS()) + { + delay(1000); + Serial.println("retry WiFi AP"); + } + Serial.println("Connected to wifi"); + + delay(10000); + + Serial.println("\nStarting connection to server..."); + while(!Udp.begin(localPort)) + { + Serial.println("retry begin"); + delay(1000); + } + + Serial.println("setup() done"); +} + +void loop() +{ + sendNTPpacket(); // send an NTP packet to a time server + // wait to see if a reply is available + delay(1000); + Serial.println( Udp.parsePacket() ); + if ( Udp.parsePacket() ) { + Serial.println("packet received"); + // We've received a packet, read the data from it + memset(packetBuffer, 0xcd, NTP_PACKET_SIZE); + Udp.read(packetBuffer, NTP_PACKET_SIZE); // read the packet into the buffer + for(int i = 0; i < NTP_PACKET_SIZE; ++i) + { + Serial.print(packetBuffer[i], HEX); + } + Serial.println(); + + + //the timestamp starts at byte 40 of the received packet and is four bytes, + // or two words, long. First, esxtract the two words: + unsigned long highWord = word(packetBuffer[40], packetBuffer[41]); + unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]); + // combine the four bytes (two words) into a long integer + // this is NTP time (seconds since Jan 1 1900): + unsigned long secsSince1900 = highWord << 16 | lowWord; + Serial.print("Seconds since Jan 1 1900 = " ); + Serial.println(secsSince1900); + + // now convert NTP time into everyday time: + Serial.print("Unix time = "); + // Unix time starts on Jan 1 1970. In seconds, that's 2208988800: + const unsigned long seventyYears = 2208988800UL; + // subtract seventy years: + unsigned long epoch = secsSince1900 - seventyYears; + // print Unix time: + Serial.println(epoch); + + + // print the hour, minute and second: + Serial.print("The UTC time is "); // UTC is the time at Greenwich Meridian (GMT) + Serial.print((epoch % 86400L) / 3600); // print the hour (86400 equals secs per day) + Serial.print(':'); + if ( ((epoch % 3600) / 60) < 10 ) { + // In the first 10 minutes of each hour, we'll want a leading '0' + Serial.print('0'); + } + Serial.print((epoch % 3600) / 60); // print the minute (3600 equals secs per minute) + Serial.print(':'); + if ( (epoch % 60) < 10 ) { + // In the first 10 seconds of each minute, we'll want a leading '0' + Serial.print('0'); + } + Serial.println(epoch % 60); // print the second + } + // wait ten seconds before asking for the time again + delay(10000); +} + +// send an NTP request to the time server at the given address +unsigned long sendNTPpacket() +{ + Serial.println("sendNTPpacket"); + // set all bytes in the buffer to 0 + memset(packetBuffer, 0, NTP_PACKET_SIZE); + // Initialize values needed to form NTP request + // (see URL above for details on the packets) + //Serial.println("2"); + packetBuffer[0] = 0b11100011; // LI, Version, Mode + packetBuffer[1] = 0; // Stratum, or type of clock + packetBuffer[2] = 6; // Polling Interval + packetBuffer[3] = 0xEC; // Peer Clock Precision + // 8 bytes of zero for Root Delay & Root Dispersion + packetBuffer[12] = 49; + packetBuffer[13] = 0x4E; + packetBuffer[14] = 49; + packetBuffer[15] = 52; + + //Serial.println("3"); + + // all NTP fields have been given values, now + // you can send a packet requesting a timestamp: + Udp.beginPacket(TIME_SERVER, 123); //NTP requests are to port 123 + //Serial.println("4"); + Udp.write(packetBuffer, NTP_PACKET_SIZE); + //Serial.println("5"); + Udp.endPacket(); + //Serial.println("6"); +} + + + + + diff --git a/hardware/arduino/mtk/libraries/LGPRS/examples/GPRSWebClient/GPRSWebClient.ino b/hardware/arduino/mtk/libraries/LGPRS/examples/GPRSWebClient/GPRSWebClient.ino new file mode 100644 index 00000000..aec3f12e --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPRS/examples/GPRSWebClient/GPRSWebClient.ino @@ -0,0 +1,65 @@ +#include +#include +#include + +char server[] = "arduino.cc"; +char path[] = "/asciilogo.txt"; +int port = 80; // HTTP + +LGPRSClient client; + +void setup() +{ + // setup Serial po + Serial.begin(115200); + + Serial.println("Attach to GPRS network by auto-detect APN setting"); + while (!LGPRS.attachGPRS()) + { + delay(500); + } + + // if you get a connection, report back via serial: + Serial.print("Connect to "); + Serial.println(server); + if (client.connect(server, port)) + { + Serial.println("connected"); + // Make a HTTP request: + client.print("GET "); + client.print(path); + client.println(" HTTP/1.1"); + client.print("Host: "); + client.println(server); + client.println("Connection: close"); + client.println(); + } + else + { + // if you didn't get a connection to the server: + Serial.println("connection failed"); + } +} + +void loop() +{ + // if there are incoming bytes available + // from the server, read them and print them: + if (client.available()) + { + char c = client.read(); + Serial.print(c); + } + + // if the server's disconnected, stop the client: + if (!client.available() && !client.connected()) + { + Serial.println(); + Serial.println("disconnecting."); + client.stop(); + + // do nothing forevermore: + for (;;) + ; + } +} diff --git a/hardware/arduino/mtk/libraries/LGPRS/examples/GPRSWebServer/GPRSWebServer.ino b/hardware/arduino/mtk/libraries/LGPRS/examples/GPRSWebServer/GPRSWebServer.ino new file mode 100644 index 00000000..aedb96bf --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPRS/examples/GPRSWebServer/GPRSWebServer.ino @@ -0,0 +1,83 @@ +#include +#include +#include + +LGPRSServer server(80); // port 80 (http) + +void setup() +{ + // setup Serial port + Serial.begin(115200); + + // detect APN + while(!LGPRS.attachGPRS()) + { + delay(500); + } + + Serial.println("Connected to GPRS network"); + + // start server + server.begin(); + + //Get IP. + for(int i = 0; i < 5; ++i) + { + IPAddress localIP = server.serverIP(); + Serial.println("Server IP address="); + Serial.println(localIP); + delay(1000); + } +} + +void loop() { + delay(50); + // checking incoming clients + LGPRSClient client = server.available(); + + if (client) + { + while (client.connected()) + { + if (client.available()) + { + Serial.println("Receiving request!"); + bool sendResponse = false; + while (int i = client.read()) { + if ((char)i == '\n') + { + sendResponse = true; + break; + } + if(i!=-1) + Serial.print((char)i); + } + + // if you've gotten to the end of the line (received a newline + // character) + if (sendResponse) + { + // send a standard http response header + client.println("HTTP/1.1 200 OK"); + client.println("Content-Type: text/html"); + client.println(); + client.println(""); + // output the value of each analog input pin + for (int analogChannel = 0; analogChannel < 6; analogChannel++) { + client.print("analog input "); + client.print(analogChannel); + client.print(" is "); + client.print(analogRead(analogChannel)); + client.println("
"); + } + client.println(""); + //necessary delay + delay(1000); + client.stop(); + } + } + } + } +} + + diff --git a/hardware/arduino/mtk/libraries/LGPS/LGPS.cpp b/hardware/arduino/mtk/libraries/LGPS/LGPS.cpp new file mode 100644 index 00000000..ffbbac17 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPS/LGPS.cpp @@ -0,0 +1,64 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "arduino.h" +#include "GPS.h" +#include "LGPS.h" + +extern void handle_gps_evt(int message, int param); + +void LGPSClass::powerOn(gpsTypeEnum type) +{ + begin(); + remoteCall(gpsPowerOn, (void*)&type); +} + +void LGPSClass::powerOff(void){ + remoteCall(gpsPowerOff, (void*)NULL); +} + +void LGPSClass::setMode(gpsModeEnum mode){ + remoteCall(gpsSetMode, (void*)&mode); +} + +void LGPSClass::getData(gpsSentenceInfoStruct* info){ + memcpy(info, &m_info, sizeof(gpsSentenceInfoStruct)); +} + +void LGPSClass::setData(gpsSentenceInfoStruct* info) { + memcpy(&m_info, info, sizeof(gpsSentenceInfoStruct)); +} + +LGPSClass LGPS; + diff --git a/hardware/arduino/mtk/libraries/LGPS/LGPS.h b/hardware/arduino/mtk/libraries/LGPS/LGPS.h new file mode 100644 index 00000000..2ad77da6 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPS/LGPS.h @@ -0,0 +1,148 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef _LGPS_H +#define _LGPS_H + +#include "LTask.h" + +#define GPS_MAX_GPGGA_SENTENCE_LENGTH 100 +#define GPS_MAX_GPGSA_SENTENCE_LENGTH 80 +#define GPS_MAX_GPRMC_SENTENCE_LENGTH 100 +#define GPS_MAX_GPVTG_SENTENCE_LENGTH 80 +#define GPS_MAX_GPGSV_SENTENCE_LENGTH 400 +#define GPS_MAX_GLGSV_SENTENCE_LENGTH 400 +#define GPS_MAX_BDGSV_SENTENCE_LENGTH 400 +#define GPS_MAX_BDGSA_SENTENCE_LENGTH 80 +#define GPS_MAX_GLGSA_SENTENCE_LENGTH 80 + +// gps sentence infomation +typedef struct +{ + unsigned char GPGGA[GPS_MAX_GPGGA_SENTENCE_LENGTH+1]; // data of GPGGA + unsigned char GPGSA[GPS_MAX_GPGSA_SENTENCE_LENGTH+1]; // data of GPGSA + unsigned char GPRMC[GPS_MAX_GPRMC_SENTENCE_LENGTH+1]; // data of GPRMC + unsigned char GPVTG[GPS_MAX_GPVTG_SENTENCE_LENGTH+1]; // data of GPVTG + unsigned char GPGSV[GPS_MAX_GPGSV_SENTENCE_LENGTH+1]; // data of GPGSV + unsigned char GLGSV[GPS_MAX_GLGSV_SENTENCE_LENGTH+1]; // data of GLGSV + unsigned char GLGSA[GPS_MAX_GLGSA_SENTENCE_LENGTH+1]; // data of GLGSA + unsigned char BDGSV[GPS_MAX_BDGSV_SENTENCE_LENGTH+1]; // data of BDGSV + unsigned char BDGSA[GPS_MAX_BDGSA_SENTENCE_LENGTH+1]; // data of BDGSA +} gpsSentenceInfoStruct; + +// gps mode +typedef enum +{ + GPS_START_MODE_NULL, + GPS_HOT_START, // GPS selects this mode when it remembers its last calculated position and the last recorded satellites is still in view. If you are at same location when the GPS was turned off, the GPS is capable of positioning in the shortest time. + GPS_WARM_START, // GPS selects this mode when it remembers its last calculated position but the last recorded satellites is not in view. The GPS then needs more time to locate the satellites and position. + GPS_COLD_START, // GPS selects this mode when it only has the current time. It takes longer time to locate the GPS information. + GPS_FULL_START, // GPS selects this mode when it has no information. There will be a full restart and it will take the longest time. + GPS_START_TYPE_END +}gpsModeEnum; + +/*gps type */ +typedef enum +{ + GPS_ONLY, /* GPS_ONLY */ + GPS_GLONASS, /* GPS+GLONASS */ + GPS_BEIDOU, /* GPS+BEIDOU */ + GPS_TYPE_END +} gpsTypeEnum; + +// LGPS class interface, With this library, you can get GPS data. Basic flow of controlling GPS: +class LGPSClass : public _LTaskClass { + +// Constructor / Destructor +public: + LGPSClass() { }; + +// Method +public: + // DESCRIPTION + // Turns on GPS device. + // RETURNS + // N/A + // EXAMPLE + // + // #include + // gpsSentenceInfoStruct info; + // void setup() + // { + // LGPS.powerOn(); + // delay(500); + // LGPS.setMode(GPS_HOT_START); + // } + // void loop() + // { + // LGPS.getData(&info); + // delay(2000); + // } + // + void powerOn(gpsTypeEnum type = GPS_GLONASS); + + // DESCRIPTION + // Turns off GPS. + // Note: Turning off GPS when GPS data are not required can save power. + // RETURNS + // N/A + void powerOff(void); + + // DESCRIPTION + // Sets up GPS start mode. + // RETURNS + // N/A + void setMode( + gpsModeEnum mode // [IN] please refer the enum gpsModeEnum + ); + + // DESCRIPTION + // get GPS data + // RETURNS + // N/A + void getData( + gpsSentenceInfoStruct* info // [IN] please refer the struct gpsSentenceInfoStruct + ); + +public: + void setData(gpsSentenceInfoStruct* info); + +private: + gpsSentenceInfoStruct m_info; + +}; + +extern LGPSClass LGPS; + +#endif diff --git a/hardware/arduino/mtk/libraries/LGPS/examples/GPS/GPS.ino b/hardware/arduino/mtk/libraries/LGPS/examples/GPS/GPS.ino new file mode 100644 index 00000000..525d3c87 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPS/examples/GPS/GPS.ino @@ -0,0 +1,121 @@ +#include + +gpsSentenceInfoStruct info; +char buff[256]; + +static unsigned char getComma(unsigned char num,const char *str) +{ + unsigned char i,j = 0; + int len=strlen(str); + for(i = 0;i < len;i ++) + { + if(str[i] == ',') + j++; + if(j == num) + return i + 1; + } + return 0; +} + +static double getDoubleNumber(const char *s) +{ + char buf[10]; + unsigned char i; + double rev; + + i=getComma(1, s); + i = i - 1; + strncpy(buf, s, i); + buf[i] = 0; + rev=atof(buf); + return rev; +} + +static double getIntNumber(const char *s) +{ + char buf[10]; + unsigned char i; + double rev; + + i=getComma(1, s); + i = i - 1; + strncpy(buf, s, i); + buf[i] = 0; + rev=atoi(buf); + return rev; +} + +void parseGPGGA(const char* GPGGAstr) +{ + /* Refer to http://www.gpsinformation.org/dale/nmea.htm#GGA + * Sample data: $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47 + * Where: + * GGA Global Positioning System Fix Data + * 123519 Fix taken at 12:35:19 UTC + * 4807.038,N Latitude 48 deg 07.038' N + * 01131.000,E Longitude 11 deg 31.000' E + * 1 Fix quality: 0 = invalid + * 1 = GPS fix (SPS) + * 2 = DGPS fix + * 3 = PPS fix + * 4 = Real Time Kinematic + * 5 = Float RTK + * 6 = estimated (dead reckoning) (2.3 feature) + * 7 = Manual input mode + * 8 = Simulation mode + * 08 Number of satellites being tracked + * 0.9 Horizontal dilution of position + * 545.4,M Altitude, Meters, above mean sea level + * 46.9,M Height of geoid (mean sea level) above WGS84 + * ellipsoid + * (empty field) time in seconds since last DGPS update + * (empty field) DGPS station ID number + * *47 the checksum data, always begins with * + */ + double latitude; + double longitude; + int tmp, hour, minute, second, num ; + if(GPGGAstr[0] == '$') + { + tmp = getComma(1, GPGGAstr); + hour = (GPGGAstr[tmp + 0] - '0') * 10 + (GPGGAstr[tmp + 1] - '0'); + minute = (GPGGAstr[tmp + 2] - '0') * 10 + (GPGGAstr[tmp + 3] - '0'); + second = (GPGGAstr[tmp + 4] - '0') * 10 + (GPGGAstr[tmp + 5] - '0'); + + sprintf(buff, "UTC timer %2d-%2d-%2d", hour, minute, second); + Serial.println(buff); + + tmp = getComma(2, GPGGAstr); + latitude = getDoubleNumber(&GPGGAstr[tmp]); + tmp = getComma(4, GPGGAstr); + longitude = getDoubleNumber(&GPGGAstr[tmp]); + sprintf(buff, "latitude = %10.4f, longitude = %10.4f", latitude, longitude); + Serial.println(buff); + + tmp = getComma(7, GPGGAstr); + num = getIntNumber(&GPGGAstr[tmp]); + sprintf(buff, "satellites number = %d", num); + Serial.println(buff); + } + else + { + Serial.println("Not get data"); + } +} + +void setup() { + // put your setup code here, to run once: + Serial.begin(115200); + LGPS.powerOn(); + Serial.println("LGPS Power on, and waiting ..."); + delay(3000); +} + +void loop() { + // put your main code here, to run repeatedly: + Serial.println("LGPS loop"); + LGPS.getData(&info); + Serial.println((char*)info.GPGGA); + parseGPGGA((const char*)info.GPGGA); + delay(2000); +} diff --git a/hardware/arduino/mtk/libraries/LGPS/keywords.txt b/hardware/arduino/mtk/libraries/LGPS/keywords.txt new file mode 100644 index 00000000..0f64ff44 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPS/keywords.txt @@ -0,0 +1,29 @@ +####################################### +# Syntax Coloring Map For LGPSClass +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +LGPS KEYWORD1 +vm_gps_sentence_info KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +powerOn KEYWORD2 +powerOff KEYWORD2 +setMode KEYWORD2 +getData KEYWORD2 + +####################################### +# Object (KEYWORD3) +####################################### +LGPS KEYWORD3 + +####################################### +# Constants (LITERAL1) +####################################### + diff --git a/hardware/arduino/mtk/libraries/LGPS/utility/GPS.cpp b/hardware/arduino/mtk/libraries/LGPS/utility/GPS.cpp new file mode 100644 index 00000000..7555c790 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPS/utility/GPS.cpp @@ -0,0 +1,126 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "arduino.h" +#include "vmgps.h" +#include "vmlog.h" +#include "GPS.h" +#include "LGPS.h" + +typedef void (*vm_gps_handler_t)(vm_gps_sentence_info* info); +vm_gps_handler_t _gps_handle = NULL; + +static void _gps_callback(VMINT msg, void* data) +{ + switch(msg) + { + case VM_GPS_OPEN_CNF: + { + VMINT result = (VMINT)data; + if(result == true) + { + vm_log_info((char*)"open success"); + } + else + { + vm_log_warn((char*)"open failed"); + } + } + break; + case VM_GPS_CLOSE_CNF: + // app cannot receive this msg now, ignore this. + break; + case VM_GPS_SET_MODE_CNF: + { + VMINT result = (VMINT)data; + if(result == true) + { + vm_log_info((char*)"set mode success"); + } + else + { + vm_log_warn((char*)"set mode failed"); + } + } + break; + case VM_GPS_SENTENCE_DATA: + { + LGPS.setData((gpsSentenceInfoStruct*)data); + } + break; + } + } + +boolean gpsPowerOn(void* user_data) +{ + VMINT result; + vm_gps_type_enum* type = (vm_gps_type_enum*)user_data; + + result = vm_gps_open( 1, *type, _gps_callback); + + if(result == VM_GPS_OPEN_SUCCESS) + { + // this is first time to open GPS, need to get the message VM_GPS_OPEN_CNF + vm_log_info((char*)"gps open success"); + } + else if(result == VM_GPS_OPEN_ALREADY_OPEN) + { + // GPS had been opened before, can get data, no need to wait VM_GPS_OPEN_CNF + // if need you can set mode + // vm_gps_set_mode(); + vm_log_info((char*)"gps already open"); + + } + else + { + // open failed + vm_log_info((char*)"gps open failed"); + } + return true; +} + +boolean gpsPowerOff(void* user_data) +{ + vm_gps_close(); + return true; +} + +boolean gpsSetMode(void* user_data) +{ + vm_gps_mode_enum* mode = (vm_gps_mode_enum*)user_data; + vm_gps_set_mode(*mode); + return true; +} + + diff --git a/hardware/arduino/mtk/libraries/LGPS/utility/GPS.h b/hardware/arduino/mtk/libraries/LGPS/utility/GPS.h new file mode 100644 index 00000000..22dcefe4 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGPS/utility/GPS.h @@ -0,0 +1,51 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef _GPS_H +#define _GPS_H + +#ifdef __cplusplus +extern "C" { +#endif + +boolean gpsPowerOn(void* user_data); +boolean gpsPowerOff(void* user_data); +boolean gpsSetMode(void* user_data); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/hardware/arduino/mtk/libraries/LGSM/LGSM.h b/hardware/arduino/mtk/libraries/LGSM/LGSM.h new file mode 100644 index 00000000..ce8fc3f4 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGSM/LGSM.h @@ -0,0 +1,212 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + + +#ifndef _LINKITGSM_h +#define _LINKITGSM_h + +#include +#include "LTask.h" + +#define LGSM_MAX_SMS_LEN 500 + +// Class of LinkIt SMS support +class LSMSClass : public Stream +{ +// Constructor / Destructor +public: + LSMSClass(void); + ~LSMSClass(void); + +// Method +public: + using Print::write; // pull in write(str) and write(buf, size) from Print + + // DESCRIPTION + // Step two of sending an SMS: Write one byte at a time into the SMS content. + // You can also use print() to write a string into SMS content at a time. + // RETURNS + // 1: Succeed, 0: Fail + size_t write( + uint8_t c // [IN] byte to write + ); + + // DESCRIPTION + // Step one of sending an SMS: Input the destination number. + // RETURNS + // 1: Succeed, 0: Fail + int beginSMS( + const char* to // [IN] SMS destination number + ); + + // DESCRIPTION + // Checks if SMS module is ready or not. + // RETURNS + // 1 if ready, 0 if not + int ready(); + + // DESCRIPTION + // The last step of sending an SMS: Confirm and send out the SMS. + // RETURNS + // 1: Sending succeeds. 0: Send fails. + int endSMS(); + + // DESCRIPTION + // Checks if there is any unread SMS. + // RETURNS + // 1: There is unread SMS. 0: There is no unread SMS. + int available(); + + // DESCRIPTION + // Returns the source number of the unread SMS. + // RETURNS + // Length of the returning SMS number + // If there is no unread SMS, it will return 0. + // If the size of input array is too small, it will return the required size without filling the input array. Please call again with larger array. + int remoteNumber( + char* number, // [OUT] array to save SMS number + int nlength // [IN] size of the array + ); + + // DESCRIPTION + // Reads the content of the unread SMS, one byte at a time. + // The difference between read() and peek() is that read() moves the cursor but peak() does not. + // RETURNS + // One byte of SMS content. Will be -1 if it reaches the end of SMS. + int read(); + + // DESCRIPTION + // Reads the content of the unread SMS, one byte at a time without moving the cursor. + // Repeatedly calling peek() will return the same result. + // RETURNS + // One byte of SMS content. Will be -1 if it reaches the end of SMS. + int peek(); + + // DESCRIPTION + // Deletes the unread SMS. + // It only works when there is unread SMS checked by available(). + void flush(); + +private: + + // member for write SMS + String _toNumber; // maximum length for TP-DA/OA should be 12 octets (14 chars) + String _toContent; + + // member for read SMS + int _msgId; // current SMS id + char *_msgNumber; // number data of current SMS + char *_msgContent; // content data of current SMS + + int _msgPos; // current position of content (for sequential read/peak) + + +}; + +extern LSMSClass LSMS; + +enum LVoiceCall_voiceCall_st { IDLE_CALL, CALLING, RECEIVINGCALL, TALKING}; + +// Class of LinkIt Voice call support +class LVoiceCallClass : public _LTaskClass +{ +// Constructor / Destructor +public: + LVoiceCallClass(void); + ~LVoiceCallClass(void); + +// Method +public: + + // DESCRIPTION + // Check if the previous voice operation has executed successfully + // RETURNS + // 1: if previous operation executed successfully. 0: if not. + int ready(); + + // DESCRIPTION + // Make a voice call to a specified number + // RETURNS + // 1: Callout succeed, 0: Fail + int voiceCall( + const char* to, // [IN] The number to call. + unsigned long timeout=30000 // [IN] timeout count + ); + + // DESCRIPTION + // Checks status of the voice call. + // RETURNS + // 0 IDLE_CALL, 1 CALLING, 2 RECEIVINGCALL, 3 TALKING + char getVoiceCallStatus(void); + + // DESCRIPTION + // Accepts an incoming voice call. + // RETURNS + // 1: Answer succeeds. 0: Answer fails. + int answerCall(void); + + + // DESCRIPTION + // Retrieves the calling number. + // RETURNS + // 1: Retrieve succeeds. 0: Retrieve fails. + int retrieveCallingNumber( + char* number, // [OUT] array to save call number + int nlength // [IN] size of the array + ); + + // DESCRIPTION + // Hang up an established call or during incoming rings. + // RETURNS + // 1: Hang succeeds. 0: Hang fails. + int hangCall(void); + +private: + + +}; + +extern LVoiceCallClass LVoiceCall; + +#undef LINKITGSM_DEBUG + +#ifdef LINKITGSM_DEBUG +#define LGSMLOG(x) Serial.println(x) +#else +#define LGSMLOG(x) +#endif + +#endif + diff --git a/hardware/arduino/mtk/libraries/LGSM/LSMS.cpp b/hardware/arduino/mtk/libraries/LGSM/LSMS.cpp new file mode 100644 index 00000000..c7445fd1 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGSM/LSMS.cpp @@ -0,0 +1,386 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "LGSM.h" + +#include +#include +#include +#include + +/***************************************************************************** +* +* structure data between Arduino / MMI thread +* +*****************************************************************************/ + +struct linkit_sms_send_struct +{ + const char *number; + const char *content; + int result; +}; + +struct linkit_sms_unread_msg_struct +{ + int id; + char *number; + char *content; +}; + + +boolean linkit_sms_ready_handler(void* userdata); +boolean linkit_sms_send_handler(void* userdata); + +boolean linkit_sms_get_unread_handler(void* userdata); +boolean linkit_sms_delete_handler(void* userdata); + +/***************************************************************************** +* +* LSMSClass class +* +*****************************************************************************/ + +LSMSClass::LSMSClass(): + _msgId(-1), + _msgPos(0) +{ + +} + +LSMSClass::~LSMSClass() +{ + +} + +int LSMSClass::ready() +{ + int result; + LTask.remoteCall(linkit_sms_ready_handler, &result); + return result; +} + +int LSMSClass::beginSMS(const char* to) +{ + _toNumber = to; + _toContent = ""; + return 1; +} + +size_t LSMSClass::write(uint8_t c) +{ + _toContent += (char)c; +} + +int LSMSClass::endSMS() +{ + linkit_sms_send_struct data; + + data.content = _toContent.c_str(); + data.number = _toNumber.c_str(); + + LTask.remoteCall(linkit_sms_send_handler, &data); + + LGSMLOG("[LOG]endSMS():"); + LGSMLOG(data.result); + + if(data.result == 1) + return 1; + else + return 0; +} + +int LSMSClass::available() +{ + linkit_sms_unread_msg_struct data; + + LTask.remoteCall(linkit_sms_get_unread_handler, &data); + + if (data.id < 0) + return false; + + _msgId = data.id; + _msgNumber = data.number; + _msgContent = data.content; + _msgPos = 0; + + return true; +} + +int LSMSClass::remoteNumber(char* number, int nlength) +{ + int len; + + if (_msgId < 0) + return 0; + + len = strlen(_msgNumber); + + if (len+1 > nlength) + return len+1; + + strcpy(number, _msgNumber); + return len; +} + +int LSMSClass::read() +{ + int result; + + if(_msgId < 0) + return -1; + + result = _msgContent[_msgPos]; + if (result) + _msgPos++; + else + result = -1; + + return result; +} + +int LSMSClass::peek() +{ + if(_msgId < 0) + return -1; + + return _msgContent[_msgPos]; +} + +void LSMSClass::flush() +{ + if(_msgId < 0) + return; + + LTask.remoteCall(linkit_sms_delete_handler, (void*)_msgId); + _msgId = -1; +} + +/***************************************************************************** +* +* LSMS MMI part (running on MMI thread) +* +*****************************************************************************/ + +boolean linkit_sms_ready_handler(void* userdata) +{ + int result; + + LGSMLOG("[LOG]vm_sim_card_count:"); + LGSMLOG(vm_sim_card_count()); + LGSMLOG("[LOG]vm_sms_is_sms_ready:"); + LGSMLOG(vm_sms_is_sms_ready()); + + result = false; + if(vm_sim_card_count() > 0 && vm_sms_is_sms_ready()) + result = true; + + *((int*)userdata) = result; + return true; +} + +linkit_sms_send_struct *g_linkit_sms_send_data; + +char *g_linkit_sms_number_buf = 0; +char *g_linkit_sms_content_buf = 0; + +void linkit_sms_send_callback(VMINT result) +{ + LGSMLOG("[LOG]linkit_sms_send_callback"); + g_linkit_sms_send_data->result = result; + LTask.post_signal(); +} + +boolean linkit_sms_send_handler(void* userdata) +{ + linkit_sms_send_struct *data = (linkit_sms_send_struct*)userdata; + VMWCHAR *number; + VMWCHAR *content; + VMINT size; + + LGSMLOG("[LOG]linkit_sms_send_handler"); + LGSMLOG("[LOG]Number:"); + LGSMLOG(data->number); + LGSMLOG("[LOG]Content:"); + LGSMLOG(data->content); + + // ascii to ucs2 + size = (strlen(data->number)+1)*sizeof(VMWCHAR); + number = (VMWCHAR *)vm_malloc(size); + vm_ascii_to_ucs2(number, size, (VMCHAR*)data->number); + + size = (strlen(data->content)+1)*sizeof(VMWCHAR); + content = (VMWCHAR *)vm_malloc(size); + vm_ascii_to_ucs2(content, size, (VMCHAR*)data->content); + + // send and wait for result + g_linkit_sms_send_data = data; + size = vm_send_sms(number, content, linkit_sms_send_callback); + LGSMLOG("[LOG]vm_send_sms:"); + LGSMLOG(size); + + // TODO: can we free them now, or need to wait for callback? + vm_free(number); + vm_free(content); + + if(!size) // send fail + { + data->result = false; + return true; + } + + return false; +} + +void linkit_sms_read_callback(vm_sms_callback_t* callback_data) +{ + linkit_sms_unread_msg_struct *dest = (linkit_sms_unread_msg_struct*)callback_data->user_data; + vm_sms_read_msg_cb_t *msg = (vm_sms_read_msg_cb_t*)callback_data->action_data; + + LGSMLOG("[LOG]linkit_sms_read_callback"); + LGSMLOG(callback_data->result); + + if (callback_data->result) + { + if(g_linkit_sms_number_buf) + { + vm_free(g_linkit_sms_number_buf); + g_linkit_sms_number_buf = 0; + } + if(g_linkit_sms_content_buf) + { + vm_free(g_linkit_sms_content_buf); + g_linkit_sms_content_buf = 0; + } + + int size = vm_wstrlen((VMWCHAR*)msg->msg_data->number); + g_linkit_sms_number_buf = (char*)vm_malloc(size+1); + vm_ucs2_to_ascii(g_linkit_sms_number_buf, size, (VMWCHAR*)msg->msg_data->number); + + // assume dcs = UCS2 + g_linkit_sms_content_buf = (char*)vm_malloc(msg->msg_data->content_buff_size/2+1); + vm_ucs2_to_ascii(g_linkit_sms_content_buf, msg->msg_data->content_buff_size/2, (VMWCHAR*)msg->msg_data->content_buff); + + dest->number = g_linkit_sms_number_buf; + dest->content = g_linkit_sms_content_buf; + + LGSMLOG("[LOG]Number:"); + LGSMLOG(g_linkit_sms_number_buf); + LGSMLOG("[LOG]Content:"); + LGSMLOG(g_linkit_sms_content_buf); + } + else + { + dest->id = -1; + } + + vm_free(msg->msg_data->content_buff); + vm_free(msg->msg_data); + + LTask.post_signal(); +} + +void linkit_sms_get_unread_callback(vm_sms_callback_t* callback_data) +{ + linkit_sms_unread_msg_struct *dest = (linkit_sms_unread_msg_struct*)callback_data->user_data; + vm_sms_query_msg_cb_t *list = (vm_sms_query_msg_cb_t*)callback_data->action_data; + int result; + + LGSMLOG("[LOG]linkit_sms_get_unread_callback"); + if (callback_data->result) + { + if (list->msg_num > 0) + { + // continue to read this message + vm_sms_msg_data_t *buf = (vm_sms_msg_data_t*)vm_malloc(sizeof(vm_sms_msg_data_t)); + + buf->content_buff = (VMINT8*)vm_malloc((LGSM_MAX_SMS_LEN+1)*sizeof(VMWCHAR)); + buf->content_buff_size = LGSM_MAX_SMS_LEN*sizeof(VMWCHAR); + + dest->id = list->msg_id_list[0]; + result = vm_sms_read_msg(dest->id, 0, buf, linkit_sms_read_callback, dest); + if(result >= 0) + { + return; // continue wait + } + else + { + LGSMLOG("[LOG]vm_sms_read_msg() fail!!:"); + LGSMLOG(dest->id); + LGSMLOG(result); + } + } + } + + LTask.post_signal(); +} + +boolean linkit_sms_get_unread_handler(void* userdata) +{ + linkit_sms_unread_msg_struct *dest = (linkit_sms_unread_msg_struct*)userdata; + vm_sms_query_t param; + int result; + + dest->id = -1; + + param.sort_flag = VM_SMS_SORT_SIM_ID; + param.order_flag = VM_SMS_ORDER_ASC; + param.status = (vm_sms_status_enum)(VM_SMS_STATUS_UNREAD | VM_SMS_STATUS_READ); + + LGSMLOG("[LOG]linkit_sms_get_unread_handler"); + result = vm_sms_get_msg_id_list(¶m, linkit_sms_get_unread_callback, userdata); + if(result < 0) + { + LGSMLOG(result); + return true; + } + return false; +} + + +void linkit_sms_delete_callback(vm_sms_callback_t* callback_data) +{ + LTask.post_signal(); +} + +boolean linkit_sms_delete_handler(void* userdata) +{ + VMUINT16 msg_id = (VMUINT16)((VMUINT32)userdata); + + vm_sms_delete_msg(msg_id, linkit_sms_delete_callback, userdata); + + return false; +} + +LSMSClass LSMS; \ No newline at end of file diff --git a/hardware/arduino/mtk/libraries/LGSM/LVoiceCall.cpp b/hardware/arduino/mtk/libraries/LGSM/LVoiceCall.cpp new file mode 100644 index 00000000..d6b4e137 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGSM/LVoiceCall.cpp @@ -0,0 +1,113 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "LGSM.h" + +#include +#include +#include +#include "VoiceCall.h" + +/***************************************************************************** +* +* LVoiceCallClass class +* +*****************************************************************************/ +LVoiceCallClass::LVoiceCallClass() +{ + registerCallback(); +} + +LVoiceCallClass::~LVoiceCallClass() +{ + +} + +int LVoiceCallClass::ready() +{ + int result = 0; + remoteCall(callready, (void*)&result); + return result; +} + +int LVoiceCallClass::voiceCall(const char* to, unsigned long timeout) +{ + call_info_struct callInfo; + strcpy(callInfo.num, to); + remoteCall(callvoiceCall, (void*)&callInfo); + return callInfo.result; +} + +char LVoiceCallClass::getVoiceCallStatus(void) +{ + char status; + remoteCall(callgetVoiceCallStatus, (void*)&status); + return status; +} + +int LVoiceCallClass::answerCall(void) +{ + int ret; + remoteCall(callanswerCall, &ret); + return ret; +} + +int LVoiceCallClass::retrieveCallingNumber(char* number, int nlength ) +{ + call_info_struct callInfo; + + memset(number, 0, nlength); + + remoteCall(callretrieveCallingNumber, (void*)&callInfo); + + if(callInfo.result == 1) + { + strcpy(number, callInfo.num); + return 1; + } + else + { + return 0; + } +} + +int LVoiceCallClass::hangCall(void) +{ + int ret; + remoteCall(callhangCall, (void*)&ret); + return ret; +} + +LVoiceCallClass LVoiceCall; + diff --git a/hardware/arduino/mtk/libraries/LGSM/examples/LVoiceCall/LVoiceCall.ino b/hardware/arduino/mtk/libraries/LGSM/examples/LVoiceCall/LVoiceCall.ino new file mode 100644 index 00000000..ba165d1b --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGSM/examples/LVoiceCall/LVoiceCall.ino @@ -0,0 +1,60 @@ +#include + +String remoteNumber = ""; // the number you will call +char charbuffer[20]; + +void setup() +{ + // initialize serial communications + Serial1.begin(115200); + Serial1.println("Make Voice Call"); + Serial1.println("Enter phone number to call."); +} + +void loop() +{ + // add any incoming characters to the String: + while (Serial1.available() > 0) + { + char inChar = Serial1.read(); + // if it's a newline, that means you should make the call: + if (inChar == '\n') + { + // make sure the phone number is not too long: + if (remoteNumber.length() < 20) + { + // let the user know you're calling: + Serial1.print("Calling to : "); + Serial1.println(remoteNumber); + Serial1.println(); + + // Call the remote number + remoteNumber.toCharArray(charbuffer, 20); + + // Check if the receiving end has picked up the call + if(LVoiceCall.voiceCall(charbuffer)) + { + Serial1.println("Call Established. Enter line to end"); + // Wait for some input from the line + while(Serial1.read() !='\n'); + // And hang up + LVoiceCall.hangCall(); + } + Serial1.println("Call Finished"); + remoteNumber=""; + Serial1.println("Enter phone number to call."); + } + else + { + Serial1.println("That's too long for a phone number. I'm forgetting it"); + remoteNumber = ""; + } + } + else + { + // add the latest character to the message to send: + if(inChar!='\r') + remoteNumber += inChar; + } + } +} diff --git a/hardware/arduino/mtk/libraries/LGSM/examples/LVoiceCallStatus/LVoiceCallStatus.ino b/hardware/arduino/mtk/libraries/LGSM/examples/LVoiceCallStatus/LVoiceCallStatus.ino new file mode 100644 index 00000000..17b6e870 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGSM/examples/LVoiceCallStatus/LVoiceCallStatus.ino @@ -0,0 +1,63 @@ +#include + +// PIN Number +#define PINNUMBER "" + +char numtel[20]; // buffer for the incoming call + +void setup() +{ + // initialize serial communications + Serial1.begin(115200); + Serial1.println("Receive Voice Call"); + + // connection state + boolean notConnected = true; + + // This makes sure the modem notifies correctly incoming events + LVoiceCall.hangCall(); + + Serial1.println("Waiting Call"); +} + +void loop() +{ + // Check the status of the voice call + switch (LVoiceCall.getVoiceCallStatus()) + { + case IDLE_CALL: // Nothing is happening + + break; + + case CALLING: // This should never happen, as we are not placing a call + + Serial1.println("CALLING"); + break; + + case RECEIVINGCALL: // Yes! Someone is calling us + + Serial1.println("RECEIVING CALL"); + + // Retrieve the calling number + LVoiceCall.retrieveCallingNumber(numtel, 20); + + // Print the calling number + Serial1.print("Number:"); + Serial1.println(numtel); + + // Answer the call, establish the call + LVoiceCall.answerCall(); + break; + + case TALKING: // In this case the call would be established + + Serial1.println("TALKING. Enter line to interrupt."); + while(Serial1.read()!='\n') + delay(100); + LVoiceCall.hangCall(); + Serial1.println("HANG. Waiting Call."); + break; + } + delay(1000); +} + diff --git a/hardware/arduino/mtk/libraries/LGSM/keywords.txt b/hardware/arduino/mtk/libraries/LGSM/keywords.txt new file mode 100644 index 00000000..7b523fc8 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGSM/keywords.txt @@ -0,0 +1,30 @@ +####################################### +# Syntax Coloring Map For LVoiceCallClass +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +LVoiceCall KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +ready KEYWORD2 +voiceCall KEYWORD2 +getVoiceCallStatus KEYWORD2 +answerCall KEYWORD2 +retrieveCallingNumber KEYWORD2 +hangCall KEYWORD2 + +####################################### +# Object (KEYWORD3) +####################################### +LVoiceCall KEYWORD3 + +####################################### +# Constants (LITERAL1) +####################################### + diff --git a/hardware/arduino/mtk/libraries/LGSM/utility/VoiceCall.cpp b/hardware/arduino/mtk/libraries/LGSM/utility/VoiceCall.cpp new file mode 100644 index 00000000..e5eedf35 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGSM/utility/VoiceCall.cpp @@ -0,0 +1,253 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "vmtel.h" +#include "vmlog.h" +#include "LGSM.h" +#include "vmchset.h" +#include "string.h" +#include "VoiceCall.h" + +extern vm_call_listener_func g_call_status_callback; + +static vm_ucm_id_info_struct g_uid_info; +static int g_call_status = IDLE_CALL; +static char g_number[42]; + +static void __call_listener_func(vm_call_listener_data* data) +{ + if(data->type_op == VM_UCM_INCOMING_CALL_IND) + { + vm_ucm_incoming_call_ind_struct* ind = (vm_ucm_incoming_call_ind_struct*)data->data; + g_uid_info.call_id = ind->uid_info.call_id; + g_uid_info.group_id = ind->uid_info.group_id; + g_uid_info.call_type = ind->uid_info.call_type; + strcpy(g_number, (char*)ind->num_uri); + g_call_status = RECEIVINGCALL; + } + else if(data->type_op == VM_UCM_OUTGOING_CALL_IND) + { + vm_ucm_outgoing_call_ind_struct* ind = (vm_ucm_outgoing_call_ind_struct*)data->data; + g_uid_info.call_id = ind->uid_info.call_id; + g_uid_info.group_id = ind->uid_info.group_id; + g_uid_info.call_type = ind->uid_info.call_type; + strcpy(g_number, (char*)ind->num_uri); + g_call_status = TALKING; + } + else if(data->type_op == VM_UCM_CALL_END) + { + g_call_status = IDLE_CALL; + } + else + { + vm_log_info("bad operation type"); + } +} + +void registerCallback(void) +{ + g_call_status_callback = __call_listener_func; +} + +static void _call_voiceCall_callback(vm_call_actions_callback_data* data) +{ + VMINT* result = (VMINT*)data->userdata; + + if(data->type_act == VM_UCM_DIAL_ACT) + { + + if(data->data_act_rsp.result_info.result == VM_UCM_RESULT_OK) + { + *result = 1; + g_call_status = CALLING; + LVoiceCall.post_signal(); + } + else + { + *result = 0; + g_call_status = IDLE_CALL; + } + } + else if(data->type_act == VM_UCM_ACCEPT_ACT) + { + if(data->data_act_rsp.result_info.result == VM_UCM_RESULT_OK) + { + *result = 1; + g_call_status = TALKING; + LVoiceCall.post_signal(); + } + else + { + *result = 0; + g_call_status = IDLE_CALL; + } + } + else if(data->type_act == VM_UCM_HOLD_ACT) + { + // not use + } + else if(data->type_act == VM_UCM_END_SINGLE_ACT) + { + *result = 1; + LVoiceCall.post_signal(); + g_call_status = IDLE_CALL; + } + else + { + // not use + } +} + +boolean callvoiceCall(void* user_data) +{ + VMINT ret; + call_info_struct* callInfo_p = (call_info_struct*)user_data; + vm_ucm_dial_act_req_struct req; + vm_call_actions_data data; + + req.call_type = VM_UCM_VOICE_CALL_TYPE; + req.is_ip_dial = 0; + req.module_id = 0; + vm_ascii_to_ucs2((VMWSTR)req.num_uri, VM_UCM_MAX_NUM_URI_LEN, (VMSTR)callInfo_p->num); + + req.phb_data = NULL; + + data.type_act = VM_UCM_DIAL_ACT; + data.data_act = (void*)&req; + data.userdata = (void*)&callInfo_p->result; + data.callback = _call_voiceCall_callback; + + ret = vm_call_actions(&data); + + if(ret == 0) + { + return false; + } + else + { + callInfo_p->result = 0; + return true; + } +} + +boolean callanswerCall(void* user_data) +{ + VMINT ret; + VMINT* result = (VMINT*)user_data; + vm_ucm_single_call_act_req_struct req; + vm_call_actions_data data; + + req.action_uid.call_type = g_uid_info.call_type; + req.action_uid.call_id = g_uid_info.call_id; + req.action_uid.group_id = g_uid_info.group_id; + + data.type_act = VM_UCM_ACCEPT_ACT; + data.data_act = (void*)&req; + data.userdata = result; + data.callback = _call_voiceCall_callback; + ret = vm_call_actions(&data); + + if(ret == 0) + { + return false; + } + else + { + *result = 0; + return true; + } +} + +boolean callretrieveCallingNumber(void* user_data) +{ + call_info_struct* callInfo = (call_info_struct*)user_data; + callInfo->result = 0; + + if(g_call_status == RECEIVINGCALL || g_call_status == TALKING) + { + strcpy((char*)callInfo->num, (char*)g_number); + callInfo->result = 1; + } + + return true; +} + +boolean callready(void* user_data) +{ + VMINT* result = (VMINT*)user_data; + *result = 1; + return true; +} + +boolean callgetVoiceCallStatus(void* user_data) +{ + char* status = (char*)user_data; + *status = g_call_status; + return true; +} + +boolean callhangCall(void* user_data) +{ + VMINT ret; + VMINT* result = (VMINT*)user_data; + vm_ucm_single_call_act_req_struct req; + vm_call_actions_data data; + + if(IDLE_CALL == g_call_status) + return true; + + req.action_uid.call_type = g_uid_info.call_type; + req.action_uid.call_id = g_uid_info.call_id; + req.action_uid.group_id = g_uid_info.group_id; + + data.type_act = VM_UCM_END_SINGLE_ACT; + data.data_act = (void*)&req; + data.userdata = user_data; + data.callback = _call_voiceCall_callback; + ret = vm_call_actions(&data); + /* + if(ret == 0) + { + return false; + } + else + */ + { + *result = 1; + return true; + } +} + + + diff --git a/hardware/arduino/mtk/libraries/LGSM/utility/VoiceCall.h b/hardware/arduino/mtk/libraries/LGSM/utility/VoiceCall.h new file mode 100644 index 00000000..694f5235 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LGSM/utility/VoiceCall.h @@ -0,0 +1,62 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef _VOICECALL_H +#define _VOICECALL_H + +#ifdef __cplusplus +extern "C" { +#endif + +boolean callvoiceCall(void* user_data); +boolean callanswerCall(void* user_data); +boolean callretrieveCallingNumber(void* user_data); +boolean callready(void* user_data); +boolean callgetVoiceCallStatus(void* user_data); +boolean callhangCall(void* user_data); + +void registerCallback(void); + +typedef struct +{ + VMINT result; + char num[42]; +}call_info_struct; + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/hardware/arduino/mtk/libraries/LStorage/LFlash.cpp b/hardware/arduino/mtk/libraries/LStorage/LFlash.cpp new file mode 100644 index 00000000..5dd79d69 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LStorage/LFlash.cpp @@ -0,0 +1,89 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "LFlash.h" + +#include "vmio.h" + +static boolean _get_drv_handler(void* userdata); + +/***************************************************************************** +* +* LFlash class +* +*****************************************************************************/ + +LFlashClass::LFlashClass() +{ + +} + +LFlashClass::~LFlashClass() +{ + +} + +boolean LFlashClass::begin() +{ + int drv; + LTask.remoteCall(_get_drv_handler, &drv); + + if(drv > 0) + { + initDrv(drv); + return true; + } + else + { + return false; + } +} + +LFlashClass LFlash; + +/***************************************************************************** +* +* MMI part (running on MMI thread) +* +*****************************************************************************/ + +static boolean _get_drv_handler(void* userdata) +{ +#ifdef LINKITSTORAGE_DEBUG + Serial.print("vm_get_system_driver()="); + Serial.println(vm_get_system_driver()); +#endif + *((int*)userdata) = vm_get_system_driver(); + return true; +} diff --git a/hardware/arduino/mtk/libraries/LStorage/LFlash.h b/hardware/arduino/mtk/libraries/LStorage/LFlash.h new file mode 100644 index 00000000..a7533885 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LStorage/LFlash.h @@ -0,0 +1,61 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + + +#ifndef _LINKITFLASH_h +#define _LINKITFLASH_h + +#include "LStorage.h" + +// Class of LinkIt Flash support +class LFlashClass : public LDrive +{ +// Constructor / Destructor +public: + LFlashClass(void); + ~LFlashClass(void); + + // DESCRIPTION + // Initialzes the Flash module + // RETURNS + // true if succeed, false if failed + virtual boolean begin(); + +}; + +extern LFlashClass LFlash; + +#endif + diff --git a/hardware/arduino/mtk/libraries/LStorage/LSD.cpp b/hardware/arduino/mtk/libraries/LStorage/LSD.cpp new file mode 100644 index 00000000..b664f6c0 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LStorage/LSD.cpp @@ -0,0 +1,89 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "LSD.h" + +#include "vmio.h" + +static boolean _get_drv_handler(void* userdata); + +/***************************************************************************** +* +* LSD class +* +*****************************************************************************/ + +LSDClass::LSDClass() +{ + +} + +LSDClass::~LSDClass() +{ + +} + +boolean LSDClass::begin() +{ + int drv; + LTask.remoteCall(_get_drv_handler, &drv); + + if(drv > 0) + { + initDrv(drv); + return true; + } + else + { + return false; + } +} + +LSDClass LSD; + +/***************************************************************************** +* +* MMI part (running on MMI thread) +* +*****************************************************************************/ + +static boolean _get_drv_handler(void* userdata) +{ +#ifdef LINKITSTORAGE_DEBUG + Serial.print("vm_get_removable_driver()="); + Serial.println(vm_get_removable_driver()); +#endif + *((int*)userdata) = vm_get_removable_driver(); + return true; +} diff --git a/hardware/arduino/mtk/libraries/LStorage/LSD.h b/hardware/arduino/mtk/libraries/LStorage/LSD.h new file mode 100644 index 00000000..90fbbc52 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LStorage/LSD.h @@ -0,0 +1,61 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + + +#ifndef _LINKITSD_h +#define _LINKITSD_h + +#include "LStorage.h" + +// Class of LinkIt SD support +class LSDClass : public LDrive +{ +// Constructor / Destructor +public: + LSDClass(void); + ~LSDClass(void); + + // DESCRIPTION + // Initialzes the SD module + // RETURNS + // true if succeed, false if failed + virtual boolean begin(); + +}; + +extern LSDClass LSD; + +#endif + diff --git a/hardware/arduino/mtk/libraries/LStorage/LStorage.cpp b/hardware/arduino/mtk/libraries/LStorage/LStorage.cpp new file mode 100644 index 00000000..2645d5e5 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LStorage/LStorage.cpp @@ -0,0 +1,858 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#include "LStorage.h" + +#include "vmio.h" +#include "vmchset.h" +#include "vmstdlib.h" + +/***************************************************************************** +* +* Utility +* +*****************************************************************************/ + +#ifdef LINKITSTORAGE_DEBUG +static void _printwstr(VMWCHAR *filepath_buf) +{ + int i = 0; + while(filepath_buf[i]) + { + Serial.write(filepath_buf[i]); + i++; + } + Serial.println(); +} +#endif + +static boolean _conv_path(char drv, const char* filepath, VMWCHAR *filepath_buf) +{ + int i; + + memset(filepath_buf, 0, (LS_MAX_PATH_LEN)*sizeof(VMWCHAR)); + + filepath_buf[i++] = drv; + filepath_buf[i++] = ':'; + if(filepath[0] != '/') + filepath_buf[i++] = '/'; + + if (vm_ascii_to_ucs2(filepath_buf+i, (LS_MAX_PATH_LEN-i)*sizeof(VMWCHAR), (char*)filepath) < 0) + return false; + + i = 0; + while(filepath_buf[i]) + { + if(filepath_buf[i] == '/') + filepath_buf[i] = '\\'; + i++; + } + +#ifdef LINKITSTORAGE_DEBUG + Serial.print("[conv1]"); + _printwstr(filepath_buf); +#endif + + return true; +} + +static boolean _conv_path_back(const VMWCHAR* filepath, char *filepath_buf) +{ + int i = 0; + + memset(filepath_buf, 0, (LS_MAX_PATH_LEN)*sizeof(char)); + + if (vm_ucs2_to_ascii(filepath_buf, (LS_MAX_PATH_LEN)*sizeof(char), (VMWCHAR*)filepath+2) < 0) + return false; + + while(filepath_buf[i]) + { + if(filepath_buf[i] == '\\') + filepath_buf[i] = '/'; + i++; + } + +#ifdef LINKITSTORAGE_DEBUG + Serial.print("[conv2]"); + LSLOG(filepath_buf); +#endif + + return true; +} + +VMUINT mode_map(uint8_t mode) +{ + if(mode == FILE_WRITE) + return MODE_CREATE_ALWAYS_WRITE; + else + return MODE_READ; +} + +/***************************************************************************** +* +* structure data between Arduino / MMI thread +* +*****************************************************************************/ + +struct linkit_file_general_struct +{ + VMUINT fd; + VMINT result; + VMUINT value; +}; + +struct linkit_file_flush_struct +{ + VMUINT fd; + VMINT result; + void *buf; + VMUINT nbyte; +}; + +struct linkit_file_read_struct +{ + VMUINT fd; + VMINT result; + void *buf; + VMUINT nbyte; + boolean peek_mode; + +}; + +struct linkit_file_seek_struct +{ + VMUINT fd; + VMINT result; + VMINT pos; +}; + +struct linkit_file_find_struct +{ + VMUINT findhdl; + char *findpath; + VMWCHAR drv; + uint8_t mode; + + uint8_t is_dir; + VMUINT fd; + VMINT result; // 0: ok, <0: error + char name[LS_MAX_PATH_LEN]; +}; + +boolean linkit_file_read_handler(void* userdata); +boolean linkit_file_seek_handler(void* userdata); +boolean linkit_file_position_handler(void* userdata); +boolean linkit_file_size_handler(void* userdata); +boolean linkit_file_close_handler(void* userdata); +boolean linkit_file_available_handler(void* userdata); +boolean linkit_file_flush_handler(void* userdata); +boolean linkit_file_find_handler(void* userdata); +boolean linkit_file_find_close_handler(void* userdata); + +struct linkit_drv_general_op_struct +{ + const char *filepath; + VMINT op; + VMINT result; + VMWCHAR drv; +}; + +struct linkit_drv_open_struct +{ + const char *filepath; + VMINT mode; + VMINT result; + VMUINT fd; + VMINT is_dir; + VMWCHAR drv; +}; + +boolean linkit_drv_general_handler(void* userdata); +boolean linkit_drv_read_handler(void* userdata); + +struct linkit_file_handle_struct +{ + VMINT _hdl; + VMINT _ref; +}; + +#define HDL(fd) ((linkit_file_handle_struct*)fd)->_hdl +#define REF(fd) ((linkit_file_handle_struct*)fd)->_ref + +/***************************************************************************** +* +* LFile class +* +*****************************************************************************/ + + +LFile::LFile() +{ + _fd = 0; + _isDir = false; + _name[0] = 0; + _drv = 0; + _bufPos = 0; +} + +LFile::LFile(unsigned int fd, boolean isdir, char drv, const char* name) +{ + _fd = fd; + _isDir = isdir; + _drv = drv; + strncpy(_name, name, LS_MAX_PATH_LEN); + _bufPos = 0; +} + +LFile::~LFile() +{ + close(); +} + +size_t LFile::write(uint8_t v) +{ + if(!_fd || _isDir) + return 0; + + _buf[_bufPos++] = v; + if(_bufPos == LS_WRITE_BUF_SIZE) + flush(); + return 1; +} + +int LFile::read() +{ + uint8_t buf[1]; + int result; + + if(!_fd || _isDir) + return -1; + + result = _read(buf, 1, false); + if(result < 0) + return result; + + return buf[0]; +} + +int LFile::peek() +{ + uint8_t buf[1]; + int result; + + if(!_fd || _isDir) + return -1; + + result = _read(buf, 1, true); + if(result < 0) + return result; + + return buf[0]; +} + +int LFile::available() +{ + linkit_file_general_struct data; + + if(!_fd || _isDir) + return -1; + + data.fd = _fd; + + LTask.remoteCall(linkit_file_available_handler, &data); + + return data.result; +} + +void LFile::flush() +{ + linkit_file_flush_struct data; + + if(!_fd || _isDir || _bufPos == 0) + return; + + data.fd = _fd; + data.buf = _buf; + data.nbyte = _bufPos; + + LTask.remoteCall(linkit_file_flush_handler, &data); + + _bufPos = 0; +} + +int LFile::read(void *buf, uint16_t nbyte) +{ + return _read(buf, nbyte, false); +} + +int LFile::_read(void *buf, uint16_t nbyte, boolean peek_mode) +{ + linkit_file_read_struct data; + + if(!_fd || _isDir) + return -1; + + data.fd = _fd; + data.buf = buf; + data.nbyte = nbyte; + data.peek_mode = peek_mode; + + LTask.remoteCall(linkit_file_read_handler, &data); + + return data.result; +} + +boolean LFile::seek(uint32_t pos) +{ + linkit_file_seek_struct data; + + if(!_fd || _isDir) + return false; + + data.fd = _fd; + data.pos = pos; + + LTask.remoteCall(linkit_file_seek_handler, &data); + + return data.result; +} + +uint32_t LFile::position() +{ + linkit_file_general_struct data; + + if(!_fd || _isDir) + return 0; + + data.fd = _fd; + + LTask.remoteCall(linkit_file_position_handler, &data); + + return data.value; +} + +uint32_t LFile::size() +{ + linkit_file_general_struct data; + + if(!_fd || _isDir) + return 0; + + data.fd = _fd; + + LTask.remoteCall(linkit_file_size_handler, &data); + + return data.value; +} + +void LFile::close() +{ + linkit_file_general_struct data; + + if(!_fd || _isDir) + return; + + flush(); + + data.fd = _fd; + + if(_isDir) + LTask.remoteCall(linkit_file_find_close_handler, &data); + else + LTask.remoteCall(linkit_file_close_handler, &data); + + _fd = 0; +} + +LFile::operator bool() +{ + return _fd ? true : false; +} + +LFile& LFile::operator=(const LFile& other) +{ + memcpy(this, &other, sizeof(LFile)); + if(_fd) + REF(_fd)++; + + return *this; +} + +char * LFile::name() +{ + int i, len = strlen(_name); + if (len == 1) + return _name; + + for(i=len-2;i--;i>=0) + if(_name[i]=='/') + break; + + i++; + return _name+i; +} + +boolean LFile::isDirectory(void) +{ + if(_isDir) + return true; + + return false; +} + +LFile LFile::openNextFile(uint8_t mode) +{ + linkit_file_find_struct data; + if (!_isDir) + return LFile(); + + data.mode = mode; + data.drv = _drv; + data.findpath = _name; + data.findhdl = _fd; + + LTask.remoteCall(linkit_file_find_handler, &data); + + _fd = data.findhdl; + + if (data.result < 0) + { + return LFile(); + } + + return LFile(data.fd, data.is_dir, _drv, data.name); +} + +void LFile::rewindDirectory(void) +{ + linkit_file_general_struct data; + if (!_isDir || !_fd) + return; + + data.fd = _fd; + LTask.remoteCall(linkit_file_find_close_handler, &data); + _fd = 0; +} + +/***************************************************************************** +* +* LFile MMI part (running on MMI thread) +* +*****************************************************************************/ + +boolean linkit_file_read_handler(void* userdata) +{ + linkit_file_read_struct *data = (linkit_file_read_struct*)userdata; + VMUINT read; + + data->result = vm_file_read(HDL(data->fd), data->buf, data->nbyte, &read); + + if(data->peek_mode) + { + // peek mode, rewind back + vm_file_seek(HDL(data->fd), -read, BASE_CURR); + } + + return true; +} + +boolean linkit_file_seek_handler(void* userdata) +{ + linkit_file_seek_struct *data = (linkit_file_seek_struct*)userdata; + + data->result = vm_file_seek(HDL(data->fd), data->pos, BASE_BEGIN); + + return true; +} + +boolean linkit_file_position_handler(void* userdata) +{ + linkit_file_general_struct *data = (linkit_file_general_struct*)userdata; + + data->result = vm_file_tell(HDL(data->fd)); + + if(data->result >= 0) + data->value = data->result; + else + data->value = 0; + + return true; +} + +boolean linkit_file_size_handler(void* userdata) +{ + linkit_file_general_struct *data = (linkit_file_general_struct*)userdata; + VMUINT size; + + data->result = vm_file_getfilesize(HDL(data->fd), &size); + if (data->result == 0) + data->value = size; + else + data->value = 0; + + return true; +} + +boolean linkit_file_close_handler(void* userdata) +{ + linkit_file_general_struct *data = (linkit_file_general_struct*)userdata; + + REF(data->fd)--; + if(REF(data->fd) == 0) + { + vm_file_close(HDL(data->fd)); + free((void*)data->fd); + data->fd = 0; + } + + return true; +} + +boolean linkit_file_available_handler(void* userdata) +{ + linkit_file_general_struct *data = (linkit_file_general_struct*)userdata; + + VMUINT size = 0; + VMINT pos = 0; + + vm_file_getfilesize(HDL(data->fd), &size); + pos = vm_file_tell(HDL(data->fd)); + + if(!size || pos < 0) + { + data->result = pos; + } + else + { + size -= pos; + data->result = size > 0x7FFF ? 0x7FFF : 0; // follow Arduino File.cpp's rule + } + + return true; +} + +boolean linkit_file_flush_handler(void* userdata) +{ + linkit_file_flush_struct *data = (linkit_file_flush_struct*)userdata; + + if(data->nbyte) + { + VMUINT written; + vm_file_write(HDL(data->fd), data->buf, data->nbyte, &written); + } + + data->result = vm_file_commit(HDL(data->fd)); + + return true; +} + +boolean linkit_file_find_handler(void* userdata) +{ + linkit_file_find_struct *data = (linkit_file_find_struct*)userdata; + VMWCHAR filepath_buf[LS_MAX_PATH_LEN]; + vm_fileinfo_t info; + VMINT attr; + VMINT findhdl; + + data->result = -1; + + if(!_conv_path(data->drv, data->findpath, filepath_buf)) + return true; + + int len = vm_wstrlen(filepath_buf); + if(filepath_buf[len-1] != '\\') + { + filepath_buf[len] = '\\'; + filepath_buf[len+1] = 0; + len++; + } + + if(!data->findhdl) + { + filepath_buf[len] = '*'; + filepath_buf[len+1] = 0; + +#ifdef LINKITSTORAGE_DEBUG + Serial.print("[find]"); + _printwstr(filepath_buf); +#endif + + findhdl = vm_find_first(filepath_buf, &info); + if(findhdl < 0) + return true; + + // skip . and .. + while( (info.filename[0] == '.' && info.filename[1] == 0) || + (info.filename[0] == '.' && info.filename[1] == '.' && info.filename[2] == 0) ) + { + data->result = vm_find_next(findhdl, &info); + if(data->result < 0) + { + vm_find_close(findhdl); + return true; + } + } + + data->findhdl = (VMUINT)malloc(sizeof(linkit_file_handle_struct)); + HDL(data->findhdl) = findhdl; + REF(data->findhdl) = 1; + } + else + { + findhdl = HDL(data->findhdl); + data->result = vm_find_next(findhdl, &info); + if(data->result < 0) + return true; + } + + vm_wstrcpy(filepath_buf+len, info.filename); + + attr = vm_file_get_attributes(filepath_buf); + if (attr >= 0 && attr & VM_FS_ATTR_DIR) + { + LSLOG("[find]dir"); + data->is_dir = true; + data->result = 0; + } + else if(attr < 0) // special case for SD label entry + { +#ifdef LINKITSTORAGE_DEBUG + Serial.print("[find]SD label?:"); + _printwstr(filepath_buf); +#endif + data->is_dir = true; + data->result = 0; + } + else + { + LSLOG("[find]file"); + data->is_dir = false; + data->result = vm_file_open(filepath_buf, mode_map(data->mode), TRUE); + if(data->result < 0) + { + REF(data->findhdl)--; + if(REF(data->findhdl) == 0) + { + vm_find_close(HDL(data->findhdl)); + free((void*)data->findhdl); + data->findhdl = 0; + } + } + else + { + data->fd = (VMUINT)malloc(sizeof(linkit_file_handle_struct)); + HDL(data->fd) = data->result; + REF(data->fd) = 1; + } + } + _conv_path_back(filepath_buf, data->name); + + return true; +} + +boolean linkit_file_find_close_handler(void* userdata) +{ + linkit_file_general_struct *data = (linkit_file_general_struct*)userdata; + + REF(data->fd)--; + if(REF(data->fd) == 0) + { + vm_find_close(HDL(data->fd)); + free((void*)data->fd); + data->fd = 0; + } + + return true; +} + +/***************************************************************************** +* +* LDrive class +* +*****************************************************************************/ + + +boolean LDrive::general_op(int op, char *filepath) +{ + linkit_drv_general_op_struct data; + + data.filepath = filepath; + data.op = op; + data.drv = _drv; + + LTask.remoteCall(linkit_drv_general_handler, &data); + + return data.result; +} + +LFile LDrive::open(const char *filename, uint8_t mode) +{ + linkit_drv_open_struct data; + + data.filepath = filename; + data.mode = mode; + data.drv = _drv; + + LTask.remoteCall(linkit_drv_read_handler, &data); + + if (!data.result) // fail, return empty object + { + LSLOG("open() fail"); + return LFile(); + } + + return LFile(data.fd, data.is_dir, _drv, filename); +} + +/***************************************************************************** +* +* LFile MMI part (running on MMI thread) +* +*****************************************************************************/ + +static int recur_mkdir(VMWCHAR* path) +{ + int result; + VMWCHAR *pos; + + // check if already exist + result = vm_file_get_attributes(path); + if(result >= 0) + return -1; // already exist + + pos = path+3; + while(*pos) + { + if(*pos == '\\') + { + *pos = 0; + vm_file_mkdir(path); + *pos = '\\'; + } + pos++; + } + vm_file_mkdir(path); + + // check if final path exist + result = vm_file_get_attributes(path); + if(result >= 0) + result = 0; // succeed + + return result; +} + +boolean linkit_drv_general_handler(void* userdata) +{ + linkit_drv_general_op_struct *data = (linkit_drv_general_op_struct*)userdata; + VMWCHAR filepath_buf[LS_MAX_PATH_LEN]; + int result; + + data->result = false; + + if(!_conv_path(data->drv, data->filepath, filepath_buf)) + return true; + + switch(data->op) + { + case 1: // exists + result = vm_file_get_attributes(filepath_buf); + break; + + case 2: // mkdir + result = recur_mkdir(filepath_buf); + break; + + case 3: // remove + result = vm_file_delete(filepath_buf); + break; + + case 4: // rmdir + result = vm_file_rmdir(filepath_buf); + break; + } + +#ifdef LINKITSTORAGE_DEBUG + Serial.print("[gen_op]"); + Serial.print(data->op); + Serial.print(":"); + Serial.println(result); +#endif + + data->result = result < 0 ? false : true; + return true; +} + +boolean linkit_drv_read_handler(void* userdata) +{ + linkit_drv_open_struct *data = (linkit_drv_open_struct*)userdata; + VMWCHAR filepath_buf[LS_MAX_PATH_LEN]; + VMINT attr; + VMINT fd; + + data->result = false; + + if(!_conv_path(data->drv, data->filepath, filepath_buf)) + { + return true; + } + + // identify if this is a file or dir + attr = vm_file_get_attributes(filepath_buf); + + if (attr >= 0 && attr & VM_FS_ATTR_DIR) + { + data->is_dir = true; + data->fd = 0; + data->result = true; + LSLOG("open ok (dir)"); + } + else + { + data->is_dir = false; + fd = vm_file_open(filepath_buf, mode_map(data->mode), TRUE); + if (fd > 0) + { + LSLOG("open ok (file)"); + data->result = true; + + data->fd = (VMUINT)malloc(sizeof(linkit_file_handle_struct)); + HDL(data->fd) = fd; + REF(data->fd) = 1; + } + } + + return true; +} + + diff --git a/hardware/arduino/mtk/libraries/LStorage/LStorage.h b/hardware/arduino/mtk/libraries/LStorage/LStorage.h new file mode 100644 index 00000000..577cc9bf --- /dev/null +++ b/hardware/arduino/mtk/libraries/LStorage/LStorage.h @@ -0,0 +1,281 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + + +#ifndef _LINKITSTORAGE_h +#define _LINKITSTORAGE_h + +#include +#include "LTask.h" + +#define LS_WRITE_BUF_SIZE 128 +#define LS_MAX_PATH_LEN 260 + +#ifndef FILE_READ +#define FILE_READ 0x01 +#endif + +#ifndef FILE_WRITE +#define FILE_WRITE 0x13 +#endif + +// Class of LinkIt File support +class LFile : public Stream +{ + friend class LSDClass; + +// Constructor / Destructor +public: + LFile(unsigned int fd, boolean isdir, char drv, const char *name); // wraps an underlying SdFile + LFile(void); // 'empty' constructor + ~LFile(void); // destructor + +// Method +public: + using Print::write; // pull in write(str) and write(buf, size) from Print + + // DESCRIPTION + // Writes data info the file opened with FILE_WRITE mode. Similar to print(). + // RETURNS + // Number of bytes written + virtual size_t write( + uint8_t v // [IN] byte to write + ); + + //virtual size_t write(const uint8_t *buf, size_t size); + + // DESCRIPTION + // Reads single byte from the file and moves the file cursor 1 step. + // In contrast, peek() reads from the file without moving the file cursor + // RETURNS + // One byte of content the file cursor points to + virtual int read(); + + // DESCRIPTION + // Reads single byte from file without moving the file cursor. + // Due to the cursor is kept at the same place, repeatedly calling peek() will always get the same result. + // In contrast, read() moves the file cursor 1 step further. + // RETURNS + // One byte of content the file cursor points to + virtual int peek(); + + // DESCRIPTION + // Queries if there are still data to be read (if it reaches the end of file or not). + // RETURNS + // Number of bytes to be read, or 0 if it is the end of file + virtual int available(); + + // DESCRIPTION + // Makes sure the data are written into SD/flash storage to prevent data corruption in case of sudden power-off. + // Note: close() also guarantees flush() will be done. + virtual void flush(); + + // DESCRIPTION + // read array of bytes from file + // RETURNS + // number of bytes read + int read( + void *buf, // [OUT] buffer to retrieve data + uint16_t nbyte // [IN] size of buffer + ); + + // DESCRIPTION + // Changes the cursor position; can be number from 0 to the size of file. + // Use read() to retrieve the content on the current position and move cursor at the same time. + // Use peek() to retrieve content on the current position without moving the cursor. + // Use position() to get the current cursor position. + // RETURNS + // true: Succeed + // false: Fail. The position is not changed. + boolean seek( + uint32_t pos // [IN] new cursor position + ); + + // DESCRIPTION + // Returns the position of file cursor. + // Use read() to retrieve content from the current position and move cursor at the same time. + // Use peek() to retrieve content from the current position without moving the cursor. + // Use seek() to change the cursor position. + // RETURNS + // Current position of file cursor + uint32_t position(); + + // DESCRIPTION + // Returns the size of file. + // RETURNS + // Size of file + uint32_t size(); + + // DESCRIPTION + // Closes the file to release resource to prevent leakage. + // Make sure the data are completely written to the SD/flash storage. + void close(); + +/* DOM-NOT_FOR_SDK-BEGIN */ + operator bool(); + + LFile& operator=(const LFile& other); +/* DOM-NOT_FOR_SDK-END */ + + // DESCRIPTION + // Returns the name of file. + // RETURNS + // Name of file + char * name(); + + // DESCRIPTION + // Folder is a special type of file. isDirectory() is used for knowing if an LFile object is a file or a folder. + // RETURNS + // true: Folder + // false: File + boolean isDirectory(void); + + // DESCRIPTION + // Folder is a special type of file. openNextFile() is used for enumerating sub-files in a folder. + // It returns the next sub-file or sub-folder in the folder. + // RETURNS + // Next sub-file or sub-folder in the folder + LFile openNextFile( + uint8_t mode = FILE_READ // [IN] open mode, can be FILE_READ or FILE_WRITE + ); + + // DESCRIPTION + // Folder is a special type of file. rewindDirectory() is used with openNextFile() to rewind the enumeration and start from the beginning; so that the next openNextFile() call will return the first sub-file (or sub-folder). + void rewindDirectory(void); + +private: + int _read(void *buf, uint16_t nbyte, boolean peek_mode); + +private: + unsigned int _fd; + char _name[LS_MAX_PATH_LEN]; + boolean _isDir; + char _drv; + + uint8_t _buf[LS_WRITE_BUF_SIZE]; + uint8_t _bufPos; +}; + + +// Base Class of LinkIt SD/Flash +class LDrive +{ +// Constructor / Destructor +protected: + LDrive(void) { _drv = 0; }; + ~LDrive(void) {}; + +// Method +public: + + // DESCRIPTION + // Initialzes the SD or Flash module + // RETURNS + // true if succeed, false if failed + virtual boolean begin() = 0; + + // DESCRIPTION + // Opens a file (or folder). + // When the file path does not exist: If FILE_WRITE mode is given, an empty file will be created; if FILE_READ mode is given, it will simply return "fail". + // FILE_READ: Read only, cannot write, starting from the beginning of file (so that you can read its content from the beginning) + // FILE_WRITE: Can read and write, starting from the end of file (so that when you write data it will append to tail). + // RETURNS + // An LFile object to represent the file (or folder) + // If the opening fails. it will return an empty LFile object. An empty LFile object can be evaluated as false, so you can use "if (f)" to test the result. + LFile open( + const char *filename, // [IN] file to open + uint8_t mode = FILE_READ // [IN] mode of opening, FILE_READ by default if not specified. + ); + + // DESCRIPTION + // Tests the given file exists or not. + // RETURNS + // true: It exists. + // false: It does not exist. + boolean exists( + char *filepath // [IN] File (or folder) to check + ) { return general_op(1, filepath); } + + // DESCRIPTION + // Creates folder. It can create multiple sub folders at once; for example, LSD.mkdir("a/b/c") can create a, b, c, 3 folders at the same time. + // RETURNS + // true: Succeed + // false: Fail + boolean mkdir( + char *filepath // [IN] Name of the folder to be created. Use "/" to seperate sub-folders. + ) { return general_op(2, filepath); } + + // DESCRIPTION + // Deletes a file. + // RETURNS + // true: Succeed + // false: Fail + boolean remove( + char *filepath // [IN] file to be deleted + ) { return general_op(3, filepath); } + + // DESCRIPTION + // Deletes a folder. The folder must be empty, or it will fail. + // RETURNS + // true: Succeed + // false: Fail + boolean rmdir( + char *filepath // [IN] folder to be deleted + ) { return general_op(4, filepath); } + +protected: + char getDrv() {return _drv;} + void initDrv(char drv_letter) { _drv = drv_letter; }; + +private: + + boolean general_op(int op, char *filepath); + +private: + char _drv; + +}; + + +#undef LINKITSTORAGE_DEBUG + +#ifdef LINKITSTORAGE_DEBUG +#define LSLOG(x) Serial.println(x) +#else +#define LSLOG(x) +#endif + +#endif + diff --git a/hardware/arduino/mtk/libraries/LWiFi/LWiFi.cpp b/hardware/arduino/mtk/libraries/LWiFi/LWiFi.cpp new file mode 100644 index 00000000..0ec00a93 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LWiFi/LWiFi.cpp @@ -0,0 +1,712 @@ +#include +#include "LTask.h" +#include "LWiFi.h" +#include "vmhttp.h" +#include "vmlog.h" +#include "vmtcp.h" + +LWiFiLoginInfo::LWiFiLoginInfo(): + m_enc(LWIFI_OPEN), + m_password(NULL) +{ +} + +LWiFiLoginInfo::LWiFiLoginInfo(LWiFiEncryption enc, const String &password): + m_enc(enc), + m_password(password) +{ +} + +LWiFiLoginInfo::LWiFiLoginInfo(LWiFiEncryption enc, const String &password, const String &username): + m_enc(enc), + m_password(password), + m_username(username) +{ +} + +struct LWiFiContext +{ + VM_SIGNAL_ID sig; + + LWiFiContext() + { + sig = vm_signal_init(); + } + + ~LWiFiContext() + { + vm_signal_deinit(sig); + sig = 0; + } +}; + +LWiFiClass::LWiFiClass() +{ + memset(&m_apInfo, 0, sizeof(m_apInfo)); + memset(&m_ipInfo, 0, sizeof(m_ipInfo)); + memset(&m_scanInfo, 0, sizeof(m_scanInfo)); + memset(&m_apParam, 0, sizeof(m_apParam)); +} + +static void onWifiInitialized(void *userData, vm_wlan_req_res_enum result) +{ + if (result != VM_WLAN_REQ_RES_DONE) + { + vm_log_error("onWifiInitialized: result error code %d", result); + } + LTask.post_signal(); +} + +boolean wifiInitialize(void *userData) +{ + // enable WiFi (as mobile station) and wait for callback + if (VM_WLAN_SET_MODE_STA != vm_wlan_mode_get()) + { + vm_wlan_mode_set(VM_WLAN_SET_MODE_STA, &onWifiInitialized, NULL); + return false; + } + + // already initialized + return true; +} + +void LWiFiClass::begin() +{ + LTask.remoteCall(&wifiInitialize, NULL); + return; +} + +static void onWifiUninitialized(void *userData, vm_wlan_req_res_enum result) +{ + if (result != VM_WLAN_REQ_RES_DONE) + { + vm_log_error("onWifiUninitialized: result error code %d", result); + } + LTask.post_signal(); +} + +boolean wifiUnitinialize(void *userData) +{ + // enable WiFi (as mobile station) and wait for callback + if (VM_WLAN_SET_MODE_OFF != vm_wlan_mode_get()) + { + vm_wlan_mode_set(VM_WLAN_SET_MODE_OFF, &onWifiUninitialized, NULL); + return false; + } + + // already initialized + return true; +} + +void LWiFiClass::end() +{ + LTask.remoteCall(&wifiUnitinialize, NULL); + return; +} + +//------------------------------------ +// Begin() connection methods +//------------------------------------ +struct LWiFiConnectContext +{ + vm_wlan_ap_info_struct apInfo; + vm_wlan_conned_ap_info_struct connectedInfo; + vm_wlan_ip_info_struct ipInfo; + vm_wlan_conn_res_struct result; + + LWiFiConnectContext() + { + memset(&apInfo, 0, sizeof(apInfo)); + memset(&ipInfo, 0, sizeof(ipInfo)); + memset(&result, 0, sizeof(result)); + memset(&connectedInfo, 0, sizeof(connectedInfo)); + } + + ~LWiFiConnectContext() + { + } +}; + +static void onWifiConnected(void *user_data, vm_wlan_conn_res_struct *conn_res) +{ + vm_log_info("onWifiConnected (MMI)"); + LWiFiConnectContext *pContext = (LWiFiConnectContext*)user_data; + + // connect result + pContext->result = *conn_res; + + vm_log_info("onWifiConnected result=%d", conn_res->result); + + if (VM_WLAN_RESULT_SUCCESS != pContext->result.result) + { + vm_log_info("FAILED ret=%d cause=%d", conn_res->result, conn_res->cause); + // connect fail, + // wakeup Arduino thread directly + LTask.post_signal(); + } + else + { + // connect OK, + // retrieve AP & IP info. + // in DHCP case, we may need to wait for IP ready + vm_wlan_get_connected_ap_info((void*)&pContext->connectedInfo, VM_WLAN_AP_INFO_ALL); + + // We should then wait for IP info, which will be callbacked + } + return; +} + +static void onWiFiIPReady(void *userData, vm_wlan_noti_struct *noti) +{ + vm_log_info("onWiFiIPReady notify_type=%d", noti->type); + LWiFiConnectContext *pContext = (LWiFiConnectContext*)userData; + + if (VM_WLAN_NOTI_IP_AVAILABLE == noti->type) + { + vm_wlan_get_ip_info(&pContext->ipInfo); + VMUINT8 *ip_addr = pContext->ipInfo.ip_addr; + vm_log_info("get localIP address = %d, %d, %d, %d", + ip_addr[0], + ip_addr[1], + ip_addr[2], + ip_addr[3]); + + // unregister to prevent receiving duplicated data + vm_wlan_dereg_noti(VM_WLAN_NOTI_IP_AVAILABLE, &onWiFiIPReady, pContext); + + // IP ready, + // notify Arduino thread to wake up + pContext->result.result = VM_WLAN_RESULT_SUCCESS; + LTask.post_signal(); + } +} + +static void onWiFiEnabled(void *userData, vm_wlan_req_res_enum result) +{ + LWiFiConnectContext *pContext = (LWiFiConnectContext*)userData; + + vm_log_info("onWiFiEnabled result=%d", result); + + do + { + if (VM_WLAN_REQ_RES_DONE != result) + { + vm_log_info("wifi status change error=%d", result); + break; + } + + vm_log_info("vm_wlan_reg_noti"); + + // register IP callback + vm_wlan_reg_noti(VM_WLAN_NOTI_IP_AVAILABLE, &onWiFiIPReady, pContext); + + vm_log_info("vm_wlan_connect"); + // connect to AP + VMINT connectRet = vm_wlan_connect(&pContext->apInfo, &onWifiConnected, pContext); + + vm_log_info("vm_wlan_connect ret =%d", connectRet); + if (connectRet != VM_WLAN_RESULT_PROCESSING) + { + vm_log_info("vm_wlan_connect fails ret=%d", connectRet); + break; + } + + vm_log_info("start waiting connect & IP address"); + return; + } + while (0); + + // fail and allow arduino thread to keep going + vm_log_info("vm_wlan_mode_set cb result=%d", result); + pContext->result.result = VM_WLAN_RESULT_FAILED; + LTask.post_signal(); +} + +static boolean wifiBegin(void* userData) +{ + vm_log_info("wifiBegin (in MMI)"); + + + LWiFiConnectContext *pContext = (LWiFiConnectContext*)userData; + + const VMINT wlanStatus = vm_wlan_status(); + // check if we already connected + if (wlanStatus & VM_WLAN_STA_STATUS_CONNECTED) + { + pContext->result.result = VM_WLAN_RESULT_STATE_ERROR; + return true; + } + + // first we enable WiFi and wait for callback + if (VM_WLAN_SET_MODE_STA != vm_wlan_mode_get()) + { + vm_wlan_mode_set(VM_WLAN_SET_MODE_STA, &onWiFiEnabled, pContext); + } + else + { + onWiFiEnabled(pContext, VM_WLAN_REQ_RES_DONE); + } + + // block Arduino thread + return false; +} + +int LWiFiClass::wifiConnectImpl(LWiFiConnectContext &context) +{ + vm_log_info("wifiConnectImpl"); + LTask.remoteCall(&wifiBegin, &context); + + // return 1 when success. 0 when fail + if (VM_WLAN_RESULT_SUCCESS == context.result.result) + { + // copy resulting information + m_apInfo = context.connectedInfo; + m_ipInfo = context.ipInfo; + return 1; + } + else + { + vm_log_info("wifiConnectImpl fails=%d", context.result.result); + return 0; + } + +} + +int LWiFiClass::connect(const char* ssid) +{ + // connect to open network + LWiFiConnectContext context; + strncpy((char*)context.apInfo.ssid, ssid, VM_WLAN_PROF_MAX_SSID_LEN); + memset(context.apInfo.password, 0, sizeof(context.apInfo.password)); + context.apInfo.auth_mode = VM_WLAN_AUTH_MODE_OPEN; + + return wifiConnectImpl(context); +} + +int LWiFiClass::connect(const char* ssid, const LWiFiLoginInfo &loginInfo) +{ + LWiFiConnectContext context; + switch (loginInfo.m_enc) + { + case LWIFI_OPEN: + context.apInfo.auth_mode = VM_WLAN_AUTH_MODE_OPEN; + break; + case LWIFI_WEP: + context.apInfo.auth_mode = VM_WLAN_AUTH_MODE_WEP; + break; + case LWIFI_WPA: + context.apInfo.auth_mode = VM_WLAN_AUTH_MODE_WPA_ONLY_PSK; + break; + } + strncpy((char*)context.apInfo.ssid, ssid, VM_WLAN_PROF_MAX_SSID_LEN); + strncpy((char*)context.apInfo.password, loginInfo.m_password.c_str(), VM_WLAN_PROF_PSWD_MAX_LEN); + + return wifiConnectImpl(context); +} + +int LWiFiClass::connectWEP(const char* ssid, const char* key) +{ + // connect with WEP + LWiFiConnectContext context; + strncpy((char*)context.apInfo.ssid, ssid, VM_WLAN_PROF_MAX_SSID_LEN); + strncpy((char*)context.apInfo.password, key, VM_WLAN_PROF_PSWD_MAX_LEN); + context.apInfo.auth_mode = VM_WLAN_AUTH_MODE_WEP; + + return wifiConnectImpl(context); +} + +int LWiFiClass::connectWPA(const char* ssid, const char *passphrase) +{ + // connect with WPA + LWiFiConnectContext context; + strncpy((char*)context.apInfo.ssid, ssid, VM_WLAN_PROF_MAX_SSID_LEN); + strncpy((char*)context.apInfo.password, passphrase, VM_WLAN_PROF_PSWD_MAX_LEN); + // There are only 4 modes supported in LINKIT: + // VM_WLAN_AUTH_MODE_OPEN + // VM_WLAN_AUTH_MODE_WEP + // VM_WLAN_AUTH_MODE_WPA2_ONLY + // VM_WLAN_AUTH_MODE_WPA_ONLY_PSK; + // and the "VM_WLAN_AUTH_MODE_WPA_ONLY_PSK" mode + // will automatically switch between WPA2 and WPA / WPA_PSK. + // so we use this mode. + context.apInfo.auth_mode = VM_WLAN_AUTH_MODE_WPA_ONLY_PSK; + + return wifiConnectImpl(context); +} + +//------------------------------------ +// scanNetworks methods +//------------------------------------ +struct LWiFiScanContext +{ + vm_wlan_scan_result_struct result; + + LWiFiScanContext() + { + memset(&result, 0, sizeof(result)); + } + + ~LWiFiScanContext() + { + + } + + static void scanCallback(VMUINT32 job_id, void *user_data, vm_wlan_scan_result_struct *scan_res) + { + LWiFiScanContext *pContext = (LWiFiScanContext*)user_data; + pContext->result = *scan_res; + // result collected. + vm_log_info("scanCallback scan_res=%d", scan_res->result); + LTask.post_signal(); + } + + static boolean mmiCall(void *userData) + { + LWiFiScanContext *pContext = (LWiFiScanContext*)userData; + const VMINT job = vm_wlan_scan(&scanCallback, pContext); + vm_log_info("vm_wlan_scan ret=%d", job); + if (job > 0) + { + // started scan, + // let Arduino thread wait for signal. + return false; + } + else + { + // failed to scan, post signal to continue; + // return true; + return false; + } + + } +}; + +int8_t LWiFiClass::scanNetworks() +{ + vm_log_info("scanNetworks"); + LWiFiScanContext context; + LTask.remoteCall(&LWiFiScanContext::mmiCall, &context); + m_scanInfo = context.result; + vm_log_info("scanNetworks ret=%d", m_scanInfo.ap_list_num); + return m_scanInfo.ap_list_num; +} + +char* LWiFiClass::SSID(uint8_t networkItem) +{ + if (networkItem >= m_scanInfo.ap_list_num) + { + return NULL; + } + + // length check + vm_wlan_scan_ap_info_struct &apInfo = m_scanInfo.ap_list[networkItem]; + + if (apInfo.ssid_len < VM_WLAN_WNDRV_SSID_MAX_LEN && apInfo.ssid_len >= 0) + { + apInfo.ssid[apInfo.ssid_len] = '\0'; + } + + return (char*)m_scanInfo.ap_list[networkItem].ssid; +} + +int32_t LWiFiClass::RSSI(uint8_t networkItem) +{ + if (networkItem >= m_scanInfo.ap_list_num) + { + return 0; + } + + return m_scanInfo.ap_list[networkItem].rssi; +} + +//------------------------------------ +// status/domain resolve methods +//------------------------------------ + +static boolean wifiStatus(void *userData) +{ + vm_wlan_sta_status_enum *pStatus = (vm_wlan_sta_status_enum*)userData; + *pStatus = (vm_wlan_sta_status_enum)vm_wlan_status(); +} + +LWifiStatus LWiFiClass::status() +{ + vm_wlan_sta_status_enum wlanStatus = VM_WLAN_STA_STATUS_INACTIVE; + LTask.remoteCall(&wifiStatus, &wlanStatus); + + if (wlanStatus & VM_WLAN_STA_STATUS_BUSY) + { + // this should not happen to Arduino, + // since we block until state change done. + // so it should not return BUSY + return LWIFI_STATUS_DISCONNECTED; + } + + if (wlanStatus & VM_WLAN_STA_STATUS_INACTIVE) + { + return LWIFI_STATUS_DISABLED; + } + + if (wlanStatus & VM_WLAN_STA_STATUS_CONNECTED) + { + return LWIFI_STATUS_CONNECTED; + } + + if (wlanStatus & VM_WLAN_STA_STATUS_ACTIVE) + { + return LWIFI_STATUS_DISCONNECTED; + } + + if (wlanStatus & VM_WLAN_STA_STATUS_INVALID_MAC) + { + return LWIFI_STATUS_DISABLED; + } + + if (wlanStatus & VM_WLAN_STA_STATUS_SNIFFER) + { + return LWIFI_STATUS_DISCONNECTED; + } +} + +struct LWiFiResolveContext +{ + const char *domainName; + vm_soc_dns_result dns; + VMINT resolveState; + + LWiFiResolveContext(): + domainName(NULL), + resolveState(VM_E_SOC_INVAL) + { + memset(&dns, 0, sizeof(dns)); + } + + ~LWiFiResolveContext() + { + } +}; + +static VMINT wifiResolveCallback(VMINT jobId, vm_soc_dns_result *pDNS, void *userData) +{ + vm_log_info("wifiResolveCallback"); + LWiFiResolveContext *pContext = (LWiFiResolveContext*)userData; + unsigned char* ipArray = (unsigned char*)&pDNS->address[0]; + vm_log_info("DNS resolve callback, cause=%d, num=%d, address=%d.%d.%d.%d", + pDNS->error_cause, + pDNS->num, + ipArray[0], + ipArray[1], + ipArray[2], + ipArray[3]); + + // TODO: since we don't know the definition of error_cause yet, + // treat all as OK. + if (pDNS && pDNS != &pContext->dns) + { + vm_log_info("pDNS != pContext->dns"); + pContext->dns = *pDNS; + } + pContext->resolveState = VM_E_SOC_SUCCESS; + LTask.post_signal(); +} + +static boolean wifiResolveDomainName(void *userData) +{ + LWiFiResolveContext *pContext = (LWiFiResolveContext*)userData; + + vm_log_info("vm_soc_get_host_by_name_ex: %s", pContext->domainName); + pContext->resolveState = vm_soc_get_host_by_name_ex(VM_TCP_APN_WIFI, + pContext->domainName, + &pContext->dns, + &wifiResolveCallback, + pContext); + vm_log_info("vm_soc_get_host_by_name_ex ret = %d", pContext->resolveState); + + if (pContext->resolveState > 0) + { + // not done yet + return false; + } + + switch (pContext->resolveState) + { + case VM_E_SOC_SUCCESS: // Get IP address successfully, result is filled. + return true; + case VM_E_SOC_WOULDBLOCK: // wait response from network, result could be gotten from callback. + // need to wait, return directly + // so MMI message loop may continue. + return false; + case VM_E_SOC_INVAL: // invalid arguments: null domain_name, etc. + case VM_E_SOC_ERROR: // unspecified error + case VM_E_SOC_LIMIT_RESOURCE: // socket resources not available + case VM_E_SOC_INVALID_ACCOUNT: // invalid data account id + return true; + } +} + +int LWiFiClass::hostByName(const char* aHostname, IPAddress& aResult) +{ + vm_log_info("hostByName"); + LWiFiResolveContext context; + // no memory copy since we're blocking call + context.domainName = aHostname; + LTask.remoteCall(&wifiResolveDomainName, (void*)&context); + + vm_log_info("context.resolveState = %d", context.resolveState); + unsigned char* ipArray = (unsigned char*)&context.dns.address[0]; + vm_log_info("Arduino DNS resolve callback, cause=%d, num=%d, address=%d.%d.%d.%d", + context.dns.error_cause, + context.dns.num, + ipArray[0], + ipArray[1], + ipArray[2], + ipArray[3]); + // parse result + if (VM_E_SOC_SUCCESS == context.resolveState) + { + // TODO: why are there multiple ip addresses? + + aResult = context.dns.address[0]; + + vm_log_info("get IP=%d.%d.%d.%d", + aResult[0], + aResult[1], + aResult[2], + aResult[3]); + return 1; + } + else + { + return 0; + } +} + +//------------------------------------ +// property methods +//------------------------------------ +struct LWiFiDisconnectContext +{ + VM_SIGNAL_ID sigDisconnect; + vm_wlan_req_res_enum result; + + LWiFiDisconnectContext(): + result((vm_wlan_req_res_enum)VM_WLAN_REQ_RES_FAILED) + { + sigDisconnect = vm_signal_init(); + } + + ~LWiFiDisconnectContext() + { + vm_signal_deinit(sigDisconnect); + } +}; + +static void LWiFiOnDisconnect(void *userData, vm_wlan_req_res_enum res) +{ + LWiFiDisconnectContext *pContext = (LWiFiDisconnectContext*)userData; + pContext->result = res; + vm_signal_post(pContext->sigDisconnect); +} + +static boolean wifiDisconnect(void* userData) +{ + LWiFiDisconnectContext *pContext = (LWiFiDisconnectContext*)userData; + vm_wlan_disconnect(&LWiFiOnDisconnect, pContext); +} + +int LWiFiClass::disconnect(void) +{ + LWiFiDisconnectContext context; + + LTask.remoteCall(&wifiDisconnect, &context); + + vm_signal_wait(context.sigDisconnect); + + return 0; +} + + +static boolean wifiMacAddress(void* userData) +{ + vm_log_info("wifiMacAddress called"); + LWiFiClass *pThis = (LWiFiClass*)userData; + vm_wlan_prof_str_info_qry_struct qry; + qry.dest = pThis->m_macAddress; + qry.dest_len = VM_WLAN_WNDRV_MAC_ADDRESS_LEN; + qry.req_len = VM_WLAN_WNDRV_MAC_ADDRESS_LEN; + pThis->m_lastError = vm_wlan_get_mac_address(&qry); + vm_log_info("wifiMacAddress called, result = %d", pThis->m_lastError); + vm_log_info("req_len=%d", qry.req_len); + return true; +} + +uint8_t* LWiFiClass::macAddress(uint8_t* mac) +{ + // clear mac address + //vm_log_info("macAddress called"); + memset(m_macAddress, 0, VM_WLAN_LOC_MAC_ADDR_LEN); + LTask.remoteCall(&wifiMacAddress, this); + if (mac) + { + memcpy(mac, m_macAddress, VM_WLAN_LOC_MAC_ADDR_LEN); + } + return (uint8_t*)&m_macAddress[0]; +} + +IPAddress LWiFiClass::localIP() +{ + return IPAddress(m_ipInfo.ip_addr); +} + +IPAddress LWiFiClass::subnetMask() +{ + return IPAddress(m_ipInfo.netmask); +} + +IPAddress LWiFiClass::gatewayIP() +{ + return IPAddress(m_ipInfo.gateway); +} + +boolean wifiSSID(void *userData) +{ + LWiFiClass *pThis = (LWiFiClass*)userData; + VMINT ret = vm_wlan_get_para(VM_WLAN_SET_MODE_STA, (void*)&pThis->m_apParam); + vm_log_info("wifiSSID ret = %d", ret); + if (ret != VM_WLAN_RESULT_SUCCESS) + { + memset(pThis->m_apParam.ssid, 0, sizeof(pThis->m_apParam.ssid)); + } + return true; +} + +char* LWiFiClass::SSID() +{ + LTask.remoteCall(&wifiSSID, this); + return m_apParam.ssid; +} + +uint8_t* LWiFiClass::BSSID(uint8_t* bssid) +{ + memcpy(bssid, m_apInfo.bssid, VM_WLAN_WNDRV_MAC_ADDRESS_LEN); + return bssid; +} + +static boolean wifiConnectedAPRSSI(void *userdata) +{ + VMINT *rssi_out = (VMINT*)userdata; + vm_wlan_get_connected_ap_info(rssi_out, VM_WLAN_AP_INFO_RSSI); + return true; +} + +int32_t LWiFiClass::RSSI() +{ + VMINT rssi_out = 0; + LTask.remoteCall(&wifiConnectedAPRSSI, &rssi_out); + return (int32_t)rssi_out; +} + +//------------------------------------ +// singleton +//------------------------------------ +LWiFiClass LWiFi; diff --git a/hardware/arduino/mtk/libraries/LWiFi/LWiFi.h b/hardware/arduino/mtk/libraries/LWiFi/LWiFi.h new file mode 100644 index 00000000..9cc09f1a --- /dev/null +++ b/hardware/arduino/mtk/libraries/LWiFi/LWiFi.h @@ -0,0 +1,225 @@ +#ifndef LWiFi_h +#define LWiFi_h + +#include "Arduino.h" +#include "IPAddress.h" +#include "vmnwsetting.h" +#include "vmconn.h" +#include "WString.h" + +class LWiFiConnectContext; + +enum LWiFiEncryption +{ + LWIFI_OPEN, // Open networks + LWIFI_WEP, // WEP encrypted networks + LWIFI_WPA, // WPA1 and WPA2 networks +}; + +enum LWifiStatus +{ + LWIFI_STATUS_DISABLED, // the LWiFi module is not enabled. use LWiFi.begin() to enable it. + LWIFI_STATUS_DISCONNECTED, // the LWiFi module is not connect to any AP, or the connection is lost due to bad signal strength + LWIFI_STATUS_CONNECTED, // the LWiFi module is connected to an AP +}; + +//LWiFiLoginInfo Class +class LWiFiLoginInfo +{ +public: + LWiFiEncryption m_enc; + String m_password; + String m_username; + +public: + LWiFiLoginInfo(); + LWiFiLoginInfo(LWiFiEncryption enc, const String &password); + LWiFiLoginInfo(LWiFiEncryption enc, const String &password, const String &username); +}; + +//LWifi Class +class LWiFiClass +{ +public: + + + LWiFiClass(); + + // DESCRIPTION + // turn on and initializes the WiFi module + // + // PARAMETERS + // N/A + void begin(); + + // DESCRIPTION + // uninitialize and turn off the WiFi module + // + // PARAMETERS + // N/A + void end(); + + // DESCRIPTION + // Start Wifi connection for OPEN networks + // + // PARAMETERS + // ssid: Pointer to the SSID string. + int connect(const char* ssid); + + // DESCRIPTION + // Start Wifi connection to networks + // The login information are stored in loginInfo. + // + // PARAMETERS + // ssid: Pointer to the SSID string. + // loginInfo: an LWiFiKey that stores login information + int connect(const char* ssid, const LWiFiLoginInfo &loginInfo); + + // DESCRIPTION + // Start Wifi connection with WEP encryption. + // Configure a key into the device. The key type (WEP-40, WEP-104) + // is determined by the size of the key (5 bytes for WEP-40, 13 bytes for WEP-104). + // + // PARAMETERS + // ssid: Pointer to the SSID string. + // key_idx: The key index to set. Valid values are 0-3. + // key: Key input buffer. + int connectWEP(const char* ssid, const char* key); + + // DESCRIPTION + // Start Wifi connection with WPA/WPA-2 passphrase + // + // PARAMETERS + // ssid: Pointer to the SSID string. + // passphrase: Passphrase. Valid characters in a passphrase + // must be between ASCII 32-126 (decimal). + int connectWPA(const char* ssid, const char *passphrase); + + // DESCRIPTION + // Disconnect from the WiFi AP + // + // RETURNS + // currently it always returns 0 + int disconnect(void); + + // DESCRIPTION + // Get the interface MAC address. + // + // RETURNS + // pointer to uint8_t array with length VM_WLAN_LOC_MAC_ADDR_LEN + uint8_t* macAddress(uint8_t* mac); + + // DESCRIPTION + // Get the interface IP address. + // + // RETURNS + // Ip address value + IPAddress localIP(); + + // DESCRIPTION + // Get the interface subnet mask address. + // + // RETURNS + // subnet mask address value + IPAddress subnetMask(); + + // DESCRIPTION + // Get the gateway ip address. + // + // RETURNS + // gateway ip address value + IPAddress gatewayIP(); + + // DESCRIPTION + // Return the current SSID associated with the network + // + // RETURNS + // ssid string + char* SSID(); + + // DESCRIPTION + // Return the current BSSID associated with the network. + // It is the MAC address of the Access Point + // + // RETURNS + // pointer to uint8_t array with length WL_MAC_ADDR_LENGTH + uint8_t* BSSID(uint8_t* bssid); + + // DESCRIPTION + // Return the current RSSI /Received Signal Strength in dBm) + // associated with the network + // + // RETURNS + // signed value + int32_t RSSI(); + + // DESCRIPTION + // Start scan WiFi networks available + // + // RETURNS + // Number of discovered networks + int8_t scanNetworks(); + + // DESCRIPTION + // Return the SSID discovered during the network scan. + // + // PARAMETERS + // networkItem: specify from which network item want to get the information + // + // RETURNS + // ssid string of the specified item on the networks scanned list + char* SSID(uint8_t networkItem); + + // DESCRIPTION + // Return the RSSI of the networks discovered during the scanNetworks + // + // PARAMETERS + // networkItem: specify from which network item want to get the information + // + // RETURNS + // signed value of RSSI of the specified item on the networks scanned list + int32_t RSSI(uint8_t networkItem); + + // DESCRIPTION + // Return Connection status. + // + // RETURNS + // one of the value defined in LWifiStatus. + // It can be + // LWIFI_STATUS_DISABLED: the LWiFi module is not enabled. use LWiFi.begin() to enable it. + // LWIFI_STATUS_DISCONNECTED: the LWiFi module is not connect to any AP, or the connection is lost due to bad signal strength + // LWIFI_STATUS_CONNECTED: the LWiFi module is connected to an AP + LWifiStatus status(); + + // DESCRIPTION + // Resolve the given hostname to an IP address. + // + // PARAMETERS + // param aHostname: Name to be resolved + // param aResult: IPAddress structure to store the returned IP address + // + // RETURNS + // 1 if aIPAddrString was successfully converted to an IP address, + // else error code + int hostByName(const char* aHostname, IPAddress& aResult); + + + friend class LWiFiClient; + friend class LWiFiServer; + +public: + // TODO: should we use compilation firewall here? + char m_macAddress[VM_WLAN_LOC_MAC_ADDR_LEN]; + vm_wlan_ip_info_struct m_ipInfo; // IP info after being connected + vm_wlan_conned_ap_info_struct m_apInfo; // This stores BSSID and RSSI of connectd AP + vm_wlan_cfg_ap_struct m_apParam; // This stores SSID for connected AP + vm_wlan_scan_result_struct m_scanInfo; // Info of scanned APs + VMINT m_lastError; + +private: + int wifiConnectImpl(LWiFiConnectContext &context); +}; + +extern LWiFiClass LWiFi; + +#endif // #ifndef LWiFi_h diff --git a/hardware/arduino/mtk/libraries/LWiFi/LWiFiClient.cpp b/hardware/arduino/mtk/libraries/LWiFi/LWiFiClient.cpp new file mode 100644 index 00000000..74744545 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LWiFi/LWiFiClient.cpp @@ -0,0 +1,29 @@ +#include "LWiFiClient.h" +#include +#include + +#if 1 +LWiFiClient::LWiFiClient(): + LTcpClient() +{ + m_apn = VM_TCP_APN_WIFI; +} + +LWiFiClient::LWiFiClient(const LTcpClient &rhs): + LTcpClient(rhs) +{ + m_apn = VM_TCP_APN_WIFI; +} + +LWiFiClient::LWiFiClient(VMINT handle): + LTcpClient(handle) +{ + m_apn = VM_TCP_APN_WIFI; +} + +LWiFiClient::LWiFiClient(VMINT handle, VMINT serverHandle): + LTcpClient(handle, serverHandle) +{ + m_apn = VM_TCP_APN_WIFI; +} +#endif diff --git a/hardware/arduino/mtk/libraries/LWiFi/LWiFiClient.h b/hardware/arduino/mtk/libraries/LWiFi/LWiFiClient.h new file mode 100644 index 00000000..b464e689 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LWiFi/LWiFiClient.h @@ -0,0 +1,21 @@ +#ifndef LWiFiClient_h +#define LWiFiClient_h +#include "Arduino.h" +#include +#include +#include + +//LWiFiClient Class +class LWiFiClient : public LTcpClient +{ +public: + LWiFiClient(); + + /* DOM-NOT_FOR_SDK-BEGIN */ + LWiFiClient(const LTcpClient &rhs); + LWiFiClient(VMINT handle); + LWiFiClient(VMINT handle, VMINT serverHandle); + /* DOM-NOT_FOR_SDK-END */ +}; + +#endif // LWiFiClient_h diff --git a/hardware/arduino/mtk/libraries/LWiFi/LWiFiServer.cpp b/hardware/arduino/mtk/libraries/LWiFi/LWiFiServer.cpp new file mode 100644 index 00000000..42d728f1 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LWiFi/LWiFiServer.cpp @@ -0,0 +1,20 @@ +#include "LWiFiServer.h" +#include +#include + +LWiFiServer::LWiFiServer(uint16_t port): + LTcpServer(port) +{ + m_apn = VM_TCP_APN_WIFI; +} + +LWiFiClient LWiFiServer::available() +{ + VMINT hClient = -1; + VMINT hServer = -1; + availableImpl(hClient, hServer); + // return a special client object that has server handle + // Note that we rely on move-constructor optimization + // to prevent temp object destructor, which stop() the connection. + return LWiFiClient(hClient, hServer); +} diff --git a/hardware/arduino/mtk/libraries/LWiFi/LWiFiServer.h b/hardware/arduino/mtk/libraries/LWiFi/LWiFiServer.h new file mode 100644 index 00000000..329d20e4 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LWiFi/LWiFiServer.h @@ -0,0 +1,15 @@ +#ifndef LWifiServer_h +#define LWifiServer_h +#include +#include +#include "LWiFiClient.h" + +//LWiFiServer Class +class LWiFiServer : public LTcpServer +{ +public: + LWiFiServer(uint16_t port); + LWiFiClient available(); +}; + +#endif diff --git a/hardware/arduino/mtk/libraries/LWiFi/LWiFiUdp.cpp b/hardware/arduino/mtk/libraries/LWiFi/LWiFiUdp.cpp new file mode 100644 index 00000000..6150c2df --- /dev/null +++ b/hardware/arduino/mtk/libraries/LWiFi/LWiFiUdp.cpp @@ -0,0 +1,23 @@ +#include +#include "LWiFiUdp.h" +#include "LWiFi.h" +#include "vmtcp.h" + +VMINT LWiFiUDP::getAPN() const +{ + return VM_TCP_APN_WIFI; +} + +int LWiFiUDP::beginPacket(const char *host, uint16_t port) +{ + // DNS loopup and bypass to IP version + if (LWiFi.hostByName(host, m_sendToIP)) + { + return beginPacket(m_sendToIP, port); + } + else + { + return 0; + } +} + diff --git a/hardware/arduino/mtk/libraries/LWiFi/LWiFiUdp.h b/hardware/arduino/mtk/libraries/LWiFi/LWiFiUdp.h new file mode 100644 index 00000000..f635d7c4 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LWiFi/LWiFiUdp.h @@ -0,0 +1,17 @@ +#ifndef lwifiudp_h +#define lwifiudp_h + +#include +#include + +class LWiFiUDP : public LUDP +{ +public: + virtual int beginPacket(const char *host, uint16_t port); + using LUDP::beginPacket; + +protected: + virtual VMINT getAPN() const; +}; + +#endif diff --git a/hardware/arduino/mtk/libraries/LWiFi/examples/ScanNetworks/ScanNetworks.ino b/hardware/arduino/mtk/libraries/LWiFi/examples/ScanNetworks/ScanNetworks.ino new file mode 100644 index 00000000..11508515 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LWiFi/examples/ScanNetworks/ScanNetworks.ino @@ -0,0 +1,35 @@ +#include +#include + +void setup() +{ + LTask.begin(); + Serial.begin(115200); +} + +// scan WiFi AP every 5 secs +void loop() +{ + // turn on wifi + LWiFi.begin(); + Serial.println("scan start"); + int apNum = LWiFi.scanNetworks(); + Serial.println("scan end"); + Serial.println(apNum); + for (int i = 0; i < apNum; ++i) + { + Serial.print("AP "); + Serial.print(i); + Serial.print(": "); + Serial.print(LWiFi.SSID(i)); + Serial.print(" dB="); + Serial.println(LWiFi.RSSI(i)); + } + + // turn off wifi + LWiFi.end(); + Serial.println("Finish"); + delay(5000); +} + + diff --git a/hardware/arduino/mtk/libraries/LWiFi/examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino b/hardware/arduino/mtk/libraries/LWiFi/examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino new file mode 100644 index 00000000..2345efed --- /dev/null +++ b/hardware/arduino/mtk/libraries/LWiFi/examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino @@ -0,0 +1,186 @@ +#include +#include + +/* + + Udp NTP Client + + Get the time from a Network Time Protocol (NTP) time server + Demonstrates use of UDP sendPacket and ReceivePacket + For more on NTP time servers and the messages needed to communicate with them, + see http://en.wikipedia.org/wiki/Network_Time_Protocol + + created 4 Sep 2010 + by Michael Margolis + modified 9 Apr 2012 + by Tom Igoe + + modified 14 Aug 2014 + by Pablo Sun + for LinkIt ONE LWiFi UDP example + + This code is in the public domain. + + */ +#include +#include + +char ssid[] = "yourssid"; // your network SSID (name) +char pass[] = "yourpassword"; // your network password + +unsigned int localPort = 2390; // local port to listen for UDP packets + +IPAddress timeServer(129, 6, 15, 28); // time.nist.gov NTP server + +const int NTP_PACKET_SIZE = 48; // NTP time stamp is in the first 48 bytes of the message + +byte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets + +// A UDP instance to let us send and receive packets over UDP +LWiFiUDP Udp; + +void setup() +{ + // Open serial communications and wait for port to open: + Serial.begin(115200); + + Serial.println("setup()"); + + // attempt to connect to Wifi network: + LWiFi.begin(); + while (!LWiFi.connectWPA(ssid, pass)) + { + delay(1000); + Serial.println("retry WiFi AP"); + } + Serial.println("Connected to wifi"); + printWifiStatus(); + + delay(10000); + + Serial.println("\nStarting connection to server..."); + Udp.begin(localPort); + + Serial.println("setup() done"); +} + +void loop() +{ + sendNTPpacket(timeServer); // send an NTP packet to a time server + // wait to see if a reply is available + delay(1000); + Serial.println( Udp.parsePacket() ); + if ( Udp.parsePacket() ) + { + Serial.println("packet received"); + // We've received a packet, read the data from it + memset(packetBuffer, 0xcd, NTP_PACKET_SIZE); + Udp.read(packetBuffer, NTP_PACKET_SIZE); // read the packet into the buffer + for (int i = 0; i < NTP_PACKET_SIZE; ++i) + { + Serial.print(packetBuffer[i], HEX); + } + Serial.println(); + + + //the timestamp starts at byte 40 of the received packet and is four bytes, + // or two words, long. First, esxtract the two words: + unsigned long highWord = word(packetBuffer[40], packetBuffer[41]); + unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]); + // combine the four bytes (two words) into a long integer + // this is NTP time (seconds since Jan 1 1900): + unsigned long secsSince1900 = highWord << 16 | lowWord; + Serial.print("Seconds since Jan 1 1900 = " ); + Serial.println(secsSince1900); + + // now convert NTP time into everyday time: + Serial.print("Unix time = "); + // Unix time starts on Jan 1 1970. In seconds, that's 2208988800: + const unsigned long seventyYears = 2208988800UL; + // subtract seventy years: + unsigned long epoch = secsSince1900 - seventyYears; + // print Unix time: + Serial.println(epoch); + + + // print the hour, minute and second: + Serial.print("The UTC time is "); // UTC is the time at Greenwich Meridian (GMT) + Serial.print((epoch % 86400L) / 3600); // print the hour (86400 equals secs per day) + Serial.print(':'); + if ( ((epoch % 3600) / 60) < 10 ) + { + // In the first 10 minutes of each hour, we'll want a leading '0' + Serial.print('0'); + } + Serial.print((epoch % 3600) / 60); // print the minute (3600 equals secs per minute) + Serial.print(':'); + if ( (epoch % 60) < 10 ) + { + // In the first 10 seconds of each minute, we'll want a leading '0' + Serial.print('0'); + } + Serial.println(epoch % 60); // print the second + } + // wait ten seconds before asking for the time again + delay(10000); +} + +// send an NTP request to the time server at the given address +unsigned long sendNTPpacket(IPAddress& address) +{ + Serial.println("sendNTPpacket"); + // set all bytes in the buffer to 0 + memset(packetBuffer, 0, NTP_PACKET_SIZE); + // Initialize values needed to form NTP request + // (see URL above for details on the packets) + //Serial.println("2"); + packetBuffer[0] = 0b11100011; // LI, Version, Mode + packetBuffer[1] = 0; // Stratum, or type of clock + packetBuffer[2] = 6; // Polling Interval + packetBuffer[3] = 0xEC; // Peer Clock Precision + // 8 bytes of zero for Root Delay & Root Dispersion + packetBuffer[12] = 49; + packetBuffer[13] = 0x4E; + packetBuffer[14] = 49; + packetBuffer[15] = 52; + + //Serial.println("3"); + + // all NTP fields have been given values, now + // you can send a packet requesting a timestamp: + Udp.beginPacket(address, 123); //NTP requests are to port 123 + //Serial.println("4"); + Udp.write(packetBuffer, NTP_PACKET_SIZE); + //Serial.println("5"); + Udp.endPacket(); + //Serial.println("6"); +} + + +void printWifiStatus() +{ + // print the SSID of the network you're attached to: + Serial.print("SSID: "); + Serial.println(LWiFi.SSID()); + + // print your LWiFi shield's IP address: + IPAddress ip = LWiFi.localIP(); + Serial.print("IP Address: "); + Serial.println(ip); + + // print the received signal strength: + long rssi = LWiFi.RSSI(); + Serial.print("signal strength (RSSI):"); + Serial.print(rssi); + Serial.println(" dBm"); +} + + + + + + + + + + diff --git a/hardware/arduino/mtk/libraries/LWiFi/examples/WifiDownloadFile/WifiDownloadFile.ino b/hardware/arduino/mtk/libraries/LWiFi/examples/WifiDownloadFile/WifiDownloadFile.ino new file mode 100644 index 00000000..8507e81b --- /dev/null +++ b/hardware/arduino/mtk/libraries/LWiFi/examples/WifiDownloadFile/WifiDownloadFile.ino @@ -0,0 +1,139 @@ +#include +#include +#include +#include +#include +#include + +#define WIFI_AP "your_ap_ssid" +#define WIFI_PASSWORD "your_password" +#define WIFI_AUTH LWIFI_WEP // choose from LWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP according to your WiFi AP configuration + +// This sample connects to HTTP server and download a file to LinkIt ONE internal storage + +#define SITE_URL "www.yourwebsite.com" +#define FILE_NAME "/url_to_file.zip" +#define DOWNLOAD_FILENAME "file_downloaded.zip" + +#define TEMP_BUF_SIZE (2048) +uint8_t buf[TEMP_BUF_SIZE] = {0}; + +void setup() +{ + LTask.begin(); + LWiFi.begin(); + Serial.begin(115200); + LFlash.begin(); + + // keep retrying until connected to AP + Serial.println("Connecting to AP"); + while (0 == LWiFi.connect(WIFI_AP, LWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD))) + { + delay(1000); + } + + LWiFiClient c; + + // keep retrying until connected to website + Serial.println("Connecting to WebSite"); + while (0 == c.connect(SITE_URL, 80)) + { + Serial.println("Re-Connecting to WebSite"); + delay(1000); + } + + Serial.println("send GET request"); + c.println("GET " FILE_NAME " HTTP/1.0"); + c.println("User-Agent: Wget/1.11.4"); + c.println("Accept: */*"); + c.println("Host: " SITE_URL); + c.println("Connection: Close"); + c.println(); + + Serial.println("waiting server response"); + int peekByte = -1; + while (peekByte == -1 && c.connected()) + { + peekByte = c.peek(); + delay(200); + } + + // wait for header finish (\r\n\r\n) + Serial.println("skipping header:"); + int lineFeedCount = 0; + while (lineFeedCount < 2) + { + int value = c.read(); + if (value == -1) + { + delay(10); + continue; + } + + Serial.print((char)value); + + if (value == '\r') + { + value = -1; + while (value == -1) + { + value = c.read(); + Serial.print((char)value); + } + + if (value == '\n') + { + lineFeedCount++; + } + else + { + lineFeedCount = 0; + } + } + else + { + lineFeedCount = 0; + } + } + + Serial.println("start downloading file"); + LFile f = LFlash.open(DOWNLOAD_FILENAME, FILE_WRITE); + int totalSize = 0; + while (c.connected()) + { + size_t bytesRead = c.read(buf, TEMP_BUF_SIZE); + if (bytesRead) + { + const size_t bytesWrite = f.write((const uint8_t *)&buf[0], (size_t)bytesRead); + if (bytesWrite > 0) + { + totalSize += bytesWrite; + Serial.print("\r"); + Serial.print(totalSize); + Serial.print(" bytes"); + } + else + { + Serial.println("error writing file"); + break; + } + } + else + { + Serial.println("server disconnected"); + break; + } + delay(100); + } + f.flush(); + f.close(); + Serial.println(); + Serial.println("download finished"); +} + +void loop() +{ + delay(1000); +} + + diff --git a/hardware/arduino/mtk/libraries/LWiFi/examples/WifiWebClient/WifiWebClient.ino b/hardware/arduino/mtk/libraries/LWiFi/examples/WifiWebClient/WifiWebClient.ino new file mode 100644 index 00000000..5a1f6c9c --- /dev/null +++ b/hardware/arduino/mtk/libraries/LWiFi/examples/WifiWebClient/WifiWebClient.ino @@ -0,0 +1,78 @@ +#include +#include +#include + +#define WIFI_AP "your_ap_ssid" +#define WIFI_PASSWORD "your_password" +#define WIFI_AUTH LWIFI_WEP // choose from LWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP. +#define SITE_URL "www.yourwebsite.com" + +LWiFiClient c; + +void setup() +{ + LTask.begin(); + LWiFi.begin(); + Serial.begin(115200); + + // keep retrying until connected to AP + Serial.println("Connecting to AP"); + while (0 == LWiFi.connect(WIFI_AP, LWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD))) + { + delay(1000); + } + + // keep retrying until connected to website + Serial.println("Connecting to WebSite"); + while (0 == c.connect(SITE_URL, 80)) + { + Serial.println("Re-Connecting to WebSite"); + delay(1000); + } + + // send HTTP request, ends with 2 CR/LF + Serial.println("send HTTP GET request"); + c.println("GET / HTTP/1.1"); + c.println("Host: " SITE_URL); + c.println("Connection: close"); + c.println(); + + // waiting for server response + Serial.println("waiting HTTP response:"); + while (!c.available()) + { + delay(100); + } +} + +boolean disconnectedMsg = false; + +void loop() +{ + // Make sure we are connected, and dump the response content to Serial + while (c) + { + int v = c.read(); + if (v != -1) + { + Serial.print((char)v); + } + else + { + Serial.println("no more content, disconnect"); + c.stop(); + while (1) + { + delay(1); + } + } + } + + if (!disconnectedMsg) + { + Serial.println("disconnected by server"); + disconnectedMsg = true; + } + delay(500); +} + diff --git a/hardware/arduino/mtk/libraries/LWiFi/examples/WifiWebServer/WifiWebServer.ino b/hardware/arduino/mtk/libraries/LWiFi/examples/WifiWebServer/WifiWebServer.ino new file mode 100644 index 00000000..2297c0a3 --- /dev/null +++ b/hardware/arduino/mtk/libraries/LWiFi/examples/WifiWebServer/WifiWebServer.ino @@ -0,0 +1,117 @@ +#include +#include +#include +#include + +#define WIFI_AP "your_ap_ssid" +#define WIFI_PASSWORD "your_password" +#define WIFI_AUTH LWIFI_WEP // choose from LWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP according to your WiFi AP configuration + +LWiFiServer server(80); + +void setup() +{ + LTask.begin(); + LWiFi.begin(); + Serial.begin(115200); + + // keep retrying until connected to AP + Serial.println("Connecting to AP"); + while (0 == LWiFi.connect(WIFI_AP, LWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD))) + { + delay(1000); + } + + printWifiStatus(); + + Serial.println("Start Server"); + server.begin(); + Serial.println("Server Started"); +} + +int loopCount = 0; + +void loop() +{ + // put your main code here, to run repeatedly: + delay(500); + loopCount++; + LWiFiClient client = server.available(); + if (client) + { + Serial.println("new client"); + // an http request ends with a blank line + boolean currentLineIsBlank = true; + while (client.connected()) + { + if (client.available()) + { + // we basically ignores client request, but wait for HTTP request end + int c = client.read(); + Serial.print((char)c); + + if (c == '\n' && currentLineIsBlank) + { + Serial.println("send response"); + // send a standard http response header + client.println("HTTP/1.1 200 OK"); + client.println("Content-Type: text/html"); + client.println("Connection: close"); // the connection will be closed after completion of the response + client.println("Refresh: 5"); // refresh the page automatically every 5 sec + client.println(); + client.println(""); + client.println(""); + // output the value of each analog input pin + client.print("loop"); + client.print(" is "); + client.print(loopCount); + client.println("
"); + client.println(""); + client.println(); + break; + } + if (c == '\n') + { + // you're starting a new line + currentLineIsBlank = true; + } + else if (c != '\r') + { + // you've gotten a character on the current line + currentLineIsBlank = false; + } + } + } + // give the web browser time to receive the data + delay(500); + + // close the connection: + Serial.println("close connection"); + client.stop(); + Serial.println("client disconnected"); + } +} + +void printWifiStatus() +{ + // print the SSID of the network you're attached to: + Serial.print("SSID: "); + Serial.println(LWiFi.SSID()); + + // print your WiFi shield's IP address: + IPAddress ip = LWiFi.localIP(); + Serial.print("IP Address: "); + Serial.println(ip); + + Serial.print("subnet mask: "); + Serial.println(LWiFi.subnetMask()); + + Serial.print("gateway IP: "); + Serial.println(LWiFi.gatewayIP()); + + // print the received signal strength: + long rssi = LWiFi.RSSI(); + Serial.print("signal strength (RSSI):"); + Serial.print(rssi); + Serial.println(" dBm"); +} diff --git a/hardware/arduino/mtk/libraries/LWiFi/examples/WifiXivelyConnection/WifiXivelyConnection.ino b/hardware/arduino/mtk/libraries/LWiFi/examples/WifiXivelyConnection/WifiXivelyConnection.ino new file mode 100644 index 00000000..f130363b --- /dev/null +++ b/hardware/arduino/mtk/libraries/LWiFi/examples/WifiXivelyConnection/WifiXivelyConnection.ino @@ -0,0 +1,84 @@ +/***************** + * This sample connectes to Xively.com API by LinkIt ONE WiFi module and keeps updating a feed in Xively. + * You need to apply an Xively API key and create the feed first. + */ +#include +#include +#include + +#define SITE_URL "api.xively.com" // Xively API URL +#define APIKEY "apikey" // replace your xively api key here +#define FEEDID 0000 // replace your feed ID +#define USERAGENT "chrome" // user agent is the project name + +#define WIFI_AP "yourssid" // replace your WiFi AP SSID +#define WIFI_PASSWORD "yourpassword" // replace your WiFi AP password +#define WIFI_AUTH LWIFI_WEP // choose from LWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP according to your AP + +void setup() +{ + Serial.begin(115200); + // Initializes LinkIt ONE WiFi module + LWiFi.begin(); + + Serial.print("Connecting to WiFi AP:"); + Serial.println(WIFI_AP); + while (0 == LWiFi.connect(WIFI_AP, LWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD))) + { + delay(1000); + } +} + +unsigned long time = 0; + +void loop() +{ + + // in this sketch, we send to process time of loop() + // to Xively server. + // The feed is created on Xively first. + unsigned long t1 = millis(); + + Serial.print("try connect "); + Serial.println(SITE_URL); + LWiFiClient c; + while (!c.connect(SITE_URL, 80)) + { + Serial.println("retry connect"); + delay(100); + } + + String data = "Time,"+String(time); + Serial.println("send PUT request"); + Serial.println(data); + + // construct a HTTP PUT request + // and set CSV data to the Xively feed. + c.print("PUT /v2/feeds/"); + c.print(FEEDID); + c.println(".csv HTTP/1.1"); + c.println("Host: api.xively.com"); + c.print("X-ApiKey: "); + c.println(APIKEY); + c.print("User-Agent: "); + c.println(USERAGENT); + c.print("Content-Length: "); + int thisLength = data.length(); + c.println(thisLength); + c.println("Content-Type: text/csv"); + c.println("Connection: close"); + c.println(); + c.println(data); + + // this is required delay, to allow server response + delay(1000); + // disconnect from server + c.stop(); + // add delay to prevent connect again too fast + delay(300); + + unsigned long t2 = millis(); + time = t2-t1; + Serial.print("Total time spend (we will send this to server next time): "); + Serial.println(time); +} diff --git a/hardware/arduino/mtk/libraries/SPI/SPI.cpp b/hardware/arduino/mtk/libraries/SPI/SPI.cpp new file mode 100644 index 00000000..678bc454 --- /dev/null +++ b/hardware/arduino/mtk/libraries/SPI/SPI.cpp @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2010 by Cristian Maglie + * SPI Master library for arduino. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of either the GNU General Public License version 2 + * or the GNU Lesser General Public License version 2.1, both as + * published by the Free Software Foundation. + */ + +#include "SPI.h" +#include "vmdcl_spi.h" +#include "Vmlog.h" + +static char buff[128]; + +extern char* spi_w_data ; +extern char* spi_r_data; +extern unsigned char* spi_data_memory; + +SPIClass::SPIClass() +{ + spi_handle = VM_DCL_HANDLE_INVALID; +} + +void SPIClass::begin() +{ + if(!changePinType(11, PIO_SPI, &spi_handle)) + return; + + if(spi_handle == VM_DCL_HANDLE_INVALID) + { + spi_handle = vm_dcl_open(vm_spi_port1,0); + setPinHandle(11, spi_handle); + } + + // default control data + conf_data.clk_high_time = 3; + conf_data.clk_low_time = 3; + conf_data.cs_hold_time = 15; + conf_data.cs_idle_time = 15; + conf_data.cs_setup_time= 15; + conf_data.clk_polarity = VM_SPI_CPOL_B0; + conf_data.clk_fmt = VM_SPI_CPHA_B0; + conf_data.rx_endian = VM_SPI_ENDIAN_LITTLE; + conf_data.tx_endian = VM_SPI_ENDIAN_LITTLE; + conf_data.rx_msbf = VM_SPI_MSBF_MSB; + conf_data.tx_msbf = VM_SPI_MSBF_MSB; + + vm_dcl_control(spi_handle,VM_SPI_IOCTL_SET_CONFIG_PARA,(void *)&conf_data); + + spi_data.mode = VM_SPI_MODE_DEASSERT; + spi_data.bEnable = VM_FALSE; + vm_dcl_control(spi_handle,VM_SPI_IOCTL_SET_MODE,(void *)&spi_data); + + + // Default speed set to 4Mhz + setClockDivider(SPI_CLOCK_DIV4); + setDataMode(SPI_MODE0); + setBitOrder(MSBFIRST); +} + +void SPIClass::end() +{ + vm_dcl_close(spi_handle); + spiPinsRest(); + spi_handle = VM_DCL_HANDLE_INVALID; +} + +void SPIClass::setBitOrder(BitOrder _bitOrder) +{ + if(VM_DCL_HANDLE_INVALID==spi_handle) + { + return; + } + + if (MSBFIRST == _bitOrder) + { + conf_data.rx_endian = VM_SPI_ENDIAN_BIG; + conf_data.tx_endian = VM_SPI_ENDIAN_BIG; + + } + else if (LSBFIRST == _bitOrder) + { + conf_data.rx_endian = VM_SPI_ENDIAN_LITTLE; + conf_data.tx_endian = VM_SPI_ENDIAN_LITTLE; + } + else + { + return; + } + + vm_dcl_control(spi_handle,VM_SPI_IOCTL_SET_CONFIG_PARA,(void *)&conf_data); + +} + +void SPIClass::setDataMode(uint8_t _mode) +{ + if(VM_DCL_HANDLE_INVALID==spi_handle) + { + return; + } + + if (_mode == SPI_MODE0) + { + conf_data.clk_polarity = VM_SPI_CPOL_B0; + conf_data.clk_fmt = VM_SPI_CPHA_B0; + } + else if (_mode == SPI_MODE1) + { + conf_data.clk_polarity = VM_SPI_CPOL_B0; + conf_data.clk_fmt = VM_SPI_CPHA_B1; + } + else if (_mode == SPI_MODE2) + { + conf_data.clk_polarity = VM_SPI_CPOL_B1; + conf_data.clk_fmt = VM_SPI_CPHA_B0; + } + else if (_mode == SPI_MODE3) + { + conf_data.clk_polarity = VM_SPI_CPOL_B1; + conf_data.clk_fmt = VM_SPI_CPHA_B1; + } + else + { + return; + } + + vm_dcl_control(spi_handle,VM_SPI_IOCTL_SET_CONFIG_PARA,(void *)&conf_data); +} + +void SPIClass::setClockDivider(uint8_t _divider) +{ + if(VM_DCL_HANDLE_INVALID == spi_handle) + { + return; + } + + if (_divider == SPI_CLOCK_DIV2) + { + conf_data.clk_high_time = 1; + conf_data.clk_low_time = 1; + } + else if (_divider == SPI_CLOCK_DIV4) + { + conf_data.clk_high_time = 3; + conf_data.clk_low_time = 3; + } + else if (_divider == SPI_CLOCK_DIV8) + { + conf_data.clk_high_time = 7; + conf_data.clk_low_time = 7; + } + else if (_divider == SPI_CLOCK_DIV16) + { + conf_data.clk_high_time = 15; + conf_data.clk_low_time = 15; + } + else if (_divider == SPI_CLOCK_DIV32) + { + conf_data.clk_high_time = 31; + conf_data.clk_low_time = 31; + } + else if (_divider == SPI_CLOCK_DIV64) + { + conf_data.clk_high_time = 63; + conf_data.clk_low_time = 63; + } + else if (_divider == SPI_CLOCK_DIV128) + { + conf_data.clk_high_time = 127; + conf_data.clk_low_time = 127; + } + else + { + return; + } + + vm_dcl_control(spi_handle,VM_SPI_IOCTL_SET_CONFIG_PARA,(void *)&conf_data); +} + +byte SPIClass::transfer(uint8_t _data) +{ + VM_SPI_CTRL_WRITE_AND_READE_T write_and_read; + + if(VM_DCL_HANDLE_INVALID == spi_handle) + { + return 0; + } + + if(spi_w_data) + { + *spi_w_data = _data; + write_and_read.pu1InData = (VMUINT8*)spi_r_data; + write_and_read.u4DataLen = 1; + write_and_read.pu1OutData = (VMUINT8*)spi_w_data; + write_and_read.uCount = 1; + vm_dcl_control(spi_handle,VM_SPI_IOCTL_WRITE_AND_READ,(void *)&write_and_read); + } + + return *spi_r_data; +} + + + +uint32_t SPIClass::write(uint8_t* _data, uint32_t size) +{ + uint8_t* p = _data; + //VM_SPI_CTRL_WRITE_AND_READE_T write_and_read; + + VM_DCL_BUFF_LEN count, datalen; + VM_DCL_STATUS status; + + if(size > 65536) + { + for(;size>65536;) + { + memcpy(spi_data_memory, p, 65536); + count = 64; + datalen = 1024; + status = vm_dcl_write(spi_handle,(VM_DCL_BUFF*)spi_data_memory,datalen,&count,0); + + if(status < VM_DCL_STATUS_OK) + return 0; + + p = &p[65536]; + size = size -65536; + } + } + + if(size > 1024) + { + count = size/1024; + datalen = 1024; + } + else + { + count = 1; + datalen = size; + } + + memcpy(spi_data_memory, _data, size); + //write_and_read.pu1InData = (VMUINT8*)spi_data_memory; + //write_and_read.pu1OutData = (VMUINT8*)spi_data_memory; + //write_and_read.u4DataLen = datalen; + //write_and_read.uCount = count; + //vm_dcl_control(spi_handle,VM_SPI_IOCTL_WRITE_AND_READ,(void *)&write_and_read); + status = vm_dcl_write(spi_handle,(VM_DCL_BUFF*)spi_data_memory,datalen,&count,0); + if(status == VM_DCL_STATUS_OK) + return size; + else + return 0; + +} + +SPIClass SPI; + diff --git a/hardware/arduino/mtk/libraries/SPI/SPI.h b/hardware/arduino/mtk/libraries/SPI/SPI.h new file mode 100644 index 00000000..79d53510 --- /dev/null +++ b/hardware/arduino/mtk/libraries/SPI/SPI.h @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2010 by Cristian Maglie + * SPI Master library for arduino. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of either the GNU General Public License version 2 + * or the GNU Lesser General Public License version 2.1, both as + * published by the Free Software Foundation. + */ + +#ifndef _SPI_H_INCLUDED +#define _SPI_H_INCLUDED + +#include "variant.h" +#include "vmdcl_spi.h" +#include + +// SPI clock is 1/4 of system clock +#define SPI_CLOCK_DIV4 0x00 +// SPI clock is 1/16 of system clock +#define SPI_CLOCK_DIV16 0x01 +// SPI clock is 1/64 of system clock +#define SPI_CLOCK_DIV64 0x02 +// SPI clock is 1/128 of system clock +#define SPI_CLOCK_DIV128 0x03 +// SPI clock is 1/2 of system clock +#define SPI_CLOCK_DIV2 0x04 +// SPI clock is 1/8 of system clock +#define SPI_CLOCK_DIV8 0x05 +// SPI clock is 1/32 of system clock +#define SPI_CLOCK_DIV32 0x06 + +// SPI data transfer mode 0 +#define SPI_MODE0 0x02 +// SPI data transfer mode 1 +#define SPI_MODE1 0x00 +// SPI data transfer mode 2 +#define SPI_MODE2 0x03 +// SPI data transfer mode 3 +#define SPI_MODE3 0x01 + +// SPI class interface +class SPIClass { + +// Constructor / Destructor +public: + SPIClass(void); + +// Method +public: + // DESCRIPTION + // Sends a byte of data to slave and receives a byte of data from the slave at the same time. + // RETURNS + // Data returned from slave to master + // EXAMPLE + // + // #include + // #define SS_PIN 10 + // + // void setup() + // { + // pinMode(SS_PIN, OUTPUT); + // SPI.begin(); + // } + // void loop() + // { + // byte ret_val; + // digitalWrite(SS_PIN, LOW); + // ret_val = SPI.transfer(100); + // digitalWrite(SS_PIN, HIGH); + // delay(1000); + // } + // + byte transfer( + uint8_t _data // [IN] Data sent from master to slave + ); + + // DESCRIPTION + // Initlize SPI, setting up the mode and initial status of pins. + // RETURNS + // N/A + // EXAMPLE + // + // #include + // #define SS_PIN 10 + // + // void setup() + // { + // pinMode(SS_PIN, OUTPUT); + // SPI.begin(); + // } + // void loop() + // { + // byte ret_val; + // digitalWrite(SS_PIN, LOW); + // ret_val = SPI.transfer(100); + // digitalWrite(SS_PIN, HIGH); + // delay(1000); + // } + // + void begin(void); + + // DESCRIPTION + // Disables SPI data transmission. + // RETURNS + // N/A + // EXAMPLE + // + // #include + // #define SS_PIN 10 + // int value = 0; + // + // void setup() + // { + // pinMode(SS_PIN, OUTPUT); + // SPI.begin(); + // } + // void loop() + // { + // for (value = 0; value < 255; value++) + // { + // digitalWrite(SS_PIN, LOW); + // SPI.transfer(value); + // digitalWrite(SS_PIN, HIGH); + // delay(1000); + // } + // SPI.end(); + // } + // + void end(void); + + // DESCRIPTION + // Sets up order of data transmission, can be MSBFIRST (MSB first) or LSBFIRST (LSB first) + // RETURNS + // N/A + // EXAMPLE + // + // #include + // #define SS_PIN 10 + // + // void setup() + // { + // pinMode(SS_PIN, OUTPUT); + // SPI.begin(); + // SPI.setBitOrder(MSBFIRST); + // } + // void loop() + // { + // byte ret_val; + // digitalWrite(SS_PIN, LOW); + // ret_val = SPI.transfer(100); + // digitalWrite(SS_PIN, HIGH); + // delay(1000); + // } + // + void setBitOrder( + BitOrder bit_order // [IN] Data transmission order (MSBFIRST or LSBFIRST) + ); + + // DESCRIPTION + // Sets up SPI data transmission mode. + // RETURNS + // N/A + // EXAMPLE + // + // #include + // #define SS_PIN 10 + // + // void setup() + // { + // pinMode(SS_PIN, OUTPUT); + // SPI.begin(); + // SPI.setDataMode(SPI_MODE1); + // } + // void loop() + // { + // byte ret_val; + // digitalWrite(SS_PIN, LOW); + // ret_val = SPI.transfer(100); + // digitalWrite(SS_PIN, HIGH); + // delay(1000); + // } + // + void setDataMode( + uint8_t mode // [IN] SPI data transmission mode (SPI_MODE0 ~ SPI_MODE3) + ); + + // DESCRIPTION + // Sets up clock divider to control the speed of data transmission. + // RETURNS + // N/A + // EXAMPLE + // + // #include + // #define SS_PIN 10 + // + // void setup() + // { + // pinMode(SS_PIN, OUTPUT); + // SPI.begin(); + // SPI.setClockDivider(SPI_CLOCK_DIV8); + // } + // void loop() + // { + // byte ret_val; + // digitalWrite(SS_PIN, LOW); + // ret_val = SPI.transfer(100); + // digitalWrite(SS_PIN, HIGH); + // delay(1000); + // } + // + void setClockDivider( + uint8_t clock_div // [IN] Clock divider (SPI_CLOCK_DIV2 ~ SPI_CLOCK_DIV128) + ); + + // DESCRIPTION + // write block memory to slave, and size need to be 2^X. + // RETURNS + // size to write, 0 means failed + // EXAMPLE + // + // #include + // #define SS_PIN 10 + // + // void setup() + // { + // pinMode(SS_PIN, OUTPUT); + // SPI.begin(); + // SPI.setClockDivider(SPI_CLOCK_DIV8); + // } + // void loop() + // { + // byte ret_val; + // uint8_t mem[64]; + // memset(mem, 0, 64); + // digitalWrite(SS_PIN, LOW); + // SPI.write(mem, 64); + // digitalWrite(SS_PIN, HIGH); + // delay(1000); + // } + // + uint32_t write( + uint8_t* _data, // [IN] the porint of data sent from master to slave + uint32_t size // [IN] data size to send, this size need to be 2^X. + ); + + private: + + // SPI config data + vm_spi_config_para_t conf_data; + + // SPI handle + VM_DCL_HANDLE spi_handle; + + // Specify a SPI mode. + vm_spi_mode_t spi_data; + + // write buffer + VMUINT8 write_buff; + + // write buffer length + VMUINT32 write_len; + + // read buffer + VMUINT8 read_buff; + + // read buffer length + VMUINT32 read_len; +}; + +extern SPIClass SPI; + +#endif diff --git a/hardware/arduino/mtk/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino b/hardware/arduino/mtk/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino new file mode 100644 index 00000000..8104fcbc --- /dev/null +++ b/hardware/arduino/mtk/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino @@ -0,0 +1,143 @@ +/* + SCP1000 Barometric Pressure Sensor Display + + Shows the output of a Barometric Pressure Sensor on a + Uses the SPI library. For details on the sensor, see: + http://www.sparkfun.com/commerce/product_info.php?products_id=8161 + http://www.vti.fi/en/support/obsolete_products/pressure_sensors/ + + This sketch adapted from Nathan Seidle's SCP1000 example for PIC: + http://www.sparkfun.com/datasheets/Sensors/SCP1000-Testing.zip + + Circuit: + SCP1000 sensor attached to pins 6, 7, 10 - 13: + DRDY: pin 6 + CSB: pin 7 + MOSI: pin 11 + MISO: pin 12 + SCK: pin 13 + + created 31 July 2010 + modified 14 August 2010 + by Tom Igoe + */ + +// the sensor communicates using SPI, so include the library: +#include + +//Sensor's memory register addresses: +const int PRESSURE = 0x1F; //3 most significant bits of pressure +const int PRESSURE_LSB = 0x20; //16 least significant bits of pressure +const int TEMPERATURE = 0x21; //16 bit temperature reading +const byte READ = 0b11111100; // SCP1000's read command +const byte WRITE = 0b00000010; // SCP1000's write command + +// pins used for the connection with the sensor +// the other you need are controlled by the SPI library): +const int dataReadyPin = 6; +const int chipSelectPin = 7; + +void setup() { + Serial.begin(9600); + + // start the SPI library: + SPI.begin(); + + // initalize the data ready and chip select pins: + pinMode(dataReadyPin, INPUT); + pinMode(chipSelectPin, OUTPUT); + + //Configure SCP1000 for low noise configuration: + writeRegister(0x02, 0x2D); + writeRegister(0x01, 0x03); + writeRegister(0x03, 0x02); + // give the sensor time to set up: + delay(100); +} + +void loop() { + //Select High Resolution Mode + writeRegister(0x03, 0x0A); + + // don't do anything until the data ready pin is high: + if (digitalRead(dataReadyPin) == HIGH) { + //Read the temperature data + int tempData = readRegister(0x21, 2); + + // convert the temperature to celsius and display it: + float realTemp = (float)tempData / 20.0; + Serial.print("Temp[C]="); + Serial.print(realTemp); + + + //Read the pressure data highest 3 bits: + byte pressure_data_high = readRegister(0x1F, 1); + pressure_data_high &= 0b00000111; //you only needs bits 2 to 0 + + //Read the pressure data lower 16 bits: + unsigned int pressure_data_low = readRegister(0x20, 2); + //combine the two parts into one 19-bit number: + long pressure = ((pressure_data_high << 16) | pressure_data_low) / 4; + + // display the temperature: + Serial.println("\tPressure [Pa]=" + String(pressure)); + } +} + +//Read from or write to register from the SCP1000: +unsigned int readRegister(byte thisRegister, int bytesToRead ) { + byte inByte = 0; // incoming byte from the SPI + unsigned int result = 0; // result to return + Serial.print(thisRegister, BIN); + Serial.print("\t"); + // SCP1000 expects the register name in the upper 6 bits + // of the byte. So shift the bits left by two bits: + thisRegister = thisRegister << 2; + // now combine the address and the command into one byte + byte dataToSend = thisRegister & READ; + Serial.println(thisRegister, BIN); + // take the chip select low to select the device: + digitalWrite(chipSelectPin, LOW); + // send the device the register you want to read: + SPI.transfer(dataToSend); + // send a value of 0 to read the first byte returned: + result = SPI.transfer(0x00); + // decrement the number of bytes left to read: + bytesToRead--; + // if you still have another byte to read: + if (bytesToRead > 0) { + // shift the first byte left, then get the second byte: + result = result << 8; + inByte = SPI.transfer(0x00); + // combine the byte you just got with the previous one: + result = result | inByte; + // decrement the number of bytes left to read: + bytesToRead--; + } + // take the chip select high to de-select: + digitalWrite(chipSelectPin, HIGH); + // return the result: + return(result); +} + + +//Sends a write command to SCP1000 + +void writeRegister(byte thisRegister, byte thisValue) { + + // SCP1000 expects the register address in the upper 6 bits + // of the byte. So shift the bits left by two bits: + thisRegister = thisRegister << 2; + // now combine the register address and the command into one byte: + byte dataToSend = thisRegister | WRITE; + + // take the chip select low to select the device: + digitalWrite(chipSelectPin, LOW); + + SPI.transfer(dataToSend); //Send register location + SPI.transfer(thisValue); //Send value to record into register + + // take the chip select high to de-select: + digitalWrite(chipSelectPin, HIGH); +} + diff --git a/hardware/arduino/mtk/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino b/hardware/arduino/mtk/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino new file mode 100644 index 00000000..b135a74f --- /dev/null +++ b/hardware/arduino/mtk/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino @@ -0,0 +1,71 @@ +/* + Digital Pot Control + + This example controls an Analog Devices AD5206 digital potentiometer. + The AD5206 has 6 potentiometer channels. Each channel's pins are labeled + A - connect this to voltage + W - this is the pot's wiper, which changes when you set it + B - connect this to ground. + + The AD5206 is SPI-compatible,and to command it, you send two bytes, + one with the channel number (0 - 5) and one with the resistance value for the + channel (0 - 255). + + The circuit: + * All A pins of AD5206 connected to +5V + * All B pins of AD5206 connected to ground + * An LED and a 220-ohm resisor in series connected from each W pin to ground + * CS - to digital pin 10 (SS pin) + * SDI - to digital pin 11 (MOSI pin) + * CLK - to digital pin 13 (SCK pin) + + created 10 Aug 2010 + by Tom Igoe + + Thanks to Heather Dewey-Hagborg for the original tutorial, 2005 + +*/ + + +// inslude the SPI library: +#include + + +// set pin 10 as the slave select for the digital pot: +const int slaveSelectPin = 10; + +void setup() { + // set the slaveSelectPin as an output: + pinMode (slaveSelectPin, OUTPUT); + // initialize SPI: + SPI.begin(); +} + +void loop() { + // go through the six channels of the digital pot: + for (int channel = 0; channel < 6; channel++) { + // change the resistance on this channel from min to max: + for (int level = 0; level < 255; level++) { + digitalPotWrite(channel, level); + delay(10); + } + // wait a second at the top: + delay(100); + // change the resistance on this channel from max to min: + for (int level = 0; level < 255; level++) { + digitalPotWrite(channel, 255 - level); + delay(10); + } + } + +} + +void digitalPotWrite(int address, int value) { + // take the SS pin low to select the chip: + digitalWrite(slaveSelectPin, LOW); + // send in the address and value via SPI: + SPI.transfer(address); + SPI.transfer(value); + // take the SS pin high to de-select the chip: + digitalWrite(slaveSelectPin, HIGH); +} diff --git a/hardware/arduino/mtk/libraries/SPI/keywords.txt b/hardware/arduino/mtk/libraries/SPI/keywords.txt new file mode 100644 index 00000000..47738f9f --- /dev/null +++ b/hardware/arduino/mtk/libraries/SPI/keywords.txt @@ -0,0 +1,31 @@ +####################################### +# Syntax Coloring Map SPI +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +SPI KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### +begin KEYWORD2 +end KEYWORD2 +transfer KEYWORD2 +#setBitOrder KEYWORD2 +setDataMode KEYWORD2 +setClockDivider KEYWORD2 + + +####################################### +# Constants (LITERAL1) +####################################### +SPI_MODE0 LITERAL1 +SPI_MODE1 LITERAL1 +SPI_MODE2 LITERAL1 +SPI_MODE3 LITERAL1 + +SPI_CONTINUE LITERAL1 +SPI_LAST LITERAL1 diff --git a/hardware/arduino/mtk/libraries/Servo/Servo.cpp b/hardware/arduino/mtk/libraries/Servo/Servo.cpp new file mode 100644 index 00000000..ec868808 --- /dev/null +++ b/hardware/arduino/mtk/libraries/Servo/Servo.cpp @@ -0,0 +1,254 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#if defined(ARDUINO_ARCH_MTK) + +#include +#include +#include "vmsys.h" +#include "vmtimer.h" +#include "vmlog.h" + +/* 32K or 13M hz */ +#define MTK_SERVO_CLOCK 32000 + +#if defined(MTK_SERVO_CLOCK) && (MTK_SERVO_CLOCK == 32000) +#define MTK_SERVO_CLOCK_VALUE 1 +#elif defined(MTK_SERVO_CLOCK) && (MTK_SERVO_CLOCK == 13000000) +#define MTK_SERVO_CLOCK_VALUE 0 +#else +#error "specified mtk clock value error" +#endif + /* CLOCK */ /* HZ */ +#define MTK_SERVO_CYCLE (MTK_SERVO_CLOCK / (1000/(REFRESH_INTERVAL/1000))) + + + + + +#define usToTicks(_us) ((_us) / 4615) // converts microseconds to tick +#define ticksToUs(_ticks) ((unsigned)_ticks * 4615) // converts from ticks back to microseconds + +#define TRIM_DURATION 0 // compensation ticks to trim adjust for digitalWrite delays + +static servo_t servos[MAX_SERVOS]; // static array of servo structures + +uint8_t ServoCount = 0; // the total number of attached servos + +static volatile int8_t Channel[_Nbr_16timers ]; // counter for the servo being pulsed for each timer (or -1 if refresh interval) + +// convenience macros +#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo +#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer +#define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel +#define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel + + +#define SERVO_MIN() ( 1000/(REFRESH_INTERVAL/1000) - this->min * 4) // minimum value in uS for this servo + +#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo +#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo + +/************ static functions common to all instances ***********************/ + +typedef struct +{ + volatile unsigned int TC_RA; + volatile unsigned int TC_CV; +}TC_CHANNEL_T; + +static TC_CHANNEL_T TC_CHANNEL[MAX_SERVOS] = {{0, REFRESH_INTERVAL}}; + +static void Servo_Handler(timer16_Sequence_t timer, uint8_t channel) +{ + // clear interrupt + timer = 0; + channel = 0; + + delayMicroseconds(TC_CHANNEL[channel].TC_RA); + if (Channel[timer] < 0) { + //tc->TC_CHANNEL[channel].TC_CCR |= TC_CCR_SWTRG; // channel set to -1 indicated that refresh interval completed so reset the timer + } else { + if (SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive == true) { + digitalWrite(SERVO(timer,Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated + } + } + + Channel[timer]++; // increment to the next channel + if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) { + TC_CHANNEL[channel].TC_RA = TC_CHANNEL[channel].TC_CV + SERVO(timer,Channel[timer]).ticks; + if(SERVO(timer,Channel[timer]).Pin.isActive == true) { // check if activated + digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high + } + } + else { + // finished all channels so wait for the refresh period to expire before starting over + if( (TC_CHANNEL[channel].TC_CV) + 4 < REFRESH_INTERVAL ) { // allow a few ticks to ensure the next OCR1A not missed + TC_CHANNEL[channel].TC_RA = (unsigned int)REFRESH_INTERVAL; + } + else { + TC_CHANNEL[channel].TC_RA = TC_CHANNEL[channel].TC_CV + 4; // at least REFRESH_INTERVAL has elapsed + } + Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel + } +} + +void initISR(timer16_Sequence_t timer) +{ + +} + + +void finISR(timer16_Sequence_t timer) +{ + +} + + +static boolean isTimerActive(timer16_Sequence_t timer) +{ + // returns true if any servo is active on this timer + for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) { + if(SERVO(timer,channel).Pin.isActive == true) + return true; + } + return false; +} + + + +/****************** end of static functions ******************************/ + +Servo::Servo() +{ + if (ServoCount < MAX_SERVOS) { + this->servoIndex = ServoCount++; // assign a servo index to this instance + //servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values + servos[this->servoIndex].ticks = DEFAULT_PULSE_WIDTH; // store default values + } else { + this->servoIndex = INVALID_SERVO; // too many servos + } +} + +uint8_t Servo::attach(int pin) +{ + return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); +} + +uint8_t Servo::attach(int pin, int min, int max) +{ + timer16_Sequence_t timer; + + if (this->servoIndex < MAX_SERVOS) { + pinMode(pin, OUTPUT); // set servo pin to output + servos[this->servoIndex].Pin.nbr = pin; + // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128 + //this->min = (int)(((float)MIN_PULSE_WIDTH/REFRESH_INTERVAL) * MTK_SERVO_CYCLE); + this->min = (MIN_PULSE_WIDTH - min)/4; // + this->max = (MAX_PULSE_WIDTH - max)/4; // + // initialize the timer if it has not already been initialized + timer = SERVO_INDEX_TO_TIMER(servoIndex); + if (isTimerActive(timer) == false) { + initISR(timer); + } + servos[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive + } + return this->servoIndex; +} + +void Servo::detach() +{ + timer16_Sequence_t timer; + + servos[this->servoIndex].Pin.isActive = false; + timer = SERVO_INDEX_TO_TIMER(servoIndex); + if(isTimerActive(timer) == false) { + finISR(timer); + } +} + +void Servo::write(int value) +{ + // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds) + if (value < MIN_PULSE_WIDTH) + { + if (value < 0) + value = 0; + else if (value > 180) + value = 180; + vm_log_info("Servo::write 1 value[%d]", value); + value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX()); + vm_log_info("Servo::write 2 value[%d]", value); + } + writeMicroseconds(value); +} + +void Servo::writeMicroseconds(int value) +{ + // calculate and store the values for the given channel + byte channel = this->servoIndex; + if( (channel < MAX_SERVOS) ) // ensure channel is valid + { + if (value < SERVO_MIN()) // ensure pulse width is valid + value = SERVO_MIN(); + else if (value > SERVO_MAX()) + value = SERVO_MAX(); + + value = value - TRIM_DURATION; + //value = usToTicks(value); // convert to ticks after compensating for interrupt overhead + servos[channel].ticks = value; // + + int curr_min = (int)(((float)MIN_PULSE_WIDTH/REFRESH_INTERVAL) * MTK_SERVO_CYCLE); + int curr_max = (int)(((float)MAX_PULSE_WIDTH/REFRESH_INTERVAL) * MTK_SERVO_CYCLE); + + int duty = map(value, SERVO_MIN(), SERVO_MAX(), curr_min, curr_max); + analogWriteAdvance(servos[this->servoIndex].Pin.nbr, + MTK_SERVO_CLOCK_VALUE, + 0, + MTK_SERVO_CYCLE, + duty); + vm_log_info("Servo::writeMicroseconds [%d:%d][%d,%d,%d,%d]", curr_min, curr_max, + servos[this->servoIndex].Pin.nbr, MTK_SERVO_CLOCK_VALUE, MTK_SERVO_CYCLE, duty); + } +} + +int Servo::read() // return the value as degrees +{ + //return map(readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180); + return map(servos[this->servoIndex].ticks, SERVO_MIN(), SERVO_MAX(), 0, 180); +} +/* +int Servo::readMicroseconds() +{ + unsigned int pulsewidth; + if (this->servoIndex != INVALID_SERVO) + pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION; + else + pulsewidth = 0; + + return pulsewidth; +} +*/ + +bool Servo::attached() +{ + return servos[this->servoIndex].Pin.isActive; +} + +#endif // ARDUINO_ARCH_MTK + diff --git a/hardware/arduino/mtk/libraries/Servo/Servo.h b/hardware/arduino/mtk/libraries/Servo/Servo.h new file mode 100644 index 00000000..d03b4bde --- /dev/null +++ b/hardware/arduino/mtk/libraries/Servo/Servo.h @@ -0,0 +1,240 @@ +/* + Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 + Copyright (c) 2009 Michael Margolis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* + A servo is activated by creating an instance of the Servo class passing + the desired pin to the attach() method. + The servos are pulsed in the background using the value most recently + written using the write() method. + + Note that analogWrite of PWM on pins associated with the timer are + disabled when the first servo is attached. + Timers are seized as needed in groups of 12 servos - 24 servos use two + timers, 48 servos will use four. + The sequence used to sieze timers is defined in timers.h + + The methods are: + + Servo - Class for manipulating servo motors connected to Arduino pins. + + attach(pin ) - Attaches a servo motor to an i/o pin. + attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds + default min is 544, max is 2400 + + write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds) + writeMicroseconds() - Sets the servo pulse width in microseconds + read() - Gets the last written servo pulse width as an angle between 0 and 180. + readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release) + attached() - Returns true if there is a servo attached. + detach() - Stops an attached servos from pulsing its i/o pin. + */ + +#ifndef Servo_h +#define Servo_h + +#include "vmsys.h" +#define timer16_Sequence_t VMINT + +#define Servo_VERSION 2 // software version of this library + +#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo +#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo +#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached +#define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microseconds + +#define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer +#define _Nbr_16timers 4 +#define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) + +#define INVALID_SERVO 255 // flag indicating an invalid servo index + +typedef struct { + VMUINT8 nbr :6 ; // a pin number from 0 to 63 + VMUINT8 isActive :1 ; // true if this channel is enabled, pin not pulsed if false +} ServoPin_t ; + +typedef struct { + ServoPin_t Pin; + volatile unsigned int ticks; +} servo_t; + +// DESCRIPTION +//Servo Library allows RC servo control on LinkIt circuit board. +//Servo integrates gears and axes, which is capable of accurate control. +// +//A standard servo system positions an axis in different angles, normally between 0 and 180 degree. +//Rotating servo continuously will set the rotation of axis to different speeds. +// +//Note: +//Only pin (D3, D9) with PWM functionality can be used by servo. +// +// EXAMPLE +// +//#include +//Servo myservo; +// +//int potpin = 0; +//int val; +// +//void setup() +//{ +// myservo.attach(9); // servo connect to pin 9 +//} +// +//void loop() +//{ +// val = analogRead(potpin); // read from Pot pin +// val = map(val, 0, 1023, 0, 180); // map from 0~1023 to 0~180 +// myservo.write(val); // control servo +// delay(200); +//} +// +class Servo +{ +public: + Servo(); + + // DESCRIPTION + // Attaches servo motor to a digital pin. Only digital pins supporting PWM (D3, D9) can use this function. + // RETURNS + // channel number or 0 if failure + // EXAMPLE + // + // #include + // + // Servo myservo; + // + // void setup() + // { + // myservo.attach(9); + // } + // + // void loop() + // { + // + // } + // + VMUINT8 attach( + int pin //pin which needs servo attachment + ); + + // DESCRIPTION + // Attaches servo motor to a digital pin. Only digital pins supporting PWM (D3, D9) can use this function. + // RETURNS + // channel number or 0 if failure + // EXAMPLE + // + // #include + // + // Servo myservo; + // + // void setup() + // { + // myservo.attach(9); + // } + // + // void loop() + // { + // + // } + // + VMUINT8 attach( + int pin, //pin which needs servo attachment + int min, //(optional)lower bound of PW, ms; PWM when servo motor is at 0 degree (default: 544) + int max //(optional)upper bound of PW, ms, PWM when servo motor is at 180 degree (default: 2400) + ); + + //Servo motor and pin detached. If all servo motors are bound, you can use PWM output and analogWrite to output. + void detach(); + + // DESCRIPTION + // Writes a value to servo to control corresponding lever. + // Sets up the lever angle for a standard servo motor to move the lever to the corresponding angle. For a continuously rotating servo motor, sets up its rotation speed (0: rotate towards one direction in full speed; 180: rotate towards another direction in full speed; 90: stay intact) + // RETURNS + // void + // EXAMPLE + // + // #include + // + // Servo myservo; + // + // void setup() + // { + // myservo.attach(9); + // myservo.write(90); // set servo to mid-point + // } + // + // void loop() + // { + // + // } + // + void write( + int value //angle written to servo, 0 ~ 180 + ); + + + // DESCRIPTION + // Writes an us value to servo to control corresponding lever. + // Sets up the rotation angle of a standard servo motor. In terms of parameters for a standard servo, 1000 means rotating counterclockwise in full speed, 2000 clockwise in full speed and 1500 in the middle. + // + // The following is extracted from the official website of Arduino: + // Some customers do not operate following the standard method, for example setting the response value of servo between 700 and 2300. You can try enlarge the limits to adjust the range of rotation. However, such operation may shorten the life of servo and should be avoided. + // RETURNS + // void + // EXAMPLE + // + // #include + // + // Servo myservo; + // + // void setup() + // { + // myservo.attach(9); + // myservo.writeMicroseconds(1500); // set servo to mid-point + // } + // + // void loop() + // { + // + // } + // + void writeMicroseconds( + int value //value of microseconds + ); + + // DESCRIPTION + // Reads the current rotation angle of servo motor. + // RETURNS + // Rotation angle of servo, 0 ~ 180 degree + int read(); + + // DESCRIPTION + // Detects if servo has been attached with a pin. + // RETURNS + // True if pin is attached; otherwise false + bool attached(); + +private: + VMUINT8 servoIndex; // index into the channel data for this servo + VMINT8 min; // minimum is this value times 4 added to MIN_PULSE_WIDTH + VMINT8 max; // maximum is this value times 4 added to MAX_PULSE_WIDTH +}; + +#endif diff --git a/hardware/arduino/mtk/libraries/Servo/examples/Servo/Servo.ino b/hardware/arduino/mtk/libraries/Servo/examples/Servo/Servo.ino new file mode 100644 index 00000000..9423cdc5 --- /dev/null +++ b/hardware/arduino/mtk/libraries/Servo/examples/Servo/Servo.ino @@ -0,0 +1,22 @@ +#include +int i; +Servo myservo; + +void setup() { + //Serial.begin(115200); + myservo.attach(9); + myservo.write(90); + +} + +void loop() { + delay(1000); + vm_log_info("loop"); + + i += 3; + if (i == 180) + i = 0; + myservo.write(i); + +} + diff --git a/hardware/arduino/mtk/libraries/Servo/keywords.txt b/hardware/arduino/mtk/libraries/Servo/keywords.txt new file mode 100644 index 00000000..ca5ba79e --- /dev/null +++ b/hardware/arduino/mtk/libraries/Servo/keywords.txt @@ -0,0 +1,24 @@ +####################################### +# Syntax Coloring Map Servo +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +Servo KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### +attach KEYWORD2 +detach KEYWORD2 +write KEYWORD2 +read KEYWORD2 +attached KEYWORD2 +writeMicroseconds KEYWORD2 +readMicroseconds KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### diff --git a/hardware/arduino/mtk/libraries/Wire/Wire.cpp b/hardware/arduino/mtk/libraries/Wire/Wire.cpp new file mode 100644 index 00000000..0d24643a --- /dev/null +++ b/hardware/arduino/mtk/libraries/Wire/Wire.cpp @@ -0,0 +1,242 @@ +/* + * TwoWire.h - TWI/I2C library for Arduino Due + * Copyright (c) 2011 Cristian Maglie . + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +extern "C" { +#include +#include +#include +#include "vmsys.h" +#include "vmdcl.h" +#include "vmdcl_i2c.h" +#include "vmlog.h" +} + +#include "Wire.h" + +VM_DCL_HANDLE i2c_handle = -1; /* Declare a VM_DCL_HANDLE variable. */ + +TwoWire::TwoWire() : + rxBufferIndex(0), rxBufferLength(0), txAddress(0), + txBufferLength(0), srvBufferIndex(0), srvBufferLength(0), status( + UNINITIALIZED) { + // Empty +} + +void TwoWire::begin(void) { + + if(!changePinType(18, PIO_I2C, &i2c_handle)) + return; + + if(i2c_handle == VM_DCL_HANDLE_INVALID) + i2c_handle = vm_dcl_open(VM_DCL_I2C,0); + else + i2c_handle = g_APinDescription[18].ulHandle; + + if(VM_DCL_HANDLE_INVALID == i2c_handle) + { + vm_log_info("begin, failed.i2c_handle:%d",i2c_handle); + } + + setPinHandle(18, i2c_handle); + + status = MASTER_IDLE; +} + +void TwoWire::begin(uint8_t address) { + status = SLAVE_IDLE;// can not porting use dcl +} + +void TwoWire::begin(int address) { + begin((uint8_t) address);// can not porting use dcl +} + +uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop) { + + // perform blocking read into buffer + int readed = 0; + VM_DCL_STATUS ret = 0; + vm_i2c_ctrl_config_t conf_data; + vm_i2c_ctrl_single_read_t read_data; + + if(i2c_handle==-1) + { + vm_log_info("requestFrom,i2c handle is invalid.i2c_handle:%d",i2c_handle); + return 0; + } + + if (quantity > BUFFER_LENGTH) + quantity = BUFFER_LENGTH; + conf_data.Reserved0 = (VM_DCL_I2C_OWNER)0; + conf_data.eTransactionMode = VM_DCL_I2C_TRANSACTION_FAST_MODE; + conf_data.fgGetHandleWait = 0; + conf_data.Reserved1 = 0; + conf_data.u1DelayLen = 0; + conf_data.u1SlaveAddress = address<<1; + conf_data.u4FastModeSpeed = 100; + conf_data.u4HSModeSpeed = 0; + ret = vm_dcl_control(i2c_handle,VM_I2C_CMD_CONFIG,(void *)&conf_data); + read_data.pu1Data = &(rxBuffer[0]); + read_data.u4DataLen = quantity; + ret = vm_dcl_control(i2c_handle,VM_I2C_CMD_SINGLE_READ,(void *)&read_data); + rxBufferIndex = 0; + rxBufferLength = quantity; + + return quantity; +} + +uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity) { + return requestFrom((uint8_t) address, (uint8_t) quantity, (uint8_t) true); +} + +uint8_t TwoWire::requestFrom(int address, int quantity) { + return requestFrom((uint8_t) address, (uint8_t) quantity, (uint8_t) true); +} + +uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop) { + return requestFrom((uint8_t) address, (uint8_t) quantity, (uint8_t) sendStop); +} + +void TwoWire::beginTransmission(uint8_t address) { + if(i2c_handle==-1) + { + vm_log_info("beginTransmission:i2c handle is invalid,return"); + return; + } + status = MASTER_SEND; + + // save address of target and empty buffer + txAddress = address<<1; + txBufferLength = 0; +} + +void TwoWire::beginTransmission(int address) { + beginTransmission((uint8_t) address); +} + +uint8_t TwoWire::endTransmission(uint8_t sendStop) { + vm_i2c_ctrl_config_t conf_data; + vm_i2c_ctrl_single_write_t write_data; + VM_DCL_STATUS ret = 0; + int32_t sent = 0; + + if(i2c_handle==-1) + { + vm_log_info("endTransmission,i2c handle is invalid.i2c_handle:%d",i2c_handle); + return 0; + } + + if(0 < txBufferLength) { + conf_data.Reserved0 = (VM_DCL_I2C_OWNER)0; + conf_data.eTransactionMode = VM_DCL_I2C_TRANSACTION_FAST_MODE; + conf_data.fgGetHandleWait = 0; + conf_data.Reserved1 = 0; + conf_data.u1DelayLen = 0; + conf_data.u1SlaveAddress = txAddress; + + conf_data.u4FastModeSpeed = 100; + conf_data.u4HSModeSpeed = 0; + ret = vm_dcl_control(i2c_handle,VM_I2C_CMD_CONFIG,(void *)&conf_data); + + write_data.pu1Data = &(txBuffer[0]); + write_data.u4DataLen = txBufferLength; + ret = vm_dcl_control(i2c_handle,VM_I2C_CMD_SINGLE_WRITE,(void *)&write_data); + sent = txBufferLength; + } + + txBufferLength = 0; + + status = MASTER_IDLE; + return sent; +} + +// This provides backwards compatibility with the original +// definition, and expected behaviour, of endTransmission +// +uint8_t TwoWire::endTransmission(void) +{ + return endTransmission(true); +} + +size_t TwoWire::write(uint8_t data) { + if (status == MASTER_SEND) { + if (txBufferLength >= BUFFER_LENGTH) + return 0; + txBuffer[txBufferLength++] = data; + return 1; + } else { + if (srvBufferLength >= BUFFER_LENGTH) + return 0; + srvBuffer[srvBufferLength++] = data; + return 1; + } +} + +size_t TwoWire::write(const uint8_t *data, size_t quantity) { + if (status == MASTER_SEND) { + for (size_t i = 0; i < quantity; ++i) { + if (txBufferLength >= BUFFER_LENGTH) + return i; + txBuffer[txBufferLength++] = data[i]; + } + } else { + for (size_t i = 0; i < quantity; ++i) { + if (srvBufferLength >= BUFFER_LENGTH) + return i; + srvBuffer[srvBufferLength++] = data[i]; + } + } + return quantity; +} + +int TwoWire::available(void) { + return rxBufferLength - rxBufferIndex; +} + +int TwoWire::read(void) { + if (rxBufferIndex < rxBufferLength) + return rxBuffer[rxBufferIndex++]; + return -1; +} + +int TwoWire::peek(void) { + if (rxBufferIndex < rxBufferLength) + return rxBuffer[rxBufferIndex]; + return -1; +} + +void TwoWire::flush(void) { + // Do nothing, use endTransmission(..) to force + // data transfer. +} + +void TwoWire::onReceive(void(*function)(int)) { + onReceiveCallback = function; +} + +void TwoWire::onRequest(void(*function)(void)) { + onRequestCallback = function; +} + +void TwoWire::onService(void) { + // Retrieve interrupt status +} +// Preinstantiate Objects ////////////////////////////////////////////////////// +TwoWire Wire = TwoWire(); + diff --git a/hardware/arduino/mtk/libraries/Wire/Wire.h b/hardware/arduino/mtk/libraries/Wire/Wire.h new file mode 100644 index 00000000..86d62941 --- /dev/null +++ b/hardware/arduino/mtk/libraries/Wire/Wire.h @@ -0,0 +1,374 @@ +/* + * TwoWire.h - TWI/I2C library for Arduino Due + * Copyright (c) 2011 Cristian Maglie . + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef TwoWire_h +#define TwoWire_h +// Include Atmel CMSIS driver +//#include + +#include "Stream.h" +#include "variant.h" + +#define BUFFER_LENGTH 8 + + +// TwoWire class interface +class TwoWire : public Stream +{ +// Constructor / Destructor +public: + TwoWire(); + +// Method +public: + // DESCRIPTION + // Sets up the host address for I2C communication. LinkIt One supports void TwoWire:begin(void), + // which means joining the I2C bus as a host. In normal condition, + // to use the Wire library,this function must be called and called only once. + // EXAMPLE + // + // #include + // void setup() + // { + // Wire.begin(); + // } + // void loop() + // { + // + // } + // + void begin(); +/* DOM-NOT_FOR_SDK-BEGIN */ + // DESCRIPTION + // Initiate the wire library and join the I2C bus as a master.This should normally + // be called only once + void begin( + uint8_t address // [IN] the 7-bit address of the device + ); + + // DESCRIPTION + // Initiate the wire library and join the I2C bus as a master.This should normally + // be called only once + void begin( + int address // [IN] the 7-bit address of the device + ); +/* DOM-NOT_FOR_SDK-END */ + + // DESCRIPTION + // Enables the communication with the slave at assigned address.After that, + // the data are written by write() and transmitted by endTransmission(). + // RETURNS + // none + // EXAMPLE + // + // #include + // void setup() + // { + // Wire.begin(); + // } + // void loop() + // { + // Wire.beginTransmission(0x27); + // Wire.write('a'); + // Wire.endTransmission(); + // } + // + void beginTransmission( + uint8_t address // [IN] Address of the assigned slave,a 7-bit address,from 0 to 127. + ); + + + // DESCRIPTION + // Enables the communication with the slave at assigned address.After that, + // the data are written by write() and transmitted by endTransmission(). + void beginTransmission( + int address // [IN] Address of the assigned slave,a 7-bit address,from 0 to 127. + ); + + + // DESCRIPTION + // Ends the communication with the slave assigned by beginTransmission() and + // transmits the data buffered by write() to the slave. + // RETURNS + // Number of bytes of data sent to slave(unit:byte) + // EXAMPLE + // + // #include + // void setup() + // { + // Wire.begin(); + // } + // void loop() + // { + // Wire.beginTransmission(0x27); + // Wire.write('a'); + // Wire.endTransmission(); + // } + // + uint8_t endTransmission(void); +/* DOM-NOT_FOR_SDK-BEGIN */ + // DESCRIPTION + // end a transmission to a slave device that was begun by beginTransmission()and transmit the bytes + // that were queued by write() + // RETURNS + // the number of byte that were sent to the slave device. + // SEE ALSO + // beginTransmission + uint8_t endTransmission( + uint8_t sendStop + ); +/* DOM-NOT_FOR_SDK-END */ + + // DESCRIPTION + // For master to request data from slave, and master can get data by + // available() and read(). + // RETURNS + // Number of bytes returned from slave + // EXAMPLE + // + // #include + // void setup() + // { + // Wire.begin(); + // } + // void loop() + // { + // Wire.requestFrom(0x27,6); + // while((Wire.available())) + // { + // int c = Wire.read(); + // } + // } + // + uint8_t requestFrom( + uint8_t address, // [IN]address:the 7-bit slave address + uint8_t quantity // [IN]quantity:number of bytes requested + ); + + // DESCRIPTION + // For master to request data from slave, and master can get data by + // available() and read(). + // RETURNS + // Number of bytes returned from slave + uint8_t requestFrom( + int address, // [IN]address:the 7-bit slave address + int quantity // [IN]quantity:number of bytes requested + ); +/* DOM-NOT_FOR_SDK-BEGIN */ + // DESCRIPTION + // used by the master to request bytes from a slave device.the bytes may then be retrieved with the + // available() and read() function + // RETURNS + // the number of bytes returned from the slave device + uint8_t requestFrom( + uint8_t address, // Param 1 + uint8_t quantity, // Param 2 + uint8_t sendStop // Param 3 + ); + + // DESCRIPTION + // used by the master to request bytes from a slave device.the bytes may then be retrieved with the + // available() and read() function + // RETURNS + // the number of bytes returned from the slave device + uint8_t requestFrom( + int address, // Param 1 + int quantity, // Param 2 + int sendStop // Param 3 + ); + /* DOM-NOT_FOR_SDK-END */ + + // DESCRIPTION + // Writes data into the queue and is called between beginTransmission() and endTransmission() + // RETURNS + // Number of bytes of data written in + // EXAMPLE + // + // #include + // void setup() + // { + // Wire.begin(); + // } + // void loop() + // { + // Wire.beginTransmission(0x27); + // Wire.write('a'); + // Wire.endTransmission(); + // } + // + virtual size_t write( + uint8_t data// [IN]A byte of data to be written. + ); + + + // DESCRIPTION + // Writes data into the queue and is called between beginTransmission() and endTransmission() + // RETURNS + // Number of bytes of data written in + // EXAMPLE + // + // #include + // uint8_t data[3]={0,1,2}; + // void setup() + // { + // Wire.begin(); + // } + // void loop() + // { + // Wire.beginTransmission(0x27); + // Wire.write(data,3); + // Wire.endTransmission(); + // } + // + + virtual size_t write( + const uint8_t * data, //[IN]address to be written data + size_t quantity //[IN]Number of bytes of data written in + ); + + + // DESCRIPTION + // Returns the number of bytes read() can read + // RETURNS + // Number of bytes that can be read + // EXAMPLE + // + // #include + // void setup() + // { + // Wire.begin(); + // } + // void loop() + // { + // Wire.requestFrom(0x27,6); + // while((Wire.available())) + // { + // int c = Wire.read(); + // } + // } + // + virtual int available(void); + + + // DESCRIPTION + // Reads a byte of data which are sent from master to slave or from + // slave to master(the master requests it by requestFrom()) + // RETURNS + // The byte of data read + // EXAMPLE + // + // #include + // void setup() + // { + // Wire.begin(); + // } + // void loop() + // { + // Wire.requestFrom(0x27,6); + // while((Wire.available())) + // { + // int c = Wire.read(); + // } + // } + // + virtual int read(void); + /* DOM-NOT_FOR_SDK-BEGIN */ + // todo + virtual int peek(void); + + // todo + virtual void flush(void); + + // todo + void onReceive(void(*)(int)); + + // todo + void onRequest(void(*)(void)); + + // todo + inline size_t write(unsigned long n) { return write((uint8_t)n); } + + // todo + inline size_t write(long n) { return write((uint8_t)n); } + + // todo + inline size_t write(unsigned int n) { return write((uint8_t)n); } + + // todo + inline size_t write(int n) { return write((uint8_t)n); } + + // todo + using Print::write; + + // todo + void onService(void); +/* DOM-NOT_FOR_SDK-END */ +//Implementation +private: + // RX Buffer + uint8_t rxBuffer[BUFFER_LENGTH]; + uint8_t rxBufferIndex; + uint8_t rxBufferLength; + + // TX Buffer + uint8_t txAddress; + uint8_t txBuffer[BUFFER_LENGTH]; + uint8_t txBufferLength; + + // Service buffer + uint8_t srvBuffer[BUFFER_LENGTH]; + uint8_t srvBufferIndex; + uint8_t srvBufferLength; + + // Callback user functions + void (*onRequestCallback)(void); + void (*onReceiveCallback)(int); + + // Called before initialization + //void (*onBeginCallback)(void); + + // TWI instance + //Twi *twi; + + // TWI state + enum TwoWireStatus { + UNINITIALIZED, + MASTER_IDLE, + MASTER_SEND, + MASTER_RECV, + SLAVE_IDLE, + SLAVE_RECV, + SLAVE_SEND + }; + TwoWireStatus status; + + // TWI clock frequency + static const uint32_t TWI_CLOCK = 100000; + + // Timeouts ( + static const uint32_t RECV_TIMEOUT = 100000; + static const uint32_t XMIT_TIMEOUT = 100000; +}; + +//the Wire object +extern TwoWire Wire; + +#endif + diff --git a/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/LiquidCrystal_I2C.cpp b/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/LiquidCrystal_I2C.cpp new file mode 100644 index 00000000..a5673329 --- /dev/null +++ b/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/LiquidCrystal_I2C.cpp @@ -0,0 +1,308 @@ +//YWROBOT +//last updated on 21/12/2011 +//Tim Starling Fix the reset bug (Thanks Tim) +//wiki doc http://www.dfrobot.com/wiki/index.php?title=I2C/TWI_LCD1602_Module_(SKU:_DFR0063) +//Support Forum: http://www.dfrobot.com/forum/ +//Compatible with the Arduino IDE 1.0 +//Library version:1.1 + + +#include "LiquidCrystal_I2C.h" +#include +//#if defined(ARDUINO) && ARDUINO >= 100 + +#include "Arduino.h" + +inline size_t LiquidCrystal_I2C::write(uint8_t value) { + send(value, Rs); + return 0; +} + +#include "Wire.h" + +// When the display powers up, it is configured as follows: +// +// 1. Display clear +// 2. Function set: +// DL = 1; 8-bit interface data +// N = 0; 1-line display +// F = 0; 5x8 dot character font +// 3. Display on/off control: +// D = 0; Display off +// C = 0; Cursor off +// B = 0; Blinking off +// 4. Entry mode set: +// I/D = 1; Increment by 1 +// S = 0; No shift +// +// Note, however, that resetting the Arduino doesn't reset the LCD, so we +// can't assume that its in that state when a sketch starts (and the +// LiquidCrystal constructor is called). + +LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t lcd_Addr,uint8_t lcd_cols,uint8_t lcd_rows) +{ + _Addr = lcd_Addr; + _cols = lcd_cols; + _rows = lcd_rows; + _backlightval = LCD_NOBACKLIGHT; +} + +void LiquidCrystal_I2C::init(){ + init_priv(); +} + +void LiquidCrystal_I2C::init_priv() +{ + Wire.begin(); + _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; + begin(_cols, _rows); +} + +void LiquidCrystal_I2C::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { + if (lines > 1) { + _displayfunction |= LCD_2LINE; + } + _numlines = lines; + + // for some 1 line displays you can select a 10 pixel high font + if ((dotsize != 0) && (lines == 1)) { + _displayfunction |= LCD_5x10DOTS; + } + + // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! + // according to datasheet, we need at least 40ms after power rises above 2.7V + // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50 + delay(50); + + // Now we pull both RS and R/W low to begin commands + expanderWrite(_backlightval); // reset expanderand turn backlight off (Bit 8 =1) + delay(1000); + + //put the LCD into 4 bit mode + // this is according to the hitachi HD44780 datasheet + // figure 24, pg 46 + + // we start in 8bit mode, try to set 4 bit mode + write4bits(0x03 << 4); + delayMicroseconds(4500); // wait min 4.1ms + + // second try + write4bits(0x03 << 4); + delayMicroseconds(4500); // wait min 4.1ms + + // third go! + write4bits(0x03 << 4); + delayMicroseconds(150); + + // finally, set to 4-bit interface + write4bits(0x02 << 4); + + + // set # lines, font size, etc. + command(LCD_FUNCTIONSET | _displayfunction); + + // turn the display on with no cursor or blinking default + _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; + display(); + + // clear it off + clear(); + + // Initialize to default text direction (for roman languages) + _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; + + // set the entry mode + command(LCD_ENTRYMODESET | _displaymode); + + home(); + +} + +/********** high level commands, for the user! */ +void LiquidCrystal_I2C::clear(){ + command(LCD_CLEARDISPLAY);// clear display, set cursor position to zero + delayMicroseconds(2000); // this command takes a long time! +} + +void LiquidCrystal_I2C::home(){ + command(LCD_RETURNHOME); // set cursor position to zero + delayMicroseconds(2000); // this command takes a long time! +} + +void LiquidCrystal_I2C::setCursor(uint8_t col, uint8_t row){ + int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; + if ( row > _numlines ) { + row = _numlines-1; // we count rows starting w/0 + } + command(LCD_SETDDRAMADDR | (col + row_offsets[row])); +} + +// Turn the display on/off (quickly) +void LiquidCrystal_I2C::noDisplay() { + _displaycontrol &= ~LCD_DISPLAYON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} +void LiquidCrystal_I2C::display() { + _displaycontrol |= LCD_DISPLAYON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} + +// Turns the underline cursor on/off +void LiquidCrystal_I2C::noCursor() { + _displaycontrol &= ~LCD_CURSORON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} +void LiquidCrystal_I2C::cursor() { + _displaycontrol |= LCD_CURSORON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} + +// Turn on and off the blinking cursor +void LiquidCrystal_I2C::noBlink() { + _displaycontrol &= ~LCD_BLINKON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} +void LiquidCrystal_I2C::blink() { + _displaycontrol |= LCD_BLINKON; + command(LCD_DISPLAYCONTROL | _displaycontrol); +} + +// These commands scroll the display without changing the RAM +void LiquidCrystal_I2C::scrollDisplayLeft(void) { + command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); +} +void LiquidCrystal_I2C::scrollDisplayRight(void) { + command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); +} + +// This is for text that flows Left to Right +void LiquidCrystal_I2C::leftToRight(void) { + _displaymode |= LCD_ENTRYLEFT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// This is for text that flows Right to Left +void LiquidCrystal_I2C::rightToLeft(void) { + _displaymode &= ~LCD_ENTRYLEFT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// This will 'right justify' text from the cursor +void LiquidCrystal_I2C::autoscroll(void) { + _displaymode |= LCD_ENTRYSHIFTINCREMENT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// This will 'left justify' text from the cursor +void LiquidCrystal_I2C::noAutoscroll(void) { + _displaymode &= ~LCD_ENTRYSHIFTINCREMENT; + command(LCD_ENTRYMODESET | _displaymode); +} + +// Allows us to fill the first 8 CGRAM locations +// with custom characters +void LiquidCrystal_I2C::createChar(uint8_t location, uint8_t charmap[]) { + location &= 0x7; // we only have 8 locations 0-7 + command(LCD_SETCGRAMADDR | (location << 3)); + for (int i=0; i<8; i++) { + write(charmap[i]); + } +} + +// Turn the (optional) backlight off/on +void LiquidCrystal_I2C::noBacklight(void) { + _backlightval=LCD_NOBACKLIGHT; + expanderWrite(0); +} + +void LiquidCrystal_I2C::backlight(void) { + _backlightval=LCD_BACKLIGHT; + expanderWrite(0); +} + +/*********** mid level commands, for sending data/cmds */ + +inline void LiquidCrystal_I2C::command(uint8_t value) { + send(value, 0); +} + + +/************ low level data pushing commands **********/ + +// write either command or data +void LiquidCrystal_I2C::send(uint8_t value, uint8_t mode) { + uint8_t highnib=value&0xf0; + uint8_t lownib=(value<<4)&0xf0; + write4bits((highnib)|mode); + write4bits((lownib)|mode); +} + +void LiquidCrystal_I2C::write4bits(uint8_t value) { + expanderWrite(value); + pulseEnable(value); +} + +void LiquidCrystal_I2C::expanderWrite(uint8_t _data){ + Wire.beginTransmission(_Addr); + Wire.write((int)(_data) | _backlightval); + Wire.endTransmission(); +} + +void LiquidCrystal_I2C::pulseEnable(uint8_t _data){ + expanderWrite(_data | En); // En high + delayMicroseconds(1); // enable pulse must be >450ns + + expanderWrite(_data & ~En); // En low + delayMicroseconds(50); // commands need > 37us to settle +} + + +// Alias functions + +void LiquidCrystal_I2C::cursor_on(){ + cursor(); +} + +void LiquidCrystal_I2C::cursor_off(){ + noCursor(); +} + +void LiquidCrystal_I2C::blink_on(){ + blink(); +} + +void LiquidCrystal_I2C::blink_off(){ + noBlink(); +} + +void LiquidCrystal_I2C::load_custom_character(uint8_t char_num, uint8_t *rows){ + createChar(char_num, rows); +} + +void LiquidCrystal_I2C::setBacklight(uint8_t new_val){ + if(new_val){ + backlight(); // turn backlight on + }else{ + noBacklight(); // turn backlight off + } +} + +void LiquidCrystal_I2C::printstr(const char c[]){ + //This function is not identical to the function used for "real" I2C displays + //it's here so the user sketch doesn't have to be changed + print(c); +} + + +// unsupported API functions +void LiquidCrystal_I2C::off(){} +void LiquidCrystal_I2C::on(){} +void LiquidCrystal_I2C::setDelay (int cmdDelay,int charDelay) {} +uint8_t LiquidCrystal_I2C::status(){return 0;} +uint8_t LiquidCrystal_I2C::keypad (){return 0;} +uint8_t LiquidCrystal_I2C::init_bargraph(uint8_t graphtype){return 0;} +void LiquidCrystal_I2C::draw_horizontal_graph(uint8_t row, uint8_t column, uint8_t len, uint8_t pixel_col_end){} +void LiquidCrystal_I2C::draw_vertical_graph(uint8_t row, uint8_t column, uint8_t len, uint8_t pixel_row_end){} +void LiquidCrystal_I2C::setContrast(uint8_t new_val){} + + \ No newline at end of file diff --git a/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/LiquidCrystal_I2C.h b/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/LiquidCrystal_I2C.h new file mode 100644 index 00000000..faf19fbe --- /dev/null +++ b/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/LiquidCrystal_I2C.h @@ -0,0 +1,126 @@ +//YWROBOT +#ifndef LiquidCrystal_I2C_h +#define LiquidCrystal_I2C_h + +#include +#include "Print.h" +#include + +// commands +#define LCD_CLEARDISPLAY 0x01 +#define LCD_RETURNHOME 0x02 +#define LCD_ENTRYMODESET 0x04 +#define LCD_DISPLAYCONTROL 0x08 +#define LCD_CURSORSHIFT 0x10 +#define LCD_FUNCTIONSET 0x20 +#define LCD_SETCGRAMADDR 0x40 +#define LCD_SETDDRAMADDR 0x80 + +// flags for display entry mode +#define LCD_ENTRYRIGHT 0x00 +#define LCD_ENTRYLEFT 0x02 +#define LCD_ENTRYSHIFTINCREMENT 0x01 +#define LCD_ENTRYSHIFTDECREMENT 0x00 + +// flags for display on/off control +#define LCD_DISPLAYON 0x04 +#define LCD_DISPLAYOFF 0x00 +#define LCD_CURSORON 0x02 +#define LCD_CURSOROFF 0x00 +#define LCD_BLINKON 0x01 +#define LCD_BLINKOFF 0x00 + +// flags for display/cursor shift +#define LCD_DISPLAYMOVE 0x08 +#define LCD_CURSORMOVE 0x00 +#define LCD_MOVERIGHT 0x04 +#define LCD_MOVELEFT 0x00 + +// flags for function set +#define LCD_8BITMODE 0x10 +#define LCD_4BITMODE 0x00 +#define LCD_2LINE 0x08 +#define LCD_1LINE 0x00 +#define LCD_5x10DOTS 0x04 +#define LCD_5x8DOTS 0x00 + +// flags for backlight control +#define LCD_BACKLIGHT 0x08 +#define LCD_NOBACKLIGHT 0x00 + +#define En B00000100 // Enable bit +#define Rw B00000010 // Read/Write bit +#define Rs B00000001 // Register select bit + +class LiquidCrystal_I2C : public Print { +public: + LiquidCrystal_I2C(uint8_t lcd_Addr,uint8_t lcd_cols,uint8_t lcd_rows); + void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS ); + void clear(); + void home(); + void noDisplay(); + void display(); + void noBlink(); + void blink(); + void noCursor(); + void cursor(); + void scrollDisplayLeft(); + void scrollDisplayRight(); + void printLeft(); + void printRight(); + void leftToRight(); + void rightToLeft(); + void shiftIncrement(); + void shiftDecrement(); + void noBacklight(); + void backlight(); + void autoscroll(); + void noAutoscroll(); + void createChar(uint8_t, uint8_t[]); + void setCursor(uint8_t, uint8_t); +#if defined(ARDUINO) && ARDUINO >= 100 + virtual size_t write(uint8_t); +#else + virtual void write(uint8_t); +#endif + void command(uint8_t); + void init(); + +////compatibility API function aliases +void blink_on(); // alias for blink() +void blink_off(); // alias for noBlink() +void cursor_on(); // alias for cursor() +void cursor_off(); // alias for noCursor() +void setBacklight(uint8_t new_val); // alias for backlight() and nobacklight() +void load_custom_character(uint8_t char_num, uint8_t *rows); // alias for createChar() +void printstr(const char[]); + +////Unsupported API functions (not implemented in this library) +uint8_t status(); +void setContrast(uint8_t new_val); +uint8_t keypad(); +void setDelay(int,int); +void on(); +void off(); +uint8_t init_bargraph(uint8_t graphtype); +void draw_horizontal_graph(uint8_t row, uint8_t column, uint8_t len, uint8_t pixel_col_end); +void draw_vertical_graph(uint8_t row, uint8_t column, uint8_t len, uint8_t pixel_col_end); + + +private: + void init_priv(); + void send(uint8_t, uint8_t); + void write4bits(uint8_t); + void expanderWrite(uint8_t); + void pulseEnable(uint8_t); + uint8_t _Addr; + uint8_t _displayfunction; + uint8_t _displaycontrol; + uint8_t _displaymode; + uint8_t _numlines; + uint8_t _cols; + uint8_t _rows; + uint8_t _backlightval; +}; + +#endif diff --git a/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/LiquidCrystal_I2C.o b/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/LiquidCrystal_I2C.o new file mode 100644 index 00000000..bca78e0d Binary files /dev/null and b/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/LiquidCrystal_I2C.o differ diff --git a/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/diff.txt b/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/diff.txt new file mode 100644 index 00000000..586578de --- /dev/null +++ b/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/diff.txt @@ -0,0 +1,69 @@ +1,6c1 +< //YWROBOT +< //last updated on 26/11/2010 +< //Tim Starling Fix the reset bug (Thanks Tim) +< //wiki doc http://www.dfrobot.com/wiki/index.php?title=I2C/TWI_LCD1602_Module_(SKU:_DFR0063) +< //Support Forum: http://www.dfrobot.com/forum/ +< +--- +> // LiquidCrystal_I2C V2.0 +10d4 +< #include "WProgram.h" +12c6 +< +--- +> #include "Arduino.h" +67c61 +< delay(50); +--- +> delayMicroseconds(50000); +77,90c71,84 +< // we start in 8bit mode, try to set 4 bit mode +< write4bits(0x03 << 4); +< delayMicroseconds(4500); // wait min 4.1ms +< +< // second try +< write4bits(0x03 << 4); +< delayMicroseconds(4500); // wait min 4.1ms +< +< // third go! +< write4bits(0x03 << 4); +< delayMicroseconds(150); +< +< // finally, set to 4-bit interface +< write4bits(0x02 << 4); +--- +> // we start in 8bit mode, try to set 4 bit mode +> write4bits(0x03); +> delayMicroseconds(4500); // wait min 4.1ms +> +> // second try +> write4bits(0x03); +> delayMicroseconds(4500); // wait min 4.1ms +> +> // third go! +> write4bits(0x03); +> delayMicroseconds(150); +> +> // finally, set to 4-bit interface +> write4bits(0x02); +225c219 +< inline void LiquidCrystal_I2C::write(uint8_t value) { +--- +> inline size_t LiquidCrystal_I2C::write(uint8_t value) { +226a221 +> return 0; +235,238c230,233 +< uint8_t highnib=value&0xf0; +< uint8_t lownib=(value<<4)&0xf0; +< write4bits((highnib)|mode); +< write4bits((lownib)|mode); +--- +> uint8_t highnib=value>>4; +> uint8_t lownib=value & 0x0F; +> write4bits((highnib)|mode); +> write4bits((lownib)|mode); +248c243 +< Wire.send((int)(_data) | _backlightval); +--- +> Wire.write((int)(_data) | _backlightval); diff --git a/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/examples/SerialDisplay/SerialDisplay.pde b/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/examples/SerialDisplay/SerialDisplay.pde new file mode 100644 index 00000000..a237475d --- /dev/null +++ b/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/examples/SerialDisplay/SerialDisplay.pde @@ -0,0 +1,34 @@ +/* + * Displays text sent over the serial port (e.g. from the Serial Monitor) on + * an attached LCD. + * YWROBOT + *Compatible with the Arduino IDE 1.0 + *Library version:1.1 + */ +#include +#include + +LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display + +void setup() +{ + lcd.init(); // initialize the lcd + lcd.backlight(); + Serial.begin(9600); +} + +void loop() +{ + // when characters arrive over the serial port... + if (Serial.available()) { + // wait a bit for the entire message to arrive + delay(100); + // clear the screen + lcd.clear(); + // read all the available characters + while (Serial.available() > 0) { + // display each character to the LCD + lcd.write(Serial.read()); + } + } +} diff --git a/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/keywords.txt b/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/keywords.txt new file mode 100644 index 00000000..8c450a9e --- /dev/null +++ b/hardware/arduino/mtk/libraries/Wire/example/LiquidCrystal_I2C1602V1/keywords.txt @@ -0,0 +1,46 @@ +########################################### +# Syntax Coloring Map For LiquidCrystal_I2C +########################################### + +########################################### +# Datatypes (KEYWORD1) +########################################### + +LiquidCrystal_I2C KEYWORD1 + +########################################### +# Methods and Functions (KEYWORD2) +########################################### +init KEYWORD2 +begin KEYWORD2 +clear KEYWORD2 +home KEYWORD2 +noDisplay KEYWORD2 +display KEYWORD2 +noBlink KEYWORD2 +blink KEYWORD2 +noCursor KEYWORD2 +cursor KEYWORD2 +scrollDisplayLeft KEYWORD2 +scrollDisplayRight KEYWORD2 +leftToRight KEYWORD2 +rightToLeft KEYWORD2 +shiftIncrement KEYWORD2 +shiftDecrement KEYWORD2 +noBacklight KEYWORD2 +backlight KEYWORD2 +autoscroll KEYWORD2 +noAutoscroll KEYWORD2 +createChar KEYWORD2 +setCursor KEYWORD2 +print KEYWORD2 +blink_on KEYWORD2 +blink_off KEYWORD2 +cursor_on KEYWORD2 +cursor_off KEYWORD2 +setBacklight KEYWORD2 +load_custom_character KEYWORD2 +printstr KEYWORD2 +########################################### +# Constants (LITERAL1) +########################################### diff --git a/hardware/arduino/mtk/libraries/Wire/keywords.txt b/hardware/arduino/mtk/libraries/Wire/keywords.txt new file mode 100644 index 00000000..e75e929e --- /dev/null +++ b/hardware/arduino/mtk/libraries/Wire/keywords.txt @@ -0,0 +1,32 @@ +####################################### +# Syntax Coloring Map For Wire +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +begin KEYWORD2 +beginTransmission KEYWORD2 +endTransmission KEYWORD2 +requestFrom KEYWORD2 +send KEYWORD2 +receive KEYWORD2 +onReceive KEYWORD2 +onRequest KEYWORD2 + +####################################### +# Instances (KEYWORD2) +####################################### + +Wire KEYWORD2 +Wire1 KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### + diff --git a/hardware/arduino/mtk/platform.txt b/hardware/arduino/mtk/platform.txt new file mode 100644 index 00000000..4af85daf --- /dev/null +++ b/hardware/arduino/mtk/platform.txt @@ -0,0 +1,84 @@ + +# Arduino MTK Core and platform. +# +# For more info: +# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification + +name=Arduino ARM (32-bits) Boards +version=1.5.6 + +# MTK compile variables +# ---------------------- + +compiler.path={runtime.ide.path}/hardware/tools/g++_arm_none_eabi/bin/ +compiler.c.cmd=arm-none-eabi-gcc +compiler.c.flags=-c -g -O2 -fvisibility=hidden -fpic -mthumb -mlittle-endian -nostdlib -nostdlib -Dprintf=iprintf +compiler.c.elf.cmd=arm-none-eabi-g++ +compiler.c.elf.flags=-O2 -Wl,--gc-sections +compiler.S.flags=-c -g -x assembler-with-cpp +compiler.cpp.cmd=arm-none-eabi-g++ +compiler.cpp.flags=-c -g -O2 -fvisibility=hidden -fpic -mthumb -mlittle-endian -nostdlib -fno-non-call-exceptions -fno-rtti -fno-exceptions -Dprintf=iprintf +compiler.ar.cmd=arm-none-eabi-ar +compiler.ar.flags=rcs +compiler.objcopy.cmd=arm-none-eabi-objcopy +compiler.objcopy.remove.flags=--strip-debug +# compiler.elf2hex.flags=-O binary +# compiler.elf2hex.cmd=arm-none-eabi-objcopy +# compiler.ldflags= +compiler.size.cmd=arm-none-eabi-size +compiler.define=-DARDUINO= +# this can be overriden in boards.txt +build.extra_flags= + + +compiler.libmtk.c.flags="-I{build.system.path}/libmtk" "-I{build.system.path}/libmtk/include" + +# USB Flags +# --------- +build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}' + +# Default usb manufacturer will be replaced at compile time using +# numeric vendor ID if available or by board's specific value. +build.usb_manufacturer="Unknown" + + +# MTK compile patterns +# --------------------- + +## Compile c files +recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {build.extra_flags} {compiler.libmtk.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Compile c++ files +recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {build.extra_flags} {compiler.libmtk.c.flags} {includes} "{source_file}" -o "{object_file}" + +## Create archives +recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} "{build.path}/{archive_file}" "{object_file}" + +## Combine gc-sections, archives, and objects +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -lm -fpic -msvr4-struct-return -pie -Wl,--entry=gcc_entry -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-unresolved-symbols -Wl,--start-group "{build.path}/syscalls_mtk.c.o" {object_files} "{build.variant.path}/{build.variant_system_lib}" "{build.path}/{archive_file}" -Wl,--end-group + +## Get debug infomation +#recipe.objcopy.get.pattern="{compiler.path}{compiler.objcopy.cmd}" --only-keep-debug "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.vxp.dbg" + +## Remove debug infomation +recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.remove.flags} "{build.path}/{build.project_name}.elf" + +## Create hex +recipe.objcopy.hex.pattern="{runtime.ide.path}/hardware/tools/mtk/PackTag.exe" "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.vxp" + +## Compute size +recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf" +recipe.size.regex=\.text\s+([0-9]+).* + + +# MTK Uploader tools +# ------------------- + +tools.bossac.cmd=pushtool +tools.bossac.cmd.windows=pushtool.exe +tools.bossac.path={runtime.ide.path}/hardware/tools/mtk + +tools.bossac.upload.params.verbose=-v -v -v -v +tools.bossac.upload.params.quiet= +tools.bossac.upload.pattern="{path}/{cmd}" {upload.verbose} -t arduino -clear -port {serial.port.file} -app "{build.path}/{build.project_name}.vxp" + diff --git a/hardware/arduino/mtk/programmers.txt b/hardware/arduino/mtk/programmers.txt new file mode 100644 index 00000000..e69de29b diff --git a/hardware/arduino/mtk/system/libmtk/build_gcc/StubGen.bat b/hardware/arduino/mtk/system/libmtk/build_gcc/StubGen.bat new file mode 100644 index 00000000..4399aab9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/build_gcc/StubGen.bat @@ -0,0 +1,73 @@ +@echo off +set GCC_PATH=C:\Program Files\CodeSourcery\Sourcery G++ Lite\bin +path %GCC_PATH%;%path%; + +rd ..\debug/s/q +md ..\debug + +cd ..\source\modules + +SET P_COUNT=16 +set LOG_FILE=..\..\debug\stubgen.log +if {%*}=={} (set mods=*) else (set mods=%*) + +REM ------------------------------Thumb code compile----------------------------- +SET CODE=ARM +SET COMPILER=GCC + +for /d %%i in (%mods%) do call:sub_run_module "make %COMPILER%%CODE% %%i" "make %%i.a -j%P_COUNT% COMPILER=%COMPILER% CODE=%CODE% MODULE=%%i" 2 "..\..\debug\%%i.log" + +copy ..\..\debug\*.a ..\..\..\..\variants\linkit_one /y + +cd ..\..\build_gcc + +rem *************************************************************************** +rem *** run Sub module +rem *** %1 = submodule description +rem *** %2 = command line +rem *** %3 = error direction (1 or 2) +rem *** %4 = log filename +rem *** %5 = log pattern +:sub_run_module +echo -----------------%~1---------------- +echo =========================================================================== >> %LOG_FILE% +rem Reset the value of SUB_MODULE_RET to FAIL +set SUB_MODULE_RET=FAIL + +echo [%Time%] %~1 >> %LOG_FILE% + +%~2 %3> %~4 + +echo [%Time%] Executed %~1 >> %LOG_FILE% + +rem Check if the program return success or not +IF %ERRORLEVEL% EQU 0 SET SUB_MODULE_RET=OK +IF %ERRORLEVEL% EQU 1 SET SUB_MODULE_RET=OK + +IF NOT "%SUB_MODULE_RET%"=="OK" ( + echo Failed!! [%ERRORLEVEL%] >> %LOG_FILE% + call:sub_parse_error %~4 %~5 +)ELSE ( + echo Succeed. [%ERRORLEVEL%][%Time%] >> %LOG_FILE% +) + +echo. >> %LOG_FILE% +goto:eof + + + +rem ************************************************************ +rem **************** Parse Error function ********************** +rem ************************************************************ +:sub_parse_error +echo log = [%1], error summarized: >> %LOG_FILE% +echo. >> %LOG_FILE% + +IF .%2==. ( + FINDSTR /I /N /R "\" %1 > ~tmp.str +) ELSE ( + FINDSTR /I /N /R "\<%2\>" %1 > ~tmp.str +) +type ~tmp.str >> %LOG_FILE% +del ~tmp.str +goto:eof \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/chip.h b/hardware/arduino/mtk/system/libmtk/chip.h new file mode 100644 index 00000000..72b4f408 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/chip.h @@ -0,0 +1,33 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _LIB_MTK_ +#define _LIB_MTK_ + +/* + * Core and peripherals registers definitions + */ +#include "include/vmsys.h" +//#include "include/vmtsdcl.h" + +//#include "include/vmtsdcl_i2c.h" +//#include "include/vmtsdcl_gpio.h" +//#include "include/vmtsdcl_eint.h" + + +#endif /* _LIB_MTK_ */ diff --git a/hardware/arduino/mtk/system/libmtk/debug/get_http_head.o b/hardware/arduino/mtk/system/libmtk/debug/get_http_head.o new file mode 100644 index 00000000..b60ed6ec Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/get_http_head.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/get_http_head_by_index.o b/hardware/arduino/mtk/system/libmtk/debug/get_http_head_by_index.o new file mode 100644 index 00000000..a54cf8cc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/get_http_head_by_index.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/get_http_head_number.o b/hardware/arduino/mtk/system/libmtk/debug/get_http_head_number.o new file mode 100644 index 00000000..86b7380a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/get_http_head_number.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/get_today_from_2000.o b/hardware/arduino/mtk/system/libmtk/debug/get_today_from_2000.o new file mode 100644 index 00000000..c566febd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/get_today_from_2000.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/libmtk.a b/hardware/arduino/mtk/system/libmtk/debug/libmtk.a new file mode 100644 index 00000000..4b3feb1e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/libmtk.a differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/libmtk.log b/hardware/arduino/mtk/system/libmtk/debug/libmtk.log new file mode 100644 index 00000000..d4eeee75 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/debug/libmtk.log @@ -0,0 +1,5 @@ +./libmtk/vmlog.c: In function 'log_it': +./libmtk/vmlog.c:76: warning: incompatible implicit declaration of built-in function 'memset' +./libmtk/vmlog.c:80: warning: incompatible implicit declaration of built-in function 'strlen' +./libmtk/vmlog.c:94: warning: incompatible implicit declaration of built-in function 'strncpy' +./libmtk/vmlog.c:100: warning: incompatible implicit declaration of built-in function 'strcat' diff --git a/hardware/arduino/mtk/system/libmtk/debug/rand.o b/hardware/arduino/mtk/system/libmtk/debug/rand.o new file mode 100644 index 00000000..325be112 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/rand.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/srand.o b/hardware/arduino/mtk/system/libmtk/debug/srand.o new file mode 100644 index 00000000..3246bad9 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/srand.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/strtoi.o b/hardware/arduino/mtk/system/libmtk/debug/strtoi.o new file mode 100644 index 00000000..6fb7756f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/strtoi.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/stubgen.log b/hardware/arduino/mtk/system/libmtk/debug/stubgen.log new file mode 100644 index 00000000..b3ca29c3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/debug/stubgen.log @@ -0,0 +1,5 @@ +=========================================================================== +[10:09:30.53] make GCCARM libmtk +[10:10:06.53] Executed make GCCARM libmtk +Succeed. [0][10:10:06.53] + diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm4res.o b/hardware/arduino/mtk/system/libmtk/debug/vm4res.o new file mode 100644 index 00000000..b319b407 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm4res.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_accept.o b/hardware/arduino/mtk/system/libmtk/debug/vm_accept.o new file mode 100644 index 00000000..0e5aebbc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_accept.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_app_log.o b/hardware/arduino/mtk/system/libmtk/debug/vm_app_log.o new file mode 100644 index 00000000..b718d50c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_app_log.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_dereg_msg_proc.o b/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_dereg_msg_proc.o new file mode 100644 index 00000000..11172227 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_dereg_msg_proc.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_dispatch_msg.o b/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_dispatch_msg.o new file mode 100644 index 00000000..abe873ec Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_dispatch_msg.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_init.o b/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_init.o new file mode 100644 index 00000000..ee9df06b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_init.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_post_msg.o b/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_post_msg.o new file mode 100644 index 00000000..ba3a9f44 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_post_msg.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_reg_msg_proc.o b/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_reg_msg_proc.o new file mode 100644 index 00000000..00ba1b8b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_reg_msg_proc.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_send_msg.o b/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_send_msg.o new file mode 100644 index 00000000..083fe763 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_appcomm_send_msg.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ascii_to_ucs2.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ascii_to_ucs2.o new file mode 100644 index 00000000..66218aee Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ascii_to_ucs2.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_assert.o b/hardware/arduino/mtk/system/libmtk/debug/vm_assert.o new file mode 100644 index 00000000..c9fa4512 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_assert.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_asyn_http_req.o b/hardware/arduino/mtk/system/libmtk/debug/vm_asyn_http_req.o new file mode 100644 index 00000000..6d4f096d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_asyn_http_req.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_atof.o b/hardware/arduino/mtk/system/libmtk/debug/vm_atof.o new file mode 100644 index 00000000..409ba84f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_atof.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_bytes_duration.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_bytes_duration.o new file mode 100644 index 00000000..8d96a6c9 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_bytes_duration.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_clear_interrupt_callback.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_clear_interrupt_callback.o new file mode 100644 index 00000000..a5085850 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_clear_interrupt_callback.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_duration.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_duration.o new file mode 100644 index 00000000..8d74b67a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_duration.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_get_time.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_get_time.o new file mode 100644 index 00000000..e20aae33 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_get_time.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_is_app_playing.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_is_app_playing.o new file mode 100644 index 00000000..f31bf15d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_is_app_playing.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_is_calling.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_is_calling.o new file mode 100644 index 00000000..223739ae Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_is_calling.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_close.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_close.o new file mode 100644 index 00000000..bc9a5aee Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_close.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_close_all.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_close_all.o new file mode 100644 index 00000000..d9d6b0ef Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_close_all.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_get_time.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_get_time.o new file mode 100644 index 00000000..29d847b8 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_get_time.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_open.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_open.o new file mode 100644 index 00000000..a72941cd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_open.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_pause.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_pause.o new file mode 100644 index 00000000..46a10cb9 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_pause.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_play.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_play.o new file mode 100644 index 00000000..e6116f14 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_play.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_resume.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_resume.o new file mode 100644 index 00000000..9f555d44 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_resume.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_set_speedup_mode.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_set_speedup_mode.o new file mode 100644 index 00000000..751fdd4a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_set_speedup_mode.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_set_start_time.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_set_start_time.o new file mode 100644 index 00000000..ee53bfbe Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_set_start_time.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_stop.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_stop.o new file mode 100644 index 00000000..6295aea4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_mixed_stop.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_pause.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_pause.o new file mode 100644 index 00000000..d1519fcf Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_pause.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_pitch_shifting_set_level.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_pitch_shifting_set_level.o new file mode 100644 index 00000000..e7ffb72d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_pitch_shifting_set_level.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_pitch_shifting_turn_off.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_pitch_shifting_turn_off.o new file mode 100644 index 00000000..d8d8ad52 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_pitch_shifting_turn_off.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_pitch_shifting_turn_on.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_pitch_shifting_turn_on.o new file mode 100644 index 00000000..2dde7647 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_pitch_shifting_turn_on.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_beep.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_beep.o new file mode 100644 index 00000000..ae3733b3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_beep.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_bytes.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_bytes.o new file mode 100644 index 00000000..20d307fa Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_bytes.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_bytes_no_block.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_bytes_no_block.o new file mode 100644 index 00000000..b2f67bbf Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_bytes_no_block.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_file.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_file.o new file mode 100644 index 00000000..9f2f2ca8 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_file.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_file_ex.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_file_ex.o new file mode 100644 index 00000000..559fe6cc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_play_file_ex.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_register_interrupt_callback.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_register_interrupt_callback.o new file mode 100644 index 00000000..503e7a79 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_register_interrupt_callback.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_resume.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_resume.o new file mode 100644 index 00000000..519b7c60 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_resume.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_resume_bg_play.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_resume_bg_play.o new file mode 100644 index 00000000..6c67e65f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_resume_bg_play.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_set_volume_type.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_set_volume_type.o new file mode 100644 index 00000000..bb47c4f5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_set_volume_type.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_stop.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_stop.o new file mode 100644 index 00000000..6bd43ff2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_stop.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_stop_all.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_stop_all.o new file mode 100644 index 00000000..afe8c0cc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_stop_all.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_suspend_bg_play.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_suspend_bg_play.o new file mode 100644 index 00000000..25458e04 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_suspend_bg_play.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_terminate_background_play.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_terminate_background_play.o new file mode 100644 index 00000000..5636a78a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_terminate_background_play.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_vocal_removal_turn_off.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_vocal_removal_turn_off.o new file mode 100644 index 00000000..1b8c6a5a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_vocal_removal_turn_off.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_audio_vocal_removal_turn_on.o b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_vocal_removal_turn_on.o new file mode 100644 index 00000000..d41ab0bf Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_audio_vocal_removal_turn_on.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_base64_decode_basic.o b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_decode_basic.o new file mode 100644 index 00000000..b81c2a10 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_decode_basic.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_base64_encode_basic.o b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_encode_basic.o new file mode 100644 index 00000000..5075abd7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_encode_basic.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_decode_append.o b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_decode_append.o new file mode 100644 index 00000000..cb485efa Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_decode_append.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_decode_finish.o b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_decode_finish.o new file mode 100644 index 00000000..d198c313 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_decode_finish.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_decode_init.o b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_decode_init.o new file mode 100644 index 00000000..840b6ee3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_decode_init.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_encode_append.o b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_encode_append.o new file mode 100644 index 00000000..dc3fa071 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_encode_append.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_encode_finish.o b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_encode_finish.o new file mode 100644 index 00000000..43c85d8a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_encode_finish.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_encode_init.o b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_encode_init.o new file mode 100644 index 00000000..b2907cef Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_base64_part_encode_init.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_bearer_close.o b/hardware/arduino/mtk/system/libmtk/debug/vm_bearer_close.o new file mode 100644 index 00000000..0d40a87d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_bearer_close.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_bearer_open.o b/hardware/arduino/mtk/system/libmtk/debug/vm_bearer_open.o new file mode 100644 index 00000000..50189839 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_bearer_open.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_bind.o b/hardware/arduino/mtk/system/libmtk/debug/vm_bind.o new file mode 100644 index 00000000..5a15b5d2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_bind.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_bridge_close.o b/hardware/arduino/mtk/system/libmtk/debug/vm_bridge_close.o new file mode 100644 index 00000000..708cc380 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_bridge_close.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_bridge_create.o b/hardware/arduino/mtk/system/libmtk/debug/vm_bridge_create.o new file mode 100644 index 00000000..7a203c38 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_bridge_create.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_bt_cm_send_passkey.o b/hardware/arduino/mtk/system/libmtk/debug/vm_bt_cm_send_passkey.o new file mode 100644 index 00000000..bc19fa5c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_bt_cm_send_passkey.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_bt_noti_check_channel_valid.o b/hardware/arduino/mtk/system/libmtk/debug/vm_bt_noti_check_channel_valid.o new file mode 100644 index 00000000..c2fe52ce Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_bt_noti_check_channel_valid.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_bt_noti_get_bt_device_addr.o b/hardware/arduino/mtk/system/libmtk/debug/vm_bt_noti_get_bt_device_addr.o new file mode 100644 index 00000000..60d45b68 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_bt_noti_get_bt_device_addr.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_exit.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_exit.o new file mode 100644 index 00000000..9a31a795 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_exit.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_get_dev_info_by_index.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_get_dev_info_by_index.o new file mode 100644 index 00000000..e6b00891 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_get_dev_info_by_index.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_get_dev_num.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_get_dev_num.o new file mode 100644 index 00000000..d0cbea43 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_get_dev_num.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_get_host_dev_info.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_get_host_dev_info.o new file mode 100644 index 00000000..122e7244 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_get_host_dev_info.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_get_power_status.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_get_power_status.o new file mode 100644 index 00000000..0901f0cc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_get_power_status.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_init.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_init.o new file mode 100644 index 00000000..4524f8fe Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_init.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_search.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_search.o new file mode 100644 index 00000000..1d4dc5ae Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_search.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_search_abort.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_search_abort.o new file mode 100644 index 00000000..d804ec8f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_search_abort.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_set_host_name.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_set_host_name.o new file mode 100644 index 00000000..845f06c3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_set_host_name.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_srv_get_visibility.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_srv_get_visibility.o new file mode 100644 index 00000000..19eefcc0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_srv_get_visibility.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_srv_set_visibility.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_srv_set_visibility.o new file mode 100644 index 00000000..71f5d592 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_srv_set_visibility.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_switch_off.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_switch_off.o new file mode 100644 index 00000000..e2f88dd4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_switch_off.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_switch_on.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_switch_on.o new file mode 100644 index 00000000..f0044126 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btcm_switch_on.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_accept.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_accept.o new file mode 100644 index 00000000..3ed59504 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_accept.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_bind.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_bind.o new file mode 100644 index 00000000..e3f3e42d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_bind.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_close.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_close.o new file mode 100644 index 00000000..ac965506 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_close.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_connect.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_connect.o new file mode 100644 index 00000000..ef939ad6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_connect.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_connect_ex.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_connect_ex.o new file mode 100644 index 00000000..6a582264 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_connect_ex.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_disconnect.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_disconnect.o new file mode 100644 index 00000000..2236acab Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_disconnect.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_get_dev_addr.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_get_dev_addr.o new file mode 100644 index 00000000..9b2b7211 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_get_dev_addr.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_get_min_buf_size.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_get_min_buf_size.o new file mode 100644 index 00000000..9e877277 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_get_min_buf_size.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_open.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_open.o new file mode 100644 index 00000000..7426e1d7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_open.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_read.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_read.o new file mode 100644 index 00000000..77ebd180 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_read.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_reject.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_reject.o new file mode 100644 index 00000000..8c870d6a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_reject.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_set_security_level.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_set_security_level.o new file mode 100644 index 00000000..5029d462 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_set_security_level.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_set_service_name.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_set_service_name.o new file mode 100644 index 00000000..45b701ff Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_set_service_name.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_write.o b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_write.o new file mode 100644 index 00000000..de7b6193 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_btspp_write.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_cache_read_char.o b/hardware/arduino/mtk/system/libmtk/debug/vm_cache_read_char.o new file mode 100644 index 00000000..f79ccee8 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_cache_read_char.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_call_actions.o b/hardware/arduino/mtk/system/libmtk/debug/vm_call_actions.o new file mode 100644 index 00000000..1d64b3fe Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_call_actions.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_call_reg_listener.o b/hardware/arduino/mtk/system/libmtk/debug/vm_call_reg_listener.o new file mode 100644 index 00000000..a71da8ba Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_call_reg_listener.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_calloc.o b/hardware/arduino/mtk/system/libmtk/debug/vm_calloc.o new file mode 100644 index 00000000..41220bd9 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_calloc.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_callout.o b/hardware/arduino/mtk/system/libmtk/debug/vm_callout.o new file mode 100644 index 00000000..86938c03 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_callout.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_callout_ex.o b/hardware/arduino/mtk/system/libmtk/debug/vm_callout_ex.o new file mode 100644 index 00000000..6692a6db Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_callout_ex.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_camera_startup.o b/hardware/arduino/mtk/system/libmtk/debug/vm_camera_startup.o new file mode 100644 index 00000000..a19148f2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_camera_startup.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_cancel_all_http_sessions.o b/hardware/arduino/mtk/system/libmtk/debug/vm_cancel_all_http_sessions.o new file mode 100644 index 00000000..852cc175 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_cancel_all_http_sessions.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_cancel_asyn_http_req.o b/hardware/arduino/mtk/system/libmtk/debug/vm_cancel_asyn_http_req.o new file mode 100644 index 00000000..d4f6a98c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_cancel_asyn_http_req.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_cancel_kal_timer.o b/hardware/arduino/mtk/system/libmtk/debug/vm_cancel_kal_timer.o new file mode 100644 index 00000000..fdeaf4ce Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_cancel_kal_timer.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_cancel_send_sms.o b/hardware/arduino/mtk/system/libmtk/debug/vm_cancel_send_sms.o new file mode 100644 index 00000000..0e0050e6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_cancel_send_sms.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_cbm_hold_bearer.o b/hardware/arduino/mtk/system/libmtk/debug/vm_cbm_hold_bearer.o new file mode 100644 index 00000000..59016598 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_cbm_hold_bearer.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_cbm_release_bearer.o b/hardware/arduino/mtk/system/libmtk/debug/vm_cbm_release_bearer.o new file mode 100644 index 00000000..b207ac25 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_cbm_release_bearer.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ce_auth_app_ex.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ce_auth_app_ex.o new file mode 100644 index 00000000..e28d818e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ce_auth_app_ex.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_cell_close.o b/hardware/arduino/mtk/system/libmtk/debug/vm_cell_close.o new file mode 100644 index 00000000..4168c5db Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_cell_close.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_cell_get_cur_cell_info.o b/hardware/arduino/mtk/system/libmtk/debug/vm_cell_get_cur_cell_info.o new file mode 100644 index 00000000..36519e9b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_cell_get_cur_cell_info.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_cell_get_nbr_cell_info.o b/hardware/arduino/mtk/system/libmtk/debug/vm_cell_get_nbr_cell_info.o new file mode 100644 index 00000000..8e8c244d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_cell_get_nbr_cell_info.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_cell_get_nbr_num.o b/hardware/arduino/mtk/system/libmtk/debug/vm_cell_get_nbr_num.o new file mode 100644 index 00000000..dc914686 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_cell_get_nbr_num.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_cell_open.o b/hardware/arduino/mtk/system/libmtk/debug/vm_cell_open.o new file mode 100644 index 00000000..b36123e6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_cell_open.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_charbat_is_charging.o b/hardware/arduino/mtk/system/libmtk/debug/vm_charbat_is_charging.o new file mode 100644 index 00000000..ac69683b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_charbat_is_charging.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_che_deinit.o b/hardware/arduino/mtk/system/libmtk/debug/vm_che_deinit.o new file mode 100644 index 00000000..aa364bd1 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_che_deinit.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_che_init.o b/hardware/arduino/mtk/system/libmtk/debug/vm_che_init.o new file mode 100644 index 00000000..b8f7db44 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_che_init.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_che_key_action.o b/hardware/arduino/mtk/system/libmtk/debug/vm_che_key_action.o new file mode 100644 index 00000000..fc6fd67b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_che_key_action.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_che_process.o b/hardware/arduino/mtk/system/libmtk/debug/vm_che_process.o new file mode 100644 index 00000000..e7f06075 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_che_process.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_che_rsa_private_decrypt.o b/hardware/arduino/mtk/system/libmtk/debug/vm_che_rsa_private_decrypt.o new file mode 100644 index 00000000..cf9965a2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_che_rsa_private_decrypt.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_che_rsa_private_encrypt.o b/hardware/arduino/mtk/system/libmtk/debug/vm_che_rsa_private_encrypt.o new file mode 100644 index 00000000..db582af9 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_che_rsa_private_encrypt.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_che_rsa_public_decrypt.o b/hardware/arduino/mtk/system/libmtk/debug/vm_che_rsa_public_decrypt.o new file mode 100644 index 00000000..50254d5a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_che_rsa_public_decrypt.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_che_rsa_public_encrypt.o b/hardware/arduino/mtk/system/libmtk/debug/vm_che_rsa_public_encrypt.o new file mode 100644 index 00000000..b8292945 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_che_rsa_public_encrypt.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_che_set_iv.o b/hardware/arduino/mtk/system/libmtk/debug/vm_che_set_iv.o new file mode 100644 index 00000000..87ebd9eb Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_che_set_iv.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_chset_convert.o b/hardware/arduino/mtk/system/libmtk/debug/vm_chset_convert.o new file mode 100644 index 00000000..4e590f69 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_chset_convert.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_closesocket.o b/hardware/arduino/mtk/system/libmtk/debug/vm_closesocket.o new file mode 100644 index 00000000..da01b2b7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_closesocket.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_command_close_port.o b/hardware/arduino/mtk/system/libmtk/debug/vm_command_close_port.o new file mode 100644 index 00000000..f9d61d9d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_command_close_port.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_command_open_port.o b/hardware/arduino/mtk/system/libmtk/debug/vm_command_open_port.o new file mode 100644 index 00000000..1c2e93f4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_command_open_port.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_command_reply.o b/hardware/arduino/mtk/system/libmtk/debug/vm_command_reply.o new file mode 100644 index 00000000..0d1013c3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_command_reply.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_connect.o b/hardware/arduino/mtk/system/libmtk/debug/vm_connect.o new file mode 100644 index 00000000..8115ab5c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_connect.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_create_array_stack.o b/hardware/arduino/mtk/system/libmtk/debug/vm_create_array_stack.o new file mode 100644 index 00000000..31ada93c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_create_array_stack.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_create_dyn_array.o b/hardware/arduino/mtk/system/libmtk/debug/vm_create_dyn_array.o new file mode 100644 index 00000000..134a1d4d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_create_dyn_array.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_create_kal_timer.o b/hardware/arduino/mtk/system/libmtk/debug/vm_create_kal_timer.o new file mode 100644 index 00000000..a684b667 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_create_kal_timer.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_create_linked_stack.o b/hardware/arduino/mtk/system/libmtk/debug/vm_create_linked_stack.o new file mode 100644 index 00000000..a72c48fd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_create_linked_stack.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_create_timer.o b/hardware/arduino/mtk/system/libmtk/debug/vm_create_timer.o new file mode 100644 index 00000000..b86aa8d1 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_create_timer.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_create_timer_ex.o b/hardware/arduino/mtk/system/libmtk/debug/vm_create_timer_ex.o new file mode 100644 index 00000000..c55ec2ea Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_create_timer_ex.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_custom_set_bt_pairing_method.o b/hardware/arduino/mtk/system/libmtk/debug/vm_custom_set_bt_pairing_method.o new file mode 100644 index 00000000..61206485 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_custom_set_bt_pairing_method.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_da_display_download_list.o b/hardware/arduino/mtk/system/libmtk/debug/vm_da_display_download_list.o new file mode 100644 index 00000000..7722dc10 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_da_display_download_list.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_da_http_dl_operation.o b/hardware/arduino/mtk/system/libmtk/debug/vm_da_http_dl_operation.o new file mode 100644 index 00000000..9f786724 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_da_http_dl_operation.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_da_http_start_download.o b/hardware/arduino/mtk/system/libmtk/debug/vm_da_http_start_download.o new file mode 100644 index 00000000..0c37ef79 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_da_http_start_download.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_delete_timer.o b/hardware/arduino/mtk/system/libmtk/debug/vm_delete_timer.o new file mode 100644 index 00000000..22148982 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_delete_timer.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_delete_timer_ex.o b/hardware/arduino/mtk/system/libmtk/debug/vm_delete_timer_ex.o new file mode 100644 index 00000000..168bec1d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_delete_timer_ex.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_des_decrypt.o b/hardware/arduino/mtk/system/libmtk/debug/vm_des_decrypt.o new file mode 100644 index 00000000..ef6222aa Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_des_decrypt.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_des_encrypt.o b/hardware/arduino/mtk/system/libmtk/debug/vm_des_encrypt.o new file mode 100644 index 00000000..beaeeb04 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_des_encrypt.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_des_reset_key.o b/hardware/arduino/mtk/system/libmtk/debug/vm_des_reset_key.o new file mode 100644 index 00000000..5a9f4c4b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_des_reset_key.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_des_set_key.o b/hardware/arduino/mtk/system/libmtk/debug/vm_des_set_key.o new file mode 100644 index 00000000..9cf01a39 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_des_set_key.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_destroy_stack.o b/hardware/arduino/mtk/system/libmtk/debug/vm_destroy_stack.o new file mode 100644 index 00000000..0266f4f5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_destroy_stack.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_client_get_mode.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_client_get_mode.o new file mode 100644 index 00000000..3f66bb79 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_client_get_mode.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_client_set_mode.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_client_set_mode.o new file mode 100644 index 00000000..e64a2f77 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_client_set_mode.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_server_get_mode.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_server_get_mode.o new file mode 100644 index 00000000..d8cc284f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_server_get_mode.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_server_get_param.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_server_get_param.o new file mode 100644 index 00000000..47b58bd3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_server_get_param.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_server_set_mode.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_server_set_mode.o new file mode 100644 index 00000000..58d3ee8e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_server_set_mode.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_server_set_param.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_server_set_param.o new file mode 100644 index 00000000..0a52129e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dhcp_server_set_param.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dialer_launch.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dialer_launch.o new file mode 100644 index 00000000..e0f7b787 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dialer_launch.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dns_get_state.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dns_get_state.o new file mode 100644 index 00000000..3ca87b0d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dns_get_state.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dns_start.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dns_start.o new file mode 100644 index 00000000..6f1308e7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dns_start.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dns_stop.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dns_stop.o new file mode 100644 index 00000000..7022cef4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dns_stop.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dtacct_select.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dtacct_select.o new file mode 100644 index 00000000..864bbe8c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dtacct_select.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dtacct_set.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dtacct_set.o new file mode 100644 index 00000000..b40555b3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dtacct_set.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dyn_array_add.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dyn_array_add.o new file mode 100644 index 00000000..bc64776c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dyn_array_add.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dyn_array_del.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dyn_array_del.o new file mode 100644 index 00000000..10055ef5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dyn_array_del.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_dyn_array_del_all.o b/hardware/arduino/mtk/system/libmtk/debug/vm_dyn_array_del_all.o new file mode 100644 index 00000000..e3368219 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_dyn_array_del_all.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_em_send_command.o b/hardware/arduino/mtk/system/libmtk/debug/vm_em_send_command.o new file mode 100644 index 00000000..a84fefd1 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_em_send_command.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_enable_proxy.o b/hardware/arduino/mtk/system/libmtk/debug/vm_enable_proxy.o new file mode 100644 index 00000000..1d5b4f82 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_enable_proxy.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ends_with.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ends_with.o new file mode 100644 index 00000000..57a7600b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ends_with.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_exit_app.o b/hardware/arduino/mtk/system/libmtk/debug/vm_exit_app.o new file mode 100644 index 00000000..abee06d4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_exit_app.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_close.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_close.o new file mode 100644 index 00000000..012a7fb0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_close.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_commit.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_commit.o new file mode 100644 index 00000000..2ad4b0ad Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_commit.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_copy.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_copy.o new file mode 100644 index 00000000..8c7ced54 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_copy.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_copy_abort.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_copy_abort.o new file mode 100644 index 00000000..e188831e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_copy_abort.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_delete.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_delete.o new file mode 100644 index 00000000..3cea728d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_delete.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_get_attributes.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_get_attributes.o new file mode 100644 index 00000000..e4626872 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_get_attributes.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_get_modify_time.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_get_modify_time.o new file mode 100644 index 00000000..aa97fb51 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_get_modify_time.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_getfilesize.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_getfilesize.o new file mode 100644 index 00000000..91af504e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_getfilesize.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_is_eof.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_is_eof.o new file mode 100644 index 00000000..7b504a6c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_is_eof.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_mkdir.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_mkdir.o new file mode 100644 index 00000000..ec0c263d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_mkdir.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_open.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_open.o new file mode 100644 index 00000000..4d4ec9cc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_open.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_read.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_read.o new file mode 100644 index 00000000..874a63fc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_read.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_rename.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_rename.o new file mode 100644 index 00000000..73febc25 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_rename.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_rmdir.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_rmdir.o new file mode 100644 index 00000000..a228c378 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_rmdir.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_seek.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_seek.o new file mode 100644 index 00000000..14b33a88 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_seek.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_set_attributes.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_set_attributes.o new file mode 100644 index 00000000..2cb523dd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_set_attributes.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_tell.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_tell.o new file mode 100644 index 00000000..95acf42a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_tell.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_file_write.o b/hardware/arduino/mtk/system/libmtk/debug/vm_file_write.o new file mode 100644 index 00000000..e2d077d1 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_file_write.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_find_close.o b/hardware/arduino/mtk/system/libmtk/debug/vm_find_close.o new file mode 100644 index 00000000..c7e13ec5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_find_close.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_find_close_ext.o b/hardware/arduino/mtk/system/libmtk/debug/vm_find_close_ext.o new file mode 100644 index 00000000..8900085c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_find_close_ext.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_find_first.o b/hardware/arduino/mtk/system/libmtk/debug/vm_find_first.o new file mode 100644 index 00000000..f57184ff Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_find_first.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_find_first_ext.o b/hardware/arduino/mtk/system/libmtk/debug/vm_find_first_ext.o new file mode 100644 index 00000000..a738181f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_find_first_ext.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_find_next.o b/hardware/arduino/mtk/system/libmtk/debug/vm_find_next.o new file mode 100644 index 00000000..426124d4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_find_next.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_find_next_ext.o b/hardware/arduino/mtk/system/libmtk/debug/vm_find_next_ext.o new file mode 100644 index 00000000..e3014e32 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_find_next_ext.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_fly_mode_is_network_service_available.o b/hardware/arduino/mtk/system/libmtk/debug/vm_fly_mode_is_network_service_available.o new file mode 100644 index 00000000..34f81011 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_fly_mode_is_network_service_available.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_fly_mode_is_switching.o b/hardware/arduino/mtk/system/libmtk/debug/vm_fly_mode_is_switching.o new file mode 100644 index 00000000..0a207f28 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_fly_mode_is_switching.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_fly_mode_switch.o b/hardware/arduino/mtk/system/libmtk/debug/vm_fly_mode_switch.o new file mode 100644 index 00000000..b5e95a96 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_fly_mode_switch.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_free.o b/hardware/arduino/mtk/system/libmtk/debug/vm_free.o new file mode 100644 index 00000000..2fe24929 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_free.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_free_dyn_array.o b/hardware/arduino/mtk/system/libmtk/debug/vm_free_dyn_array.o new file mode 100644 index 00000000..575c115d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_free_dyn_array.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_abort.o b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_abort.o new file mode 100644 index 00000000..caadaf8b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_abort.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_close.o b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_close.o new file mode 100644 index 00000000..2b7321f3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_close.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_commit.o b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_commit.o new file mode 100644 index 00000000..caa9c800 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_commit.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_delete.o b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_delete.o new file mode 100644 index 00000000..8fceb617 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_delete.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_get_working_buf_size.o b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_get_working_buf_size.o new file mode 100644 index 00000000..ed2e4455 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_get_working_buf_size.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_open.o b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_open.o new file mode 100644 index 00000000..9e3a9ce1 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_open.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_read.o b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_read.o new file mode 100644 index 00000000..71fe7433 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_read.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_seek.o b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_seek.o new file mode 100644 index 00000000..b3f16754 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_seek.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_write.o b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_write.o new file mode 100644 index 00000000..b4efb347 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_fs_async_write.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_gb2312_string.o b/hardware/arduino/mtk/system/libmtk/debug/vm_gb2312_string.o new file mode 100644 index 00000000..3bd9d40a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_gb2312_string.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_gb2312_to_ucs2.o b/hardware/arduino/mtk/system/libmtk/debug/vm_gb2312_to_ucs2.o new file mode 100644 index 00000000..c5de8145 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_gb2312_to_ucs2.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_apn_info.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_apn_info.o new file mode 100644 index 00000000..f237f36c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_apn_info.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_asyn_http_req_handle.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_asyn_http_req_handle.o new file mode 100644 index 00000000..0ba23362 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_asyn_http_req_handle.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_battery_level.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_battery_level.o new file mode 100644 index 00000000..0b9cf1c7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_battery_level.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_cache_free_space.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_cache_free_space.o new file mode 100644 index 00000000..0a8de368 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_cache_free_space.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_curr_utc.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_curr_utc.o new file mode 100644 index 00000000..3a310e4f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_curr_utc.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_current_lang_country_code.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_current_lang_country_code.o new file mode 100644 index 00000000..c0592669 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_current_lang_country_code.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_cust_apn_info.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_cust_apn_info.o new file mode 100644 index 00000000..7fa0b781 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_cust_apn_info.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_customer_name.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_customer_name.o new file mode 100644 index 00000000..ce42bdfe Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_customer_name.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_default_apn_info.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_default_apn_info.o new file mode 100644 index 00000000..352b994e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_default_apn_info.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_default_folder_path.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_default_folder_path.o new file mode 100644 index 00000000..f4546c2e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_default_folder_path.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_disk_free_space.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_disk_free_space.o new file mode 100644 index 00000000..4aa1fade Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_disk_free_space.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_disk_info.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_disk_info.o new file mode 100644 index 00000000..ea2ad913 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_disk_info.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_encoded_dtacct_id.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_encoded_dtacct_id.o new file mode 100644 index 00000000..1b24704a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_encoded_dtacct_id.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_exec_filename.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_exec_filename.o new file mode 100644 index 00000000..c1979929 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_exec_filename.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_filename.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_filename.o new file mode 100644 index 00000000..5b15cfa1 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_filename.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_full_path_by_short_name.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_full_path_by_short_name.o new file mode 100644 index 00000000..2e248e6a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_full_path_by_short_name.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_imei.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_imei.o new file mode 100644 index 00000000..09348cec Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_imei.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_imei_ext.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_imei_ext.o new file mode 100644 index 00000000..fb90cada Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_imei_ext.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_imsi.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_imsi.o new file mode 100644 index 00000000..b9d03357 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_imsi.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_language.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_language.o new file mode 100644 index 00000000..a26a6cf1 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_language.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_language_ssc.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_language_ssc.o new file mode 100644 index 00000000..eb0c7fd0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_language_ssc.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_malloc_stat.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_malloc_stat.o new file mode 100644 index 00000000..80e1d969 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_malloc_stat.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_modules.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_modules.o new file mode 100644 index 00000000..084394ce Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_modules.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_mre_modules.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_mre_modules.o new file mode 100644 index 00000000..323fef2c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_mre_modules.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_mre_total_mem_size.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_mre_total_mem_size.o new file mode 100644 index 00000000..a578ab81 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_mre_total_mem_size.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_mre_version.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_mre_version.o new file mode 100644 index 00000000..cf7e8f7a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_mre_version.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_multi_tags.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_multi_tags.o new file mode 100644 index 00000000..55ad87fb Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_multi_tags.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_multi_tags_by_lang_id.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_multi_tags_by_lang_id.o new file mode 100644 index 00000000..47012bd0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_multi_tags_by_lang_id.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_operator.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_operator.o new file mode 100644 index 00000000..b79e1292 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_operator.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_origin_release_verno.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_origin_release_verno.o new file mode 100644 index 00000000..d49b830a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_origin_release_verno.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_path.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_path.o new file mode 100644 index 00000000..bfd5d7cd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_path.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_removable_driver.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_removable_driver.o new file mode 100644 index 00000000..d0c901c3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_removable_driver.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_res_header.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_res_header.o new file mode 100644 index 00000000..60ebb7ef Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_res_header.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_resource_offset.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_resource_offset.o new file mode 100644 index 00000000..6ce3d1ac Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_resource_offset.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_resource_offset_from_file.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_resource_offset_from_file.o new file mode 100644 index 00000000..be90b778 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_resource_offset_from_file.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_rtc.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_rtc.o new file mode 100644 index 00000000..54069f9d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_rtc.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_sim_card_status.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_sim_card_status.o new file mode 100644 index 00000000..b6426036 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_sim_card_status.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_sys_property.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_sys_property.o new file mode 100644 index 00000000..a9a0ddf9 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_sys_property.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_sys_scene.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_sys_scene.o new file mode 100644 index 00000000..ef05c4dc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_sys_scene.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_sys_time_zone.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_sys_time_zone.o new file mode 100644 index 00000000..ae5c1b85 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_sys_time_zone.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_system_driver.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_system_driver.o new file mode 100644 index 00000000..4c7fa5a7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_system_driver.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_tag_by_lang_id.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_tag_by_lang_id.o new file mode 100644 index 00000000..0b890d38 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_tag_by_lang_id.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_tick_count.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_tick_count.o new file mode 100644 index 00000000..bd16bbc7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_tick_count.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_time.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_time.o new file mode 100644 index 00000000..5c35f145 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_time.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_total_mem_size.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_total_mem_size.o new file mode 100644 index 00000000..e4e0725c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_total_mem_size.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_version.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_version.o new file mode 100644 index 00000000..e4314abb Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_version.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_vm_tag.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_vm_tag.o new file mode 100644 index 00000000..e5a7ec33 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_vm_tag.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_get_volume.o b/hardware/arduino/mtk/system/libmtk/debug/vm_get_volume.o new file mode 100644 index 00000000..6b0767b2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_get_volume.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_getpeername.o b/hardware/arduino/mtk/system/libmtk/debug/vm_getpeername.o new file mode 100644 index 00000000..ac5a1095 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_getpeername.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_getsockname.o b/hardware/arduino/mtk/system/libmtk/debug/vm_getsockname.o new file mode 100644 index 00000000..c4c07ae0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_getsockname.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_getsockopt.o b/hardware/arduino/mtk/system/libmtk/debug/vm_getsockopt.o new file mode 100644 index 00000000..99357e73 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_getsockopt.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_global_free.o b/hardware/arduino/mtk/system/libmtk/debug/vm_global_free.o new file mode 100644 index 00000000..08996872 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_global_free.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_global_get_max_alloc_size.o b/hardware/arduino/mtk/system/libmtk/debug/vm_global_get_max_alloc_size.o new file mode 100644 index 00000000..0cbc33b4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_global_get_max_alloc_size.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_global_malloc.o b/hardware/arduino/mtk/system/libmtk/debug/vm_global_malloc.o new file mode 100644 index 00000000..1237e10e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_global_malloc.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_gps_close.o b/hardware/arduino/mtk/system/libmtk/debug/vm_gps_close.o new file mode 100644 index 00000000..fe39cb23 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_gps_close.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_gps_open.o b/hardware/arduino/mtk/system/libmtk/debug/vm_gps_open.o new file mode 100644 index 00000000..03cad74c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_gps_open.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_gps_set_mode.o b/hardware/arduino/mtk/system/libmtk/debug/vm_gps_set_mode.o new file mode 100644 index 00000000..43714dce Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_gps_set_mode.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_has_sim_card.o b/hardware/arduino/mtk/system/libmtk/debug/vm_has_sim_card.o new file mode 100644 index 00000000..7eeb82b2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_has_sim_card.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_htonl.o b/hardware/arduino/mtk/system/libmtk/debug/vm_htonl.o new file mode 100644 index 00000000..2093e973 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_htonl.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_htons.o b/hardware/arduino/mtk/system/libmtk/debug/vm_htons.o new file mode 100644 index 00000000..d165faed Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_htons.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_http_add_header.o b/hardware/arduino/mtk/system/libmtk/debug/vm_http_add_header.o new file mode 100644 index 00000000..079d2bb8 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_http_add_header.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_http_fetch_handle.o b/hardware/arduino/mtk/system/libmtk/debug/vm_http_fetch_handle.o new file mode 100644 index 00000000..ac911210 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_http_fetch_handle.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_http_free_handle.o b/hardware/arduino/mtk/system/libmtk/debug/vm_http_free_handle.o new file mode 100644 index 00000000..f82bca21 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_http_free_handle.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_http_get_current_handle.o b/hardware/arduino/mtk/system/libmtk/debug/vm_http_get_current_handle.o new file mode 100644 index 00000000..54a75a8d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_http_get_current_handle.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_http_recv_data.o b/hardware/arduino/mtk/system/libmtk/debug/vm_http_recv_data.o new file mode 100644 index 00000000..d27f40c5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_http_recv_data.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_http_reg_receiver.o b/hardware/arduino/mtk/system/libmtk/debug/vm_http_reg_receiver.o new file mode 100644 index 00000000..761bc0bd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_http_reg_receiver.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_http_reg_sender.o b/hardware/arduino/mtk/system/libmtk/debug/vm_http_reg_sender.o new file mode 100644 index 00000000..81f49d1c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_http_reg_sender.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_http_request.o b/hardware/arduino/mtk/system/libmtk/debug/vm_http_request.o new file mode 100644 index 00000000..8ee631b6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_http_request.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_http_send_data.o b/hardware/arduino/mtk/system/libmtk/debug/vm_http_send_data.o new file mode 100644 index 00000000..2d6eb3f6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_http_send_data.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_http_set_body.o b/hardware/arduino/mtk/system/libmtk/debug/vm_http_set_body.o new file mode 100644 index 00000000..37bef89c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_http_set_body.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_http_set_current_handle.o b/hardware/arduino/mtk/system/libmtk/debug/vm_http_set_current_handle.o new file mode 100644 index 00000000..e5213885 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_http_set_current_handle.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_http_set_url.o b/hardware/arduino/mtk/system/libmtk/debug/vm_http_set_url.o new file mode 100644 index 00000000..d346d9fc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_http_set_url.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_https_register_wps_cntxt_and_callback.o b/hardware/arduino/mtk/system/libmtk/debug/vm_https_register_wps_cntxt_and_callback.o new file mode 100644 index 00000000..96e67916 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_https_register_wps_cntxt_and_callback.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_cancel_req.o b/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_cancel_req.o new file mode 100644 index 00000000..201fff50 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_cancel_req.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_post_content_res.o b/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_post_content_res.o new file mode 100644 index 00000000..96665b14 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_post_content_res.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_read_content_req.o b/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_read_content_req.o new file mode 100644 index 00000000..4e48cefe Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_read_content_req.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_req.o b/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_req.o new file mode 100644 index 00000000..1f09d966 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_req.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_req_ext.o b/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_req_ext.o new file mode 100644 index 00000000..9c222bf0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_req_ext.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_set_channel_req.o b/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_set_channel_req.o new file mode 100644 index 00000000..49cbb856 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_set_channel_req.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_unset_channel_req.o b/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_unset_channel_req.o new file mode 100644 index 00000000..3b316be8 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_https_send_unset_channel_req.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_idle_swatch_pedometer_register_callback.o b/hardware/arduino/mtk/system/libmtk/debug/vm_idle_swatch_pedometer_register_callback.o new file mode 100644 index 00000000..63a31023 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_idle_swatch_pedometer_register_callback.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_addr.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_addr.o new file mode 100644 index 00000000..de81a0c1 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_addr.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_ftpd_restart.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_ftpd_restart.o new file mode 100644 index 00000000..fcd1a3e0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_ftpd_restart.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_ftpd_start.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_ftpd_start.o new file mode 100644 index 00000000..b1a5e3e2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_ftpd_start.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_ftpd_stop.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_ftpd_stop.o new file mode 100644 index 00000000..e9b531dd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_ftpd_stop.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_cgi_job_finish.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_cgi_job_finish.o new file mode 100644 index 00000000..3d42f202 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_cgi_job_finish.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_disable_ssl.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_disable_ssl.o new file mode 100644 index 00000000..244458a0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_disable_ssl.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_enable_ssl.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_enable_ssl.o new file mode 100644 index 00000000..c685f636 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_enable_ssl.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_getenv.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_getenv.o new file mode 100644 index 00000000..a66a63ab Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_getenv.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_read.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_read.o new file mode 100644 index 00000000..4f3d7b62 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_read.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_restart.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_restart.o new file mode 100644 index 00000000..e82f6382 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_restart.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_start.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_start.o new file mode 100644 index 00000000..18157cfd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_start.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_stop.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_stop.o new file mode 100644 index 00000000..05c01cd7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_stop.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_write.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_write.o new file mode 100644 index 00000000..cb6078bc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_httpd_write.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_ntoa.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_ntoa.o new file mode 100644 index 00000000..0a9d1491 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_ntoa.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_register_cb.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_register_cb.o new file mode 100644 index 00000000..aeace3c6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_register_cb.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_restart.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_restart.o new file mode 100644 index 00000000..237bfa49 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_restart.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_set_stream_identify.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_set_stream_identify.o new file mode 100644 index 00000000..4fe92d64 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_set_stream_identify.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_start.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_start.o new file mode 100644 index 00000000..54241149 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_start.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_stop.o b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_stop.o new file mode 100644 index 00000000..a7f009a6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_inet_rtspd_stop.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_is_empty_stack.o b/hardware/arduino/mtk/system/libmtk/debug/vm_is_empty_stack.o new file mode 100644 index 00000000..2b092b7f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_is_empty_stack.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_is_exist_stack.o b/hardware/arduino/mtk/system/libmtk/debug/vm_is_exist_stack.o new file mode 100644 index 00000000..8345383c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_is_exist_stack.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_is_support_camera_sensor.o b/hardware/arduino/mtk/system/libmtk/debug/vm_is_support_camera_sensor.o new file mode 100644 index 00000000..4b79290f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_is_support_camera_sensor.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_is_support_gsensor.o b/hardware/arduino/mtk/system/libmtk/debug/vm_is_support_gsensor.o new file mode 100644 index 00000000..ebb78556 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_is_support_gsensor.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_is_support_wifi.o b/hardware/arduino/mtk/system/libmtk/debug/vm_is_support_wifi.o new file mode 100644 index 00000000..a2f071e0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_is_support_wifi.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ivr_call.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ivr_call.o new file mode 100644 index 00000000..3fe80e57 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ivr_call.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ivr_dial_number.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ivr_dial_number.o new file mode 100644 index 00000000..902a3eef Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ivr_dial_number.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ivr_end.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ivr_end.o new file mode 100644 index 00000000..4b1c2b60 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ivr_end.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_listen.o b/hardware/arduino/mtk/system/libmtk/debug/vm_listen.o new file mode 100644 index 00000000..9b70062c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_listen.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_load_resource.o b/hardware/arduino/mtk/system/libmtk/debug/vm_load_resource.o new file mode 100644 index 00000000..8d4c4b8c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_load_resource.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_load_resource_from_file.o b/hardware/arduino/mtk/system/libmtk/debug/vm_load_resource_from_file.o new file mode 100644 index 00000000..5fabe73b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_load_resource_from_file.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_load_resource_use_outside_memory.o b/hardware/arduino/mtk/system/libmtk/debug/vm_load_resource_use_outside_memory.o new file mode 100644 index 00000000..8612f7e7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_load_resource_use_outside_memory.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_lower_case.o b/hardware/arduino/mtk/system/libmtk/debug/vm_lower_case.o new file mode 100644 index 00000000..3fd36eb4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_lower_case.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_magic_wrapper_for_customer.o b/hardware/arduino/mtk/system/libmtk/debug/vm_magic_wrapper_for_customer.o new file mode 100644 index 00000000..028c0f4c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_magic_wrapper_for_customer.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_malloc.o b/hardware/arduino/mtk/system/libmtk/debug/vm_malloc.o new file mode 100644 index 00000000..8fa45ad5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_malloc.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_malloc_nc.o b/hardware/arduino/mtk/system/libmtk/debug/vm_malloc_nc.o new file mode 100644 index 00000000..b49bdc97 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_malloc_nc.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_malloc_nc_topmost.o b/hardware/arduino/mtk/system/libmtk/debug/vm_malloc_nc_topmost.o new file mode 100644 index 00000000..3f1f4559 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_malloc_nc_topmost.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_malloc_topmost.o b/hardware/arduino/mtk/system/libmtk/debug/vm_malloc_topmost.o new file mode 100644 index 00000000..128863fb Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_malloc_topmost.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_memcpy.o b/hardware/arduino/mtk/system/libmtk/debug/vm_memcpy.o new file mode 100644 index 00000000..6dcbeb83 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_memcpy.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_midi_get_time.o b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_get_time.o new file mode 100644 index 00000000..99030057 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_get_time.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_midi_pause.o b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_pause.o new file mode 100644 index 00000000..3d6e173f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_pause.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_midi_play.o b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_play.o new file mode 100644 index 00000000..01486772 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_play.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_midi_play_by_bytes.o b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_play_by_bytes.o new file mode 100644 index 00000000..0844573b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_play_by_bytes.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_midi_play_by_bytes_ex.o b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_play_by_bytes_ex.o new file mode 100644 index 00000000..b0e55915 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_play_by_bytes_ex.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_midi_play_ex.o b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_play_ex.o new file mode 100644 index 00000000..1a84de4d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_play_ex.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_midi_resume.o b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_resume.o new file mode 100644 index 00000000..e0c160c8 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_resume.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_midi_set_type.o b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_set_type.o new file mode 100644 index 00000000..18de7672 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_set_type.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_midi_stop.o b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_stop.o new file mode 100644 index 00000000..79e6ee45 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_stop.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_midi_stop_all.o b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_stop_all.o new file mode 100644 index 00000000..42ffdfb3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_midi_stop_all.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_mms_cancel_download.o b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_cancel_download.o new file mode 100644 index 00000000..18165811 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_cancel_download.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_mms_cancel_send_mms.o b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_cancel_send_mms.o new file mode 100644 index 00000000..faab2300 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_cancel_send_mms.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_mms_clear_interrupt_event_handler.o b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_clear_interrupt_event_handler.o new file mode 100644 index 00000000..6d2b18b8 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_clear_interrupt_event_handler.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_mms_delete.o b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_delete.o new file mode 100644 index 00000000..85840d93 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_delete.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_mms_download.o b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_download.o new file mode 100644 index 00000000..4b2d49fc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_download.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_mms_get_content.o b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_get_content.o new file mode 100644 index 00000000..63abb06b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_get_content.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_mms_get_msg_id_list.o b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_get_msg_id_list.o new file mode 100644 index 00000000..f1d9093a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_get_msg_id_list.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_mms_launch.o b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_launch.o new file mode 100644 index 00000000..e54db68d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_launch.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_mms_send_mms.o b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_send_mms.o new file mode 100644 index 00000000..edd8a41c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_send_mms.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_mms_set_interrupt_event_handler.o b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_set_interrupt_event_handler.o new file mode 100644 index 00000000..89a363b3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_mms_set_interrupt_event_handler.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_mode_block.o b/hardware/arduino/mtk/system/libmtk/debug/vm_mode_block.o new file mode 100644 index 00000000..ef4df3f0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_mode_block.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_mode_unblock.o b/hardware/arduino/mtk/system/libmtk/debug/vm_mode_unblock.o new file mode 100644 index 00000000..e17ec044 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_mode_unblock.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_nvram_get_data.o b/hardware/arduino/mtk/system/libmtk/debug/vm_nvram_get_data.o new file mode 100644 index 00000000..9e75517e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_nvram_get_data.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_nvram_set_data.o b/hardware/arduino/mtk/system/libmtk/debug/vm_nvram_set_data.o new file mode 100644 index 00000000..f6b57be4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_nvram_set_data.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_peek_stack.o b/hardware/arduino/mtk/system/libmtk/debug/vm_peek_stack.o new file mode 100644 index 00000000..d2bf8f79 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_peek_stack.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_phb_add_contact.o b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_add_contact.o new file mode 100644 index 00000000..74f74ccb Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_add_contact.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_phb_delete_contact.o b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_delete_contact.o new file mode 100644 index 00000000..a130d33c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_delete_contact.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_contact.o b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_contact.o new file mode 100644 index 00000000..2bf914c7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_contact.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_contact_syn.o b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_contact_syn.o new file mode 100644 index 00000000..73c2266d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_contact_syn.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_group_list.o b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_group_list.o new file mode 100644 index 00000000..d375f360 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_group_list.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_group_list_count.o b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_group_list_count.o new file mode 100644 index 00000000..512f3a3f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_group_list_count.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_group_name_by_id.o b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_group_name_by_id.o new file mode 100644 index 00000000..1c675e78 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_group_name_by_id.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_total_contacts.o b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_total_contacts.o new file mode 100644 index 00000000..2c41c1f0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_total_contacts.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_used_contacts.o b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_used_contacts.o new file mode 100644 index 00000000..b6c13dfb Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_used_contacts.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_used_contacts_count.o b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_used_contacts_count.o new file mode 100644 index 00000000..866c18cc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_get_used_contacts_count.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_phb_search_contact.o b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_search_contact.o new file mode 100644 index 00000000..1dc14553 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_search_contact.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_phb_search_contact_list.o b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_search_contact_list.o new file mode 100644 index 00000000..e6efeead Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_search_contact_list.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_phb_search_contact_syn.o b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_search_contact_syn.o new file mode 100644 index 00000000..971cc0ee Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_search_contact_syn.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_phb_update_contact.o b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_update_contact.o new file mode 100644 index 00000000..bde13c9c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_phb_update_contact.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_delete_process.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_delete_process.o new file mode 100644 index 00000000..2692f9f5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_delete_process.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_get_app_handle.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_get_app_handle.o new file mode 100644 index 00000000..bf98ff9b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_get_app_handle.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_get_current_handle.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_get_current_handle.o new file mode 100644 index 00000000..b8a13f12 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_get_current_handle.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_get_handle.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_get_handle.o new file mode 100644 index 00000000..de1ec17d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_get_handle.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_reset_ctx.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_reset_ctx.o new file mode 100644 index 00000000..a81be328 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_reset_ctx.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_restore_default_event_filter.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_restore_default_event_filter.o new file mode 100644 index 00000000..67bd0da5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_restore_default_event_filter.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_send_app_sys_event.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_send_app_sys_event.o new file mode 100644 index 00000000..b2770cb3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_send_app_sys_event.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_set_bg.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_set_bg.o new file mode 100644 index 00000000..b9b8cf4e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_set_bg.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_set_ctx.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_set_ctx.o new file mode 100644 index 00000000..798c35b8 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_set_ctx.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_set_event_filter.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_set_event_filter.o new file mode 100644 index 00000000..92ddf401 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_set_event_filter.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_set_fg.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_set_fg.o new file mode 100644 index 00000000..38d21cdf Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_set_fg.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_state.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_state.o new file mode 100644 index 00000000..9c28d881 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pmng_state.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pn_dereg.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_dereg.o new file mode 100644 index 00000000..2d0b02c6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_dereg.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pn_get_global_setting.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_get_global_setting.o new file mode 100644 index 00000000..eae2f881 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_get_global_setting.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pn_get_mps_info.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_get_mps_info.o new file mode 100644 index 00000000..c006ffe7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_get_mps_info.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pn_get_mps_info_ex.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_get_mps_info_ex.o new file mode 100644 index 00000000..50bcbb2e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_get_mps_info_ex.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pn_get_object.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_get_object.o new file mode 100644 index 00000000..3348ac45 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_get_object.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pn_is_support.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_is_support.o new file mode 100644 index 00000000..c3686f7d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_is_support.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pn_query.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_query.o new file mode 100644 index 00000000..b723dbeb Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_query.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pn_reg.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_reg.o new file mode 100644 index 00000000..183764ed Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_reg.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pn_set_badge.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_set_badge.o new file mode 100644 index 00000000..5129bda0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_set_badge.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_pn_set_notify_style.o b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_set_notify_style.o new file mode 100644 index 00000000..5980a239 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_pn_set_notify_style.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_popup_stack.o b/hardware/arduino/mtk/system/libmtk/debug/vm_popup_stack.o new file mode 100644 index 00000000..7277d239 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_popup_stack.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_post_msg.o b/hardware/arduino/mtk/system/libmtk/debug/vm_post_msg.o new file mode 100644 index 00000000..e8b80476 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_post_msg.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_push_stack.o b/hardware/arduino/mtk/system/libmtk/debug/vm_push_stack.o new file mode 100644 index 00000000..c7703ecb Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_push_stack.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_query_operator_code.o b/hardware/arduino/mtk/system/libmtk/debug/vm_query_operator_code.o new file mode 100644 index 00000000..6ce1a8c7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_query_operator_code.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_read_cache.o b/hardware/arduino/mtk/system/libmtk/debug/vm_read_cache.o new file mode 100644 index 00000000..dd78a446 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_read_cache.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_read_from_uart.o b/hardware/arduino/mtk/system/libmtk/debug/vm_read_from_uart.o new file mode 100644 index 00000000..44860468 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_read_from_uart.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_read_line.o b/hardware/arduino/mtk/system/libmtk/debug/vm_read_line.o new file mode 100644 index 00000000..5ddd7008 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_read_line.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_realloc.o b/hardware/arduino/mtk/system/libmtk/debug/vm_realloc.o new file mode 100644 index 00000000..59f76cea Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_realloc.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_realloc_topmost.o b/hardware/arduino/mtk/system/libmtk/debug/vm_realloc_topmost.o new file mode 100644 index 00000000..e7a6792c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_realloc_topmost.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_reboot_normal_start.o b/hardware/arduino/mtk/system/libmtk/debug/vm_reboot_normal_start.o new file mode 100644 index 00000000..4e2f7ddd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_reboot_normal_start.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_record_pause.o b/hardware/arduino/mtk/system/libmtk/debug/vm_record_pause.o new file mode 100644 index 00000000..e60338ac Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_record_pause.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_record_resume.o b/hardware/arduino/mtk/system/libmtk/debug/vm_record_resume.o new file mode 100644 index 00000000..85123af1 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_record_resume.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_record_start.o b/hardware/arduino/mtk/system/libmtk/debug/vm_record_start.o new file mode 100644 index 00000000..6fd6f908 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_record_start.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_record_stop.o b/hardware/arduino/mtk/system/libmtk/debug/vm_record_stop.o new file mode 100644 index 00000000..ceca39d5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_record_stop.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_recv.o b/hardware/arduino/mtk/system/libmtk/debug/vm_recv.o new file mode 100644 index 00000000..2524e400 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_recv.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_recvfrom.o b/hardware/arduino/mtk/system/libmtk/debug/vm_recvfrom.o new file mode 100644 index 00000000..d387424f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_recvfrom.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_reg_func_callback.o b/hardware/arduino/mtk/system/libmtk/debug/vm_reg_func_callback.o new file mode 100644 index 00000000..d62facaa Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_reg_func_callback.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_reg_http_notification.o b/hardware/arduino/mtk/system/libmtk/debug/vm_reg_http_notification.o new file mode 100644 index 00000000..2ee67d2b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_reg_http_notification.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_reg_msg_proc.o b/hardware/arduino/mtk/system/libmtk/debug/vm_reg_msg_proc.o new file mode 100644 index 00000000..49f54dba Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_reg_msg_proc.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_reg_sysevt_callback.o b/hardware/arduino/mtk/system/libmtk/debug/vm_reg_sysevt_callback.o new file mode 100644 index 00000000..6ec121ff Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_reg_sysevt_callback.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_reset_stack.o b/hardware/arduino/mtk/system/libmtk/debug/vm_reset_stack.o new file mode 100644 index 00000000..ee103021 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_reset_stack.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_resource_get_data.o b/hardware/arduino/mtk/system/libmtk/debug/vm_resource_get_data.o new file mode 100644 index 00000000..8a17f1fe Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_resource_get_data.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_resource_get_data_from_file.o b/hardware/arduino/mtk/system/libmtk/debug/vm_resource_get_data_from_file.o new file mode 100644 index 00000000..0e2591b8 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_resource_get_data_from_file.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_restore_irq_mask.o b/hardware/arduino/mtk/system/libmtk/debug/vm_restore_irq_mask.o new file mode 100644 index 00000000..e4899ab5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_restore_irq_mask.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_safe_wstrcpy.o b/hardware/arduino/mtk/system/libmtk/debug/vm_safe_wstrcpy.o new file mode 100644 index 00000000..5b46c3fc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_safe_wstrcpy.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_save_irq_mask.o b/hardware/arduino/mtk/system/libmtk/debug/vm_save_irq_mask.o new file mode 100644 index 00000000..ee2c8e52 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_save_irq_mask.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_select.o b/hardware/arduino/mtk/system/libmtk/debug/vm_select.o new file mode 100644 index 00000000..8618b8fe Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_select.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_send.o b/hardware/arduino/mtk/system/libmtk/debug/vm_send.o new file mode 100644 index 00000000..18e5f85b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_send.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_send_msg.o b/hardware/arduino/mtk/system/libmtk/debug/vm_send_msg.o new file mode 100644 index 00000000..5095d5c0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_send_msg.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_send_sms.o b/hardware/arduino/mtk/system/libmtk/debug/vm_send_sms.o new file mode 100644 index 00000000..5832de80 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_send_sms.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sendto.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sendto.o new file mode 100644 index 00000000..fcdcf07e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sendto.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_set_active_sim_card.o b/hardware/arduino/mtk/system/libmtk/debug/vm_set_active_sim_card.o new file mode 100644 index 00000000..1ba2d7de Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_set_active_sim_card.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_set_app_desired_input_mode.o b/hardware/arduino/mtk/system/libmtk/debug/vm_set_app_desired_input_mode.o new file mode 100644 index 00000000..6067c6cd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_set_app_desired_input_mode.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_set_cust_apn_info.o b/hardware/arduino/mtk/system/libmtk/debug/vm_set_cust_apn_info.o new file mode 100644 index 00000000..661ba0c1 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_set_cust_apn_info.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_set_kal_timer.o b/hardware/arduino/mtk/system/libmtk/debug/vm_set_kal_timer.o new file mode 100644 index 00000000..d27843da Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_set_kal_timer.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_set_ringtone.o b/hardware/arduino/mtk/system/libmtk/debug/vm_set_ringtone.o new file mode 100644 index 00000000..cd29ae15 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_set_ringtone.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_set_volume.o b/hardware/arduino/mtk/system/libmtk/debug/vm_set_volume.o new file mode 100644 index 00000000..8246bb59 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_set_volume.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_setsockopt.o b/hardware/arduino/mtk/system/libmtk/debug/vm_setsockopt.o new file mode 100644 index 00000000..d3965dcf Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_setsockopt.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_setting_get_date_format.o b/hardware/arduino/mtk/system/libmtk/debug/vm_setting_get_date_format.o new file mode 100644 index 00000000..cbd1044d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_setting_get_date_format.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_setting_get_date_seperator.o b/hardware/arduino/mtk/system/libmtk/debug/vm_setting_get_date_seperator.o new file mode 100644 index 00000000..03480d2d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_setting_get_date_seperator.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_setting_get_time_format.o b/hardware/arduino/mtk/system/libmtk/debug/vm_setting_get_time_format.o new file mode 100644 index 00000000..284a90c0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_setting_get_time_format.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_setting_srv_command.o b/hardware/arduino/mtk/system/libmtk/debug/vm_setting_srv_command.o new file mode 100644 index 00000000..9d9f0aba Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_setting_srv_command.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_settings_set_tone.o b/hardware/arduino/mtk/system/libmtk/debug/vm_settings_set_tone.o new file mode 100644 index 00000000..3a50bca5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_settings_set_tone.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_settings_set_wallpaper.o b/hardware/arduino/mtk/system/libmtk/debug/vm_settings_set_wallpaper.o new file mode 100644 index 00000000..bbd809df Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_settings_set_wallpaper.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_shutdown.o b/hardware/arduino/mtk/system/libmtk/debug/vm_shutdown.o new file mode 100644 index 00000000..5221a545 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_shutdown.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_shutdown_normal_start.o b/hardware/arduino/mtk/system/libmtk/debug/vm_shutdown_normal_start.o new file mode 100644 index 00000000..75210612 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_shutdown_normal_start.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sim_card_count.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_card_count.o new file mode 100644 index 00000000..562f4a5d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_card_count.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_active_sim_card.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_active_sim_card.o new file mode 100644 index 00000000..e4c127e3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_active_sim_card.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_card_status.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_card_status.o new file mode 100644 index 00000000..f315b4be Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_card_status.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_iccid.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_iccid.o new file mode 100644 index 00000000..17cc8f18 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_iccid.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_imei.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_imei.o new file mode 100644 index 00000000..8acad47f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_imei.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_imei_ext.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_imei_ext.o new file mode 100644 index 00000000..82962072 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_imei_ext.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_imsi.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_imsi.o new file mode 100644 index 00000000..a4176b82 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_imsi.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_operator.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_operator.o new file mode 100644 index 00000000..36c49aac Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_operator.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_prefer_sim_card.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_prefer_sim_card.o new file mode 100644 index 00000000..1b155f14 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_get_prefer_sim_card.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sim_has_card.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_has_card.o new file mode 100644 index 00000000..571b2215 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_has_card.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sim_max_card_count.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_max_card_count.o new file mode 100644 index 00000000..b4f9d5f2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_max_card_count.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sim_query_operator_code.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_query_operator_code.o new file mode 100644 index 00000000..8a601a62 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_query_operator_code.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sim_set_active_card.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_set_active_card.o new file mode 100644 index 00000000..b5d1c0c6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sim_set_active_card.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sla_custom_logging.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sla_custom_logging.o new file mode 100644 index 00000000..08b401d2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sla_custom_logging.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_add_msg.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_add_msg.o new file mode 100644 index 00000000..af97db26 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_add_msg.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_clear_interrupt_event_handler.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_clear_interrupt_event_handler.o new file mode 100644 index 00000000..10313588 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_clear_interrupt_event_handler.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_clear_interrupt_event_handler_forpay.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_clear_interrupt_event_handler_forpay.o new file mode 100644 index 00000000..6ac9ece2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_clear_interrupt_event_handler_forpay.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_delete_msg.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_delete_msg.o new file mode 100644 index 00000000..c887bdf0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_delete_msg.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_delete_msg_forpay.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_delete_msg_forpay.o new file mode 100644 index 00000000..c9c603dd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_delete_msg_forpay.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_delete_msg_list.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_delete_msg_list.o new file mode 100644 index 00000000..1fa3c354 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_delete_msg_list.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_box_size.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_box_size.o new file mode 100644 index 00000000..416043dc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_box_size.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_msg_id.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_msg_id.o new file mode 100644 index 00000000..f6182e00 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_msg_id.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_msg_id_list.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_msg_id_list.o new file mode 100644 index 00000000..cd3955c3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_msg_id_list.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_sc_address.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_sc_address.o new file mode 100644 index 00000000..3c081ebd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_sc_address.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_sc_address_syn.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_sc_address_syn.o new file mode 100644 index 00000000..ed7c24e7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_get_sc_address_syn.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_is_sms_ready.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_is_sms_ready.o new file mode 100644 index 00000000..1381d15f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_is_sms_ready.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_launch.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_launch.o new file mode 100644 index 00000000..da21c52b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_launch.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_read_msg.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_read_msg.o new file mode 100644 index 00000000..6aa7312b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_read_msg.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_set_interrupt_event_handler.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_set_interrupt_event_handler.o new file mode 100644 index 00000000..de1e46a8 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_set_interrupt_event_handler.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sms_set_interrupt_event_handler_forpay.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_set_interrupt_event_handler_forpay.o new file mode 100644 index 00000000..2c3956cd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sms_set_interrupt_event_handler_forpay.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_get_account_localip.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_get_account_localip.o new file mode 100644 index 00000000..a9ca7efd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_get_account_localip.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_get_host_by_name.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_get_host_by_name.o new file mode 100644 index 00000000..46f3bbc4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_get_host_by_name.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_get_host_by_name_ex.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_get_host_by_name_ex.o new file mode 100644 index 00000000..c74f4cb2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_get_host_by_name_ex.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_get_last_error.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_get_last_error.o new file mode 100644 index 00000000..789ac639 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_get_last_error.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_accept_sync.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_accept_sync.o new file mode 100644 index 00000000..3d013790 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_accept_sync.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_close_client.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_close_client.o new file mode 100644 index 00000000..b40bc095 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_close_client.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_close_client_sync.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_close_client_sync.o new file mode 100644 index 00000000..5441e67a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_close_client_sync.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_deinit.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_deinit.o new file mode 100644 index 00000000..4401428a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_deinit.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_deinit_sync.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_deinit_sync.o new file mode 100644 index 00000000..4303624d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_deinit_sync.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_get_soc_id.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_get_soc_id.o new file mode 100644 index 00000000..3b447bfe Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_get_soc_id.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_init.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_init.o new file mode 100644 index 00000000..35622ad3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_init.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_init_sync.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_init_sync.o new file mode 100644 index 00000000..de34b013 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_init_sync.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_read.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_read.o new file mode 100644 index 00000000..ffb58ee8 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_read.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_read_sync.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_read_sync.o new file mode 100644 index 00000000..57c295cd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_read_sync.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_send.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_send.o new file mode 100644 index 00000000..14b57d22 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_send.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_send_sync.o b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_send_sync.o new file mode 100644 index 00000000..8b9afa00 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_soc_svr_send_sync.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_socket.o b/hardware/arduino/mtk/system/libmtk/debug/vm_socket.o new file mode 100644 index 00000000..0a6681f5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_socket.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_socket_ex.o b/hardware/arduino/mtk/system/libmtk/debug/vm_socket_ex.o new file mode 100644 index 00000000..e785855d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_socket_ex.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sprintf.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sprintf.o new file mode 100644 index 00000000..c75ddb29 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sprintf.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_srv_bt_noti_check_connection.o b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_bt_noti_check_connection.o new file mode 100644 index 00000000..7150d17d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_bt_noti_check_connection.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_srv_bt_noti_register_callback.o b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_bt_noti_register_callback.o new file mode 100644 index 00000000..d578a031 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_bt_noti_register_callback.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_srv_bt_noti_send_cmd_ext.o b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_bt_noti_send_cmd_ext.o new file mode 100644 index 00000000..b856fe87 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_bt_noti_send_cmd_ext.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_srv_bt_noti_send_ex.o b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_bt_noti_send_ex.o new file mode 100644 index 00000000..70bb64be Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_bt_noti_send_ex.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_srv_funet_trigger.o b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_funet_trigger.o new file mode 100644 index 00000000..b5b983b4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_funet_trigger.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_srv_nw_info_get_protocol.o b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_nw_info_get_protocol.o new file mode 100644 index 00000000..82d54034 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_nw_info_get_protocol.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_srv_nw_info_get_service_availability.o b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_nw_info_get_service_availability.o new file mode 100644 index 00000000..fb12e9a7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_nw_info_get_service_availability.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_acc_data_rigister_cb.o b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_acc_data_rigister_cb.o new file mode 100644 index 00000000..b453859e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_acc_data_rigister_cb.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_disable_mode.o b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_disable_mode.o new file mode 100644 index 00000000..1ffc0d7e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_disable_mode.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_enable_mode.o b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_enable_mode.o new file mode 100644 index 00000000..ca4691d9 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_enable_mode.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_hr_data_rigister_cb.o b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_hr_data_rigister_cb.o new file mode 100644 index 00000000..a737fc86 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_hr_data_rigister_cb.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_is_available.o b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_is_available.o new file mode 100644 index 00000000..303f0e8d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_is_available.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_start_listen.o b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_start_listen.o new file mode 100644 index 00000000..9668ba4e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_start_listen.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_stop_listen.o b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_stop_listen.o new file mode 100644 index 00000000..bfcd71b7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_srv_sensor_stop_listen.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sscanf.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sscanf.o new file mode 100644 index 00000000..c3ffd19d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sscanf.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_base64_decode.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_base64_decode.o new file mode 100644 index 00000000..77288e31 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_base64_decode.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_base64_encode.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_base64_encode.o new file mode 100644 index 00000000..db2b6165 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_base64_encode.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_close.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_close.o new file mode 100644 index 00000000..febb01b7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_close.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_connect.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_connect.o new file mode 100644 index 00000000..1cab47fa Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_connect.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_get_verify_result.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_get_verify_result.o new file mode 100644 index 00000000..de218889 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_get_verify_result.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_is_support.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_is_support.o new file mode 100644 index 00000000..5faa5ca5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_is_support.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_load_ca_chain_cert.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_load_ca_chain_cert.o new file mode 100644 index 00000000..37b92404 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_load_ca_chain_cert.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_read.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_read.o new file mode 100644 index 00000000..60c5946a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_read.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_sha1_hmac.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_sha1_hmac.o new file mode 100644 index 00000000..93a3d5a5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_sha1_hmac.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_write.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_write.o new file mode 100644 index 00000000..aae4d342 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ssl_write.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_add_account.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_add_account.o new file mode 100644 index 00000000..4781384d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_add_account.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_cancel.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_cancel.o new file mode 100644 index 00000000..04a48a64 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_cancel.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_del_account.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_del_account.o new file mode 100644 index 00000000..d48cdde4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_del_account.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_account.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_account.o new file mode 100644 index 00000000..278989bb Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_account.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_account_count.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_account_count.o new file mode 100644 index 00000000..8905b414 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_account_count.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_account_name.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_account_name.o new file mode 100644 index 00000000..9f81f9a4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_account_name.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_accounts.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_accounts.o new file mode 100644 index 00000000..e9dd9b29 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_accounts.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_credentials.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_credentials.o new file mode 100644 index 00000000..7cc72e92 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_credentials.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_provider.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_provider.o new file mode 100644 index 00000000..932ce73d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_provider.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_provider_count.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_provider_count.o new file mode 100644 index 00000000..bcfeac78 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_provider_count.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_provider_icon.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_provider_icon.o new file mode 100644 index 00000000..e0811517 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_provider_icon.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_provider_name.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_provider_name.o new file mode 100644 index 00000000..d4298513 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_provider_name.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_providers.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_providers.o new file mode 100644 index 00000000..e20dbb07 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_get_providers.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_login_account.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_login_account.o new file mode 100644 index 00000000..afc6a220 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_login_account.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_logout_account.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_logout_account.o new file mode 100644 index 00000000..cb63dae4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_logout_account.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sso_refresh_credentials.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_refresh_credentials.o new file mode 100644 index 00000000..e17a5812 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sso_refresh_credentials.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_start_app.o b/hardware/arduino/mtk/system/libmtk/debug/vm_start_app.o new file mode 100644 index 00000000..cc1d3180 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_start_app.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_start_app_with_para.o b/hardware/arduino/mtk/system/libmtk/debug/vm_start_app_with_para.o new file mode 100644 index 00000000..f6cbb2bb Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_start_app_with_para.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_storage_close.o b/hardware/arduino/mtk/system/libmtk/debug/vm_storage_close.o new file mode 100644 index 00000000..5ec252a6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_storage_close.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_storage_open.o b/hardware/arduino/mtk/system/libmtk/debug/vm_storage_open.o new file mode 100644 index 00000000..f11bd778 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_storage_open.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_storage_read.o b/hardware/arduino/mtk/system/libmtk/debug/vm_storage_read.o new file mode 100644 index 00000000..50d0689c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_storage_read.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_storage_write.o b/hardware/arduino/mtk/system/libmtk/debug/vm_storage_write.o new file mode 100644 index 00000000..5283d206 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_storage_write.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_stream_connect.o b/hardware/arduino/mtk/system/libmtk/debug/vm_stream_connect.o new file mode 100644 index 00000000..d8d095bf Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_stream_connect.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_stream_disconnect.o b/hardware/arduino/mtk/system/libmtk/debug/vm_stream_disconnect.o new file mode 100644 index 00000000..1745fdf7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_stream_disconnect.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_stream_set_volume.o b/hardware/arduino/mtk/system/libmtk/debug/vm_stream_set_volume.o new file mode 100644 index 00000000..04e47f3f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_stream_set_volume.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_string_equals_ignore_case.o b/hardware/arduino/mtk/system/libmtk/debug/vm_string_equals_ignore_case.o new file mode 100644 index 00000000..52ad1f5d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_string_equals_ignore_case.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_strtol.o b/hardware/arduino/mtk/system/libmtk/debug/vm_strtol.o new file mode 100644 index 00000000..a1f3559f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_strtol.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_switch_backlight.o b/hardware/arduino/mtk/system/libmtk/debug/vm_switch_backlight.o new file mode 100644 index 00000000..15543f54 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_switch_backlight.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_switch_power_saving_mode.o b/hardware/arduino/mtk/system/libmtk/debug/vm_switch_power_saving_mode.o new file mode 100644 index 00000000..e583794b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_switch_power_saving_mode.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_close.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_close.o new file mode 100644 index 00000000..8a27e85d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_close.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_delete.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_delete.o new file mode 100644 index 00000000..b4e4235a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_delete.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_get_space.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_get_space.o new file mode 100644 index 00000000..801433a1 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_get_space.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_open.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_open.o new file mode 100644 index 00000000..158982a2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_open.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_read.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_read.o new file mode 100644 index 00000000..fc5aacde Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_read.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_seek.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_seek.o new file mode 100644 index 00000000..8980f7ff Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_seek.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_write.o b/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_write.o new file mode 100644 index 00000000..9f23e690 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_sys_file_write.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_close.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_close.o new file mode 100644 index 00000000..04acb157 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_close.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_close_sync.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_close_sync.o new file mode 100644 index 00000000..cb269c3f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_close_sync.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_connect.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_connect.o new file mode 100644 index 00000000..9bf9d4a1 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_connect.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_connect_ex.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_connect_ex.o new file mode 100644 index 00000000..5f355f9d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_connect_ex.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_connect_sync.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_connect_sync.o new file mode 100644 index 00000000..73d856e3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_connect_sync.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_get_soc_id.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_get_soc_id.o new file mode 100644 index 00000000..fa0282f4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_get_soc_id.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_read.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_read.o new file mode 100644 index 00000000..2b4a110d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_read.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_read_sync.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_read_sync.o new file mode 100644 index 00000000..7a7d466d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_read_sync.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_write.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_write.o new file mode 100644 index 00000000..71a9332d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_write.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_write_sync.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_write_sync.o new file mode 100644 index 00000000..dab78ded Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tcp_write_sync.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_thread_create.o b/hardware/arduino/mtk/system/libmtk/debug/vm_thread_create.o new file mode 100644 index 00000000..bbabc98d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_thread_create.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_thread_get_current_handle.o b/hardware/arduino/mtk/system/libmtk/debug/vm_thread_get_current_handle.o new file mode 100644 index 00000000..3eef9017 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_thread_get_current_handle.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_thread_get_main_handle.o b/hardware/arduino/mtk/system/libmtk/debug/vm_thread_get_main_handle.o new file mode 100644 index 00000000..1ee7e45b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_thread_get_main_handle.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_thread_get_msg.o b/hardware/arduino/mtk/system/libmtk/debug/vm_thread_get_msg.o new file mode 100644 index 00000000..74fdca2e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_thread_get_msg.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_thread_send_msg.o b/hardware/arduino/mtk/system/libmtk/debug/vm_thread_send_msg.o new file mode 100644 index 00000000..1a55012e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_thread_send_msg.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_auto_rehandshake.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_auto_rehandshake.o new file mode 100644 index 00000000..31108d80 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_auto_rehandshake.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_check_invalid_cert.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_check_invalid_cert.o new file mode 100644 index 00000000..f2522be5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_check_invalid_cert.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_check_peer_name.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_check_peer_name.o new file mode 100644 index 00000000..8befa525 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_check_peer_name.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_connect.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_connect.o new file mode 100644 index 00000000..8872db52 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_connect.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_delete_conn.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_delete_conn.o new file mode 100644 index 00000000..db71d16f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_delete_conn.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_delete_ctx.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_delete_ctx.o new file mode 100644 index 00000000..d2edebf9 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_delete_ctx.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_get_cipher.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_get_cipher.o new file mode 100644 index 00000000..75481147 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_get_cipher.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_get_cipher_info.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_get_cipher_info.o new file mode 100644 index 00000000..7c448ad1 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_get_cipher_info.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_get_peer_cert.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_get_peer_cert.o new file mode 100644 index 00000000..cea11d30 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_get_peer_cert.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_handshake.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_handshake.o new file mode 100644 index 00000000..540fc231 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_handshake.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_log_plaintext.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_log_plaintext.o new file mode 100644 index 00000000..b4ee1179 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_log_plaintext.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_new_conn.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_new_conn.o new file mode 100644 index 00000000..520b4ce9 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_new_conn.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_new_ctx.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_new_ctx.o new file mode 100644 index 00000000..10ff3181 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_new_ctx.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_read.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_read.o new file mode 100644 index 00000000..0bcb3f2f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_read.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_rehandshake.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_rehandshake.o new file mode 100644 index 00000000..5ef8b9f3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_rehandshake.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_ciphers.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_ciphers.o new file mode 100644 index 00000000..6d0cf5a3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_ciphers.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_client_auth.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_client_auth.o new file mode 100644 index 00000000..60a52fe8 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_client_auth.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_identity.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_identity.o new file mode 100644 index 00000000..692a28a6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_identity.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_null_client_auth.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_null_client_auth.o new file mode 100644 index 00000000..f47d4587 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_null_client_auth.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_verify.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_verify.o new file mode 100644 index 00000000..bad5c108 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_set_verify.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_shutdown.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_shutdown.o new file mode 100644 index 00000000..a71d9e30 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_shutdown.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_soc_connect.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_soc_connect.o new file mode 100644 index 00000000..aeba76e2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_soc_connect.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tls_write.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_write.o new file mode 100644 index 00000000..393183f5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tls_write.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_tmp_filename.o b/hardware/arduino/mtk/system/libmtk/debug/vm_tmp_filename.o new file mode 100644 index 00000000..8d22d760 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_tmp_filename.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ts_driver_free.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ts_driver_free.o new file mode 100644 index 00000000..ad486754 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ts_driver_free.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ts_driver_get_handle.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ts_driver_get_handle.o new file mode 100644 index 00000000..dcaf4f0b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ts_driver_get_handle.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ts_driver_get_mem.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ts_driver_get_mem.o new file mode 100644 index 00000000..0d07aed8 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ts_driver_get_mem.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ts_driver_load.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ts_driver_load.o new file mode 100644 index 00000000..91ff40a7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ts_driver_load.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ucs2_string_by_ascii.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ucs2_string_by_ascii.o new file mode 100644 index 00000000..402df34e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ucs2_string_by_ascii.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ucs2_to_ascii.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ucs2_to_ascii.o new file mode 100644 index 00000000..d173d392 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ucs2_to_ascii.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ucs2_to_gb2312.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ucs2_to_gb2312.o new file mode 100644 index 00000000..e44781c9 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ucs2_to_gb2312.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_udp_close.o b/hardware/arduino/mtk/system/libmtk/debug/vm_udp_close.o new file mode 100644 index 00000000..993116b2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_udp_close.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_udp_create.o b/hardware/arduino/mtk/system/libmtk/debug/vm_udp_create.o new file mode 100644 index 00000000..3d8aadea Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_udp_create.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_udp_recvfrom.o b/hardware/arduino/mtk/system/libmtk/debug/vm_udp_recvfrom.o new file mode 100644 index 00000000..1df8e035 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_udp_recvfrom.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_udp_sendto.o b/hardware/arduino/mtk/system/libmtk/debug/vm_udp_sendto.o new file mode 100644 index 00000000..a0e6c2f4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_udp_sendto.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_update_cancel.o b/hardware/arduino/mtk/system/libmtk/debug/vm_update_cancel.o new file mode 100644 index 00000000..8765b7c6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_update_cancel.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_update_check_launch.o b/hardware/arduino/mtk/system/libmtk/debug/vm_update_check_launch.o new file mode 100644 index 00000000..330df459 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_update_check_launch.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_update_check_version.o b/hardware/arduino/mtk/system/libmtk/debug/vm_update_check_version.o new file mode 100644 index 00000000..b36242a7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_update_check_version.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_update_download.o b/hardware/arduino/mtk/system/libmtk/debug/vm_update_download.o new file mode 100644 index 00000000..3098fd9c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_update_download.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_update_update_file.o b/hardware/arduino/mtk/system/libmtk/debug/vm_update_update_file.o new file mode 100644 index 00000000..4ca93e9d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_update_update_file.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_upnp_get_ext_ip.o b/hardware/arduino/mtk/system/libmtk/debug/vm_upnp_get_ext_ip.o new file mode 100644 index 00000000..11f094d3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_upnp_get_ext_ip.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_upnp_mapping_ports.o b/hardware/arduino/mtk/system/libmtk/debug/vm_upnp_mapping_ports.o new file mode 100644 index 00000000..e6e9ffda Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_upnp_mapping_ports.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_upper_case.o b/hardware/arduino/mtk/system/libmtk/debug/vm_upper_case.o new file mode 100644 index 00000000..b1a792de Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_upper_case.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_uriagent_uri_request.o b/hardware/arduino/mtk/system/libmtk/debug/vm_uriagent_uri_request.o new file mode 100644 index 00000000..5af18965 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_uriagent_uri_request.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_url_decode_gb2312.o b/hardware/arduino/mtk/system/libmtk/debug/vm_url_decode_gb2312.o new file mode 100644 index 00000000..a1ff45f2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_url_decode_gb2312.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_url_encode_gb2312.o b/hardware/arduino/mtk/system/libmtk/debug/vm_url_encode_gb2312.o new file mode 100644 index 00000000..f7481cb4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_url_encode_gb2312.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_usb_get_cable_status.o b/hardware/arduino/mtk/system/libmtk/debug/vm_usb_get_cable_status.o new file mode 100644 index 00000000..f5b84e6a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_usb_get_cable_status.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ust_get_current_time.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ust_get_current_time.o new file mode 100644 index 00000000..6fdcdc21 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ust_get_current_time.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_ust_get_duration.o b/hardware/arduino/mtk/system/libmtk/debug/vm_ust_get_duration.o new file mode 100644 index 00000000..2fe02b44 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_ust_get_duration.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vad_get_level.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vad_get_level.o new file mode 100644 index 00000000..0af5f4a0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vad_get_level.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vad_is_on.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vad_is_on.o new file mode 100644 index 00000000..bff3f596 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vad_is_on.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vad_register_callback.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vad_register_callback.o new file mode 100644 index 00000000..4fc2a9c5 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vad_register_callback.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vad_set_level.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vad_set_level.o new file mode 100644 index 00000000..62a0f7bc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vad_set_level.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vad_switch_on_off.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vad_switch_on_off.o new file mode 100644 index 00000000..8a1d249b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vad_switch_on_off.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_pause.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_pause.o new file mode 100644 index 00000000..1f4bfd0f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_pause.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_power_down.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_power_down.o new file mode 100644 index 00000000..bb08716a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_power_down.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_power_up.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_power_up.o new file mode 100644 index 00000000..58ae85b6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_power_up.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_preview.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_preview.o new file mode 100644 index 00000000..cd550fbc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_preview.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_record.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_record.o new file mode 100644 index 00000000..dda70da0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_record.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_resume.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_resume.o new file mode 100644 index 00000000..e729b926 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_resume.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_rtsp_local_save_start.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_rtsp_local_save_start.o new file mode 100644 index 00000000..deff46ab Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_rtsp_local_save_start.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_rtsp_local_save_stop.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_rtsp_local_save_stop.o new file mode 100644 index 00000000..6445cb5e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_rtsp_local_save_stop.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_save_to_file.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_save_to_file.o new file mode 100644 index 00000000..9f294d6b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_save_to_file.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_set_param.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_set_param.o new file mode 100644 index 00000000..38888f62 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_set_param.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_stop.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_stop.o new file mode 100644 index 00000000..3c7a80e2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vdorec_stop.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vibrator_off.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vibrator_off.o new file mode 100644 index 00000000..20f2860a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vibrator_off.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vibrator_on.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vibrator_on.o new file mode 100644 index 00000000..bc9b5b59 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vibrator_on.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vibrator_once.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vibrator_once.o new file mode 100644 index 00000000..ab66ae14 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vibrator_once.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_close_buffer.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_close_buffer.o new file mode 100644 index 00000000..9d76e5c9 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_close_buffer.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_close_file.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_close_file.o new file mode 100644 index 00000000..8668ddf9 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_close_file.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_get_cur_play_time.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_get_cur_play_time.o new file mode 100644 index 00000000..bab6de02 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_get_cur_play_time.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_open_buffer.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_open_buffer.o new file mode 100644 index 00000000..95d0a8e1 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_open_buffer.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_open_file.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_open_file.o new file mode 100644 index 00000000..fda13f88 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_open_file.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_pause.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_pause.o new file mode 100644 index 00000000..32234a2d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_pause.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_play.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_play.o new file mode 100644 index 00000000..c04b369d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_play.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_play_by_filepath.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_play_by_filepath.o new file mode 100644 index 00000000..f6ee17fc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_play_by_filepath.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_play_stream_from_rtsp_link.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_play_stream_from_rtsp_link.o new file mode 100644 index 00000000..d214e6d9 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_play_stream_from_rtsp_link.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_play_stream_from_sdp_file.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_play_stream_from_sdp_file.o new file mode 100644 index 00000000..337c4f21 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_play_stream_from_sdp_file.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_resume.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_resume.o new file mode 100644 index 00000000..e296193a Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_resume.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_seek_and_getframe.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_seek_and_getframe.o new file mode 100644 index 00000000..e060c4cb Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_seek_and_getframe.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_set_brightness.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_set_brightness.o new file mode 100644 index 00000000..d7685d43 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_set_brightness.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_set_contrast.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_set_contrast.o new file mode 100644 index 00000000..e9d7e5a6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_set_contrast.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_snapshot.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_snapshot.o new file mode 100644 index 00000000..1516e731 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_snapshot.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_video_stop.o b/hardware/arduino/mtk/system/libmtk/debug/vm_video_stop.o new file mode 100644 index 00000000..b9c224bd Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_video_stop.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vsprintf.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vsprintf.o new file mode 100644 index 00000000..97c44005 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vsprintf.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_vwsprintf.o b/hardware/arduino/mtk/system/libmtk/debug/vm_vwsprintf.o new file mode 100644 index 00000000..dd818f44 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_vwsprintf.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wdt_feed.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wdt_feed.o new file mode 100644 index 00000000..051ef256 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wdt_feed.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wdt_start.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wdt_start.o new file mode 100644 index 00000000..68ff1796 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wdt_start.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wdt_stop.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wdt_stop.o new file mode 100644 index 00000000..2ba0dfeb Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wdt_stop.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wends_with.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wends_with.o new file mode 100644 index 00000000..ff9961f3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wends_with.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wifi_is_connected.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wifi_is_connected.o new file mode 100644 index 00000000..de26c483 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wifi_is_connected.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_connect.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_connect.o new file mode 100644 index 00000000..37935b4c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_connect.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_dereg_noti.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_dereg_noti.o new file mode 100644 index 00000000..f1029369 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_dereg_noti.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_disconnect.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_disconnect.o new file mode 100644 index 00000000..bcdfc15e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_disconnect.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_get_connected_ap_info.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_get_connected_ap_info.o new file mode 100644 index 00000000..eefe5734 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_get_connected_ap_info.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_get_ip_info.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_get_ip_info.o new file mode 100644 index 00000000..df157897 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_get_ip_info.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_get_mac_address.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_get_mac_address.o new file mode 100644 index 00000000..d738d9c3 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_get_mac_address.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_get_para.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_get_para.o new file mode 100644 index 00000000..a06a6301 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_get_para.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_loc_get_connected_info.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_loc_get_connected_info.o new file mode 100644 index 00000000..c75208b7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_loc_get_connected_info.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_loc_search.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_loc_search.o new file mode 100644 index 00000000..2c796d78 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_loc_search.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_loc_search_abort.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_loc_search_abort.o new file mode 100644 index 00000000..1b9e98b2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_loc_search_abort.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_mode_get.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_mode_get.o new file mode 100644 index 00000000..0c4022ae Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_mode_get.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_mode_set.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_mode_set.o new file mode 100644 index 00000000..a58d4432 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_mode_set.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_perfer.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_perfer.o new file mode 100644 index 00000000..ccc17aca Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_perfer.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_add.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_add.o new file mode 100644 index 00000000..0d0512e7 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_add.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_connect.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_connect.o new file mode 100644 index 00000000..73fcb8b6 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_connect.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_delete.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_delete.o new file mode 100644 index 00000000..2e8b97ff Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_delete.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_get_reconn_id.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_get_reconn_id.o new file mode 100644 index 00000000..a205b88b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_get_reconn_id.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_init.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_init.o new file mode 100644 index 00000000..d58b1417 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_init.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_query.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_query.o new file mode 100644 index 00000000..aff11a68 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_query.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_query_list.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_query_list.o new file mode 100644 index 00000000..e7d15bee Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_query_list.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_set_reconn_id.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_set_reconn_id.o new file mode 100644 index 00000000..baaf5cf8 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_set_reconn_id.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_update.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_update.o new file mode 100644 index 00000000..ecbbf199 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_prof_update.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_reg_noti.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_reg_noti.o new file mode 100644 index 00000000..7c04c105 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_reg_noti.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_roaming_get.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_roaming_get.o new file mode 100644 index 00000000..b4cc664c Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_roaming_get.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_roaming_set.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_roaming_set.o new file mode 100644 index 00000000..730027c0 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_roaming_set.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_scan.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_scan.o new file mode 100644 index 00000000..b94a1d42 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_scan.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_scan_abort.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_scan_abort.o new file mode 100644 index 00000000..174879b2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_scan_abort.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_scan_get_param.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_scan_get_param.o new file mode 100644 index 00000000..68d66714 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_scan_get_param.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_scan_set_param.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_scan_set_param.o new file mode 100644 index 00000000..0a4fcdf9 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_scan_set_param.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_set_para.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_set_para.o new file mode 100644 index 00000000..a217288d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_set_para.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_sniffer_off.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_sniffer_off.o new file mode 100644 index 00000000..4e4d5aec Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_sniffer_off.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_sniffer_on.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_sniffer_on.o new file mode 100644 index 00000000..c4add5cc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_sniffer_on.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_status.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_status.o new file mode 100644 index 00000000..cd169392 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wlan_status.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_write_cache.o b/hardware/arduino/mtk/system/libmtk/debug/vm_write_cache.o new file mode 100644 index 00000000..6f28d258 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_write_cache.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wstarts_with.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wstarts_with.o new file mode 100644 index 00000000..0caa0dbc Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wstarts_with.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wstrcat.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wstrcat.o new file mode 100644 index 00000000..adf74193 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wstrcat.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wstrcmp.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wstrcmp.o new file mode 100644 index 00000000..7dd4e68e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wstrcmp.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wstrcmp_ignore_case.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wstrcmp_ignore_case.o new file mode 100644 index 00000000..a8f47fd2 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wstrcmp_ignore_case.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wstrcpy.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wstrcpy.o new file mode 100644 index 00000000..961ab01e Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wstrcpy.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wstrlen.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wstrlen.o new file mode 100644 index 00000000..354bf970 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wstrlen.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_wstrncpy.o b/hardware/arduino/mtk/system/libmtk/debug/vm_wstrncpy.o new file mode 100644 index 00000000..6183cb4b Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_wstrncpy.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_xml_get_error.o b/hardware/arduino/mtk/system/libmtk/debug/vm_xml_get_error.o new file mode 100644 index 00000000..dcf2185f Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_xml_get_error.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_xml_new_parser.o b/hardware/arduino/mtk/system/libmtk/debug/vm_xml_new_parser.o new file mode 100644 index 00000000..849f6103 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_xml_new_parser.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_xml_parse.o b/hardware/arduino/mtk/system/libmtk/debug/vm_xml_parse.o new file mode 100644 index 00000000..a3882add Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_xml_parse.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_xml_set_data_handler.o b/hardware/arduino/mtk/system/libmtk/debug/vm_xml_set_data_handler.o new file mode 100644 index 00000000..8898fa75 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_xml_set_data_handler.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_xml_set_doctype_handlers.o b/hardware/arduino/mtk/system/libmtk/debug/vm_xml_set_doctype_handlers.o new file mode 100644 index 00000000..f6342801 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_xml_set_doctype_handlers.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vm_xml_set_element_handlers.o b/hardware/arduino/mtk/system/libmtk/debug/vm_xml_set_element_handlers.o new file mode 100644 index 00000000..42d9e247 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vm_xml_set_element_handlers.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vmdcl.o b/hardware/arduino/mtk/system/libmtk/debug/vmdcl.o new file mode 100644 index 00000000..320ade99 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vmdcl.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vmlog.o b/hardware/arduino/mtk/system/libmtk/debug/vmlog.o new file mode 100644 index 00000000..d7887be4 Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vmlog.o differ diff --git a/hardware/arduino/mtk/system/libmtk/debug/vmthread.o b/hardware/arduino/mtk/system/libmtk/debug/vmthread.o new file mode 100644 index 00000000..dfeed26d Binary files /dev/null and b/hardware/arduino/mtk/system/libmtk/debug/vmthread.o differ diff --git a/hardware/arduino/mtk/system/libmtk/include/vm4res.h b/hardware/arduino/mtk/system/libmtk/include/vm4res.h new file mode 100644 index 00000000..21092df3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vm4res.h @@ -0,0 +1,627 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef _VRE4RES_SDK_H_ +#define _VRE4RES_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define VM_RES_SUCCESS 0 /* load resource success */ +#define VM_RES_OUT_OF_MEM -1 /* memory not enough */ +#define VM_RES_PARAM_ERROR -2 /* parameter is not right */ +#define VM_RES_ITEM_NOT_FOUND -3 /* resource not find or file open faild*/ + +#undef __VM_RES_DEBUG_DATA__ + +#ifdef __LINKIT_SDK__ +#define GetString(x) vm_res_get_string((VMUINT32)x) +#define GetImage(x) vm_res_get_image((VMUINT32)x) +#define GetAudio(x) vm_res_get_audio((VMUINT32)x) +#define FreeRes(x) vm_res_delete((VMUINT32)x); +#endif + +/***************************************************************************** + * FUNCTION + * vm_res_init + * DESCRIPTION + * Init LINKIT resource, will load current language table into RAM + * Need to be called before use LINKIT Resource. + * PARAMETERS + * VMINT32 + * RETURNS + * VM_RES_SUCCESS + * VM_RES_ITEM_NOT_FOUND : file cannot open + * SEE ALSO + * vm_res_deinit + * EXAMPLE + * init the resource + * + * vm_res_init(); + * ... + * vm_res_deinit(); + * + *****************************************************************************/ +extern VMINT32 vm_res_init(void); + + +/***************************************************************************** + * FUNCTION + * vm_res_init_with_language + * DESCRIPTION + * Init LINKIT resource, will load special language table into RAM + * Need to be called before use LINKIT Resource. + * PARAMETERS + * language : language id to load, the id can be get for reseditor + * RETURNS + * VM_RES_SUCCESS + * VM_RES_ITEM_NOT_FOUND : file cannot open + * EXAMPLE + * init the resource + * + * vm_res_init_with_language(44); // load english + * ... + * vm_res_deinit(); + * + *****************************************************************************/ +extern VMINT32 vm_res_init_with_language(VMUINT32 language); + + +/***************************************************************************** + * FUNCTION + * vm_res_deinit + * DESCRIPTION + * Release all LINKIT resource, will free all memory of resource + * Could be called after use LINKIT Resource. + * PARAMETERS + * VMINT32 + * RETURNS + * VM_RES_SUCCESS + * VM_RES_ITEM_NOT_FOUND : file cannot open + * SEE ALSO + * vm_res_deinit + * EXAMPLE + * init the resource + * + * vm_res_init(); + * ... + * vm_res_deinit(); + * + *****************************************************************************/ +extern VMINT32 vm_res_deinit(void); + + +/***************************************************************************** + * FUNCTION + * vm_res_get_string + * DESCRIPTION + * Get the string by ID, no need to delete + * PARAMETERS + * string_id [IN] ID to get. + * RETURNS + * VMUINT8 * String pointer of the ID, only current language, NULL for not found + * EXAMPLE + * display a string in resource + * + * int x; + * int y; + * int wstr_len; + * VMWSTR s; + * vm_graphic_color color; + * + * vm_res_init(); + * s = (VMWSTR)vm_res_get_string(STR_ID_HELLO); + * + * wstr_len = vm_graphic_get_string_width(s); + * + * x = (vm_graphic_get_screen_width() - wstr_len) / 2; + * y = (vm_graphic_get_screen_height() - vm_graphic_get_character_height()) / 2; + * + * color.vm_color_565 = VM_COLOR_WHITE; + * vm_graphic_setcolor(&color); + * + * vm_graphic_fill_rect_ex(layer_hdl[0], 0, 0, vm_graphic_get_screen_width(), vm_graphic_get_screen_height()); + * + * color.vm_color_565 = VM_COLOR_BLUE; + * vm_graphic_setcolor(&color); + * + * vm_graphic_textout_to_layer(layer_hdl[0],x, y, s, wstr_len); + * + * vm_graphic_flush_layer(layer_hdl, 1); + * + * vm_res_deinit(); + * + *****************************************************************************/ +extern VMUINT8 *vm_res_get_string(VMUINT32 string_id); + +/* DOM-NOT_FOR_SDK-BEGIN */ +/***************************************************************************** + * FUNCTION + * vm_res_load_image_start + * DESCRIPTION + * phase out, no use now + * PARAMETERS + * void + * RETURNS + * VMINT32 + *****************************************************************************/ +extern VMINT32 vm_res_load_image_start(void); + + +/***************************************************************************** + * FUNCTION + * vm_res_load_image_end + * DESCRIPTION + * phase out, no use now + * PARAMETERS + * void + * RETURNS + * VMINT32 + *****************************************************************************/ +extern VMINT32 vm_res_load_image_end(void); +/* DOM-NOT_FOR_SDK-END */ + + +/***************************************************************************** + * FUNCTION + * vm_res_get_image + * DESCRIPTION + * Get Image data by ID. Will alloc memory, need to use FreeRes/vm_res_delete to free. + * Only alloc 1 time for the same ID. Will return Image size at the same time. + * PARAMETERS + * image_id : [IN] ID to get. + * size : [OUT] Image size + * RETURNS + * VMUINT8 * Image pointer of the ID + * EXAMPLE + * + * VMUINT8 *res=NULL; + * VMUINT8 *target_layer_buf; + * VMUINT32 size; + * VMINT canvas; + * VMUINT8 *canvas_buffer = NULL; + * struct frame_prop* image_prop = NULL; + * + * vm_res_init(); + * target_layer_buf = vm_graphic_get_layer_buffer(layer_hdl[0]); + * + * res = vm_res_get_image_and_size(IMAGE_1,&size); + * + * if(!res) + * { + * return; + * } + * + * canvas = vm_graphic_load_image(res,size); + * canvas_buffer = vm_graphic_get_canvas_buffer(canvas); + * image_prop = vm_graphic_get_img_property(canvas,1); + * vm_graphic_fill_rect(target_layer_buf, 0, 0, vm_graphic_get_screen_width(), vm_graphic_get_screen_height(), VM_COLOR_BLUE, VM_COLOR_BLUE); + * vm_graphic_blt(target_layer_buf,45,80,canvas_buffer,0,0,image_prop->width,image_prop->height,1); + * vm_graphic_release_canvas(canvas); + * vm_graphic_flush_layer(layer_hdl, 1); + * vm_res_delete(IMAGE_1); + * vm_res_deinit(); + * + *****************************************************************************/ +extern VMUINT8 *vm_res_get_image_and_size(VMUINT32 image_id, VMUINT32 *size); + + +/***************************************************************************** + * FUNCTION + * vm_res_get_image_with_header + * DESCRIPTION + * this is use for vpp file, get Image data by ID. Will alloc memory, need to use FreeRes/vm_res_delete to free. + * Only alloc 1 time for the same ID. + * PARAMETERS + * image_id [IN] ID to get. + * RETURNS + * VMUINT8 * Image pointer of the ID + * SEE ALSO + * vm_res_get_image_and_size_with_header + *****************************************************************************/ +extern VMUINT8 *vm_res_get_image_with_header(VMUINT32 image_id); + + +/***************************************************************************** + * FUNCTION + * vm_res_get_image_and_size_with_header + * DESCRIPTION + * this is use for vpp file, get Image data by ID. Will alloc memory, need to use FreeRes/vm_res_delete to free. + * Only alloc 1 time for the same ID. Will return Image size at the same time. + * PARAMETERS + * image_id : [IN] ID to get. + * size : [OUT] Image size + * RETURNS + * VMUINT8 * Image pointer of the ID + * SEE ALSO + * vm_res_get_image_and_size + *****************************************************************************/ +extern VMUINT8 *vm_res_get_image_and_size_with_header(VMUINT32 image_id, VMUINT32 *size); + + +/***************************************************************************** + * FUNCTION + * vm_res_get_image_and_size_from_file + * DESCRIPTION + * Get other file's image data by ID. this api need application to alloc memory. + * PARAMETERS + * filename : [IN] File full path + * image_id : [IN] ID to get. + * buff : [IN] Buffer to put image data, if the is NULL, the function will return image size + * size : [IN/OUT] when buff is NULL, this is output parameter, will get image size; when buff is not NULL, this is input parameter + * RETURNS + * VMINT 1 is ok, o is error + * SEE ALSO + * vm_res_get_audio_and_size_from_file + * EXAMPLE + * + VMINT result; + * VMUINT8 *res=NULL; + * VMUINT8 *target_layer_buf; + * VMUINT32 size; + * VMINT canvas; + * VMUINT8 *canvas_buffer = NULL; + * struct frame_prop* image_prop = NULL; + * + * vm_res_init(); + * target_layer_buf = vm_graphic_get_layer_buffer(layer_hdl[0]); + * + * result = vm_res_get_image_and_size_from_file("E:\\sample.vxp", IMAGE_1,NULL, &size); + * + * if(!result ) + * { + * return; + * } + * + * res = vm_calloc(size+1); + * result = vm_res_get_image_and_size_from_file("E:\\sample.vxp", IMAGE_1,res, &size); + * + * if(!result ) + * { + * vm_free(res); + * return; + * } + * + * canvas = vm_graphic_load_image(res,size); + * canvas_buffer = vm_graphic_get_canvas_buffer(canvas); + * image_prop = vm_graphic_get_img_property(canvas,1); + * vm_graphic_fill_rect(target_layer_buf, 0, 0, vm_graphic_get_screen_width(), vm_graphic_get_screen_height(), VM_COLOR_BLUE, VM_COLOR_BLUE); + * vm_graphic_blt(target_layer_buf,45,80,canvas_buffer,0,0,image_prop->width,image_prop->height,1); + * vm_graphic_release_canvas(canvas); + * vm_graphic_flush_layer(layer_hdl, 1); + * vm_free(res) + * vm_res_deinit(); + * + *****************************************************************************/ +extern VMINT vm_res_get_image_and_size_from_file(VMWSTR filename, VMUINT32 image_id, void* buff, VMUINT32 *size); + + +/***************************************************************************** + * FUNCTION + * vm_res_get_audio_and_size_from_file + * DESCRIPTION + * Get file's audio data by ID. this api need application to alloc memory. + * PARAMETERS + * filename : [IN] File full path + * image_id : [IN] ID to get. + * buff : [IN] Buffer to put audio data, if the is NULL, the function will return audio size + * size : [IN/OUT] when buff is NULL, this is output parameter, will get audio size; when buff is not NULL, this is input parameter + * RETURNS + * VMINT 1 is ok, o is error + * SEE ALSO + * vm_res_get_image_and_size_from_file + * EXAMPLE + * + * VMINT result; + * VMUINT8 *res=NULL; + * VMUINT32 size; + * + * vm_res_init(); + * + * result = vm_res_get_audio_and_size_from_file("E:\\sample.vxp", AUDIO_1,NULL, &size); + * + * if(!result ) + * { + * return; + * } + * + * res = vm_calloc(size+1); + * result = vm_res_get_audio_and_size_from_file("E:\\sample.vxp", AUDIO_1,res, &size); + * + * if(!result ) + * { + * vm_free(res); + * return; + * } + * + * vm_free(res) + * vm_res_deinit(); + * + *****************************************************************************/ +extern VMINT vm_res_get_audio_and_size_from_file(VMWSTR filename, VMUINT32 audio_id, void *buff, VMUINT32 *size); + + +/***************************************************************************** + * FUNCTION + * vm_res_get_string_and_size_from_file + * DESCRIPTION + * Get file's string data by ID. this api need application to alloc memory. + * PARAMETERS + * filename : [IN] File full path + * image_id : [IN] ID to get. + * buff : [IN] Buffer to put string data, if the is NULL, the function will return string size + * size : [IN/OUT] when buff is NULL, this is output parameter, will get string size; when buff is not NULL, this is input parameter + * RETURNS + * VMINT 1 is ok, o is error + * SEE ALSO + * vm_res_get_audio_and_size_from_file + * EXAMPLE + * + * VMINT result; + * VMUINT8 *res=NULL; + * VMUINT32 size; + * + * vm_res_init(); + * + * result = vm_res_get_string_and_size_from_file("E:\\sample.vxp", STRING_1,NULL, &size); + * + * if(!result ) + * { + * return; + * } + * + * res = vm_calloc(size+1); + * result = vm_res_get_string_and_size_from_file("E:\\sample.vxp", STRING_1,res, &size); + * + * if(!result ) + * { + * vm_free(res); + * return; + * } + * + * vm_free(res) + * vm_res_deinit(); + * + *****************************************************************************/ +extern VMINT vm_res_get_string_and_size_from_file(VMWSTR filename, VMUINT32 string_id, void *buff, VMUINT32 *size); + + +/***************************************************************************** + * FUNCTION + * vm_res_get_image_and_size_from_rom + * DESCRIPTION + * Get rom app's image data by ID. this api no need application to alloc memory. + * PARAMETERS + * filename : [IN] File full path + * image_id : [IN] ID to get. + * buff : [OUT] image data pointer + * size : [OUT] image size + * RETURNS + * VMINT 1 is ok, o is error + * SEE ALSO + * vm_res_get_audio_and_size_from_rom + * EXAMPLE + * display a string in resource + * + VMINT result; + * VMUINT8 *res=NULL; + * VMUINT8 *target_layer_buf; + * VMUINT32 size; + * VMINT canvas; + * VMUINT8 *canvas_buffer = NULL; + * struct frame_prop* image_prop = NULL; + * + * vm_res_init(); + * target_layer_buf = vm_graphic_get_layer_buffer(layer_hdl[0]); + * + * result = vm_res_get_image_and_size_from_rom("@:\xxxxx.rom", IMAGE_1,&res, &size); + * + * if(!result ) + * { + * return; + * } + * + * canvas = vm_graphic_load_image(res,size); + * canvas_buffer = vm_graphic_get_canvas_buffer(canvas); + * image_prop = vm_graphic_get_img_property(canvas,1); + * vm_graphic_fill_rect(target_layer_buf, 0, 0, vm_graphic_get_screen_width(), vm_graphic_get_screen_height(), VM_COLOR_BLUE, VM_COLOR_BLUE); + * vm_graphic_blt(target_layer_buf,45,80,canvas_buffer,0,0,image_prop->width,image_prop->height,1); + * vm_graphic_release_canvas(canvas); + * vm_graphic_flush_layer(layer_hdl, 1); + * vm_res_deinit(); + * + *****************************************************************************/ +extern VMINT vm_res_get_image_and_size_from_rom(VMWSTR filename, VMUINT32 image_id, void **buff, VMUINT32 *size); + + +/***************************************************************************** + * FUNCTION + * vm_res_get_audio_and_size_from_rom + * DESCRIPTION + * Get rom app's audio data by ID. this api no need application to alloc memory. + * PARAMETERS + * filename : [IN] File full path + * image_id : [IN] ID to get. + * buff : [OUT] audio data pointer + * size : [OUT] audio size + * RETURNS + * VMINT 1 is ok, o is error + * SEE ALSO + * vm_res_get_image_and_size_from_rom + *****************************************************************************/ +extern VMINT vm_res_get_audio_and_size_from_rom(VMWSTR filename, VMUINT32 audio_id, void **buff, VMUINT32 *size); + + +/***************************************************************************** + * FUNCTION + * vm_res_get_string_and_size_from_rom + * DESCRIPTION + * Get rom app's string data by ID. this api no need application to alloc memory. + * PARAMETERS + * filename : [IN] File full path + * image_id : [IN] ID to get. + * buff : [OUT] string data pointer + * size : [OUT] string size + * RETURNS + * VMINT 1 is ok, o is error + * SEE ALSO + * vm_res_get_audio_and_size_from_rom + *****************************************************************************/ +extern VMINT vm_res_get_string_and_size_from_rom(VMWSTR filename, VMUINT32 string_id, void **buff, VMUINT32 *size); + + +/***************************************************************************** + * FUNCTION + * vm_res_get_image + * DESCRIPTION + * Get Image data by ID. Will alloc memory, need to use FreeRes/vm_res_delete to free. + * Only alloc 1 time for the same ID. + * PARAMETERS + * image_id [IN] ID to get. + * RETURNS + * VMUINT8 * Image pointer of the ID + * SEE ALSO + * vm_res_get_image_and_size + * EXAMPLE + * + * VMUINT8 *res=NULL; + * + * res = vm_res_get_image(IMAGE_1); + * + * if(!res) + * { + * return; + * } + * // do somthing + * vm_res_delete(IMAGE_1); + * + *****************************************************************************/ +extern VMUINT8 *vm_res_get_image(VMUINT32 image_id); + + +/***************************************************************************** + * FUNCTION + * vm_res_get_audio + * DESCRIPTION + * Get audio data by ID. Will alloc memory, need to use FreeRes/vm_res_delete to free. + * Only alloc 1 time for the same ID. + * PARAMETERS + * audio_id [IN] ID to get. + * RETURNS + * VMUINT8 * Audio pointer of the ID + * SEE ALSO + * vm_res_get_image + * EXAMPLE + * + * VMUINT8 *res=NULL; + * + * res = vm_res_get_audio(AUDIO_1); + * + * if(!res) + * { + * return; + * } + * // do somthing + * vm_res_delete(AUDIO_1); + * + *****************************************************************************/ +extern VMUINT8 *vm_res_get_audio(VMUINT32 audio_id); + + +/***************************************************************************** + * FUNCTION + * vm_res_delete + * DESCRIPTION + * Management the list of current allocated resource. This is the delete node func + * PARAMETERS + * id [IN] ID of the resource + * RETURNS + * VM_RES_SUCCESS + * VM_RES_PARAM_ERROR + * VM_RES_ITEM_NOT_FOUND + * SEE ALSO + * vm_res_get_image_and_size + * EXAMPLE + * + * VMUINT8 *res=NULL; + * + * res = vm_res_get_audio(AUDIO_1); + * + * if(!res) + * { + * return; + * } + * // do somthing + * vm_res_delete(AUDIO_1); + * + *****************************************************************************/ +extern VMINT32 vm_res_delete(VMUINT32 id); + + +/***************************************************************************** + * FUNCTION + * vm_res_get_virtual_image + * DESCRIPTION + * load resource from current file, system will alloc 16 bytes as virtual image for graphic interface + * this need to call vm_res_delete after use. this will not load the real data of image, only load res offset + * and file handle, graphic interface will load the real data when it to show the image + * PARAMETERS + * image_id [IN] ID of the resource + * RETURNS + * NULL: resource error + * VMUINT8 * virtual struct pointer + * EXAMPLE + * + * VMUINT8 *res=NULL; + * + * res = vm_res_get_virtual_image(IMAGE_1); + * + * if(!res) + * { + * return; + * } + * // do somthing + * vm_res_delete(IMAGE_1); + * + *****************************************************************************/ +extern VMUINT8 *vm_res_get_virtual_image(VMUINT32 image_id); + + +#ifdef __cplusplus +} +#endif + +#endif /* _VRE4RES_SDK_H_ */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmalarm.h b/hardware/arduino/mtk/system/libmtk/include/vmalarm.h new file mode 100644 index 00000000..8101f081 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmalarm.h @@ -0,0 +1,104 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMALARM_SDK_H_ +#define VMALARM_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +typedef struct +{ + VMUINT16 nYear; + VMUINT8 nMonth; + VMUINT8 nDay; + VMUINT8 nHour; + VMUINT8 nMin; + VMUINT8 nSec; + VMUINT8 DayIndex; /* reserved*/ +} vm_alarm_time_struct; + + +typedef enum +{ + VM_ALARM_ERROR_INVALID_ID = -6, // invalid alarm id + VM_ALARM_ERROR_INVALID_TIME, // invalid alarm time. For example: set time is earlier than current phone time + VM_ALARM_ERROR_OF_PROCESS, // the operated alarm does not belong to current app + VM_ALARM_ERROR_OF_RES , // exceed to alarm resource limitation, the max value is 10 + VM_ALARM_ERROR_OF_MEM , // memory is not enough for alarm operation + VM_ALARM_ERROR , // native alarm error + VM_ALARM_OK // success +} vm_alarm_error_t; + + +/* alarm expire callback function prototype */ +typedef void (*VM_ALARMPROC_T)(VMINT alarm_id); + + +/****************************************************************************** + * FUNCTION + * vm_alarm_set + * DESCRIPTION + * set alarm with a dedicated time and expire callback function, the set time must be later than current phone time. + * When the set time expire, the expire callback function will be executed + * PARAMETERS + * expire_time : [IN] set time + * alarm_proc : [IN] expire callback function + * RETURNS + * if succeed, return VM_ALARM_OK ,otherwise, return error code + *****************************************************************************/ +VMINT vm_alarm_set(vm_alarm_time_struct* expire_time, VM_ALARMPROC_T alarm_proc); + + +/****************************************************************************** + * FUNCTION + * vm_alarm_cancel + * DESCRIPTION + * cancel alarm. If the alarm has expire, this cancel operation will do nothing + * PARAMETERS + * alarm_id : [IN] alarm id + * RETURNS + * if succeed, return VM_ALARM_OK ,otherwise, return error code + *****************************************************************************/ +VMINT vm_alarm_cancel(VMINT alarm_id); + +#ifdef __cplusplus +} +#endif + +#endif /* VMALARM_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmappcomm.h b/hardware/arduino/mtk/system/libmtk/include/vmappcomm.h new file mode 100644 index 00000000..e7f5ad20 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmappcomm.h @@ -0,0 +1,246 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef _VM_APP_COMM_SDK_H +#define _VM_APP_COMM_SDK_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" +#include "vmpromng.h" + +/* max number of messages in LINKIT message queue */ +#define VM_APPCOMM_MESSAGE_QUEUE_SIZE 16 + +/* LINKIT application messge id base, application should define its own message id started from this. */ +#define VM_MESSAGE_ID_BASE 1000 + +#define VM_MESSAGE_INVALID_ID 0 + + +/* LINKIT message structure */ +typedef struct +{ + VM_P_HANDLE sender; /* process handle of sender */ + VM_P_HANDLE receiver; /* process handle of receiver */ + VMUINT msg_id; /* message ID */ + VMINT wparam; /* wparam of message */ + VMINT lparam; /* lparam of message */ +} vm_message_struct; + +/* LINKIT message queue struct, a circle array */ +typedef struct +{ + vm_message_struct message[VM_APPCOMM_MESSAGE_QUEUE_SIZE]; /* message array */ + VMINT head; /* message index which first come into the message queue */ + VMINT tail; /* message index which last come into the message queue */ +}vm_message_queue_struct; + +/* mapping table size of native application and LINKIT application */ +#define VM_APPCOMM_MAPPING_TABLE_SIZE 10 + + +/* message mapping table item for the message from LINKIT application to native application*/ +typedef struct +{ + VM_P_HANDLE sender; /* process handle of the LINKIT sendor application want to listen */ + VM_MESSAGE_PROC proc; /* native application receiver callback function */ +}vm_message_proc_mapping_struct; + + +/***************************************************************************** + * FUNCTION + * vm_appcomm_init + * DESCRIPTION + * initialize LINKIT message queue + * PARAMETERS + * void + * RETURNS + * void + * EXAMPLE + * + * You does not need to call this API + * + *****************************************************************************/ +void vm_appcomm_init(void); + + +/***************************************************************************** +* FUNCTION + * vm_appcomm_dispatch_msg + * DESCRIPTION + * dispatch LINKIT message in MMI task. +* RETURNS +* void +* EXAMPLE +* +* you does not need to call this api unless you think the message proc delay +* for a long time +* +*****************************************************************************/ +void vm_appcomm_dispatch_msg(void); + + +/***************************************************************************** + * FUNCTION + * vm_appcomm_reg_msg_proc + * DESCRIPTION + * register LINKIT message proc + * PARAMETERS + * handle : [IN] message sender handle, if despite of sender, this parameter should be set to zero. + * proc : [IN] message proc + * RETURNS + * 1 if register successfully + * 0 if register failed + * EXAMPLE + * + * typedef enum + * { + * CUSTOMER_APPCOMM_SCREEN = VM_MESSAGE_ID_BASE + 1, + * CUSTOMER_APPCOMM_MAX_NUM + * }PEDOMETER_PROCESS_STATUS; + * + * VMINT customer_appcomm_example_cb(VM_P_HANDLE sender, VMUINT msg_id, VMINT wparam, VMINT lparam) + * { + * if (VM_MSG_PAINT != msg_id && VM_MSG_QUIT != msg_id) + * { + * return 0; + * } + * switch(msg_id) + * { + * case CUSTOMER_APPCOMM_SCREEN: + * vm_log_debug("customer_appcomm_example_cb"); + * break; + * + * default: + * break; + * } + * return 1; + * } + * + * void customer_appcomm_init(void) + * { + * VMINT handle = 0; + * handle = vm_pmng_get_current_handle(); + * vm_appcomm_reg_msg_proc(handle, customer_appcomm_example_cb); + * } + * + * void customer_appcomm_deinit(void) + * { + * VMINT handle = 0; + * handle = vm_pmng_get_current_handle(); + * vm_appcomm_dereg_msg_proc(handle, customer_appcomm_example_cb); + * } + * + * void customer_appcomm_handle(void) + * { + * VMINT handle = 0; + * handle = vm_pmng_get_current_handle(); + * vm_post_msg(handle, CUSTOMER_APPCOMM_SCREEN, 0, 0); + * //vm_appcomm_send_msg(handle, CUSTOMER_APPCOMM_SCREEN, 0, 0); + * } + * + *****************************************************************************/ +VMINT vm_appcomm_reg_msg_proc(VMINT handle, VM_MESSAGE_PROC proc); + + +/***************************************************************************** + * FUNCTION + * vm_appcomm_dereg_msg_proc + * DESCRIPTION + * deregister LINKIT message proc + * PARAMETERS + * handle : [IN] message sender handle, if despite of sender, this parameter should be set to zero. + * proc : [IN] message proc + * RETURNS + * 1 if deregister successfully + * 0 if deregister failed + * EXAMPLE + * + * refer from vm_appcomm_reg_msg_proc code example + * + *****************************************************************************/ +VMINT vm_appcomm_dereg_msg_proc(VMINT handle, VM_MESSAGE_PROC proc); + + +/***************************************************************************** + * FUNCTION + * vm_appcomm_send_msg + * DESCRIPTION + * send message to LINKIT app or native app, will invoke message procedure directly. + * PARAMETERS + * phandle : [IN] receiver process handle, if receiver is native application, this value should be zero. + * msg_id : [IN] user defined message ID, should larger than VM_MESSAGE_ID_BASE. + * wparam : [IN] wparam of message. + * lparam : [IN] lparam of message. + * RETURNS + * message procedure return value. + * EXAMPLE + * + * refer from vm_appcomm_reg_msg_proc code example + * + *****************************************************************************/ +VMINT vm_appcomm_send_msg(VMINT handle, VMUINT msg_id, VMINT wparam, VMINT lparam); + + +/***************************************************************************** + * FUNCTION + * vm_appcomm_post_msg + * DESCRIPTION + * post message to LINKIT app or native app, will put this message to the end of LINKIT message queue. + * when this function call finish, MMI task will dispatch LINKIT message and invoke message procedure. + * PARAMETERS + * phandle : [IN] receiver process handle, if receiver is native application, this value should be zero. + * msg_id : [IN] user defined message ID, should larger than VM_MESSAGE_ID_BASE. + * wparam : [IN] wparam of message. + * lparam : [IN] lparam of message. + * RETURNS + * message procedure return value. + * EXAMPLE + * + * refer from vm_appcomm_reg_msg_proc code example + * + *****************************************************************************/ +VMINT vm_appcomm_post_msg(VMINT handle, VMUINT msg_id, VMINT wparam, VMINT lparam); + + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_APP_COMM_SDK_H */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmappmgr.h b/hardware/arduino/mtk/system/libmtk/include/vmappmgr.h new file mode 100644 index 00000000..60df39be --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmappmgr.h @@ -0,0 +1,365 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmappmgr_sdk.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * application manager header file + * + * Author: + * ------- + * + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ +* *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== +*******************************************************************************/ +#ifndef VM_APPMGR_SDK_H +#define VM_APPMGR_SDK_H +#ifdef __cplusplus +extern "C"{ +#endif/*__cplusplus*/ +#include "vmsys.h" +#include "vmdatetime.h" + +#define VM_INSTALL_ID_LEN 60 +#define VM_APPMGR_DEVELOPER_NAME_LEN 30 +#define VM_APPMGR_TEL_NUM_LEN 20 +#define VM_APPMGR_APP_NAME_LEN 15 +#define VM_APPMGR_FILEPATH_LEN 260 + +#define VM_APPMGR_MRE_ALL_FLAG 0x0001 +#define VM_APPMGR_MRE_INSTALLED_FLAG 0x0002 +#define VM_APPMGR_MRE_SHORTCUT_FLAG 0x0004 + +#define VM_APPMGR_WIDGET_PACKAGE_FLAG (0x8001) /* mre widget app */ +#define VM_APPMGR_WALLPAPER_PACKAGE_FLAG (0x8002) /* mre wallpaper app */ +#define VM_APPMGR_LAUNCHER_PACKAGE_FLAG (0x8004) /* mre launcher app */ +#define VM_APPMGR_SCRLOCK_PACKAGE_FLAG (0x8008) /* mre screen lock app */ + +#define VM_APPMGR_VPP_PACKAGE_FLAG \ + (VM_APPMGR_WIDGET_PACKAGE_FLAG |\ + VM_APPMGR_WALLPAPER_PACKAGE_FLAG |\ + VM_APPMGR_LAUNCHER_PACKAGE_FLAG |\ + VM_APPMGR_SCRLOCK_PACKAGE_FLAG) + + +typedef VMCHAR vm_install_id[VM_INSTALL_ID_LEN]; + + + + +typedef enum +{ + VM_APPMGR_INSTALL_TYPE_UNKNOWN = 0, /* UNKNOWN */ + VM_APPMGR_INSTALL_TYPE_DOWNLOAD, /* dwonload from server */ + VM_APPMGR_INSTALL_TYPE_ROM, /* build-in app */ + VM_APPMGR_INSTALL_TYPE_LOCAL_INSTALL, /* install from local */ + VM_APPMGR_INSTALL_TYPE_SHORTCUT, /* shortcut app */ + VM_APPMGR_INSTALL_TYPE_END_OF_ENUM +}vm_appmgr_install_type; + +/* Application storage position type */ +typedef enum +{ + VM_APPMGR_APP_POSITION_UNKNOWN = 0, /* UNKNOWN */ + VM_APPMGR_APP_POSITION_PHONE, /* Phone */ + VM_APPMGR_APP_POSITION_CARD, /* Memory card */ + VM_APPMGR_APP_POSITION_ROM, /* build-in app */ + VM_APPMGR_APP_POSITION_END_OF_ENUM +} vm_appmgr_app_storage_position; + +typedef struct +{ + VMUINT app_id; + VMUINT app_size; + vm_appmgr_install_type install_type; + vm_appmgr_app_storage_position store_pos; + vm_time_t installed_time; + VMUINT16 developer[VM_APPMGR_DEVELOPER_NAME_LEN]; + VMUINT16 tel[VM_APPMGR_TEL_NUM_LEN]; + VMUINT16 app_name[VM_APPMGR_APP_NAME_LEN]; + VMUINT16 app_path[VM_APPMGR_FILEPATH_LEN]; +}vm_install_info; + +typedef enum +{ + VM_WALLPAPER_SRC_HOME_SCREEN, + VM_WALLPAPER_SRC_LOCK_SCREEN +} vm_app_mgr_wallpaper_src_enum; + + +/***************************************************************************** + * FUNCTION + * vm_appmgr_install + * DESCRIPTION + * install mre app + * PARAMETERS + * path : [IN] path of app + * flag : [IN] reserved, please fill 0 + * install_id : [OUT] identification of installed app + * RETURNS + * error code 0 means success + *****************************************************************************/ +VMINT vm_appmgr_install(VMWSTR path, VMINT flag, vm_install_id install_id); + +/***************************************************************************** + * FUNCTION + * vm_appmgr_uninstall + * DESCRIPTION + * uninstall mre app + * PARAMETERS + * install_id : [IN] identification of installed app, can get + * by using vm_appmgr_get_installed_list or vm_appmgr_is_installed + * RETURNS + * error code 0 means success + *****************************************************************************/ +VMINT vm_appmgr_uninstall(vm_install_id install_id); + + +/***************************************************************************** + * FUNCTION + * vm_appmgr_is_installed + * DESCRIPTION + * check the mre app is intalled or not + * PARAMETERS + * path : [IN] path of app + * install_id : [OUT] identification of installed app + * RETURNS + * error code 0 means success + *****************************************************************************/ +VMBOOL vm_appmgr_is_installed(VMWSTR path, vm_install_id install_id); + +/***************************************************************************** + * FUNCTION + * vm_appmgr_get_installed_list + * DESCRIPTION + * get installed app list. set install_id_list to NULL to get number of installed app. + * PARAMETERS + * flag : [IN] + * install_id_list : [OUT] identifications of installed app + * num :[IN/OUT] number of installed app + * RETURNS + * error code 0 means success + *****************************************************************************/ +VMINT vm_appmgr_get_installed_list(VMINT flag ,vm_install_id* install_id_list, VMUINT* num); + +/***************************************************************************** + * FUNCTION + * vm_appmgr_get_install_info + * DESCRIPTION + * get installed app detail information + * PARAMETERS + * vm_install_id : [IN] identification of installed app + * vm_install_info : [OUT] detail information + * RETURNS + * error code 0 means success + *****************************************************************************/ +VMINT vm_appmgr_get_install_info(vm_install_id install_id, vm_install_info* install_info); +/***************************************************************************** + * FUNCTION + * vm_appmgr_activate_launcher + * DESCRIPTION + * Active launcher plug-in + * PARAMETERS + * install_id : [IN] identification of installed app, can get + * by using vm_appmgr_get_installed_list or vm_appmgr_is_installed + * RETURNS + * error code 0 means success + *****************************************************************************/ +VMINT vm_appmgr_activate_launcher(vm_install_id install_id); + +/***************************************************************************** + * FUNCTION + * vm_appmgr_activate_screen_lock + * DESCRIPTION + * Active Screen-Lock plug-in + * PARAMETERS + * install_id : [IN] identification of installed app, can get + * by using vm_appmgr_get_installed_list or vm_appmgr_is_installed + * RETURNS + * error code 0 means success + *****************************************************************************/ +VMINT vm_appmgr_activate_screen_lock(vm_install_id install_id); + +/***************************************************************************** + * FUNCTION + * vm_appmgr_activate_wallpaper + * DESCRIPTION + * Active wallpaper plug-in + * PARAMETERS + * install_id : [IN] identification of installed app, can get + * by using vm_appmgr_get_installed_list or vm_appmgr_is_installed + * RETURNS + * error code 0 means success + *****************************************************************************/ +VMINT vm_appmgr_activate_wallpaper(vm_install_id install_id, vm_app_mgr_wallpaper_src_enum src); + +/****************************************************************************** + * FUNCTION + * vm_appmgr_get_mem_size + * DESCRIPTION + * Get Memory size of DLUI components + * PARAMETERS + * Package : [IN] VM_APPMGR_WIDGET_PACKAGE_FLAG + * VM_APPMGR_LAUNCHER_PACKAGE_FLAG + * VM_APPMGR_WALLPAPER_PACKAGE_FLAG + * VM_APPMGR_SCRLOCK_PACKAGE_FLAG + * RETURNS + * Memory Size requirement, -1 means not support. + ******************************************************************************/ +VMINT vm_appmgr_get_mem_size(VMUINT32 package); +/****************************************************************************** + * FUNCTION + * vm_is_support_downloadable_app_icon + * DESCRIPTION + * check whether downloadable app icon is supported. + * PARAMETERS + * void + * RETURNS + * TRUE means support, FALSE means NOT support. + ******************************************************************************/ +VMINT vm_is_support_downloadable_app_icon(void); + + +/****************************************************************************** + * FUNCTION + * vm_appmgr_is_launcher_activated + * DESCRIPTION + * check whether launcher is activated. + * PARAMETERS + * install_id : [IN] identification of installed app, can get by using + * vm_appmgr_get_installed_list or vm_appmgr_is_installed. + * RETURNS + * TRUE means activated, FALSE means NOT activated. + ******************************************************************************/ +VMINT vm_appmgr_is_launcher_activated(vm_install_id install_id); + + +/****************************************************************************** + * FUNCTION + * vm_appmgr_is_wallpaper_activated + * DESCRIPTION + * check whether wallpaper is activated. + * PARAMETERS + * install_id : [IN] identification of installed app, can get by using + * vm_appmgr_get_installed_list or vm_appmgr_is_installed. + * src : [IN] wallpaper src. + * RETURNS + * TRUE means activated, FALSE means NOT activated. + ******************************************************************************/ +VMINT vm_appmgr_is_wallpaper_activated( + vm_install_id install_id, + VMINT src); + +/****************************************************************************** + * FUNCTION + * vm_appmgr_is_screen_lock_activated + * DESCRIPTION + * check whether screen lock is activated. + * PARAMETERS + * install_id : [IN] identification of installed app, can get by using + * vm_appmgr_get_installed_list or vm_appmgr_is_installed. + * RETURNS + * TRUE means activated, FALSE means NOT activated. + ******************************************************************************/ +VMINT vm_appmgr_is_screen_lock_activated(vm_install_id install_id); + +/****************************************************************************** + * FUNCTION + * vm_appmgr_is_support_launcher + * DESCRIPTION + * check whether launcher is supported. + * PARAMETERS + * void. + * RETURNS + * TRUE means support, FALSE means NOT support. + ******************************************************************************/ +VMINT vm_appmgr_is_support_launcher(void); + + +/****************************************************************************** + * FUNCTION + * vm_appmgr_is_support_wallpaper + * DESCRIPTION + * check whether wallpaper is supported. + * PARAMETERS + * void. + * RETURNS + * TRUE means support, FALSE means NOT support. + ******************************************************************************/ +VMINT vm_appmgr_is_support_wallpaper(void); + +/****************************************************************************** + * FUNCTION + * vm_appmgr_is_support_screen_lock + * DESCRIPTION + * check whether screen_lock is supported. + * PARAMETERS + * void. + * RETURNS + * TRUE means support, FALSE means NOT support. + ******************************************************************************/ +VMINT vm_appmgr_is_support_screen_lock(void); + +/****************************************************************************** + * FUNCTION + * vm_appmgr_is_support_widget + * DESCRIPTION + * check whether widget is supported. + * PARAMETERS + * void. + * RETURNS + * TRUE means support, FALSE means NOT support. + ******************************************************************************/ +VMINT vm_appmgr_is_support_widget(void); + +#ifdef __cplusplus +} +#endif/*__cplusplus*/ + +#endif/*VM_APPMGR_SDK_H*/ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmatcmd.h b/hardware/arduino/mtk/system/libmtk/include/vmatcmd.h new file mode 100644 index 00000000..93020208 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmatcmd.h @@ -0,0 +1,240 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMATCMD_SDK_H +#define VMATCMD_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/***************************************************************************** +* Typedef +*****************************************************************************/ +/*vm_command_type*/ +typedef enum +{ + VM_CMD_AT = 0, // receive AT command + VM_CMD_TYPE_TOTAL // total received command type +} vm_command_type; + +/*vm_command_transmitter_type*/ +typedef enum +{ + VM_UART_TYPE = 0, // reply command resoult though UART + VM_TRANSMITTER_TYPE_TOTAL // reply command type +} vm_command_transmitter_type; + +/*vm_command_struct*/ +typedef struct +{ + VMUINT32 command_type; // command type + VMUINT32 command_buf_size; // command buffer size + char* command_buf; // command buffer +}vm_command_struct; + +/*vm_command_callback*/ +typedef void (*vm_command_callback)(vm_command_struct *param, void *user_data); + + +/***************************************************************************** +* Function +*****************************************************************************/ + +/***************************************************************************** + * FUNCTION + * vm_command_open_port + * DESCRIPTION + * After app open one port, all the command send to the port will transfer to the app. + * Remember that, the port number which just in scope(500~65535) can be used by app. + * User can send AT command like such format: "AT+[port]commandstring",ex:AT+[5000]command1. + * PARAMETERS + * port [IN] the port number, only can use from 500 ~ 65535. + * call_back [IN] callback function, will be invoked when receive at command from this port. + * user_data [IN] user data when you want to use in callback function; if no use, give NULL value. + * RETURNS + * The opened port if sucess, or 0 + * EXAMPLE + * + * + * #define ATCMD_PORT 5000 + * + * void vm_atcmd_callback(vm_command_struct *param, void *user_data) + * { + * int len; + * char ret_buf[50]; + * + * if (VM_CMD_AT == param->command_type) + * { + * // use "AT+[5000]command1" to trigger it. + * if (strncmp(command_buf, "command1", param->command_buf_size)) + * { + * // handle the command and fill the result buffer. + * hadle_command1(ret_buf, &len); + * vm_command_reply(ret_buf, len, VM_UART_TYPE); + * } + * } + * return; + * } + * + * void handle_sysevt(VMINT message, VMINT param) + * { + * switch (message) + * { + * case VM_MSG_CREATE: + * vm_command_open_port(ATCMD_PORT, vm_atcmd_callback, NULL); + * break; + * case VM_MSG_QUIT: + * vm_command_close_port(ATCMD_PORT); + * break; + * } + * } + * return 0; + * } + * + *****************************************************************************/ +extern VMUINT16 vm_command_open_port(VMUINT16 port, vm_command_callback call_back, void *user_data); + +/***************************************************************************** + * FUNCTION + * vm_command_close_port + * DESCRIPTION + * Close the command port when app stop or you don't want to use it. + * PARAMETERS + * port [IN] the port number which be open by vm_open_command_port(). + * RETURNS + * None + * EXAMPLE + * + * + * #define ATCMD_PORT 5000 + * + * void vm_atcmd_callback(vm_command_struct *param, void *user_data) + * { + * int len; + * char ret_buf[50]; + * + * if (VM_CMD_AT == param->command_type) + * { + * // use "AT+[5000]command1" to trigger it. + * if (strncmp(command_buf, "command1", param->command_buf_size)) + * { + * // handle the command and fill the result buffer. + * hadle_command1(ret_buf, &len); + * vm_command_reply(ret_buf, len, VM_UART_TYPE); + * } + * } + * return; + * } + * + * void handle_sysevt(VMINT message, VMINT param) + * { + * switch (message) + * { + * case VM_MSG_CREATE: + * vm_command_open_port(ATCMD_PORT, vm_atcmd_callback, NULL); + * break; + * case VM_MSG_QUIT: + * vm_command_close_port(ATCMD_PORT); + * break; + * } + * } + * return 0; + * } + * + *****************************************************************************/ +extern void vm_command_close_port(VMUINT16 port); + + +/***************************************************************************** + * FUNCTION + * vm_command_reply + * DESCRIPTION + * Response the command resoult to remote terminal which send the AT command. + * PARAMETERS + * reply_buf [IN] command resoult string buffer. + * buf_size [IN] the size of the buffer. + * reply_type [IN] default transfer 0 for AT command reply. + * RETURNS + * None + * EXAMPLE + * + * + * #define ATCMD_PORT 5000 + * + * void vm_atcmd_callback(vm_command_struct *param, void *user_data) + * { + * int len; + * char ret_buf[50]; + * + * if (VM_CMD_AT == param->command_type) + * { + * // use "AT+[5000]command1" to trigger it. + * if (strncmp(command_buf, "command1", param->command_buf_size)) + * { + * // handle the command and fill the result buffer. + * hadle_command1(ret_buf, &len); + * vm_command_reply(ret_buf, len, VM_UART_TYPE); + * } + * } + * return; + * } + * + * void handle_sysevt(VMINT message, VMINT param) + * { + * switch (message) + * { + * case VM_MSG_CREATE: + * vm_command_open_port(ATCMD_PORT, vm_atcmd_callback, NULL); + * break; + * case VM_MSG_QUIT: + * vm_command_close_port(ATCMD_PORT); + * break; + * } + * } + * return 0; + * } + * + *****************************************************************************/ +extern void vm_command_reply(char* reply_buf, VMUINT32 buf_size, VMUINT32 reply_type); + +#ifdef __cplusplus +} +#endif + +#endif /* VMATCMD_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmbase64.h b/hardware/arduino/mtk/system/libmtk/include/vmbase64.h new file mode 100644 index 00000000..22e9ef04 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmbase64.h @@ -0,0 +1,478 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMBASE64_SDK_H_ +#define VMBASE64_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "vmsys.h" + +/* System used, the structure used to record and maintain the context of base64 */ +typedef struct +{ + VMUINT8 buf[4]; /* private data, All the fileds in this structure are absolutely private data, which only will be accessed by BASE64 lib inside. So no detail information about them be here. */ + VMUINT8 buf_cnt; /* private data */ + VMUINT8 finish_flag;/* private data */ + VMUINT8 illchr_flag;/* private data */ + VMUINT8 illpad_flag;/* private data */ + + VMUINT8 wrap_count; /* private data */ + VMUINT8 wrap_max; /* private data */ + VMUINT8 reserved[2];/* private data */ +}vm_base64_part_context; + +/***************************************************************************** +* FUNCTION +* vm_base64_encode_basic +* DESCRIPTION +* The vm_base64_encode_basic function encodes a piece of data into BASE64 format. +* PARAMETERS +* src : [IN] Point to the source content buffer to be encoded. +* srcl : [IN] Number of the size of source content buffer to be encoded. +* dst : [IN/OUT] Point to the output buffer of encoded content. +* If the parameter is NULL, the return value will be the needed output buffer size. +* dstl : [IN] Number of the size of output buffer of encoded content. +* If the [dst] parameter is NULL, this parameter will be ignored. +* auto_line_wrap : [IN] Line break (CRLF) will be added after each 76 bytes have been written to output buffer. +* RETURN VALUES +* -1 : It indicates that the given output buffer size is not enough, which SHOULD be avoid. +* >=0 : the number of needed output buffer size OR the number of bytes written to the buffer pointed to by [dst]. +* EXAMPLE +* +* #define VM_BASE64_LEN (64) +* +* char src[] = "MediaTek (Beijing) Inc"; +* char des_encode[VM_BASE64_LEN]; +* char des_decode[VM_BASE64_LEN]; +* +* VMINT32 src_len, des_len1, des_len2; +* +* src_len = strlen(src); +* memset(des_encode, 0, sizeof(des_encode)); +* +* des_len1 = VM_BASE64_LEN; +* des_len2 = VM_BASE64_LEN; +* +* vm_base64_encode_basic( +* src, +* src_len, +* des_encode, +* des_len1, +* TRUE); +* +* memset(des_decode, 0, sizeof(des_decode)); +* des_len2 = VM_BASE64_LEN; +* des_len1 = strlen(des_encode); +* +* vm_base64_decode_basic( +* des_encode, +* des_len1, +* des_decode, +* des_len2); +* +* +*****************************************************************************/ +VMINT32 vm_base64_encode_basic( + const VMCHAR *src, + VMINT32 srcl, + VMCHAR *dst, + VMINT32 dstl, + VMBOOL auto_line_wrap); + +/***************************************************************************** + * FUNCTION + * vm_base64_decode_basic + * DESCRIPTION + * This function is used to decode Base64 string. + * PARAMETERS + * src : [IN] Pointer to the buffer containing encoded data + * srcl : [IN] Length of the encoded data + * dst : [IN/OUT] Point to the output buffer of decoded content. + * If the parameter is NULL, the return value will be the needed output buffer size. + * Note that the returned value is not accurate; it may be larger than the indeed decoded size. + * dstl : [IN] Length of destination buffer. + * RETURN VALUES + * -1 : It indicates that the given output buffer size is not enough, which should be avoid + * >=0 : The number of needed output buffer size OR the number of bytes written to the buffer pointed to by [dst]. + * EXAMPLE + * + * #define VM_BASE64_LEN (64) + * + * char src[] = "MediaTek (Beijing) Inc"; + * char des_encode[VM_BASE64_LEN]; + * char des_decode[VM_BASE64_LEN]; + * + * VMINT32 src_len, des_len1, des_len2; + * + * src_len = strlen(src); + * memset(des_encode, 0, sizeof(des_encode)); + * + * des_len1 = VM_BASE64_LEN; + * des_len2 = VM_BASE64_LEN; + * + * vm_base64_encode_basic( + * src, + * src_len, + * des_encode, + * des_len1, + * TRUE); + * + * memset(des_decode, 0, sizeof(des_decode)); + * des_len2 = VM_BASE64_LEN; + * des_len1 = strlen(des_encode); + * + * vm_base64_decode_basic( + * des_encode, + * des_len1, + * des_decode, + * des_len2); + * + * + *****************************************************************************/ +VMINT32 vm_base64_decode_basic( + const VMCHAR *src, + VMINT32 srcl, + VMCHAR *dst, + VMINT32 dstl); + +/***************************************************************************** + * FUNCTION + * vm_base64_part_encode_init + * DESCRIPTION + * This function initializes the STREAM-STYLE part by part BASE64 + * encode process and calculate the needed output buffer size per-part. + * PARAMETERS + * cntx : [IN] point to the vm_base64_part_context + * max_part_buf_size : [IN] the number of MAX input buffer size per-part. + * auto_line_wrap : [IN] Line break (CRLF) will be added after each 76 bytes have been written to output buffer. + * RETURN VALUES + * -1 : Invalid parameter, It the context is NULL + * >= 0 : The MIN output buffer size needed for the per-parts process. + * EXAMPLE + * + * #define VM_BASE64_LEN (64) + * + * char src[] = "MediaTek (Beijing) Inc"; + * char des_encode[VM_BASE64_LEN]; + * char des_decode[VM_BASE64_LEN]; + * vm_base64_part_context cntx; + * VMINT32 src_len, des_len1, des_len2, temp; + * + * src_len = strlen(src); + * memset(des_encode, 0, sizeof(des_encode)); + * des_len1 = VM_BASE64_LEN; + * + * vm_base64_part_encode_init(&cntx, 0, TRUE); + * + * temp =src_len; + * vm_base64_part_encode_append(&cntx, src, &temp, des_encode, des_len1); + * + * vm_base64_part_encode_finish(&cntx, des_encode+reval, des_len1-reval); + * + * vm_base64_part_decode_init(&cntx,0); + * + * temp=des_len1; + * memset(des_decode, 0, sizeof(des_decode)); + * des_len2 = VM_BASE64_LEN; + * vm_base64_part_decode_append(&cntx, des_encode, &temp, des_decode,des_len2); + * + * vm_base64_part_decode_finish(&cntx, NULL); + * + * + *****************************************************************************/ +VMINT32 vm_base64_part_encode_init( + vm_base64_part_context *cntx, + VMINT32 max_part_buf_size, + VMBOOL auto_line_wrap); + +/***************************************************************************** + * FUNCTION + * vm_base64_part_encode_append + * DESCRIPTION + * The vm_base64_part_encode_append function accepts next part of source data, encode them to BASE64 format. + * PARAMETERS + * cntx : [IN] Point to the BASE64 part context. + * src : [IN] Point to the source content buffer to be encoded. + * srcl : [IN/OUT] Point to the number of the size of source content buffer to be encoded, it MUST NOT be NULL, the the number MUST NOT be less than ZERO. + * dst : [IN/OUT] Point to the output buffer of encoded content. + * dstl : [IN] Number of the size of output buffer. + * RETURN VALUES + * -1 : If the context is NULL or it was modified outside, the return value is -1. + * >=0 : If the function succeeds, the return value is the number of bytes written to output buffer, and the [*srcl] indicates how many input buffer was processed. Note that: if the output buffer size is NOT LESS THAN the return value of the vm_base64_part_decode_init function, and the input size buffer is NOT LARGER THAN the [max_part_buf_size] value, the OUT [*srcl] value is always equal to the IN [*src] value, in this case you can ignore the OUT [*srcl] value safely. + * EXAMPLE + * + * #define VM_BASE64_LEN (64) + * + * char src[] = "MediaTek (Beijing) Inc"; + * char des_encode[VM_BASE64_LEN]; + * char des_decode[VM_BASE64_LEN]; + * vm_base64_part_context cntx; + * VMINT32 src_len, des_len1, des_len2, temp; + * + * src_len = strlen(src); + * memset(des_encode, 0, sizeof(des_encode)); + * des_len1 = VM_BASE64_LEN; + * + * vm_base64_part_encode_init(&cntx, 0, TRUE); + * + * temp =src_len; + * vm_base64_part_encode_append(&cntx, src, &temp, des_encode, des_len1); + * + * vm_base64_part_encode_finish(&cntx, des_encode+reval, des_len1-reval); + * + * vm_base64_part_decode_init(&cntx,0); + * + * temp=des_len1; + * memset(des_decode, 0, sizeof(des_decode)); + * des_len2 = VM_BASE64_LEN; + * vm_base64_part_decode_append(&cntx, des_encode, &temp, des_decode,des_len2); + * + * vm_base64_part_decode_finish(&cntx, NULL); + * + * + *****************************************************************************/ +VMINT32 vm_base64_part_encode_append( + vm_base64_part_context *cntx, + const VMCHAR *src, + VMINT32 *srcl, + VMCHAR *dst, + VMINT32 dstl); + +/***************************************************************************** + * FUNCTION + * vm_base64_part_encode_finish + * DESCRIPTION + * The vm_base64_part_encode_finish function finish the part-by-part encode process, encode the last bytes into BASE64 format if there are. + * PARAMETERS + * cntx : [IN] Point to the vm_qprint_context + * dst : [IN/OUT] Point to the output buffer of decoded content. + * dstl : [IN] Number of the size of output buffer of encoded content. It must be larger than 6. + * RETURN VALUES + * >=0 : If the function succeeds, the return value is the number of bytes written to output buffer, + * -1 : If the function failed, the return value is -1 it means the context data was NULL or be changed outsides or the output buffer size is too small. + * EXAMPLE + * + * #define VM_BASE64_LEN (64) + * + * char src[] = "MediaTek (Beijing) Inc"; + * char des_encode[VM_BASE64_LEN]; + * char des_decode[VM_BASE64_LEN]; + * vm_base64_part_context cntx; + * VMINT32 src_len, des_len1, des_len2, temp; + * + * src_len = strlen(src); + * memset(des_encode, 0, sizeof(des_encode)); + * des_len1 = VM_BASE64_LEN; + * + * vm_base64_part_encode_init(&cntx, 0, TRUE); + * + * temp =src_len; + * vm_base64_part_encode_append(&cntx, src, &temp, des_encode, des_len1); + * + * vm_base64_part_encode_finish(&cntx, des_encode+reval, des_len1-reval); + * + * vm_base64_part_decode_init(&cntx,0); + * + * temp=des_len1; + * memset(des_decode, 0, sizeof(des_decode)); + * des_len2 = VM_BASE64_LEN; + * vm_base64_part_decode_append(&cntx, des_encode, &temp, des_decode,des_len2); + * + * vm_base64_part_decode_finish(&cntx, NULL); + * + * + *****************************************************************************/ +VMINT32 vm_base64_part_encode_finish( + vm_base64_part_context* cntx, + VMCHAR *dst, + VMINT32 dstl); + +/***************************************************************************** + * FUNCTION + * vm_base64_part_decode_init + * DESCRIPTION + * The vm_base64_part_decode_init function initialize the part by part style BASE64 decode process and calculate the needed output buffer size per-part. + * PARAMETERS + * cntx : [IN] Point to the BASE64 part context. + * max_part_buf_size : [IN] The number of MAX input buffer size per-part. + * RETURN VALUES + * >=0 : If the function succeeds, the return value is the MIN output buffer size needed for the per-part process. + * -1 : If the context is NULL, the return value is -1. + * EXAMPLE + * + * #define VM_BASE64_LEN (64) + * + * char src[] = "MediaTek (Beijing) Inc"; + * char des_encode[VM_BASE64_LEN]; + * char des_decode[VM_BASE64_LEN]; + * vm_base64_part_context cntx; + * VMINT32 src_len, des_len1, des_len2, temp; + * + * src_len = strlen(src); + * memset(des_encode, 0, sizeof(des_encode)); + * des_len1 = VM_BASE64_LEN; + * + * vm_base64_part_encode_init(&cntx, 0, TRUE); + * + * temp =src_len; + * vm_base64_part_encode_append(&cntx, src, &temp, des_encode, des_len1); + * + * vm_base64_part_encode_finish(&cntx, des_encode+reval, des_len1-reval); + * + * vm_base64_part_decode_init(&cntx,0); + * + * temp=des_len1; + * memset(des_decode, 0, sizeof(des_decode)); + * des_len2 = VM_BASE64_LEN; + * vm_base64_part_decode_append(&cntx, des_encode, &temp, des_decode,des_len2); + * + * vm_base64_part_decode_finish(&cntx, NULL); + * + * + *****************************************************************************/ +VMINT32 vm_base64_part_decode_init( + vm_base64_part_context *cntx, + VMINT32 max_part_buf_size); + +/***************************************************************************** + * FUNCTION + * vm_base64_part_decode_append + * DESCRIPTION + * This function accepts next part of source data; + * decode them from BASE64 format + * PARAMETERS + * cntx : [IN] Point to the BASE64 part context. + * src : [IN] Point to the source content buffer to be decoded. + * srcl : [IN] Point to the number of the size of source content buffer to de encoded. + * dst : [IN/OUT] Point to the output buffer of decoded content. + * dstl : [IN] Number of the size of output buffer. + * RETURN VALUES + * >=0 : If the function succeeds, the return value is the number of bytes written to output buffer. and the [*srcl] indicates how many input buffer was processed. Note that: if the output buffer size is NOT LESS THAN the return value of the vm_base64_part_decode_init function, and the input size buffer is NOT LARGER THAN the [max_part_buf_size] value, the OUT [*srcl] value is always equal to the IN [*src] value + * -1 : It the context is NULL or modified outside, the return value is -1. + * EXAMPLE + * + * #define VM_BASE64_LEN (64) + * + * char src[] = "MediaTek (Beijing) Inc"; + * char des_encode[VM_BASE64_LEN]; + * char des_decode[VM_BASE64_LEN]; + * vm_base64_part_context cntx; + * VMINT32 src_len, des_len1, des_len2, temp; + * + * src_len = strlen(src); + * memset(des_encode, 0, sizeof(des_encode)); + * des_len1 = VM_BASE64_LEN; + * + * vm_base64_part_encode_init(&cntx, 0, TRUE); + * + * temp =src_len; + * vm_base64_part_encode_append(&cntx, src, &temp, des_encode, des_len1); + * + * vm_base64_part_encode_finish(&cntx, des_encode+reval, des_len1-reval); + * + * vm_base64_part_decode_init(&cntx,0); + * + * temp=des_len1; + * memset(des_decode, 0, sizeof(des_decode)); + * des_len2 = VM_BASE64_LEN; + * vm_base64_part_decode_append(&cntx, des_encode, &temp, des_decode,des_len2); + * + * vm_base64_part_decode_finish(&cntx, NULL); + * + * + *****************************************************************************/ +VMINT32 vm_base64_part_decode_append( + vm_base64_part_context* cntx, + const VMCHAR *src, + VMINT32 *srcl, + VMCHAR *dst, + VMINT32 dstl); + +/***************************************************************************** + * FUNCTION + * vm_base64_part_decode_finish + * DESCRIPTION + * This function finishes the part-by-part decoding process. + * PARAMETERS + * cntx : [IN] Point to the BASE64 part context. + * illegal_format : [IN/OUT] Point to the illegal format flag, if you can ignore this safely, you can set it NULL. + * RETURN VALUES + * 0 : If the function succeeds, the return value is 0. if illegal character or invalid pad character was found during the process, and the [illegal_format] is NOT NULL, the [illegal_format] will be set as TRUE. + * -1 : If the context is NULL or modified outside, the return value is -1. + * EXAMPLE + * + * #define VM_BASE64_LEN (64) + * + * char src[] = "MediaTek (Beijing) Inc"; + * char des_encode[VM_BASE64_LEN]; + * char des_decode[VM_BASE64_LEN]; + * vm_base64_part_context cntx; + * VMINT32 src_len, des_len1, des_len2, temp; + * + * src_len = strlen(src); + * memset(des_encode, 0, sizeof(des_encode)); + * des_len1 = VM_BASE64_LEN; + * + * vm_base64_part_encode_init(&cntx, 0, TRUE); + * + * temp =src_len; + * vm_base64_part_encode_append(&cntx, src, &temp, des_encode, des_len1); + * + * vm_base64_part_encode_finish(&cntx, des_encode+reval, des_len1-reval); + * + * vm_base64_part_decode_init(&cntx,0); + * + * temp=des_len1; + * memset(des_decode, 0, sizeof(des_decode)); + * des_len2 = VM_BASE64_LEN; + * vm_base64_part_decode_append(&cntx, des_encode, &temp, des_decode,des_len2); + * + * vm_base64_part_decode_finish(&cntx, NULL); + * + * + *****************************************************************************/ +VMINT32 vm_base64_part_decode_finish( + vm_base64_part_context* cntx, + VMBOOL* illegal_format); + +#ifdef __cplusplus +} +#endif + +#endif /* VMSTDLIB_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmbitstream.h b/hardware/arduino/mtk/system/libmtk/include/vmbitstream.h new file mode 100644 index 00000000..6183ae7a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmbitstream.h @@ -0,0 +1,386 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef _VM_BITSTREAM_SDK_H +#define _VM_BITSTREAM_SDK_H +/* SDK header file */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + + +#define VM_BITSTREAM_SUCCEED 0 +#define VM_BITSTREAM_BUFFER_OVERFLOW 8001 +#define VM_BITSTREAM_BUFFER_UNDERFLOW 8002 +#define VM_BITSTREAM_EVENT_NONE 8003 +#define VM_BITSTREAM_EVENT_DATA_REQUEST 8004 +#define VM_BITSTREAM_EVENT_ERROR 8005 +#define VM_BITSTREAM_RECOVER 8006 +#define VM_BITSTREAM_INTERRUPT 8100 +#define VM_BITSTREAM_INTERRUPT_RESUME 8101 + +#define VM_BITSTREAM_ERR_FAILED -8001 +#define VM_BITSTREAM_ERR_INVALID_RESOULTION -8002 +#define VM_BITSTREAM_ERR_UNSUPPORTED_FORMAT -8003 +#define VM_BITSTREAM_ERR_INVALID_BITSTREAM -8004 +#define VM_BITSTREAM_ERR_MEMORY_INSUFFICIENT -8005 +#define VM_BITSTREAM_ERR_INSUFFICIENT_MEMORY -8006 /* MED memory is not enough, should check MED memory scenario */ +#define VM_BITSTREAM_ERR_INVALID_FORMAT -8007 /* there is some error while decoding the frame, the frame may not be a valid one */ +#define VM_BITSTREAM_NOT_SUPPORTED -8008 /* Something which is not supported by Bitstream API, e.g. incorrect invoking sequence, features not available */ +#define VM_BITSTREAM_INVALID_PARAMETER -8009 /* The parameter passed through the API is invalid */ + +#define VM_BITSTREAM_FAILED -1 + + +/* format type */ +typedef enum +{ + VM_BITSTREAM_CODEC_TYPE_NONE, /* No type */ + VM_BITSTREAM_CODEC_TYPE_SILENT, /* To play silence frame for video only file */ + VM_BITSTREAM_CODEC_TYPE_AMR, /* AMR */ + VM_BITSTREAM_CODEC_TYPE_AMRWB, /* Wideband AMR */ + VM_BITSTREAM_CODEC_TYPE_AAC, /* AAC */ + VM_BITSTREAM_CODEC_TYPE_DAF, /* DAF */ + VM_BITSTREAM_CODEC_TYPE_MP4A, /* Mpeg-4 audio */ + VM_BITSTREAM_CODEC_TYPE_MP4AG, + VM_BITSTREAM_CODEC_TYPE_WAV, /* RAW data wav */ + VM_BITSTREAM_CODEC_TYPE_ADPCM, /* compressed wav*/ + VM_BITSTREAM_CODEC_TYPE_PCM, /*RAW data, for input data strengh calculation*/ + VM_BITSTREAM_CODEC_TYPE_TOTAL /* Total codec type */ +} vm_bitstream_codec_type_enum; + +typedef enum +{ + VM_BITSTREAM_SAMPLE_FREQ_8000, /* 8000 */ + VM_BITSTREAM_SAMPLE_FREQ_11025, /* 11025 */ + VM_BITSTREAM_SAMPLE_FREQ_16000, /* 16000 */ + VM_BITSTREAM_SAMPLE_FREQ_22050, /* 22050 */ + VM_BITSTREAM_SAMPLE_FREQ_24000, /* 24000 */ + VM_BITSTREAM_SAMPLE_FREQ_32000, /* 32000 */ + VM_BITSTREAM_SAMPLE_FREQ_44100, /* 44100 */ + VM_BITSTREAM_SAMPLE_FREQ_48000, /* 48000 */ + VM_BITSTREAM_SAMPLE_FREQ_TOTAL /* Total sample frequency number */ + +} vm_bitstream_sample_freq_enum; + +/* bitstream aduio configuration structure*/ +typedef struct +{ + vm_bitstream_codec_type_enum vm_codec_type; +} vm_bitstream_audio_cfg_struct; + +/* PCM bitstream aduio configuration structure*/ +typedef struct +{ + vm_bitstream_codec_type_enum vm_codec_type; + VMBOOL isStereo; /* FALSE: mono, TRUE: stereo*/ + VMUINT8 bitPerSample; /* 8 or 16, commonly use 16 bits*/ + vm_bitstream_sample_freq_enum sampleFreq; /* 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000*/ +} vm_bitstream_pcm_audio_cfg_struct; + +/* buffer status */ +typedef struct +{ + VMUINT total_buf_size; + VMUINT free_buf_size; +} vm_bitstream_audio_buffer_status; + +/* paly audio parameters */ +typedef struct +{ + VMUINT start_time; + VMUINT8 volume; + VMUINT8 audio_path; +} vm_bitstream_audio_start_param; + +/* callback function */ +typedef void (*vm_bitstream_audio_result_callback)(VMINT handle, VMINT result); + + +/* Bitstream record quality */ +typedef enum +{ + VM_BITSTREAM_RECORD_QUALITY_LOW, /* Low quality */ + VM_BITSTREAM_RECORD_QUALITY_MED, /* Reserved */ + VM_BITSTREAM_RECORD_QUALITY_HIGH, /* High quality */ + VM_BITSTREAM_RECORD_QUALITY_BEST, /* Reserved */ + + /* For VM_BITSTREAM_CODEC_TYPE_AMR only */ + VM_BITSTREAM_RECORD_AMR_4_75, /* AMR 4.75 kbit/s */ + VM_BITSTREAM_RECORD_AMR_5_15, /* AMR 5.15 kbit/s */ + VM_BITSTREAM_RECORD_AMR_5_9, /* AMR 5.9 kbit/s */ + VM_BITSTREAM_RECORD_AMR_6_7, /* AMR 6.7 kbit/s */ + VM_BITSTREAM_RECORD_AMR_7_4, /* AMR 7.4 kbit/s */ + VM_BITSTREAM_RECORD_AMR_7_95, /* AMR 7.95 kbit/s */ + VM_BITSTREAM_RECORD_AMR_10_2, /* AMR 10.2 kbit/s */ + VM_BITSTREAM_RECORD_AMR_12_2 /* AMR 12.2 kbit/s */ +}vm_bitstream_rec_quality_enum; + +/* Get type of bitstream recorder */ +typedef enum +{ + VM_BITSTREAM_RECORD_GET_LENGTH, /* Get the length of recorded data(VMUINT16*) */ + VM_BITSTREAM_RECORD_GET_DATA, /* Get recorded data(VMUINT16*) */ + VM_BITSTREAM_RECORD_GET_STRENGTH /* Get current data strengh value*/ +}vm_bitstream_record_get_type_enum; + +/* Set type of bitstream recorder */ +typedef enum +{ + VM_BITSTREAM_RECORD_SET_PAUSE, /* Pause bitstream record */ + VM_BITSTREAM_RECORD_SET_RESUME, /* Resume bitstream record */ + VM_BITSTREAM_RECORD_SET_CB_THRESHOLD /* Set callback threshold: default is 200 (words), pass the address of a VMUINT32 to data_p*/ +}vm_bitstream_record_set_type_enum; + +typedef struct +{ + VMUINT16 codec_type; /* vm_bitstream_codec_type_enum */ + VMUINT16 quality; /* vm_bitstream_rec_quality_enum */ +}vm_bitstream_record_cfg_struct; + + +/* ======================== BitStream Audio ============================= */ + +/***************************************************************************** + * FUNCTION + * vm_bitstream_audio_open + * DESCRIPTION + * open bitstream audio. + * PARAMETERS + * handle : [OUT] bitstream handle. + * audio_type : [IN] current type, support ARM,AAC,MP3. + * callback : [IN] callback function. + * RETURNS + * open success or not. + * RETURN VALUES + * VM_BITSTREAM_SUCCEED : open success. + * VM_BITSTREAM_FAILED : open failed. +*****************************************************************************/ +VMINT vm_bitstream_audio_open( + VMINT* handle, + vm_bitstream_audio_cfg_struct *audio_type, + vm_bitstream_audio_result_callback callback); + + +/***************************************************************************** + * FUNCTION + * vm_bitstream_audio_open_pcm + * DESCRIPTION + * open pcm type bitstream audio. + * PARAMETERS + * handle : [OUT] bitstream handle. + * audio_type : [IN] current type, support PCM. + * callback : [IN] callback function. + * RETURNS + * open success or not. + * RETURN VALUES + * VM_BITSTREAM_SUCCEED : open success. + * VM_BITSTREAM_FAILED : open failed. +*****************************************************************************/ +VMINT vm_bitstream_audio_open_pcm( + VMINT* handle, + vm_bitstream_pcm_audio_cfg_struct *audio_type, + vm_bitstream_audio_result_callback callback); + + +/***************************************************************************** + * FUNCTION + * vm_bitstream_audio_finished + * DESCRIPTION + * tell driver no data to put any more. + * PARAMETERS + * handle : [IN] bitstream handle which is getted by vm_bitstream_audio_open. + * RETURNS + * close success or not. + * RETURN VALUES + * VM_BITSTREAM_SUCCEED : finished success. + * VM_BITSTREAM_FAILED : finished failed. +*****************************************************************************/ +VMINT vm_bitstream_audio_finished(VMINT handle); + + +/***************************************************************************** + * FUNCTION + * vm_bitstream_audio_close + * DESCRIPTION + * close bitstream audio. + * PARAMETERS + * handle : [IN] bitstream handle which is getted by vm_bitstream_audio_open. + * RETURNS + * close success or not. + * RETURN VALUES + * VM_BITSTREAM_SUCCEED : close success. + * VM_BITSTREAM_FAILED : close failed. +*****************************************************************************/ +VMINT vm_bitstream_audio_close(VMINT handle); + + +/***************************************************************************** + * FUNCTION + * vm_bitstream_audio_get_buffer_status + * DESCRIPTION + * get data buffer status include free buffer and total buffer size + * PARAMETERS + * handle : [IN] bitstream handle. + * status : [OUT] the status of buffer, please refer the stucture of vm_bitstream_audio_buffer_status. + * RETURNS + * get status success or not. + * RETURN VALUES + * VM_BITSTREAM_SUCCEED : get status success. + * VM_BITSTREAM_FAILED : get status failed. +*****************************************************************************/ +VMINT vm_bitstream_audio_get_buffer_status( + VMINT handle, + vm_bitstream_audio_buffer_status *status); + + +/***************************************************************************** + * FUNCTION + * vm_bitstream_audio_put_data + * DESCRIPTION + * put audio data to buffer. + * PARAMETERS + * handle : [IN] bitstream handle. + * buffer : [IN] buffer data to put. + * buffer_size : [IN] data buffer size. + * written : [OUT] the real data size to put. + * RETURNS + * put data to buffer success or not. + * RETURN VALUES + * VM_BITSTREAM_SUCCEED : put data success. + * VM_BITSTREAM_FAILED : put data failed. +*****************************************************************************/ +VMINT vm_bitstream_audio_put_data( + VMINT handle, + VMUINT8 *buffer, + VMUINT buffer_size, + VMUINT *written); + + +/***************************************************************************** + * FUNCTION + * vm_bitstream_audio_start + * DESCRIPTION + * start to play audio. + * PARAMETERS + * handle : [IN] bitstream handle. + * para : [IN] audio paremeters,refer the structure of vm_bitstream_audio_start_param. + * RETURNS + * play audio success or not. + * RETURN VALUES + * VM_BITSTREAM_SUCCEED : play audio success. + * VM_BITSTREAM_FAILED : play audio failed. +*****************************************************************************/ +VMINT vm_bitstream_audio_start( + VMINT handle, + vm_bitstream_audio_start_param *para); + + +/***************************************************************************** + * FUNCTION + * vm_bitstream_audio_stop + * DESCRIPTION + * stop play audio. + * PARAMETERS + * handle : [IN] bitstream handle. + * RETURNS + * stop audio success or not. + * RETURN VALUES + * VM_BITSTREAM_SUCCEED : stop audio success. + * VM_BITSTREAM_FAILED : stop audio failed. +*****************************************************************************/ +VMINT vm_bitstream_audio_stop(VMINT handle); + + +/***************************************************************************** + * FUNCTION + * vm_bitstream_audio_get_play_time + * DESCRIPTION + * get current play time. + * PARAMETERS + * handle : [IN] bitstream handle. + * current_time : [OUT] current play time(ms). + * RETURNS + * get current play time success or not. + * RETURN VALUES + * VM_BITSTREAM_SUCCEED : get time success. + * VM_BITSTREAM_FAILED : get time failed. +*****************************************************************************/ +VMINT vm_bitstream_audio_get_play_time( + VMINT handle, + VMUINT* current_time); + + +/***************************************************************************** + * FUNCTION + * vm_bitstream_audio_register_interrupt_callback + * DESCRIPTION + * register interrupt callback. + * PARAMETERS + * callback : [IN] callback function pointer. + * RETURNS + * handle of register function + * RETURN VALUES + * 0 : failed. +*****************************************************************************/ +VMINT vm_bitstream_audio_register_interrupt_callback(vm_bitstream_audio_result_callback callback); + + +/***************************************************************************** + * FUNCTION + * vm_bitstream_audio_clear_interrupt_callback + * DESCRIPTION + * clear the interrupt callback. + * PARAMETERS + * handle : [IN] handle from vm_bitstream_audio_register_interrupt_callback. +*****************************************************************************/ +void vm_bitstream_audio_clear_interrupt_callback(VMINT handle); + + +VMINT vm_bitstream_record_open(VMINT* handle_p,vm_bitstream_record_cfg_struct* cfg_p,vm_bitstream_audio_result_callback callback); +VMINT vm_bitstream_record_close(VMINT handle); +VMINT vm_bitstream_record_start(VMINT handle); +VMINT vm_bitstream_record_stop(VMINT handle); +VMINT vm_bitstream_record_get(VMINT handle,vm_bitstream_record_get_type_enum get_type,void* data_p,VMUINT16* data_len_p); +VMINT vm_bitstream_record_set(VMINT handle,vm_bitstream_record_set_type_enum set_type,void* data_p,VMUINT16 data_len); + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_BITSTREAM_SDK_H */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmbridge.h b/hardware/arduino/mtk/system/libmtk/include/vmbridge.h new file mode 100644 index 00000000..d327bf99 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmbridge.h @@ -0,0 +1,192 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmbridge_sdk.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * driver bridge header file + * + * Author: + * ------- + * jianying.li(mtk81091) + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ +* *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== +*******************************************************************************/ +#ifndef VM_BRIDGE_SDK_H +#define VM_BRIDGE_SDK_H +#ifdef __cplusplus +extern "C"{ +#endif/*__cplusplus*/ +#include "vmsys.h" + +/*vm_pipe_type*/ +typedef enum +{ + VM_SOCKET_PIPE_TYPE = 0x01,//VM_SOCKET_PIPE_TYPE + VM_UART_PIPE_TYPE,//VM_UART_PIPE_TYPE + VM_USB_PIPE_TYPE,// VM_USB_PIPE_TYPE + VM_UNDEFINED_TYPE//VM_UNDEFINED_TYPE +}vm_pipe_type; + +/*vm_socket_info*/ +typedef struct +{ + VMINT socket_accpet_fd;//socket_accpet_fd +}vm_socket_info; + +typedef struct +{ + VMUINT8 usb_port;//usb_port +}vm_usb_info; + +/*vm_uart_info*/ +typedef struct +{ + VMUINT32 uart_band;//uart_band + VMUINT8 uart_port;//uart_port + VMUINT8 flowControl;//flowControl +}vm_uart_info; + +/*vm_bridge_info*/ +typedef struct +{ + VMINT type;//type + union//type_info + { + vm_socket_info sock_info;//sock_info + vm_uart_info uart_info;//uart_info + vm_usb_info usb_info;//usb_info + }type_info;//type_info +}vm_bridge_info; + + + +/***************************************************************************** + * FUNCTION + * vm_bridge_create + * DESCRIPTION + * create bridge and connect firPeer and secPeer + * PARAMETERS + * firPeer: the first peer to create + * secPeer: the second peer to create + * RETURNS + * if create success, return 0, else return non_zero val + * USE CASE + * + * //accept sockect fd should obtain when socket accpet() return + * VMINT accpet_id; + * VMINT uart_port_id; + * vm_bridge_info firBridgeInfo, secBridgeInfo; + * VMINT ret; + * // accpet fd should create by your socket listen() action + * firBridgeInfo.type = VM_SOCKET_PIPE_TYPE; + * firBridgeInfo.type_info.sock_info.socket_accpet_fd = accpet_id; + * + * secBridgeInfo.type = VM_UART_PIPE_TYPE; + * secBridgeInfo.type_info.uart_info.uart_port = uart_port_id; + * secBridgeInfo.type_info.uart_info.uart_band = UART_BAUD_9600; + * secBridgeInfo.type_info.uart_info.flowControl = 0; + * + * ret = vm_bridge_create(&firBridgeInfo, &secBridgeInfo); + * if(0 != ret) + * { + * //create bridge fail and can record trace + * } + * + * // run bridge... + * + * //close bridge(optional) + * ret = vm_bridge_close(&firBridgeInfo, &secBridgeInfo); + * + *****************************************************************************/ +extern VMINT vm_bridge_create(vm_bridge_info *firPeer, vm_bridge_info *secPeer); +/***************************************************************************** + * FUNCTION + * vm_bridge_close + * DESCRIPTION + * close bridge and disconnect firPeer and secPeer + * PARAMETERS + * firPeer: the first peer to create + * secPeer: the second peer to create + * RETURNS + * if close success, return 0, else return non_zero val + * USE CASE like vm_bridge_create. + * + * //accept sockect fd should obtain when socket accpet() return + * VMINT accpet_id; + * VMINT uart_port_id; + * vm_bridge_info firBridgeInfo, secBridgeInfo; + * VMINT ret; + * // accpet fd should create by your socket listen() action + * firBridgeInfo.type = VM_SOCKET_PIPE_TYPE; + * firBridgeInfo.type_info.sock_info.socket_accpet_fd = accpet_id; + * + * secBridgeInfo.type = VM_UART_PIPE_TYPE; + * secBridgeInfo.type_info.uart_info.uart_port = uart_port_id; + * secBridgeInfo.type_info.uart_info.uart_band = UART_BAUD_9600; + * secBridgeInfo.type_info.uart_info.flowControl = 0; + * + * ret = vm_bridge_create(&firBridgeInfo, &secBridgeInfo); + * if(0 != ret) + * { + * //create bridge fail and can record trace + * } + * + * // run bridge... + * + * //close bridge(optional) + * ret = vm_bridge_close(&firBridgeInfo, &secBridgeInfo); + * + *****************************************************************************/ +extern VMINT vm_bridge_close(vm_bridge_info *firPeer, vm_bridge_info *secPeer); +#ifdef __cplusplus +} +#endif/*__cplusplus*/ + +#endif/*VM_BRIDGE_SDK_H*/ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmbtcm.h b/hardware/arduino/mtk/system/libmtk/include/vmbtcm.h new file mode 100644 index 00000000..bb597785 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmbtcm.h @@ -0,0 +1,453 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VM_BTCM_SDK_H +#define VM_BTCM_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "vmsys.h" + +#define VM_SRV_BT_CM_BD_FNAME_LEN 56 +#define VM_SRV_BT_CM_MAX_HOST_SUPPORTED_PROFILE 10 + +typedef enum +{ + VM_BT_CM_ERR_LOGICAL = -5, + VM_BT_CM_ERR_BAD_PARAM, + VM_BT_CM_ERR_NO_RESOURCE, + VM_BT_CM_ERR_NOT_SUPPORT, + VM_BT_CM_ERR_NO_AUTHORIZATION, + VM_BT_CM_ERR_SUCCESS = 0 +}vm_btcm_error_t; + +typedef enum +{ + VM_SRV_BT_CM_RESULT_SUCCESS = 0, /* success */ + VM_SRV_BT_CM_RESULT_FAILED = -1, /* failed */ + VM_SRV_BT_CM_RESULT_INVALID_HANDLE = -2, /* invalid instance handler */ + VM_SRV_BT_CM_RESULT_DEV_NOT_FOUND = -3, /* device not found */ + VM_SRV_BT_CM_RESULT_DEV_LIST_FULL = -4, /* device list full */ + VM_SRV_BT_CM_RESULT_NO_CONNECTION = -5, /* there is no connection */ + VM_SRV_BT_CM_RESULT_ONE_HEADSET_CONNECTED = -6, /* there is one headset connected */ + VM_SRV_BT_CM_RESULT_ONE_A2DP_CONNECTED = -7, /* there is one A2DP connection */ + VM_SRV_BT_CM_RESULT_SAME_HEADSET_CONNECTED = -8, /* the same headset is connected */ + VM_SRV_BT_CM_RESULT_PROFILE_NOT_SUPPORT = -9, /* the profile is not supported */ + VM_SRV_BT_CM_RESULT_TOTAL /* last enum for BT CM result code */ +} vm_srv_bt_cm_result_codes_enum; + + +/* event definiation */ +typedef enum +{ + VM_SRV_BT_CM_EVENT_ACTIVATE = 0x00000001, /* activate */ + VM_SRV_BT_CM_EVENT_DEACTIVATE = 0x00000002, /* deactivate */ + VM_SRV_BT_CM_EVENT_INQUIRY_IND = 0x00000004, /* inquiry indication */ + VM_SRV_BT_CM_EVENT_INQUIRY_COMPLETE = 0x00000008, /* inquiry complete */ + VM_SRV_BT_CM_EVENT_BEGIN_ACTIVATE = 0x00000010, // begin activate + VM_SRV_BT_CM_EVENT_BEGIN_DEACTIVATE = 0x00800000, // begin deactivate + VM_SRV_BT_CM_EVENT_BOND_RES = 0x00000020, /* bond result */ + VM_SRV_BT_CM_EVENT_PAIR_IND = 0x00000040, /* pair indication */ + VM_SRV_BT_CM_EVENT_PAIR_RES = 0x00000080, /* pair result */ + VM_SRV_BT_CM_EVENT_SECURITY_USER_CONFIRM = 0x00000100, /* security user confirm */ + VM_SRV_BT_CM_EVENT_SECURITY_PASSKEY_NOTIFY = 0x00000200, /* security passkey notify */ + VM_SRV_BT_CM_EVENT_SECURITY_KEYPRESS_NOTIFY = 0x00000400, /* security keypress notify */ + VM_SRV_BT_CM_EVENT_CONNECT_REQ = 0x00000800, /* connect request */ + VM_SRV_BT_CM_EVENT_CONNECT_RES = 0x00001000, /* connect result */ + VM_SRV_BT_CM_EVENT_DISCONNECT_IND = 0x00002000, /* disconnect indication */ + VM_SRV_BT_CM_EVENT_RELEASE_ALL_CONN = 0x00004000, /* release all connection */ + VM_SRV_BT_CM_EVENT_REFRESH_PROFILE = 0x00008000, /* refresh profile */ + VM_SRV_BT_CM_EVENT_SET_AUTHORIZE = 0x00010000, /* set authorize */ + VM_SRV_BT_CM_EVENT_UNBLOCK = 0x00020000, /* unblock device */ + VM_SRV_BT_CM_EVENT_MYDEV_DEL = 0x00040000, /* mydevice delete */ + VM_SRV_BT_CM_EVENT_SET_VISIBILITY = 0x00100000, /* set visibility */ + VM_SRV_BT_CM_EVENT_SET_NAME = 0x00200000, /* set name */ + VM_SRV_BT_CM_EVENT_SET_AUTHENTICATION = 0x00400000, /* set authentication */ + VM_SRV_BT_CM_EVENT_SET_SIMAP = 0x01000000, /* set SIMAP */ + VM_SRV_BT_CM_EVENT_SCO_IND = 0x02000000, /* sco indication */ + VM_SRV_BT_CM_EVENT_PANIC_IND = 0x04000000, /* panic inidation */ + VM_SRV_BT_CM_EVENT_READ_REMOTE_DEV_NAME = 0x08000000, /* read remote device */ + VM_SRV_BT_CM_EVENT_SET_LIMIT_DISCOVERABLE_MODE = 0x10000000, /* set limit discoverable mode */ + VM_SRV_BT_CM_EVENT_CHIP_DETECT = 0x20000000, /* chip auto detect */ + VM_SRV_BT_CM_EVENT_BOND_CANCEL = 0x40000000, /* bond cancel */ + VM_SRV_BT_CM_EVENT_FAIL_CONN_TO = 0x80000000, /* bond cancel */ + VM_SRV_BT_CM_EVENT_TOTAL /* last bt srv event enum */ +}vm_srv_bt_cm_event_enum; + +/* the power status of BT */ +typedef enum +{ + VM_SRV_BT_CM_POWER_ON, /* power on */ + VM_SRV_BT_CM_POWER_OFF, /* power off */ + VM_SRV_BT_CM_POWER_SWITCHING_ON, /* power switching on */ + VM_SRV_BT_CM_POWER_SWITCHING_OFF, /* power switching off */ + VM_SRV_BT_CM_POWER_TOTAL /* last enum for BT power status */ +}vm_srv_bt_cm_power_status_enum; + +/* visibility type enum */ +typedef enum +{ + VM_SRV_BT_CM_VISIBILITY_ON = 1, /* visibility on, can be discovered by other bt device */ + VM_SRV_BT_CM_VISIBILITY_TEMPORARY_ON, /* visibility temporary on, can be discovered by other bt device for some time */ + VM_SRV_BT_CM_VISIBILITY_OFF, /* visibility off, can not be discovered by other bt device */ + VM_SRV_BT_CM_VISIBILITY_TOTAL /* last enum for visibility type */ +}vm_srv_bt_cm_visibility_type; + +/* Bluetooth device type */ +typedef enum +{ + VM_SRV_BT_CM_DISCOVERED_DEV, /* discovered device */ + VM_SRV_BT_CM_RECENT_USED_DEV, /* recent used device */ + VM_SRV_BT_CM_PAIRED_DEV, /* paired device */ + VM_SRV_BT_CM_ALL_DEV, /* all device */ + VM_SRV_BT_CM_DEV_TYPE_TOTAL +}vm_srv_bt_cm_dev_type_enum; + +/* bt addr */ +struct _vm_srv_bt_cm_bt_addr +{ + VMUINT lap; /* Lower Address Part 00..23 */ + VMUINT8 uap; /* upper Address Part 24..31 */ + VMUINT16 nap; /* Non-significant 32..47 */ +}; + +#ifndef vm_bt_cm_bt_addr +#define vm_bt_cm_bt_addr +typedef struct _vm_srv_bt_cm_bt_addr vm_srv_bt_cm_bt_addr; +#endif + +/* pair indication struct */ +typedef struct +{ + VMINT32 srv_hd; /* service handle*/ + void* user_data; /* user data */ + VMUINT8* dev_name; /* device name */ + VMUINT8 enable_16digits_pin_code; /* whether enable 16 digits pin code */ + vm_srv_bt_cm_bt_addr dev_addr; /* device address */ +} vm_srv_bt_cm_pair_ind_struct; + +/* dev info structure */ +typedef struct +{ + VMUINT cod; /* class of device */ + VMUINT8 name[VM_SRV_BT_CM_BD_FNAME_LEN]; /* device name */ + vm_srv_bt_cm_bt_addr bd_addr; /* device addres */ + VMUINT8 attribute; /* authorized or blocked */ + VMUINT8 service_list_num; /* supported service number */ + VMINT service_list[VM_SRV_BT_CM_MAX_HOST_SUPPORTED_PROFILE]; /* supported service list */ +}vm_srv_bt_cm_dev_struct; + + + +/* event struct for VM_SRV_BT_CM_EVENT_ACTIVATE */ +typedef struct +{ + VMINT res_hd; /* res handle*/ + void * user_data; /* user data */ + VMINT result; /* activate result */ +}vm_srv_bt_cm_activate_struct; + + +/* event struct for VM_SRV_BT_CM_EVENT_DEACTIVATE */ +typedef struct +{ + VMINT res_hd; /* res handle*/ + void * user_data; /* user data */ + VMINT result; /* deactivate result */ +}vm_srv_bt_cm_deactivate_struct; + + +/* event struct for VM_SRV_BT_CM_EVENT_INQUIRY_IND */ +typedef struct +{ + VMINT res_hd; /* res handle*/ + void* user_data; /* user data */ + VMUINT discovered_dev_num; /* discovered device number */ +} vm_srv_bt_cm_inquiry_indication_struct; + +/* event struct for VM_SRV_BT_CM_EVENT_INQUIRY_COMPLETE */ +typedef struct +{ + VMINT res_hd; /* res handle*/ + void * user_data; /* user data */ + VMINT result; /* inquiry complete result */ + VMINT is_cancelled; /* non zero : cancelled by user + * zero : not cancelled by user */ +}vm_srv_bt_cm_inquiry_complete_struct; + +/* event struct for VM_SRV_BT_CM_EVENT_SET_VISIBILITY */ +typedef struct +{ + VMINT res_hd; /* res handle*/ + void * user_data; /* user data */ + VMINT result; /* set visibility result */ + VMINT is_from_mmi; /* to identify whether the action is initiated by MMI + * or change the visibility just by CM service due to A2DP connected */ +}vm_srv_bt_cm_set_visibility_struct; + +/* event struct for VM_SRV_BT_CM_EVENT_SET_NAME */ +typedef struct +{ + VMINT res_hd; /* res handle*/ + void * user_data; /* user data */ + VMINT result; /* set name result in vm_srv_bt_cm_result_codes_enum */ +}vm_srv_bt_cm_set_name_struct; + + +//Pairing method +typedef enum +{ + VM_PIN_AND_SSP = 0, //Pairing need UI and user should confirm,normal case for product,such as phone/mid,we support both pin and ssp + VM_FIXED_PIN_ONLY, //Pairing no need UI,auto accept pairing ,only adopt FIXED PIN CODE method + VM_FIXED_PIN_AND_SSP_JUST_WORK //Pairing no need UI,auto accept pairing ,adopt FIXED PIN CODE and JUST WORK of SSP +}vm_bt_pairing_Type; + + +/****************************************************************************** + * FUNCTION + * vm_btcm_init + * DESCRIPTION + * Bluetooth CM set notifier, after set successfully, + * notifier will receive the event notification it it happens. + * PARAMETERS + * callback : [IN] notifier + * evt_mask: [IN] event mask, refer to vm_srv_bt_cm_event_enum + * user_data : [IN] user data + * + * RETURNS + * VMINT res handle, failure if less than 0, see vm_btcm_error_t + ******************************************************************************/ +VMINT vm_btcm_init(void (*callback)(VMUINT evt, void * param, void * user_data), VMUINT evt_mask, void * user_data); + +/***************************************************************************** + * FUNCTION + * vm_btcm_exit + * DESCRIPTION + * exit btcm, + * PARAMETERS + * res_hd : [IN] res handle + * RETURNS + * failure if less than 0, else successful, see vm_btcm_error_t + *****************************************************************************/ +VMINT vm_btcm_exit(VMINT res_hd); + +/***************************************************************************** + * FUNCTION + * vm_btcm_get_power_status + * DESCRIPTION + * This function is to get current bt power status + * PARAMETERS + * void + * RETURNS + * failure if less than 0, else + * vm_srv_bt_cm_power_status_enum + * VM_SRV_BT_CM_POWER_ON means BT power is ON + * VM_SRV_BT_CM_POWER_OFF means BT power is OFF + * VM_SRV_BT_CM_POWER_SWITCHING_ON means switching power to be ON now + * VM_SRV_BT_CM_POWER_SWITCHING_OFF means switching power to be OFF now + *****************************************************************************/ +VMINT vm_btcm_get_power_status(void); + + +/***************************************************************************** + * FUNCTION + * vm_btcm_switch_on + * DESCRIPTION + * This function is to switch on bt chip, + * and it will also help to activate bt profiles registered to CM service + * PARAMETERS + * void + * RETURNS + * VMINT : refer to vm_srv_bt_cm_result_codes_enum + *****************************************************************************/ +VMINT vm_btcm_switch_on(void); + +/***************************************************************************** + * FUNCTION + * vm_btcm_switch_off + * DESCRIPTION + * This function is to switch off bt, it will also help to deactivate all the activated bt profiles, + * if there is live connection(s), it will disconnect the live connection(s) firstly + * PARAMETERS + * RETURNS + * VMINT : refer to vm_srv_bt_cm_result_codes_enum + *****************************************************************************/ +VMINT vm_btcm_switch_off(void); + +/****************************************************************************** + * FUNCTION + * vm_btcm_srv_set_visibility + * DESCRIPTION + * this function is to set bluetooth visibility + * PARAMETERS + * type: [IN] visibility type + * RETURNS + * VMINT : refer to vm_srv_bt_cm_result_codes_enum + ******************************************************************************/ +VMINT vm_btcm_srv_set_visibility(vm_srv_bt_cm_visibility_type type); + +/****************************************************************************** + * FUNCTION + * vm_btcm_srv_get_visibility + * DESCRIPTION + * this function is to get bluetooth visibility + * PARAMETERS + * void + * RETURNS + * VMINT : refer to vm_srv_bt_cm_result_codes_enum + ******************************************************************************/ +VMINT vm_btcm_srv_get_visibility(void); + +/***************************************************************************** + * FUNCTION + * vm_btcm_search + * DESCRIPTION + * This function is to process inquiry request, + * each time finding a device, it will notify notifier with event VM_SRV_BT_CM_EVENT_INQUIRY_IND , + * after search procedure completed, it will notify notifier VM_SRV_BT_CM_EVENT_INQUIRY_COMPLETE. + * PARAMETERS + * max_response : [IN] max repsone number of device + * time_out : [IN] inquiry timeout timer + * cod : [IN] class of device + * is_name_discovery: [IN] whether do name discovery + * RETURNS + * VMINT : failure if less than 0, see vm_srv_bt_cm_result_codes_enum, else successful + *****************************************************************************/ +VMINT vm_btcm_search(VMUINT8 max_response, VMUINT16 time_out, VMUINT cod, VMBYTE is_name_discovery); + +/***************************************************************************** + * FUNCTION + * vm_btcm_search_abort + * DESCRIPTION + * This function is to process inquiry cancel request + * and invoke srv_bt_cm_cancel_discovery_req_hdler, + * notifier will receive VM_SRV_BT_CM_EVENT_INQUIRY_COMPLETE after cancel inquiry procedure is completed + * PARAMETERS + * void + * RETURNS + * VMINT : refer to vm_srv_bt_cm_result_codes_enum + *****************************************************************************/ +VMINT vm_btcm_search_abort(void); + +/***************************************************************************** + * FUNCTION + * vm_btcm_set_host_name + * DESCRIPTION + * This function is to set host device name, it will notify notifier VM_SRV_BT_CM_EVENT_SET_NAME + * after set host device name procedure is completed. + * PARAMETERS + * name : [IN] host device name, UTF-8 coding + * RETURNS + * VMINT : refer to vm_srv_bt_cm_result_codes_enum + *****************************************************************************/ +VMINT vm_btcm_set_host_name(VMUINT8 * name); + +/***************************************************************************** + * FUNCTION + * vm_btcm_get_host_name + * DESCRIPTION + * This function is to get host device information + * PARAMETERS + * info : [IN] host device info structure in vm_srv_bt_cm_dev_struct + * RETURNS + * VMINT : failure if less than 0, see vm_btcm_error_t, else successful + *****************************************************************************/ +VMINT vm_btcm_get_host_dev_info(vm_srv_bt_cm_dev_struct * info); + +/****************************************************************************** + * FUNCTION + * vm_btcm_get_dev_num + * DESCRIPTION + * this function is to get device number according to device type + * PARAMETERS + * dev_type: [IN] refer to vm_srv_bt_cm_dev_type_enum + * + * RETURNS + * VMINT : device number of designated device type + ******************************************************************************/ +VMINT vm_btcm_get_dev_num(vm_srv_bt_cm_dev_type_enum dev_type); + +/****************************************************************************** + * FUNCTION + * vm_btspp_get_dev_info_by_index + * DESCRIPTION + * this function is to get device info + * PARAMETERS + * index : [IN] device index + * dev_type: [IN] device type + * info: [OUT] device type + * + * RETURNS + * if succeed to find the device, return VM_BT_CM_ERR_SUCCESS + * return value less than 0, if failed to find the device + ******************************************************************************/ +VMINT vm_btcm_get_dev_info_by_index(VMUINT idx, vm_srv_bt_cm_dev_type_enum dev_type, vm_srv_bt_cm_dev_struct * info); + +/***************************************************************************** + * FUNCTION + * vm_bt_cm_send_passkey + * DESCRIPTION + * This function is to process pair request and send passkey + * PARAMETERS + * dev_addr : [IN] device address + * dev_passkey: [IN] passkey + * result : [IN] VM_TURE: valid passkey, VM_FALSE:reject this pair + * RETURNS + * U32 : refer to srv_bt_cm_result_codes_enum + *****************************************************************************/ +VMINT vm_bt_cm_send_passkey(vm_srv_bt_cm_bt_addr* dev_addr, VMUINT8* dev_passkey, VMBOOL result); + + +/***************************************************************************** + * FUNCTION + * vm_custom_set_bt_pairing_method + * DESCRIPTION + * This function is to set bt pair type + * PARAMETERS + * config_type : [IN] pair type + * RETURNS + * None + *****************************************************************************/ +void vm_custom_set_bt_pairing_method(vm_bt_pairing_Type config_type); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* VM_BTCM_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmbtgatt.h b/hardware/arduino/mtk/system/libmtk/include/vmbtgatt.h new file mode 100644 index 00000000..13bba233 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmbtgatt.h @@ -0,0 +1,880 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VM_BTGATT_SDK_H +#define VM_BTGATT_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "vmsys.h" + +#define VM_ATT_HANDLE VMUINT16 + + +typedef VMUINT32 VM_GATT_CHAR_PROPERTIES; +#define VM_GATT_CHAR_PROP_BROADCAST 0x01 +#define VM_GATT_CHAR_PROP_READ 0x02 +#define VM_GATT_CHAR_PROP_WRITE_WO_RESPONSE 0x04 +#define VM_GATT_CHAR_PROP_WRITE 0x08 +#define VM_GATT_CHAR_PROP_NOTIFY 0x10 +#define VM_GATT_CHAR_PROP_INDICATE 0x20 +#define VM_GATT_CHAR_PROP_SIGNED_WRITE 0x40 +#define VM_GATT_EXT_PROP 0x80 + +typedef VMUINT32 VM_GATT_PERMISSION; +#define VM_GATT_PERM_READ (1 << 0) /* bit 0 */ +#define VM_GATT_PERM_READ_ENCRYPTED (1 << 1) /* bit 1 */ +#define VM_GATT_PERM_READ_ENC_MITM (1 << 2) /* bit 2 */ +#define VM_GATT_PERM_WRITE (1 << 4) /* bit 4 */ +#define VM_GATT_PERM_WRITE_ENCRYPTED (1 << 5) /* bit 5 */ +#define VM_GATT_PERM_WRITE_ENC_MITM (1 << 6) /* bit 6 */ +#define VM_GATT_PERM_WRITE_SIGNED (1 << 7) /* bit 7 */ +#define VM_GATT_PERM_WRITE_SIGNED_MITM (1 << 8) /* bit 8 */ + + +typedef enum +{ + VM_OS_STATUS_SUCCESS = 0, + VM_OS_STATUS_FAILED = 1, +}VM_OS_STATUS; + + +#define VM_BD_ADDR_SIZE 6 +typedef struct _VM_BD_ADDR +{ + VMUINT8 addr[VM_BD_ADDR_SIZE]; +}VM_BD_ADDR; + +#define VM_ATT_MAX_VALUE_LEN 512 +typedef struct +{ + VMUINT16 len; + VMUINT8 value[VM_ATT_MAX_VALUE_LEN]; +}VM_ATT_VALUE; + + +typedef struct +{ + /* the len can only be 2, 4, or 16 */ + VMUINT8 len; + VMUINT8 uuid[16]; +}VM_BT_UUID; +typedef struct +{ + VM_BT_UUID uuid; + VMUINT8 inst; +}VM_ATT_UUID; +typedef struct +{ + VM_ATT_UUID uuid; + VMUINT8 is_primary; +}VM_GATT_SVC_UUID; + + + +typedef struct +{ + VMUINT8 uu[16]; +}vm_bt_uuid_struct; + +typedef struct +{ + void *reg_ctx; + void *conn_ctx; +}vm_gatt_conn_struct; + + +/**************************************************************************** +* data define +****************************************************************************/ +/** BT-GATT Server callback structure. */ + +/** Callback invoked in response to register */ +typedef void (*vmt_register_server_callback)(void *reg_ctx, VM_OS_STATUS status, vm_bt_uuid_struct *app_uuid); + +/** Callback indicating that a remote device has connected or been disconnected */ +typedef void (*vmt_connection_callback)(vm_gatt_conn_struct *conn, VMBOOL connected, VM_BD_ADDR *bd_addr); + +/** Callback triggered in response to listen */ +typedef void (*vmt_listen_callback)(void *reg_ctx, VM_OS_STATUS status); + +/** Callback invoked in response to create_service */ +typedef void (*vmt_service_added_callback)(VM_OS_STATUS status, void *reg_ctx, + VM_GATT_SVC_UUID *srvc_id, VM_ATT_HANDLE srvc_handle); + +/** Callback indicating that an included service has been added to a service */ +typedef void (*vmt_included_service_added_callback)(VM_OS_STATUS status, void *reg_ctx, + VM_ATT_HANDLE srvc_handle, VM_ATT_HANDLE incl_srvc_handle); + +/** Callback invoked when a characteristic has been added to a service */ +typedef void (*vmt_characteristic_added_callback)(VM_OS_STATUS status, void *reg_ctx, + VM_ATT_UUID *uuid, VM_ATT_HANDLE srvc_handle, VM_ATT_HANDLE char_handle); + +/** Callback invoked when a descriptor has been added to a characteristic */ +typedef void (*vmt_descriptor_added_callback)(VM_OS_STATUS status, void *reg_ctx, + VM_ATT_UUID *uuid, VM_ATT_HANDLE srvc_handle, VM_ATT_HANDLE descr_handle); + +/** Callback invoked in response to start_service */ +typedef void (*vmt_service_started_callback)(VM_OS_STATUS status, void *reg_ctx, + VM_ATT_HANDLE srvc_handle); + +/** Callback invoked in response to stop_service */ +typedef void (*vmt_service_stopped_callback)(VM_OS_STATUS status, void *reg_ctx, + VM_ATT_HANDLE srvc_handle); + +/** Callback triggered when a service has been deleted */ +typedef void (*vmt_service_deleted_callback)(VM_OS_STATUS status, void *reg_ctx, + VM_ATT_HANDLE srvc_handle); + +/** + * Callback invoked when a remote device has requested to read a characteristic + * or descriptor. The application must respond by calling send_response + */ +typedef void (*vmt_request_read_callback)(vm_gatt_conn_struct *conn, VMUINT16 trans_id, VM_BD_ADDR *bd_addr, + VM_ATT_HANDLE attr_handle, VMUINT16 offset, VMBOOL is_long); + +/** + * Callback invoked when a remote device has requested to write to a + * characteristic or descriptor. + */ +typedef void (*vmt_request_write_callback)(vm_gatt_conn_struct *conn, VMUINT16 trans_id, VM_BD_ADDR *bd_addr, + VM_ATT_HANDLE attr_handle, VM_ATT_VALUE *value, VMUINT16 offset, + VMBOOL need_rsp, VMBOOL is_prep); + +/** Callback invoked when a previously prepared write is to be executed */ +typedef void (*vmt_request_exec_write_callback)(vm_gatt_conn_struct *conn, VMUINT16 trans_id, + VM_BD_ADDR *bd_addr, VMBOOL cancel); + +/** + * Callback triggered in response to send_response if the remote device + * sends a confirmation. + */ +typedef void (*vmt_response_confirmation_callback)(VM_OS_STATUS status, VM_ATT_HANDLE handle); + +/** Callback triggered in response to read_tx_power */ +typedef void (*vmt_read_tx_power_callback)(void *reg_ctx, VM_OS_STATUS status, VM_BD_ADDR *bd_addr, VMUINT8 tx_power); + +typedef struct +{ + vmt_register_server_callback register_server_cb; + vmt_connection_callback connection_cb; + vmt_listen_callback listen_cb; + vmt_service_added_callback service_added_cb; + vmt_included_service_added_callback included_service_added_cb; + vmt_characteristic_added_callback characteristic_added_cb; + vmt_descriptor_added_callback descriptor_added_cb; + vmt_service_started_callback service_started_cb; + vmt_service_stopped_callback service_stopped_cb; + vmt_service_deleted_callback service_deleted_cb; + vmt_request_read_callback request_read_cb; + vmt_request_write_callback request_write_cb; + vmt_request_exec_write_callback request_exec_write_cb; + vmt_response_confirmation_callback response_confirmation_cb; + vmt_read_tx_power_callback read_tx_power_cb; +}vm_gatts_callback_struct; + +/***************************************************************************** + * FUNCTION + * vm_gatts_register + * DESCRIPTION + * Registers a GATT server application with the stack + * PARAMETERS + * uuid [IN] : BT UUID + * callback [IN] : the pointer of callback structure + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_register(vm_bt_uuid_struct *uuid, vm_gatts_callback_struct *callback); + +/***************************************************************************** + * FUNCTION + * vm_gatts_deregister + * DESCRIPTION + * Unregister a server application from the stack + * PARAMETERS + * reg_ctx [IN] : the context of gatt server + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_deregister(void *reg_ctx); + +/***************************************************************************** + * FUNCTION + * vm_gatts_connect + * DESCRIPTION + * Create a connection to a remote peripheral + * PARAMETERS + * reg_ctx [IN] : + * bd_addr [IN] : + * direct [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_connect(void *reg_ctx, VM_BD_ADDR *bd_addr, VMBOOL direct); + +/***************************************************************************** + * FUNCTION + * vm_gatts_disconnect + * DESCRIPTION + * Disconnect an established connection or cancel a pending one + * PARAMETERS + * conn [IN] : + * bd_addr [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_disconnect(vm_gatt_conn_struct *conn, VM_BD_ADDR *bd_addr); + +/***************************************************************************** + * FUNCTION + * vm_gatts_listen + * DESCRIPTION + * Start or stop a listen for connection + * PARAMETERS + * reg_ctx [IN] : + * start [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_listen(void *reg_ctx, VMBOOL start); + +/***************************************************************************** + * FUNCTION + * vm_gatts_add_service + * DESCRIPTION + * Create a new service + * PARAMETERS + * reg_ctx [IN] : + * srvc_id [IN] : + * num_handles [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_add_service(void *reg_ctx, VM_GATT_SVC_UUID *srvc_id, VMUINT16 num_handles); + +/***************************************************************************** + * FUNCTION + * vm_gatts_add_included_service + * DESCRIPTION + * Assign an included service to it's parent service + * PARAMETERS + * reg_ctx [IN] : + * service_handle [IN] : + * included_handle [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_add_included_service(void *reg_ctx, VM_ATT_HANDLE service_handle, VM_ATT_HANDLE included_handle); + +/***************************************************************************** + * FUNCTION + * vm_gatts_add_characteristic + * DESCRIPTION + * Add a characteristic to a service + * PARAMETERS + * reg_ctx [IN] : + * service_handle [IN] : + * uuid [IN] : + * properties [IN] : + * permission [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_add_characteristic(void *reg_ctx, + VM_ATT_HANDLE service_handle, VM_ATT_UUID *uuid, + VM_GATT_CHAR_PROPERTIES properties, VM_GATT_PERMISSION permission); + +/***************************************************************************** + * FUNCTION + * vm_gatts_add_descriptor + * DESCRIPTION + * Add a descriptor to a given service + * PARAMETERS + * reg_ctx [IN] : + * service_handle [IN] : + * uuid [IN] : + * permission [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_add_descriptor(void *reg_ctx, VM_ATT_HANDLE service_handle, + VM_ATT_UUID *uuid, VM_GATT_PERMISSION permission); + +/***************************************************************************** + * FUNCTION + * vm_gatts_start_service + * DESCRIPTION + * Starts a local service + * PARAMETERS + * reg_ctx [IN] : + * service_handle [IN] : + * transport [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_start_service(void *reg_ctx, VM_ATT_HANDLE service_handle, + VMUINT8 transport); + +/***************************************************************************** + * FUNCTION + * vm_gatts_stop_service + * DESCRIPTION + * Stops a local service + * PARAMETERS + * reg_ctx [IN] : + * service_handle [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_stop_service(void *reg_ctx, VM_ATT_HANDLE service_handle); + +/***************************************************************************** + * FUNCTION + * vm_gatts_delete_service + * DESCRIPTION + * Delete a local service + * PARAMETERS + * reg_ctx [IN] : + * service_handle [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_delete_service(void *reg_ctx, VM_ATT_HANDLE service_handle); + +/***************************************************************************** + * FUNCTION + * vm_gatts_send_indication + * DESCRIPTION + * Send value indication to a remote device + * PARAMETERS + * conn [IN] : + * attribute_handle [IN] : + * need_confirm [IN] : + * value [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_send_indication(vm_gatt_conn_struct *conn, VM_ATT_HANDLE attribute_handle, + VMBOOL need_confirm, VM_ATT_VALUE *value); + +/***************************************************************************** + * FUNCTION + * vm_gatts_send_response + * DESCRIPTION + * Send a response to a read/write operation + * PARAMETERS + * conn [IN] : + * trans_id [IN] : + * status [IN] : + * handle [IN] : + * value [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_send_response(vm_gatt_conn_struct *conn, VMUINT16 trans_id, + VM_OS_STATUS status, VM_ATT_HANDLE handle, VM_ATT_VALUE *value); + + +/***************************************************************************** + * FUNCTION + * vm_gatts_read_tx_power + * DESCRIPTION + * Request tx power for a given remote device + * PARAMETERS + * reg_ctx [IN] : + * bd_addr [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gatts_read_tx_power(void *reg_ctx, VM_BD_ADDR *bd_addr); + + + +/**************************************************************************** +* data define +****************************************************************************/ +/* authentication requirement */ +typedef VMUINT8 VM_GATTC_AUTH_REQ; +#define VM_GATTC_AUTH_REQ_NONE 0 +#define VM_GATTC_AUTH_REQ_NO_MITM 1 /* unauthenticated encryption */ +#define VM_GATTC_AUTH_REQ_MITM 2 /* authenticated encryption */ +#define VM_GATTC_AUTH_REQ_SIGNED_NO_MITM 3 +#define VM_GATTC_AUTH_REQ_SIGNED_MITM 4 + +typedef VMUINT8 VM_GATTC_WRITE_TYPE; +#define VM_GATTC_WRITE_TYPE_NO_RSP 1 +#define VM_GATTC_WRITE_TYPE_REQUEST 2 +#define VM_GATTC_WRITE_TYPE_PREPARE 3 + +typedef VMUINT8 VM_GATTC_DEV_TYPE; +#define VM_GATTC_DEV_TYPE_UNKNOWN 0 +#define VM_GATTC_DEV_TYPE_LE 1 +#define VM_GATTC_DEV_TYPE_BR_EDR 2 +#define VM_GATTC_DEV_TYPE_BR_EDR_LE 3 + + + +typedef struct +{ + VM_GATT_SVC_UUID *svc_uuid; + VM_ATT_UUID *ch_uuid; +}vm_gattc_char_struct; + +typedef struct +{ + VM_GATT_SVC_UUID *svc_uuid; + VM_ATT_UUID *ch_uuid; + VM_ATT_UUID *descr_uuid; +}vm_gattc_descr_struct; + +/** BT-GATT Client callback structure. */ + +/** Callback invoked in response to register */ +typedef void (*vmt_register_client_callback)(void *reg_ctx, VM_OS_STATUS status, vm_bt_uuid_struct *app_uuid); + +/** Callback for scan results */ +typedef void (*vmt_scan_result_callback)(void *reg_ctx, VM_BD_ADDR *bd_addr, VMINT32 rssi, VMUINT8 eir_len, VMUINT8 *eir); + +/** Callback indicating that a remote device has connected or been disconnected */ +//typedef void (*vmt_connection_callback)(vm_gatt_conn_struct *conn, VMBOOL connected, VM_BD_ADDR *bd_addr); + +/** Callback triggered in response to listen */ +//typedef void (*vmt_listen_callback)(void *reg_ctx, VM_OS_STATUS status); + +/** Callback triggered in response to set_adv_data */ +typedef void (*vmt_set_adv_data_callback)(void *reg_ctx, VM_OS_STATUS status); + +/** + * Invoked in response to search_service when the GATT service search + * has been completed. + */ +typedef void (*vmt_search_complete_callback)(void *reg_ctx, VM_OS_STATUS status); + +/** Reports GATT services on a remote device */ +typedef void (*vmt_search_result_callback)(vm_gatt_conn_struct *conn, VM_GATT_SVC_UUID *uuid); + +/** GATT characteristic enumeration result callback */ +typedef void (*vmt_get_characteristic_callback)(vm_gatt_conn_struct *conn, VM_OS_STATUS status, + vm_gattc_char_struct *ch, VM_GATT_CHAR_PROPERTIES properties); + +/** GATT descriptor enumeration result callback */ +typedef void (*vmt_get_descriptor_callback)(vm_gatt_conn_struct *conn, VM_OS_STATUS status, vm_gattc_descr_struct *descr); + +/** GATT included service enumeration result callback */ +typedef void (*vmt_get_included_service_callback)(vm_gatt_conn_struct *conn, VM_OS_STATUS status, + VM_GATT_SVC_UUID *svc_uuid, VM_GATT_SVC_UUID *incl_svc_uuid); + +/** Callback invoked in response to [de]register_for_notification */ +typedef void (*vmt_register_for_notification_callback)(void *reg_ctx, VM_OS_STATUS status, + VM_BD_ADDR *bd_addr, vm_gattc_char_struct *ch); + +/** + * Remote device notification callback, invoked when a remote device sends + * a notification or indication that a client has registered for. + */ +typedef void (*vmt_notify_callback)(vm_gatt_conn_struct *conn, VM_BD_ADDR *bd_addr, + vm_gattc_char_struct *ch, VM_ATT_VALUE *value, VMBOOL is_notify); + +/** Reports result of a GATT read operation */ +typedef void (*vmt_read_characteristic_callback)(vm_gatt_conn_struct *conn, VM_OS_STATUS status, + vm_gattc_char_struct *ch, VM_ATT_VALUE *value); + +/** GATT write characteristic operation callback */ +typedef void (*vmt_write_characteristic_callback)(vm_gatt_conn_struct *conn, VM_OS_STATUS status, + vm_gattc_char_struct *ch); + +/** Callback invoked in response to read_descriptor */ +typedef void (*vmt_read_descriptor_callback)(vm_gatt_conn_struct *conn, VM_OS_STATUS status, + vm_gattc_descr_struct *descr, VM_ATT_VALUE *value); + +/** Callback invoked in response to write_descriptor */ +typedef void (*vmt_write_descriptor_callback)(vm_gatt_conn_struct *conn, VM_OS_STATUS status, + vm_gattc_descr_struct *descr); + +/** GATT execute prepared write callback */ +typedef void (*vmt_execute_write_callback)(vm_gatt_conn_struct *conn, VM_OS_STATUS status); + +/** Callback triggered in response to read_remote_rssi */ +typedef void (*vmt_read_remote_rssi_callback)(void *reg_ctx, VM_OS_STATUS status, VM_BD_ADDR *bd_addr, VMINT32 rssi); + +/** Callback triggered in response to get_device_type */ +typedef void (*vmt_get_device_type_callback)(void *reg_ctx, VM_OS_STATUS status, VM_BD_ADDR *bd_addr, VM_GATTC_DEV_TYPE dev_type); + +/* status : Used by message handler to return result of request */ + +typedef struct +{ + vmt_register_client_callback register_client_cb; + vmt_scan_result_callback scan_result_cb; + vmt_connection_callback connection_cb; + vmt_listen_callback listen_cb; + vmt_set_adv_data_callback set_adv_data_cb; + vmt_search_complete_callback search_complete_cb; + vmt_search_result_callback search_result_cb; + vmt_get_characteristic_callback get_characteristic_cb; + vmt_get_descriptor_callback get_descriptor_cb; + vmt_get_included_service_callback get_included_service_cb; + vmt_register_for_notification_callback register_for_notification_cb; + vmt_notify_callback notify_cb; + vmt_read_characteristic_callback read_characteristic_cb; + vmt_write_characteristic_callback write_characteristic_cb; + vmt_read_descriptor_callback read_descriptor_cb; + vmt_write_descriptor_callback write_descriptor_cb; + vmt_execute_write_callback execute_write_cb; + vmt_read_remote_rssi_callback read_remote_rssi_cb; + vmt_get_device_type_callback get_device_type_cb; +}vm_gattc_callback_struct; + +/**************************************************************************** +* function define +****************************************************************************/ +/***************************************************************************** + * FUNCTION + * vm_gattc_register + * DESCRIPTION + * Registers a GATT client application with the stack + * PARAMETERS + * app_uuid [IN] : BT UUID + * callback [IN] : the pointer of callback structure + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_register(vm_bt_uuid_struct *app_uuid, vm_gattc_callback_struct *callback); + +/***************************************************************************** + * FUNCTION + * vm_gattc_deregister + * DESCRIPTION + * Unregister a client application from the stack + * PARAMETERS + * reg_ctx [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_deregister(void *reg_ctx); + +/***************************************************************************** + * FUNCTION + * vm_gattc_scan + * DESCRIPTION + * Start or stop LE device scanning + * PARAMETERS + * reg_ctx [IN] : + * start [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_scan(void *reg_ctx, VMBOOL start); + +/***************************************************************************** + * FUNCTION + * vm_gattc_connect + * DESCRIPTION + * Create a connection to a remote LE or dual-mode device + * PARAMETERS + * reg_ctx [IN] : + * bd_addr [IN] : + * direct [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_connect(void *reg_ctx, VM_BD_ADDR *bd_addr, VMBOOL direct); + +/***************************************************************************** + * FUNCTION + * vm_gattc_disconnect + * DESCRIPTION + * Disconnect a remote device or cancel a pending connection + * PARAMETERS + * conn [IN] : + * bd_addr [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_disconnect(vm_gatt_conn_struct *conn, VM_BD_ADDR *bd_addr); + +/***************************************************************************** + * FUNCTION + * vm_gattc_listen + * DESCRIPTION + * Start or stop a listen for connection + * PARAMETERS + * reg_ctx [IN] : + * start [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_listen(void *reg_ctx, VMBOOL start); + +/***************************************************************************** + * FUNCTION + * vm_gattc_set_adv_data + * DESCRIPTION + * Set advertise data + * PARAMETERS + * reg_ctx [IN] : + * set_scan_rsp [IN] : + * include_name [IN] : + * include_txpower [IN] : + * min_interval [IN] : + * max_interval [IN] : + * appearance [IN] : + * manufacturer_len [IN] : + * manufacturer_data [IN] : + * service_data_len [IN] : + * service_data [IN] : + * service_uuid_len [IN] : + * service_uuid [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_set_adv_data(void *reg_ctx, VMBOOL set_scan_rsp, VMBOOL include_name, VMBOOL include_txpower, + VMUINT16 min_interval, VMUINT16 max_interval, VMUINT16 appearance, + VMUINT16 manufacturer_len, VMCHAR *manufacturer_data, + VMUINT16 service_data_len, VMCHAR *service_data, + VMUINT16 service_uuid_len, VMCHAR *service_uuid); + +/***************************************************************************** + * FUNCTION + * vm_gattc_refresh + * DESCRIPTION + * Clear the attribute cache for a given device + * PARAMETERS + * reg_ctx [IN] : + * bd_addr [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_refresh(void *reg_ctx, VM_BD_ADDR *bd_addr); + +/***************************************************************************** + * FUNCTION + * vm_gattc_search_service + * DESCRIPTION + * Enumerate all GATT services on a connected device. + * Optionally, the results can be filtered for a given UUID. + * PARAMETERS + * conn [IN] : + * uuid [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_search_service(vm_gatt_conn_struct *conn, vm_bt_uuid_struct *uuid); + +/***************************************************************************** + * FUNCTION + * vm_gattc_get_included_service + * Enumerate included services for a given service. + * Set start_incl_srvc_id to NULL to get the first included service. + * PARAMETERS + * conn [IN] : + * svc_uuid [IN] : + * incl_svc_uuid [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_get_included_service(vm_gatt_conn_struct *conn, VM_GATT_SVC_UUID *svc_uuid, + VM_GATT_SVC_UUID *incl_svc_uuid); + +/***************************************************************************** + * FUNCTION + * vm_gattc_get_characteristic + * DESCRIPTION + * Enumerate characteristics for a given service. + * Set start_char_uuid to NULL to get the first characteristic. + * PARAMETERS + * conn [IN] : + * svc_uuid [IN] : + * start_char_uuid [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_get_characteristic(vm_gatt_conn_struct *conn, VM_GATT_SVC_UUID *svc_uuid, VM_ATT_UUID *start_char_uuid); + +/***************************************************************************** + * FUNCTION + * vm_gattc_get_descriptor + * DESCRIPTION + * Enumerate descriptors for a given characteristic. + * Set start_descr_id to NULL to get the first descriptor. + * PARAMETERS + * conn [IN] : + * char_info [IN] : + * start_descr_uuid [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_get_descriptor(vm_gatt_conn_struct *conn, vm_gattc_char_struct *char_info, VM_ATT_UUID *start_descr_uuid); + +/***************************************************************************** + * FUNCTION + * vm_gattc_read_characteristic + * DESCRIPTION + * Read a characteristic on a remote device + * PARAMETERS + * conn [IN] : + * ch [IN] : + * auth_req [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_read_characteristic(vm_gatt_conn_struct *conn, vm_gattc_char_struct *ch, VM_GATTC_AUTH_REQ auth_req); + +/***************************************************************************** + * FUNCTION + * vm_gattc_write_characteristic + * DESCRIPTION + * Write a remote characteristic + * PARAMETERS + * conn [IN] : + * ch [IN] : + * value [IN] : + * write_type [IN] : + * auth_req [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_write_characteristic(vm_gatt_conn_struct *conn, vm_gattc_char_struct *ch, + VM_ATT_VALUE *value, VM_GATTC_WRITE_TYPE write_type, VM_GATTC_AUTH_REQ auth_req); + +/***************************************************************************** + * FUNCTION + * vm_gattc_read_descriptor + * DESCRIPTION + * Read the descriptor for a given characteristic + * PARAMETERS + * conn [IN] : + * descr [IN] : + * auth_req [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_read_descriptor(vm_gatt_conn_struct *conn, vm_gattc_descr_struct *descr, VM_GATTC_AUTH_REQ auth_req); + +/***************************************************************************** + * FUNCTION + * vm_gattc_write_descriptor + * DESCRIPTION + * Write a remote descriptor for a given characteristic + * PARAMETERS + * conn [IN] : + * descr [IN] : + * value [IN] : + * write_type [IN] : + * auth_req [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_write_descriptor(vm_gatt_conn_struct *conn, vm_gattc_descr_struct *descr, + VM_ATT_VALUE *value, VM_GATTC_WRITE_TYPE write_type, VM_GATTC_AUTH_REQ auth_req); + +/***************************************************************************** + * FUNCTION + * vm_gattc_execute_write + * DESCRIPTION + * Execute a prepared write operation + * PARAMETERS + * conn [IN] : + * exeute [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_execute_write(vm_gatt_conn_struct *conn, VMUINT8 exeute); + +/***************************************************************************** + * FUNCTION + * vm_gattc_register_for_notification + * DESCRIPTION + * Register to receive notifications or indications for a given + * characteristic + * PARAMETERS + * reg_ctx [IN] : + * bd_addr [IN] : + * ch [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_register_for_notification(void *reg_ctx, VM_BD_ADDR *bd_addr, vm_gattc_char_struct *ch); + +/***************************************************************************** + * FUNCTION + * vm_gattc_deregister_for_notification + * DESCRIPTION + * Deregister a previous request for notifications/indications + * PARAMETERS + * reg_ctx [IN] : + * bd_addr [IN] : + * ch [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_deregister_for_notification(void *reg_ctx, VM_BD_ADDR *bd_addr, vm_gattc_char_struct *ch); + +/***************************************************************************** + * FUNCTION + * vm_gattc_read_remote_rssi + * DESCRIPTION + * Request RSSI for a given remote device + * PARAMETERS + * reg_ctx [IN] : + * bd_addr [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_read_remote_rssi(void *reg_ctx, VM_BD_ADDR *bd_addr); + +/***************************************************************************** + * FUNCTION + * vm_gattc_get_device_type + * DESCRIPTION + * Determine the type of the remote device (LE, BR/EDR, Dual-mode) + * PARAMETERS + * reg_ctx [IN] : + * bd_addr [IN] : + * RETURNS + * failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_gattc_get_device_type(void *reg_ctx, VM_BD_ADDR *bd_addr); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* VM_BTCM_SDK_H */ + + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmbtnotify.h b/hardware/arduino/mtk/system/libmtk/include/vmbtnotify.h new file mode 100644 index 00000000..337acce6 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmbtnotify.h @@ -0,0 +1,187 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef VM_BTNOTIFY_SDK_H +#define VM_BTNOTIFY_SDK_H + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "vmsys.h" +#include "vmbtcm.h" + +#define VM_BT_NOTIFY_MRE_FILE_NAME_LENTH 50 +#define VM_BT_NOTIFY_MRE_MAX_DATA_LENTH (2047 - 30) +#define VM_MAX_IOER (16) + +/* mre callback data type */ +typedef enum +{ + VM_SRV_BT_NOTI_MRE_DATA_TYPE_BUFFER = 0, + VM_SRV_BT_NOTI_MRE_DATA_TYPE_FILE +}vm_srv_bt_noti_mre_data_type_enum; + + +typedef enum +{ + VM_SRV_BT_NOTIFY_RET_NO_ERROR = 0, + VM_SRV_BT_NOTIFY_RET_UNKNOWN_ERROR = -1000, /* unknown error */ + VM_SRV_BT_NOTIFY_RET_FILE_NOT_EXIST, /* file not exist */ + VM_SRV_BT_NOTIFY_RET_FILE_INTEGRITY_ERROR, /* file length error */ + VM_SRV_BT_NOTIFY_RET_LINK_DISCONNECTED, + VM_SRV_BT_NOTIFY_RET_MRE_PARSE_PARA_ERROR, + VM_SRV_BT_NOTIFY_RET_MAP_FILE_PARSE_PARA_ERROR +} vm_srv_bt_notify_ret_code; + + +/* mre callback struct */ +typedef struct +{ + VMCHAR sender[VM_MAX_IOER]; /* sender id for FP */ + VMCHAR receiver[VM_MAX_IOER]; /* receiver id for SP */ + VMINT32 err_code; /* error code */ + VMINT data_type; /* data type, 0 for buffer, 1 for file */ + union + { + VMWCHAR file_path[VM_BT_NOTIFY_MRE_FILE_NAME_LENTH]; /* file path */ + struct + { + VMUINT8 buf[VM_BT_NOTIFY_MRE_MAX_DATA_LENTH]; /* buffer address */ + VMUINT16 len; /* buffer length */ + }buffer; + }data; + vm_srv_bt_cm_bt_addr bt_addr; /* bt addr */ +}vm_srv_bt_noti_callback_struct; + + +/* The bt notification callback mre engine */ +typedef void (*vm_srv_bt_noti_callback)(vm_srv_bt_noti_callback_struct *data); + +/***************************************************************************** + * FUNCTION + * vm_srv_bt_noti_check_connection + * DESCRIPTION + * check the connection status. + * RETURNS + * VMINT : 0 is connection succesfully else no connection + *****************************************************************************/ +VMINT vm_srv_bt_noti_check_connection(void); + +/***************************************************************************** + * FUNCTION + * vm_srv_bt_noti_register_mre_callback + * DESCRIPTION + * regist the callback, it will be called while here is a notify from spp service + * PARAMETERS + * bt_addr : [IN] bt address + * sender [IN]: the id of yourself (sender id) + * cb [IN]: callback + * RETURNS + * VMINT : 0 is succesful else failure + *****************************************************************************/ +VMINT vm_srv_bt_noti_register_callback(const vm_srv_bt_cm_bt_addr *bt_addr, const VMCHAR sender[VM_MAX_IOER], vm_srv_bt_noti_callback cb); + +/* MREE sender_id data_type data_len data CANNOT EXCEED VM_BT_NOTIFY_MRE_MAX_DATA_LENTH */ + +/***************************************************************************** + * FUNCTION + * vm_srv_bt_noti_send_cmd_ext + * DESCRIPTION + * send data to the other side. this API will conbine the param to string, the total size could not exceed the VM_BT_NOTIFY_MRE_MAX_DATA_LENTH. + * or the -4 will be return. + * PARAMETERS + * bt_addr : [IN] bt address + * reader [IN]: whose id you want to send. + * data_type [IN]: refer to vm_srv_bt_noti_mre_data_type_enum + * data [IN]: what data want to be sent + * len [IN]: sending data length + * RETURNS + * VMINT : 0 is succesful else failure + *****************************************************************************/ +VMINT vm_srv_bt_noti_send_cmd_ext(const vm_srv_bt_cm_bt_addr *bt_addr, const VMCHAR reader[VM_MAX_IOER], VMINT data_type, const VMBYTE *data, VMINT len); + +/***************************************************************************** + * FUNCTION + * vm_srv_bt_noti_send_ex + * DESCRIPTION + * send data to the other side. this API will conbine the param to string, the total size could not exceed the VM_BT_NOTIFY_MRE_MAX_DATA_LENTH. + * or the -4 will be return. + * PARAMETERS + * bt_addr : [IN] bt address + * sender [IN]: whose id you want to send. + * receiver [IN]: whose id you want to read. + * data_type [IN]: refer to vm_srv_bt_noti_mre_data_type_enum + * data [IN]: what data want to be sent + * len [IN]: sending data length + * RETURNS + * VMINT : 0 is succesful else failure + *****************************************************************************/ +VMINT vm_srv_bt_noti_send_ex(const vm_srv_bt_cm_bt_addr *bt_addr, const VMCHAR sender[VM_MAX_IOER], const VMCHAR receiver[VM_MAX_IOER], VMINT data_type, const VMBYTE *data, VMINT len); + +/***************************************************************************** + * FUNCTION + * vm_bt_noti_check_channel_valid + * DESCRIPTION + * This function is to check validation context channel + * PARAMETERS + * cntx_chnl : [IN] channel index + * RETURNS + * VMINT : 0 is valid else failure + *****************************************************************************/ +VMINT vm_bt_noti_check_channel_valid(VMINT cntx_chnl); + + +/***************************************************************************** + * FUNCTION + * vm_bt_noti_get_bt_device_addr + * DESCRIPTION + * This function is to get bt device address from context channel + * PARAMETERS + * cntx_chnl : [IN] channel index + * RETURNS + * VMINT : 0 is succesful else failure + *****************************************************************************/ +VMINT vm_bt_noti_get_bt_device_addr(VMINT cntx_chnl, vm_srv_bt_cm_bt_addr *bt_addr); + +#define vm_srv_bt_noti_register_mre_callback vm_srv_bt_noti_register_callback + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* VM_BTNOTIFY_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmbtspp.h b/hardware/arduino/mtk/system/libmtk/include/vmbtspp.h new file mode 100644 index 00000000..ef3b10b4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmbtspp.h @@ -0,0 +1,322 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef VM_BTSPP_SDK_H +#define VM_BTSPP_SDK_H + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "vmsys.h" + + +/*spp connect type*/ +typedef enum{ + VM_SRV_SPP_CONNECT_WITH_SCO = 0x01, /* connect with SOC */ + VM_SRV_SPP_CONNECT_WITHOUT_SCO = 0x02 /* connect without SOC */ +}vm_srv_spp_connect_type; + +/*spp return error type*/ +typedef enum +{ + VM_BT_SPP_ERR_LOGICAL = -5, /* error in logical */ + VM_BT_SPP_ERR_BAD_PARAM, /* error in bad param */ + VM_BT_SPP_ERR_NO_RESOURCE, /* error in resource */ + VM_BT_SPP_ERR_NOT_SUPPORT, /* error in support */ + VM_BT_SPP_ERR_NO_AUTHORIZATION, /* error in authorization */ + VM_BT_SPP_ERR_SUCCESS = 0 /* no error */ +}vm_btspp_error_t; + +/*spp security level*/ +typedef enum{ + VM_SRV_SPP_SEC_NAN = 0x00, /* security NAN */ + VM_SRV_SPP_SEC_AUTHENTICATION = 0x01, /* security level */ + VM_SRV_SPP_SEC_AUTHORIZATION = 0x04, /* security level */ + VM_SRV_SPP_SEC_ENCRYPTION = 0x10, /* security level */ + VM_SRV_SPP_SEC_ALL = 0xff /* */ +}vm_srv_spp_security_level; + +/*spp srv for app event enum*/ +typedef enum{ + VM_SRV_SPP_EVENT_START = 0x0001, /* spp event start */ + VM_SRV_SPP_EVENT_BIND_FAIL = 0x0002, /* spp event bind fail */ + VM_SRV_SPP_EVENT_AUTHORIZE = 0x0004, /* spp event authorize */ + VM_SRV_SPP_EVENT_CONNECT = 0x0008, /* spp event connect */ + VM_SRV_SPP_EVENT_SCO_CONNECT = 0x0010, /* spp event soc connect */ + VM_SRV_SPP_EVENT_READY_TO_WRITE = 0x0020, /* spp event ready to write */ + VM_SRV_SPP_EVENT_READY_TO_READ = 0x0040, /* spp event ready to read */ + VM_SRV_SPP_EVENT_DISCONNECT = 0x0080, /* spp event disconnect */ + VM_SRV_SPP_EVENT_SCO_DISCONNECT = 0x0100, /* spp event soc disconnect */ + VM_SRV_SPP_EVENT_END +}vm_srv_spp_event_enum; + +/*spp srv for app event structure */ +typedef struct{ + VMINT res_hd; /* res handle*/ + void * user_data; /* user data */ + VMINT ret; /* result (bool) */ + VMINT conn_id; /* connection id */ +}vm_srv_spp_event_cntx; + + +#ifndef vm_bt_cm_bt_addr +#define vm_bt_cm_bt_addr +typedef struct _vm_srv_bt_cm_bt_addr vm_srv_bt_cm_bt_addr; +#endif + +/***************************************************************************** + * FUNCTION + * vm_btspp_get_min_buf_size + * DESCRIPTION + * get spp minmal buf, return the minmal buf for tx and rx + * PARAMETERS + * void + * RETURNS + * VMINT : failure if less than 0, else buf size + *****************************************************************************/ +VMINT vm_btspp_get_min_buf_size(void); + +/***************************************************************************** + * FUNCTION + * vm_btspp_open + * DESCRIPTION + * open btspp, return the resource handle if success + * PARAMETERS + * void + * RETURNS + * VMINT : failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_btspp_open(VMUINT evt_mask, void (*callback)(VMUINT evt, void * param, void * user_data), void * user_data); + +/***************************************************************************** + * FUNCTION + * vm_btspp_distory + * DESCRIPTION + * This function is for distorying a spp resource + * PARAMETERS + * res_hd [IN]: res handler + * RETURNS + * VMINT : failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_btspp_close(VMINT res_hd); + +/***************************************************************************** + * FUNCTION + * vm_btspp_disconnect + * DESCRIPTION + * This function is for app disconnect a connect + * PARAMETERS + * conn_id [IN]: connnect id + * RETURNS + * VMINT : failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_btspp_disconnect(VMINT conn_id); + +/***************************************************************************** + * FUNCTION + * vm_btspp_write + * DESCRIPTION + * This function is for app write data + * PARAMETERS + * conn_id [IN]: connect id + * buf [IN]: data buf want to transfer + * size [IN]: the size of data want to transfer + * RETURNS + * VMINT : failure if less than 0, see vm_btspp_error_t, + * else return the size of data transferred successfully + *****************************************************************************/ +VMINT vm_btspp_write(VMUINT conn_id, void * buf, VMUINT size); + +/***************************************************************************** + * FUNCTION + * vm_btspp_read + * DESCRIPTION + * This function is for app read data + * PARAMETERS + * conn_id [IN]: connect id + * buf [IN]: data buf want to receive + * size [IN]: the size of data want to receive + * RETURNS + * VMINT : failure if less than 0, see vm_btspp_error_t, + * else return the size of data received successfully + *****************************************************************************/ +VMINT vm_btspp_read(VMUINT conn_id, void * buf, VMUINT size); + +/***************************************************************************** + * FUNCTION + * vm_btspp_get_dev_addr + * DESCRIPTION + * get the bt addr with the conn_id + * PARAMETERS + * conn_id [IN]: connect id + * bt_addr [IN]: bt_addr. + * RETURNS + * VMINT : failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_btspp_get_dev_addr(VMINT conn_id, vm_srv_bt_cm_bt_addr * bt_addr); + +/***************************************************************************** + * FUNCTION + * vm_btspp_set_security_level + * DESCRIPTION + * This function is for set security level by handle + * PARAMETERS + * res_hd [IN]: res handler + * level [IN]: spp instance security level in vm_srv_spp_security_level + * RETURNS + * VMINT : failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_btspp_set_security_level(VMINT res_hd, VMINT level); + +/***************************************************************************** + * FUNCTION + * vm_btspp_set_service_name + * DESCRIPTION + * This function is for set a spp resource name + * PARAMETERS + * res_hd [IN]: res handler + * name [IN]: spp resource name UCS2 + * RETURNS + * VMINT : failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_btspp_set_service_name(VMINT res_hd, VMWCHAR * name); + +/* SPP SERVER USING START*/ + +/***************************************************************************** + * FUNCTION + * vm_btspp_bind + * DESCRIPTION + * This function is for app create a spp instance + * PARAMETERS + * res_hd [IN]: res handler + * uuid [IN]: profile id + * RETURNS + * VMINT : failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_btspp_bind(VMINT res_hd, VMUINT16 uuid); + +/***************************************************************************** + * FUNCTION + * vm_btspp_accept + * DESCRIPTION + * This function is used for server whether do accept when notified by event VM_SRV_SPP_EVENT_AUTHORIZE + * PARAMETERS + * conn_id [IN]: connect id + * buf [IN]: tx rx buffer + * tx_size [IN]: tx buffer size + * rx_size [IN]: rx buffer size + * RETURNS + * VMINT : failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_btspp_accept(VMINT conn_id, + void * buf, + VMUINT tx_size, + VMUINT rx_size + ); + +/***************************************************************************** + * FUNCTION + * vm_btspp_reject + * DESCRIPTION + * This function is used for server whether do accept when notified by event VM_SRV_SPP_EVENT_AUTHORIZE + * PARAMETERS + * conn_id : connect id + * RETURNS + * VMINT : failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_btspp_reject(VMINT conn_id); + +/* SPP SERVER USING END */ + + +/* SPP CLIENT USING START */ + +/***************************************************************************** + * FUNCTION + * vm_srv_spp_connect + * DESCRIPTION + * This function is for app connect server + * PARAMETERS + * res_hd [IN]: res handler + * bt_addr [IN]: server bt address + * buf [IN]: for tx rx buffer + * tx_size [IN]: tx buffer size + * rx_size [IN]: rx buffer size + * uuid [IN]: profile id + * RETURNS + * VMINT : failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_btspp_connect(VMINT res_hd, + const vm_srv_bt_cm_bt_addr * bt_addr, + void * buf, + VMUINT tx_size, + VMUINT rx_size, + VMUINT16 uuid); + +/***************************************************************************** + * FUNCTION + * vm_srv_spp_connect_ex + * DESCRIPTION + * This function is for app connect server + * PARAMETERS + * res_hd [IN]: res handler + * bt_addr [IN]: bt address. + * buf [IN]: for tx rx buffer + * tx_size [IN]: tx buffer size + * rx_size [IN]: rx_size + * connect_type [IN]: with sco or not + * uuid [IN]: profile id + * RETURNS + * VMINT : failure if less than 0, else successful + *****************************************************************************/ +VMINT vm_btspp_connect_ex(VMINT res_hd, + const vm_srv_bt_cm_bt_addr * bt_addr, + void * buf, + VMUINT tx_size, + VMUINT rx_size, + vm_srv_spp_connect_type conn_type, + VMUINT16 uuid); + +/* SPP CLIENT USING END */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* VM_BTSPP_SDK_H */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmcamera.h b/hardware/arduino/mtk/system/libmtk/include/vmcamera.h new file mode 100644 index 00000000..45879412 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmcamera.h @@ -0,0 +1,1038 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMCAMERA_SDK_H_ +#define VMCAMERA_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" +#include "vmgraph.h" + +typedef VMINT VM_CAMERA_HANDLE; + +/* camera id */ +typedef enum +{ + VM_CAMERA_MAIN_ID = 1, + VM_CAMERA_MAIN_LOW_RESOURCE_ID +}VM_CAMERA_ID; + +/* The maximum number of af zone */ +#define VM_CAMERA_AF_ZONE_MAX_NO 5 + +/* camera result */ +typedef enum +{ + VM_CAM_PREVIEW_START_DONE = 1, /* preview success */ + VM_CAM_PREVIEW_START_ABORT, /* preview abort */ + VM_CAM_PREVIEW_STOP_DONE, /* stop preview done */ + VM_CAM_PREVIEW_STOP_ABORT, /* stop preview failed */ + VM_CAM_PREVIEW_FRAME_RECEIVED, /* receive data */ + VM_CAM_CAPTURE_DONE, /* capture success */ + VM_CAM_CAPTURE_ABORT /* capture abort */ +}VM_CAMERA_MESSAGE; + +/* camera status */ +typedef enum +{ + VM_CAM_READY_STATUS = 1, /* create camera success status */ + VM_CAM_STARTING_PREVIEW_STATUS, /* starting preview status */ + VM_CAM_STOPPING_PREVIEW_STATUS, /* stopping preview status */ + VM_CAM_PREVIEW_STATUS, /* preview status */ + VM_CAM_CAPTURING_STATUS /* capturing status */ +}VM_CAMERA_STATUS; + + +/* operation success */ +#define VM_CAM_SUCCESS (0) + +/* no memory */ +#define VM_CAM_ERR_NOMEMORY (-1) + +/* not support operation in this status */ +#define VM_CAM_ERR_OPERATE_BAD_STATUS (-2) + +/* wrong parameters */ +#define VM_CAM_ERR_BAD_PARAM (-3) + +/* invalid handle */ +#define VM_CAM_ERR_INVALID_CAM_HANDLE (-4) + +/* linkit not support operation */ +#define VM_CAM_ERR_UNSUPPORT_OPERATION (-5) + +/* instance has been created */ +#define VM_CAM_ERR_CAM_INSTANCE_CREATED (-6) + +/* not register callback function */ +#define VM_CAM_ERR_NOT_REGISTER_NOTIFY (-7) + +/* invalid camera id */ +#define VM_CAM_ERR_INVALID_CAM_ID (-8) + +/* internal error */ +#define VM_CAM_ERR_CAM_INTERNAL_ERROR (-9) + +/* not support camera feature */ +#define VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE (-10) + +/* not support under background run */ +#define VM_CAM_OPERATION_IN_PROCESS_STATUS (-11) + + +#define VM_CAM_XENONFLASH_CHARGING 1001 +#define VM_CAM_ERR_FAILED -1001 +#define VM_CAM_ERR_DISK_FULL -1002 +#define VM_CAM_ERR_WRITE_PROTECTION -1003 +#define VM_CAM_ERR_NO_DISK -1004 +#define VM_CAM_ERR_HW_NOT_READY -1005 +#define VM_CAM_ERR_MEMORY_NOT_ENOUGH -1006 +#define VM_CAM_ERR_PREVIEW_FAILED -1007 +#define VM_CAM_ERR_CAPTURE_FAILED -1008 +#define VM_CAM_ERR_ROOT_DIR_FULL -1009 +#define VM_CAM_ERR_XENONFLASH_TIMEOUT -1010 +#define VM_CAM_ERR_XENONFLASH_LOW_BATTERY -1011 +#define VM_CAM_ERR_CBM_BEARER_ERROR -1012 +#define VM_CAM_ERR_SAVE_FAILED -1013 + + + +#define VM_CAMERA_ROTATE_0 0 +#define VM_CAMERA_ROTATE_90 1 +#define VM_CAMERA_ROTATE_180 2 +#define VM_CAMERA_ROTATE_270 3 + +typedef void (*vm_camera_rotate_callback)(VMUINT8 rotate); + +/* pixel format */ +typedef enum +{ + PIXTEL_RGB565 = 1, + PIXTEL_BGR565, + PIXTEL_RGB888, + PIXTEL_BGR888, + PIXTEL_ARGB8888, + PIXTEL_ABGR8888, + PIXTEL_UYUV422 +}PIXTEL_FORMAT_T; + +typedef enum +{ + VM_RAWDATA_RGB565 = 0, + Vm_RAWDATA_YUV420 +}ROW_DATA_FORMAT_T; + + +/* frame raw data */ +typedef struct vm_cam_frame_raw_data_t +{ + VMUINT row_pixel; /* pixels per row */ + VMUINT col_pixel; /* pixels per column */ + ROW_DATA_FORMAT_T format; /* pixel format */ + void* buffer; /* buffer */ + VMINT buffer_size; /* buffer size */ +}vm_cam_frame_raw_data_t; + + +/* frame data */ +typedef struct vm_cam_frame_data_t +{ + VMUINT row_pixel; /* pixels per row */ + VMUINT col_pixel; /* pixels per column */ + PIXTEL_FORMAT_T pixtel_format; /* pixel format */ + void* pixtel_data; /* data */ + VMINT reserved; /* no use */ +}vm_cam_frame_data_t; + +/* capture data */ +typedef struct vm_cam_capture_data_t +{ + VMCHAR mime_type[32]; /* data type */ + VMUINT8* data; /* data */ + VMUINT data_size; /* data size */ + VMINT reserved; /* no use */ +}vm_cam_capture_data_t; + +/* notify data */ +typedef struct vm_cam_notify_data_t +{ + VM_CAMERA_HANDLE handle; /* camera handle */ + VM_CAMERA_MESSAGE cam_message; /* message type */ + VM_CAMERA_STATUS cam_status; /* curent status */ +}vm_cam_notify_data_t; + +/* callback function */ +typedef void (*VM_CAMERA_STATUS_NOTIFY)(const vm_cam_notify_data_t* notify_data, void* user_data); +/* camera size */ +typedef struct vm_cam_size_t +{ + VMUINT width; + VMUINT height; +}vm_cam_size_t; + +/* camera size */ +typedef struct vm_cam_origin_t +{ + VMUINT x; + VMUINT y; +}vm_cam_origin_t; + + +/* AF zone structure */ +typedef struct +{ + VMUINT af_zone_w; /* Width */ + VMUINT af_zone_h; /* Height */ + VMUINT af_zone_x; /* Offset x */ + VMUINT af_zone_y; /* Offset y */ +}vm_camera_af_zone_struct; + + +/* AF window structure */ +typedef struct +{ + VMUINT af_active_zone; /* Active zone */ + vm_camera_af_zone_struct af_zone[VM_CAMERA_AF_ZONE_MAX_NO]; /* AF zone array */ +}vm_camera_af_window_struct; + +/* The result of af */ +typedef enum +{ + VM_AF_SEARCH_STATUS_IDLE=0, /* Idle */ + VM_AF_SEARCH_STATUS_BUSY, /* Busy */ + VM_AF_SEARCH_STATUS_FOUND_FAIL, /* Failed */ + VM_AF_SEARCH_STATUS_FOUND_SUCCESS, /* Success */ + VM_AF_SEARCH_STATUS_FOUND_NOFOCUS, /* No focus */ + VM_AF_SEARCH_STATUS_SWITCH_MACRO /* Switch to marco */ +}vm_af_result_enum; + +/* af struct */ +typedef struct +{ + vm_af_result_enum af_result; /* AF result */ + VMUINT af_success_zone; /* AF success zone */ +}vm_camera_af_result_struct; + +typedef void (*vm_camera_af_ind_callback) (vm_camera_af_result_struct result_ind, void* user_data); + +/* camera parameter setting struct */ +typedef struct +{ + unsigned int preview_x; /* preview x */ + unsigned int preview_y; /* preview y */ + unsigned int preview_width; /* preview width */ + unsigned int preview_height; /* preview height */ + unsigned int preview_layer; /* preview layer handle */ + void* preview_layer_buffer; /* preview layer buffer */ + + unsigned int osd_x; /* osd x */ + unsigned int osd_y; /* osd y */ + unsigned int osd_width; /* osd width */ + unsigned int osd_height; /* osd height */ + unsigned int osd_layer; /* osd ayer handle */ + void* osd_layer_buffer; /* osd layer buffer */ + + VMUINT16 af_operation_mode; /* af mode */ + VMUINT16 af_range; /* af range */ +}vm_camera_para_struct; + +void vm_camera_sensor_driver_install(void* func_install1,void* func_install2); + +/***************************************************************************** + * FUNCTION + * vm_create_camera_instance + * DESCRIPTION + * create camera instance and get the handle, you can use the handle to do other operation, + * if you don't need use this instance, please use vm_release_camera_instance to release it. + * PARAMETERS + * camera_id : [IN] camera's id, you can refer the VM_CAMERA_ID. + * handle_ptr : [OUT] camera's handle. + * RETURNS + * create camera instance success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : create success. + * VM_CAM_ERR_NOMEMORY : there is no enough memory. + * VM_CAM_ERR_INVALID_CAM_ID : camera id is wrong. + * VM_CAM_ERR_CAM_INSTANCE_CREATED : camera instance is in use. + * VM_CAM_ERR_CAM_INTERNAL_ERROR : preview size is not support. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. + * VM_CAM_OPERATION_IN_PROCESS_STATUS : after LINKIT, when application is in background status + * not allow to create camera. + * EXAMPLE + * + * VM_CAM_READY_STATUS VM_CAM_STARTING_PREVIEW_STATUS VM_CAM_PREVIEW_STATUS VM_CAM_STOPPING_PREVIEW_STATUS VM_CAM_CAPTURING_STATUS + * | vm_camera_preview_start + * -------------------------------> + * |VM_CAM_PREVIEW_START_DONE + * --------------------------------> + * | | + * VM_CAM_PREVIEW_START_ABORT | | + * <-------------------------------- |vm_camera_preview_stop + * | -------------------------------> + * | | VM_CAM_PREVIEW_STOP_ABORT | + * | <------------------------------- + * | | + * | VM_CAM_PREVIEW_STOP_DONE | + * <------------------------------------------------------------------------------------------------ + * | | + * | |vm_camera_capture + * | ---------------------------------------------------------------> + * | VM_CAM_CAPTURE_DONE/VM_CAM_CAPTURE_ABORT | + * <------------------------------------------------------------------------------------------------------------------------------- + * |vm_camera_capture | + * -------------------------------------------------------------------------------------------------------------------------------> + * | VM_CAM_CAPTURE_DONE/VM_CAM_CAPTURE_ABORT | + * <------------------------------------------------------------------------------------------------------------------------------- + * +*****************************************************************************/ +VMINT vm_create_camera_instance(VM_CAMERA_ID camera_id, + VM_CAMERA_HANDLE* handle_ptr); + +/***************************************************************************** + * FUNCTION + * vm_release_camera_instance + * DESCRIPTION + * release camera instance, after vm_create_camera_instance, when application exit or not use camera, + * please invole this function to release it. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * RETURNS + * release camera instance success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : release success. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to release camera instance. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. +*****************************************************************************/ +VMINT vm_release_camera_instance(VM_CAMERA_HANDLE handle); + +/***************************************************************************** + * FUNCTION + * vm_get_camera_status + * DESCRIPTION + * get camera's current status. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * cam_status : [OUT] camera's status, please refer struct VM_CAMERA_STATUS. + * RETURNS + * get camera's success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : get status success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. +*****************************************************************************/ +VMINT vm_get_camera_status(VM_CAMERA_HANDLE handle, VM_CAMERA_STATUS* cam_status); + + + + + +/***************************************************************************** + * FUNCTION + * vm_camera_register_notify + * DESCRIPTION + * register callback function, system will invoke this function when camera's status changes. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * notify_callback : [IN] application's callback function. + * user_data : [IN] user data use as parameter for callback function, if no need, set to NULL. + * RETURNS + * register success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : register success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. +*****************************************************************************/ +VMINT vm_camera_register_notify(VM_CAMERA_HANDLE handle, VM_CAMERA_STATUS_NOTIFY notify_callback, void* user_data); + + + + + +/***************************************************************************** + * FUNCTION + * vm_camera_get_support_preview_size + * DESCRIPTION + * get camera's support preview size. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * cam_size_list : [OUT] camera's support preview size list. + * list_size : [OUT] camera's support preview size list size. + * RETURNS + * get camera's success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : get status success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_CAM_INTERNAL_ERROR : preview size is not support. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. + * EXAMPLE + * + * void app_set_preview_size(void) + * { + * vm_cam_size_t* ptr = NULL; + * VMUINT size = 0, i = 0; + * if (vm_camera_get_support_preview_size(camera_handle, &ptr, &size) == VM_CAM_SUCCESS) + * { + * vm_cam_size_t my_cam_size; + * + * for (i = 0; i < size; i++) + * { + * my_cam_size.width = (ptr + i)->width; + * my_cam_size.height =(ptr + i) ->height; + * } + * vm_camera_set_preview_size(camera_handle, &my_cam_size); + * } + * } + * +*****************************************************************************/ +VMINT vm_camera_get_support_preview_size(VM_CAMERA_HANDLE handle, const vm_cam_size_t** cam_size_list, VMUINT* list_size); + +/***************************************************************************** + * FUNCTION + * vm_camera_set_preview_size + * DESCRIPTION + * set camera's preview size. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * preview_size : [IN] preview size to set. + * RETURNS + * set camera's preview size success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : get status success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_CAM_INTERNAL_ERROR : preview size is not support. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to set camera's preview size. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. +*****************************************************************************/ +VMINT vm_camera_set_preview_size(VM_CAMERA_HANDLE handle, const vm_cam_size_t* preview_size); + +/***************************************************************************** + * FUNCTION + * vm_camera_set_preview_fps + * DESCRIPTION + * set camera's preview frame number per second, the max is 30, if not set the default is the max number. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * fps : [IN] frame number, the max is 30, if this is bigger than 30, it will change to 30. + * RETURNS + * set preview frame number success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : set frame number success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_CAM_INTERNAL_ERROR : preview size is not support. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to set camera's preview size. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. +*****************************************************************************/ +VMINT vm_camera_set_preview_fps(VM_CAMERA_HANDLE handle, VMUINT fps); + +/***************************************************************************** + * FUNCTION + * vm_camera_preview_start + * DESCRIPTION + * start to preview. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * RETURNS + * start preview success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : start preview success. + * VM_CAM_ERR_NOT_REGISTER_NOTIFY : not register callback function. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to start preview. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. + * VM_CAM_OPERATION_IN_PROCESS_STATUS : after LINKIT SDK, when application is in background status + * not allow to create camera. +*****************************************************************************/ +VMINT vm_camera_preview_start(VM_CAMERA_HANDLE handle); + +/***************************************************************************** + * FUNCTION + * vm_camera_preview_stop + * DESCRIPTION + * stop preview. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * RETURNS + * stop preview success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : stop preview success. + * VM_CAM_ERR_NOT_REGISTER_NOTIFY : not register callback function. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to set camera's preview size. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. +*****************************************************************************/ +VMINT vm_camera_preview_stop(VM_CAMERA_HANDLE handle); + +/***************************************************************************** + * FUNCTION + * vm_camera_get_frame + * DESCRIPTION + * get camera's one frame. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * frame_data : [OUT] the frame data. + * RETURNS + * get frame success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : get status success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to get frame. + * VM_CAM_ERR_CAM_INTERNAL_ERROR : pixtel format is not support, now support BGR565,BGR888,ABGR8888. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. + * EXAMPLE + * + * void cam_message_callback(vm_cam_notify_data_t* notify_data, void* user_data) + * { + * if (notify_data != NULL) + * { + * vm_cam_frame_data_t frame; + * + * switch (notify_data->cam_message) + * { + * case VM_CAM_PREVIEW_SOPT_DONE: + * // + * break; + * case VM_CAM_PREVIEW_FRAME_RECEIVED: + * if (vm_camera_get_frame(cam_handle, &frame) == VM_CAM_SUCCESS) + * { + + * VMUINT app_frame_data_size = 0; + * VMUINT8* app_frame_data = NULL; + * + * if (frame.pixtel_format == PIXTEL_RGB565 || frame.pixtel_format == PIXTEL_BGR565) + * app_frame_data_size = row_pixel * col_pixel * 2; + * else if (frame.pixtel_format == PIXTEL_RGB888 || frame.pixtel_format == PIXTEL_BGR888) + * app_frame_data_size = row_pixel * col_pixel * 3; + * else + * app_frame_data_size = row_pixel * col_pixel * 4; + * + * if ((app_frame_data = vm_malloc(app_frame_data_size)) != NULL) + * { + * memcpy(app_frame_data, frame.pixtel_data, app_frame_data_size); + * } + * else + * { + * // if (frame.rgbformat == screen format) + * // { + * // copy frame.pixtel_data to screen buffer; + * // flush screen buffer; + * // } + * } + * + * } + * break; + * case ...... + * } + * } + * } + * +*****************************************************************************/ +VMINT vm_camera_get_frame(VM_CAMERA_HANDLE handle, vm_cam_frame_data_t* frame_data); + + +/***************************************************************************** + * FUNCTION + * vm_camera_get_raw_data_frame + * DESCRIPTION + * get raw dat use application's memory. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * frame_data : [IN] please refer vm_cam_frame_raw_data_t + * RETURNS + * get raw data success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : get raw data success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to set capture size. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. + * VM_CAM_ERR_DISK_FULL Disk full + * VM_CAM_ERR_WRITE_PROTECTION Disk write protection + * VM_CAM_ERR_NO_DISK No disk + * VM_CAM_ERR_CAPTURE_FAILED Capture failed +*****************************************************************************/ +VMINT vm_camera_get_raw_data_frame(VM_CAMERA_HANDLE handle, vm_cam_frame_raw_data_t* frame_data); + + +/***************************************************************************** + * FUNCTION + * vm_camera_get_support_capture_size + * DESCRIPTION + * get camera's support capture size. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * cam_size_list : [OUT] camera's support capture size list. + * list_size : [OUT] camera's support capture size list size. + * RETURNS + * get camera's success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : get status success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_CAM_INTERNAL_ERROR : capture size is not support. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. + * EXAMPLE + * + * void app_set_capture_size(void) + * { + * vm_cam_size_t* ptr = NULL; + * VMUINT size = 0, i = 0; + * if (vm_camera_get_support_capture_size(camera_handle, &ptr, &size) == VM_CAM_SUCCESS) + * { + * vm_cam_size_t my_cam_size; + * + * for (i = 0; i < size; i++) + * { + * my_cam_size.width = (ptr + i)->width; + * my_cam_size.height =(ptr + i) ->height; + * } + * vm_camera_set_capture_size(camera_handle, &my_cam_size); + * } + * } + * +*****************************************************************************/ +VMINT vm_camera_get_support_capture_size(VM_CAMERA_HANDLE handle, const vm_cam_size_t** cam_size_list, VMUINT* list_size); + +/***************************************************************************** + * FUNCTION + * vm_camera_set_capture_size + * DESCRIPTION + * set camera's capture size. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * size : [IN] capture size to set. + * RETURNS + * set camera's capture size success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : get max capture size success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to set capture size. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. +*****************************************************************************/ +VMINT vm_camera_set_capture_size(VM_CAMERA_HANDLE handle, const vm_cam_size_t* size); + +/***************************************************************************** + * FUNCTION + * vm_camera_capture + * DESCRIPTION + * capture a image. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * RETURNS + * capture success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : capture a image success. + * VM_CAM_ERR_NOT_REGISTER_NOTIFY : not register callback function. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to capture a image. + * VM_CAM_ERR_NOMEMORY : there is no enough memory. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. +*****************************************************************************/ +VMINT vm_camera_capture(VM_CAMERA_HANDLE handle); + + +/***************************************************************************** + * FUNCTION + * vm_camera_get_capture_data + * DESCRIPTION + * get capture data. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * capture_data : [OUT] capture data. + * RETURNS + * get camera's capture data success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : get capture data success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to get get data. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. +*****************************************************************************/ +VMINT vm_camera_get_capture_data(VM_CAMERA_HANDLE handle, vm_cam_capture_data_t* capture_data); + + +/***************************************************************************** + * FUNCTION + * vm_camera_get_focus_zone + * DESCRIPTION + * get focuse zone. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * zone : [OUT] zone data. + * RETURNS + * success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : get capture data success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to get get data. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. +*****************************************************************************/ +VMINT vm_camera_get_focus_zone(VM_CAMERA_HANDLE handle, vm_camera_af_window_struct* zone); + + +/***************************************************************************** + * FUNCTION + * vm_camera_start_autofocus_process + * DESCRIPTION + * start auto focuse process + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * af_callback : [IN] callback function. + * user_data : [IN] user data. + * RETURNS + * success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : get capture data success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to get get data. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. +*****************************************************************************/ +VMINT vm_camera_start_autofocus_process(VM_CAMERA_HANDLE handle, vm_camera_af_ind_callback af_callback, void* user_data); + + +/***************************************************************************** + * FUNCTION + * vm_camera_stop_autofocus_process + * DESCRIPTION + * stop auto foucs process. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * RETURNS + * stop auto focus success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : get capture data success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to get get data. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. +*****************************************************************************/ +VMINT vm_camera_stop_autofocus_process(VM_CAMERA_HANDLE handle); + + +/***************************************************************************** + * FUNCTION + * vm_camera_update_parameter + * DESCRIPTION + * update parameter. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * para : [OUT] capture data. + * RETURNS + * update parameter success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : get capture data success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to get get data. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. +*****************************************************************************/ +VMINT vm_camera_update_parameter(VM_CAMERA_HANDLE handle, vm_camera_para_struct* para); + + +/***************************************************************************** + * FUNCTION + * vm_camera_get_default_parameter + * DESCRIPTION + * get default parameter. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * para : [OUT] camera data. + * RETURNS + * get parameter success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : get capture data success. + * VM_CAM_ERR_BAD_PARAM : parameter is wrong. + * VM_CAM_ERR_INVALID_CAM_HANDLE : camera's handle is wrong. + * VM_CAM_ERR_OPERATE_BAD_STATUS : bad status to get get data. + * VM_CAM_ERR_UNSPPUORT_CAMERA_FEATURE : not support camera function. +*****************************************************************************/ +VMINT vm_camera_get_default_parameter(VM_CAMERA_HANDLE handle, vm_camera_para_struct* para); + + +/***************************************************************************** + * FUNCTION + * vm_camera_get_osd_layer_buffer + * DESCRIPTION + * get osd layer buffer. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * osd : [OUT] osd layer width and height. + * RETURNS + * layer buffer pointer + * RETURN VALUES + * NULL : error +*****************************************************************************/ +void* vm_camera_get_osd_layer_buffer(VM_CAMERA_HANDLE handle, vm_cam_size_t* osd); + + +/***************************************************************************** + * FUNCTION + * vm_camera_get_osd_layer_handle + * DESCRIPTION + * get osd layer handle. + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * RETURNS + * handle id + * RETURN VALUES + * 0 : error +*****************************************************************************/ +VMINT vm_camera_get_osd_layer_handle(VM_CAMERA_HANDLE handle); + + +/***************************************************************************** + * FUNCTION + * vm_camera_set_camera_id + * DESCRIPTION + * get capture data. + * PARAMETERS + * camera_id : [IN] please refer VM_CAMERA_ID + * RETURNS + * set camera's id success or not. + * RETURN VALUES + * VM_CAM_SUCCESS : get capture data success. + * other : error +*****************************************************************************/ +VMINT vm_camera_set_camera_id(VMUINT16 camera_id); + +/***************************************************************************** + * FUNCTION + * vm_camera_get_main_camera_id + * DESCRIPTION + * get main camera id + * PARAMETERS + * + * RETURNS + * main camera id + * RETURN VALUES + * -1 : error +*****************************************************************************/ +VMINT vm_camera_get_main_camera_id(void); + +/***************************************************************************** + * FUNCTION + * vm_camera_get_sub_camera_id + * DESCRIPTION + * get sub camera id + * PARAMETERS + * + * RETURNS + * sub camera id + * RETURN VALUES + * -1 : error +*****************************************************************************/ +VMINT vm_camera_get_sub_camera_id(void); + + +/***************************************************************************** + * FUNCTION + * vm_camera_is_support_dual_camera + * DESCRIPTION + * support dual camera or not + * PARAMETERS + * + * RETURNS + * + * RETURN VALUES + * 1 : support + * 0: not support +*****************************************************************************/ +VMINT vm_camera_is_support_dual_camera(void); + +/***************************************************************************** + * FUNCTION + * vm_camera_register_rotation_callback + * DESCRIPTION + * register ratate callback function + * PARAMETERS + * callback + * RETURNS +*****************************************************************************/ +void vm_camera_register_rotation_callback(vm_camera_rotate_callback callback); + +/***************************************************************************** + * FUNCTION + * vm_camera_set_capture_rotation + * DESCRIPTION + * set capture rotation + * PARAMETERS + * rotate + * RETURNS +*****************************************************************************/ +void vm_camera_set_capture_rotation(VMUINT8 rotate); + +/***************************************************************************** + * FUNCTION + * vm_camera_update_para_image_size + * DESCRIPTION + * update image size + * PARAMETERS + * image_width: image width + * image_height: image height + * RETURNS +*****************************************************************************/ +void vm_camera_update_para_image_size(VMUINT16 image_width, VMUINT16 image_height); + + +/***************************************************************************** + * FUNCTION + * vm_camera_set_auto_detect_mode + * DESCRIPTION + * set auto detect mode + * PARAMETERS + * mode: TRUE or FALSE + * + * RETURNS +*****************************************************************************/ +void vm_camera_set_auto_detect_mode(VMBOOL mode); + + +/***************************************************************************** + * FUNCTION + * vm_camera_set_lcd_update + * DESCRIPTION + * set lcd update or not + * PARAMETERS + * update: TRUE or FALSE + * + * RETURNS +*****************************************************************************/ +void vm_camera_set_lcd_update(VMBOOL update); + + +/***************************************************************************** + * FUNCTION + * vm_camera_enable_osd_layer + * DESCRIPTION + * use new layer as osd layer or not + * PARAMETERS + * mode: TRUE or FALSE + * + * RETURNS +*****************************************************************************/ +void vm_camera_enable_osd_layer(VMBOOL enable); + + +/***************************************************************************** + * FUNCTION + * vm_camera_is_horizontal_sensor + * DESCRIPTION + * is horizontal sensor or not + * PARAMETERS + * + * RETURNS + * + * RETURN VALUES + * 1 : horizontal + * 0: not horizontal +*****************************************************************************/ +VMINT vm_camera_is_horizontal_sensor(void); + + +/***************************************************************************** + * FUNCTION + * vm_camera_set_capture_disable_jaia + * DESCRIPTION + * Enable/disable capture with JAIA + * PARAMETERS + * is_disable : [IN] enable[FALSE]/disable[TRUE] + * RETURNS + * void + *****************************************************************************/ +void vm_camera_set_capture_disable_jaia(VMBOOL is_disable); + + +/***************************************************************************** + * FUNCTION + * vm_camera_rotate_osd_layer + * DESCRIPTION + * rotate osd layer + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * RETURNS + * success or not + * RETURN VALUES + * FALSE + * TRUE +*****************************************************************************/ +VMBOOL vm_camera_rotate_osd_layer(VM_CAMERA_HANDLE handle, vm_graphic_rotate_value rotatevalue); + +/***************************************************************************** + * FUNCTION + * vm_camera_set_preview_origin + * DESCRIPTION + * set preview origin point + * PARAMETERS + * handle : [IN] camera's handle which is created by vm_create_camera_instance. + * origin : [IN] origin point. + * RETURNS + * success or not + * RETURN VALUES + * FALSE + * TRUE +*****************************************************************************/ +VMINT vm_camera_set_preview_origin(VM_CAMERA_HANDLE handle, const vm_cam_origin_t* origin); + +/***************************************************************************** + * FUNCTION + * vm_camera_use_anonymous_memory + * DESCRIPTION + * use/no use anonymous memory + * PARAMETERS + * mode : [IN] no use[FALSE]/use[TRUE] + * RETURNS + * void + *****************************************************************************/ +void vm_camera_use_anonymous_memory(VMBOOL mode); + +#ifdef __cplusplus +} +#endif + +#endif /* VMCAMERA_SDK_H_ */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmcell.h b/hardware/arduino/mtk/system/libmtk/include/vmcell.h new file mode 100644 index 00000000..b04286de --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmcell.h @@ -0,0 +1,129 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMCELL_SDK_H_ +#define VMCELL_SDK_H_ + +#include "vmsys.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*cell info structure*/ +typedef struct{ + VMUINT16 arfcn; /*ARFCN*/ + VMUINT8 bsic; /*BSIC*/ + VMUINT8 rxlev; /*Received signal level*/ + VMUINT16 mcc; /*MCC*/ + VMUINT16 mnc; /*MNC*/ + VMUINT16 lac; /*LAC*/ + VMUINT16 ci; /*CI*/ +}vm_cell_info_struct; + +/*CELL register state*/ +typedef enum{ + VM_CELL_OPEN_REG_ERROR = -2, /*CELL Info register error*/ + VM_CELL_OPEN_RES_LESS = -1, /*lack of reource*/ + VM_CELL_OPEN_SUCCESS = 0, /*open successfully*/ + VM_CELL_OPEN_ALREADY_OPEN = 1 /*already open*/ +} vm_cell_reg_state_enum; + +/***************************************************************************** +* FUNCTION + * vm_cell_open + * DESCRIPTION + * open CELL ID reource + * RETURNS + * result of open operation. + * RETURN VALUES + * VM_CELL_OPEN_SUCCESS : open successfully. + * VM_CELL_OPEN_ALREADY_OPEN : already open. + * VM_CELL_OPEN_RES_LESS : lack of reource + * VM_CELL_OPEN_REG_ERROR : CELL Info register error + * +*****************************************************************************/ +VMINT vm_cell_open(void); + +/***************************************************************************** +* FUNCTION + * vm_cell_close + * DESCRIPTION + * close CELL ID reource + * +*****************************************************************************/ +void vm_cell_close(void); + +/***************************************************************************** +* FUNCTION + * vm_cell_get_cur_cell_info + * DESCRIPTION + * get current cell information. vm_cell_open() should be invoked before this API, + * or NULL will be returned. + * RETURNS + * the pointer to current cell information or NULL. + * +*****************************************************************************/ +vm_cell_info_struct* vm_cell_get_cur_cell_info(void); + +/***************************************************************************** +* FUNCTION + * vm_cell_get_nbr_cell_info + * DESCRIPTION + * get neighbor cell information. vm_cell_open() should be invoked before this API, + * or NULL will be returned. + * RETURNS + * the pointer to neighbor cell information or NULL. + * +*****************************************************************************/ +vm_cell_info_struct** vm_cell_get_nbr_cell_info(void); + +/***************************************************************************** +* FUNCTION + * vm_cell_get_nbr_num + * DESCRIPTION + * get the number of neighbor cell information. vm_cell_open() should be invoked before this API, + * or NULL will be returned. + * RETURNS + * the pointer to the number of neighbor cell information or NULL. + * +*****************************************************************************/ +VMINT* vm_cell_get_nbr_num(void); + +#ifdef __cplusplus +} +#endif +#endif /* VMCELL_SDK_H_ */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmcert.h b/hardware/arduino/mtk/system/libmtk/include/vmcert.h new file mode 100644 index 00000000..7704715a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmcert.h @@ -0,0 +1,195 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef _VM_CERT_MANAGER_SDK_ +#define _VM_CERT_MANAGER_SDK_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +#define RSA_LEN 64 + +#define DIG_MD5_LEN 16 +#define DIG_SHA_LEN 20 + +#define DIG_MAX_LEN DIG_SHA_LEN +#define DIG_MIN_LEN DIG_MD5_LEN + +#define CERT_HEAD_LEN 6 + +#define CERT_DIGEST_TYPE_MD5 1 +#define CERT_DIGEST_TYPE_SHA 2 + +#define CERT_DIGEST_LEN 64 + +#define ISD_APP_NUM -1 + +#define RESERVED_BYTES_NUM 8 + +/* tag define */ +enum{ + VM_CE_INFO_END = 0, /* 0x00, null */ + VM_CE_INFO_DEV, /* 0x01, application developer name */ + VM_CE_INFO_APP_ID, /* 0x02, application identification */ + VM_CE_INFO_CERT_ID, /* 0x03, index of key id */ + VM_CE_INFO_NAME, /* 0x04, application name */ + VM_CE_INFO_VER, /* 0x05, application version */ + VM_CE_INFO_ISSUE, /* 0x06, valid start time (no use) */ + VM_CE_INFO_EXPIRED, /* 0x07, valid end time (no use) */ + VM_CE_INFO_PAY, /* 0x08, billing-related setting (no use) */ + VM_CE_INFO_PAY_NODE, /* 0x09, billing-related setting (no use) */ + VM_CE_INFO_PRICE, /* 0x0a, billing-related setting (no use) */ + VM_CE_INFO_PAY_MODE, /* 0x0b, billing-related setting (no use) */ + VM_CE_INFO_PAY_PARAM, /* 0x0c, billing-related setting (no use) */ + VM_CE_INFO_APP_USE, /* 0x0d, billing-related setting (no use) */ + VM_CE_INFO_PAY_CHANNEL, /* 0x0e, billing-related setting (no use) */ + VM_CE_INFO_MEM_REQ, /* 0x0f, memory size application required */ + VM_CE_INFO_RESOLUTION_REQ, /* 0x10, resolution application support */ + VM_CE_INFO_PLAT_REQ, /* 0x11, engine version (no use) */ + VM_CE_INFO_IMSI, /* 0x12, check for individual application */ + VM_CE_INFO_PERMISSION, /* 0x13, system permission list */ + VM_CE_INFO_TRIAL, /* 0x14, (no use) */ + VM_CE_INFO_COMPILER, /* 0x15, compiler type (no use) */ + VM_CE_INFO_INPUT_MODE, /* 0x16, (no use) */ + VM_CE_INFO_DESC, /* 0x17, application descriptionl */ + VM_CE_INFO_SUPPORT_BG_RUN, /* 0x18, is support background run or not */ + VM_CE_INFO_NAME_LIST, /* 0x19, application name multilanguage */ + VM_CE_INFO_DESC_LIST, /* 0x1a, application description multilanguage */ + VM_CE_INFO_ZIMO_LIST, /* 0x1b, application name zimo multilanguage */ + VM_CE_INFO_ROTATE, /* 0x1c, is support rotate or not */ + VM_CE_INFO_SM, /* 0x1d, sm type (no use) */ + VM_CE_INFO_SM_TYPE, /* 0x1e, sm type: general(0), UI(1) (no use) */ + VM_CE_INFO_SM_PRIVATE, /* 0x1f, private sm */ + VM_CE_INFO_SM_CRYPTEXT, /* 0x20, private key */ + VM_CE_INFO_FILE_TYPE, /* 0x21, file type */ + VM_CE_INFO_RO_RW_ZIP, /* 0x22, is zipped or not */ + VM_CE_INFO_CHARSET, /* 0x23, is encoding using UCS2 */ + VM_CE_INFO_SUPPORT_VP, /* 0x24, 0 means not support Venus componet, 1 means support Venus component, and will link venus lib in package*/ + VM_CE_INFO_SYS_FILE_SIZE, /* 0x25, system file max size*/ + VM_CE_INFO_MULTI_NAME_LIST, /* 0x26, app name multi language support*/ + VM_CE_INFO_URL, /* 0x27, update server URL*/ + VM_CE_INFO_UPDATE_INFO, /* 0x28, update information*/ + VM_CE_INFO_NO_SCREEN, /* 0x29, is use screen or not*/ + VM_CE_INFO_VPP_TYPE, /* 0x2a, vpp type:1:widget,2:wallpaper,3:launcher,4:screen lock*/ + VM_CE_INFO_PUSH = 0x2c, /* 0x2c, app support PUSH nor not ,1 means support,0 means NOT support*/ + VM_CE_INFO_PUSH_APPID, /* 0x2d, app push id */ + VM_CE_INFO_PUSH_SENDERID, /* 0x2e, app push sender id normal is a e-mail address */ + VM_CE_INFO_RES_AB2, /* 0x2f, app use AB2 formant image */ + VM_CE_INFO_BUILD_ID, /* 0x30 */ + VM_CE_INFO_ADV_ICON, /* 0x31, app use advanced ICON, support PNG and any size */ + VM_CE_INFO_AUTO_START, /* 0x32, app auto start when power on*/ + VM_CE_INFO_IDLE_SHORTCUT, /* 0x33, app set idle shortcut when install*/ + VM_CE_INFO_CLOCK_APP, /* 0x34, 1 means app is clock app,0 means not*/ + VM_CE_INFO_TOTAL +}; + + +/* DOM-NOT_FOR_SDK-BEGIN */ +#define VM_CE_INFO_LIST_START VM_CE_INFO_NAME_LIST +#define VM_CE_INFO_LIST_END VM_CE_INFO_ZIMO_LIST + +/* define the Cert envelop head */ +typedef struct _MRECertHead +{ + VMINT digestype; /* digest type MD5 or SHA1 */ + VMUCHAR signature[RSA_LEN]; /* signature */ + VMINT offset; /* offset of signature */ + VMUCHAR reserve[RESERVED_BYTES_NUM]; /* reserve */ +} MRECertHead; + +/* Extend Cert envelop head */ +typedef struct _MRECertHead_Ex +{ + VMINT digestype; /* digest type MD5 or SHA1 */ + VMUCHAR signature[RSA_LEN * 2]; /* signature */ + VMINT offset; /* offset of signature */ + VMUCHAR reserve[RESERVED_BYTES_NUM]; /* reserve */ +} MRECertHead_Ex; + +/* Cert structure */ +typedef struct _MRECert +{ + VMUCHAR* digest; /* digest data */ + VMINT diglen; /* digest lenth */ + VMINT digesttype; /* digest type */ +} MRECert; +/* DOM-NOT_FOR_SDK-END */ + +/* Auth type */ +enum +{ + VERIFY_SIG = 1, /* only signature */ + VERIFY_FULL /* full Auth */ +}; + +/***************************************************************************** + * FUNCTION + * vm_ce_auth_app_ex + * DESCRIPTION + * verify the file, to check if it is legal + * PARAMETERS + * filename : [IN] full path to check + * cache_buf : [IN] buffer for engine used + * cache_len : [IN] size of buffer + * mode : [IN] VERIFY_SIG(signature, resolution), VERIFY_FULL(include memory) + * RETURNS + * if succeed, return >=0, otherwise failure. + * EXAMPLE + * + * VMUCHAR* ce_digest_buffer = NULL; + * VMINT ce_digest_buffer_len = (10 * 1024); + * + * VMINT rescode = -1; + * + * if ((ce_digest_buffer = vm_malloc(ce_digest_buffer_len)) == NULL) + * return ; + * + * rescode = vm_ce_auth_app_ex( vxp_filename, ce_digest_buffer, ce_digest_buffer_len, VERIFY_SIG); + * + * vm_free( ce_digest_buffer ); + * + * return rescode; + * + *****************************************************************************/ +extern VMINT vm_ce_auth_app_ex( VMWSTR filename, VMUCHAR * cache_buf, VMINT cache_len, VMINT mode ); + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_CERT_MANAGER_SDK_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmche.h b/hardware/arduino/mtk/system/libmtk/include/vmche.h new file mode 100644 index 00000000..49ecb36c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmche.h @@ -0,0 +1,965 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMCHE_SDK_H_ +#define VMCHE_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/* The structure vm_stche is defined to record and maintain the context of CHE */ +typedef struct _vm_stche_t +{ + VMUINT cheLastLength; /* last block length */ + VMUINT8 *cheLastDstAddr; /* last destination address */ + VMUINT8 *cheWorkBuf; /* pointe to a space used by each algorithm */ + VMUINT cheBufLen; /* the length of cheWorkBuf. It depends on the encrypt algorithm */ + VMUINT cipher_type; /* cipher type */ + VMUINT8 *cheKey; /* key stream */ + VMUINT8 *cheIV; /* initial vector */ + VMUINT cheKeyLength; /* key stream length */ + VMUINT cheIVLength; /* initial vector length */ + VMUINT8 cheFirstFlag; /* first block flag */ + } vm_stche; + +/* CHE error cause */ +typedef enum +{ + VM_CHE_OK = 0, /* success */ + VM_CHE_ERROR = -1, /* error occurs */ + VM_CHE_KEY_CHK_FAIL = -2, /* public or private key check fail */ + VM_CHE_INVALID_LENGTH = -3, /* buffer length too small or too long */ + VM_CHE_OPERATION_FAIL = -4 /* che operation fails, such as cipher fail */ +} vm_che_result_error_enum; + +/* vm_che_type define the cipher and hash function algorithm type */ +typedef enum +{ + VM_CHE_MD5 = 1, /* MD5 hash algorithm. The output length is fixed 16 bytes */ + VM_CHE_SHA1, /* SHA1 hash algorithm. The output length is fixed 20 bytes */ + VM_CHE_DES, /* DES block cipher algorithm. The CHE will do auto padding in DES type. The maximum padding length is 8 bytes */ + VM_CHE_3DES, /* 3DES block cipher algorithm. The CHE will do auto padding in 3DES type. The maximum padding length is 8 bytes */ + VM_CHE_AES, /* AES block cipher algorithm. The CHE will do auto padding in AES(ECB, CBC) type. The maximum padding length is 16 bytes */ + VM_CHE_MD4, /* MD4 hash algorithm. The output length is fixed 16 bytes */ + VM_CHE_MAC_MD5, /* HMAC_MD5 hash algorithm. The output length is fixed 16 bytes */ + VM_CHE_MAC_SHA1, /* HMAC_SHA1 hash algorithm. The output length is fixed 20 bytes */ + VM_CHE_RC4, /* RC4 stream cipher algorithm. No padding */ + VM_CHE_RSA, /* RSA asym cipher algorithm. */ + VM_CHE_DH, /* Diffie Hellman cipher algorithm used to generate the key. No padding */ + VM_CHE_MAC_SHA224, /* HMAC_SHA224 hash algorithm. The output length is fixed 28 bytes */ + VM_CHE_MAC_SHA256, /* HMAC_SHA256 hash algorithm. The output length is fixed 32 bytes */ + VM_CHE_SHA224, /* SHA 224 algorithm */ + VM_CHE_SHA256, /* SHA 256 algorithm */ + VM_CHE_TYPE_END +} vm_che_type; + +/* vm_che_operation_mode define the cipher function mode. For hash function, it could be set VM_CHE_MODE_NULL */ +typedef enum +{ + VM_CHE_MODE_NULL = 0, /* null mode. This mode is used when there is no mode operation */ + VM_CHE_ECB, /* AES/DES ECB mode */ + VM_CHE_CBC, /* AES/DES CBC mode */ + VM_CHE_CTR, /* AES CTR(counter) mode */ + VM_CHE_F8, /* AES F8 mode */ + VM_CHE_SKIP, /* RC4 Skip mode */ + VM_CHE_KEY_WRAP, /* AES key wrap mode */ + VM_CHE_KEY_UNWRAP /* AES key unwrap mode */ +} vm_che_operation_mode; + +/* vm_che_rsa_padding_mode_enum define the RSA padding mode. */ +typedef enum +{ + VM_CHE_RSA_MODE_NULL = 0, /* null mode. This mode is used when there is no padding */ + VM_CHE_RSA_PKCS1_V15, /* RSA PKCS#1 v1.5 padding mode */ + VM_CHE_RSA_MODE_TOTAL +} vm_che_rsa_padding_mode_enum; + +/* vm_che_action define this CHE process should run hash, encipher or decipher */ +typedef enum +{ + VM_CHE_HASH, /* generate hash value */ + VM_CHE_ENC, /* encryption data */ + VM_CHE_DEC, /* decryption data */ + VM_CHE_MAC_HASH, /* generate HMAC value */ + VM_DH_INIT, /* initialize the Diffie-Hellman */ + VM_DH_MAKE_PARAMS, /* Suppose A=G^a mod p. generate discrete logarithms(a) and A */ + VM_DH_MAKE_PUBLIC, /* Suppose A=G^a mod p. generate discrete logarithms(a) and A */ + VM_DH_CALC_SECRET, /* Suppose B=G^b mod p. Calculate the shared secret (G^b)^a mod P */ + VM_DH_FREE /* finialize the Diffie-Hellman */ +} vm_che_action; + +/* vm_che_key_action_type define the CHE Key process. The life cycle of input key buffer should be maintained until che_deinit except RSA.*/ +typedef enum +{ + VM_CHE_GEN_KEY, /* generate the key exclude asynmetry and RC4 algirhtm */ + VM_CHE_SET_KEY, /* set the key exclude asynmetry and RC4 algirhtm */ + VM_CHE_GET_KEY, /* get the key exclude asynmetry and RC4 algirhtm*/ + VM_CHE_DEL_KEY, /* delete the key exclude asynmetry and RC4 algirhtm */ + VM_CHE_SET_RC4_KEY, /* set the RC4 key */ + VM_CHE_SET_RSA_N, /* set the RSA modulus N. N=P*Q. N is prime number. The input N is a binary data */ + VM_CHE_SET_RSA_E, /* set the RSA public exponent: E. The input E is a binary data */ + VM_CHE_SET_RSA_D, /* set the RSA private exponent: D. The input D is a binary data */ + VM_CHE_SET_RSA_P, /* set the RSA modulus P(CRT format). The input P is a binary data */ + VM_CHE_SET_RSA_Q, /* set the RSA modulus Q(CRT format). The input Q is the binary data */ + VM_CHE_SET_RSA_dModPm1, /* set the RSA private exponent(CRT format): DP. The input DP is a binary data */ + VM_CHE_SET_RSA_dModQm1, /* set the RSA private exponent(CRT format): DQ. The input DQ is a binary data */ + VM_CHE_SET_RSA_qInvModP, /* set the coefficient Integer(CRT format): inverse Q. The input InvQ is a binary data */ + VM_CHE_SET_DH_P, /* set the DH modulus: P. The input P is a binary data. */ + VM_CHE_SET_DH_G, /* set the DH prime root: G. The input G is a binary data */ + VM_CHE_SET_DH_SELF_PUBLIC, /* set the self public value. G^X mod P. The input is a binary data. */ + VM_CHE_SET_DH_PEER_PUBLIC, /* set the peer public value. G^Y mod P. The input is a binary data. */ + VM_CHE_SET_DH_PRIVATE, /* set the discrete logarithms(private key): X. The input X is a binary data. */ + VM_CHE_GET_DH_SELF_PUBLIC_LEN, /* get the self public length */ + VM_CHE_GET_DH_PRIVATE_LEN, /* get the discrete logarithm length */ + VM_CHE_GET_DH_SECRET_LEN, /* get the secret length */ + VM_CHE_GET_DH_SELF_PUBLIC, /* get self public value */ + VM_CHE_GET_DH_PRIVATE, /* get the discrete logarithm */ + VM_CHE_GET_DH_SECRET, /* get the shared key,i.e. key. key = GY^X mod P */ + VM_CHE_GET_RSA_N, /* get the RSA modulus N. N=P*Q. N is prime number. The output N is binary data */ + VM_CHE_GET_RSA_E, /* get the RSA public exponent: E. The output E is a binary data */ + VM_CHE_GET_RSA_D, /* get the RSA private exponent: D. The output D is a binary data */ + VM_CHE_GET_RSA_P, /* get the RSA modulus P(CRT format). The output P is a binary data */ + VM_CHE_GET_RSA_Q, /* get the RSA modulus Q(CRT format). The output Q is the binary data */ + VM_CHE_GET_RSA_dModPm1, /* get the RSA private exponent(CRT format): DP. The output DP is a binary data */ + VM_CHE_GET_RSA_dModQm1, /* get the RSA private exponent(CRT format): DQ. The output DQ is a binary data */ + VM_CHE_GET_RSA_qInvModP, /* get the coefficient Integer(CRT format): inverse Q. The output InvQ is a binary data */ + VM_CHE_GET_RSA_N_LEN, /* get the RSA modulus N. N=P*Q. N is prime number. The output N is binary data */ + VM_CHE_GET_RSA_E_LEN, /* get the RSA public exponent: E. The output E is a binary data */ + VM_CHE_GET_RSA_D_LEN, /* get the RSA private exponent: D. The output D is a binary data */ + VM_CHE_GET_RSA_P_LEN, /* get the RSA modulus P(CRT format). The output P is a binary data */ + VM_CHE_GET_RSA_Q_LEN, /* get the RSA modulus Q(CRT format). The output Q is the binary data */ + VM_CHE_GET_RSA_dModPm1_LEN, /* get the RSA private exponent(CRT format): DP. The output DP is a binary data */ + VM_CHE_GET_RSA_dModQm1_LEN, /* get the RSA private exponent(CRT format): DQ. The output DQ is a binary data */ + VM_CHE_GET_RSA_qInvModP_LEN, /* get the coefficient Integer(CRT format): inverse Q. The output InvQ is a binary data */ + VM_CHE_ACTION_TYPE_END +}vm_che_key_action_type; + + + +/***************************************************************************** + * FUNCTION + * vm_che_init + * DESCRIPTION + * Initialize the vm_stche data structure created by application + * PARAMETERS + * che_context_p : [IN] CHE context + * type : [IN] CHE type (vm_che_type) + * RETURN VALUES + * void + * SEE ALSO + * vm_che_deinit + * EXAMPLE + * + * vm_stche context; + * vm_che_init(&context, VM_CHE_SHA1); + * + *****************************************************************************/ + extern void vm_che_init(vm_stche *che_context_p, VMUINT type); + +/***************************************************************************** + * FUNCTION + * vm_che_deinit + * DESCRIPTION + * Deinitialize the CHE context + * PARAMETERS + * che_context_p : [IN] CHE context + * RETURN VALUES + * void + * SEE ALSO + * vm_che_init + * EXAMPLE + * + * vm_stche context; + * vm_che_init(&context, VM_CHE_SHA1); + * ... + * vm_che_deinit(&context); + * + *****************************************************************************/ +extern void vm_che_deinit(vm_stche *che_context_p); + +/***************************************************************************** + * DESCRIPTION + * API used to set, get, delete, generate the key value. + * If user uses this API to get the key, CHE only stores the pointer of the key. + * Thus, the key has to be kept until the che_deinit is called. There is only + * One exception, in the RSA, we will allocate another space to store the key. + * Thus, user doesn't have to care if they can release the buffer of key. + * PARAMETERS + * che_context_p : [IN] CHE context + * type : [IN] key action type (vm_che_key_action_type) + * key : [IN/OUT] key stream + * key_len : [IN] key stream length + * EXAMPLE + * + * vm_stche che_context; + * vm_che_init(&che_context, VM_CHE_MAC_MD5); + * vm_che_key_action(&che_context, VM_CHE_SET_KEY, (VMUINT8 *) key, key_len); + * + *****************************************************************************/ +extern void vm_che_key_action(vm_stche *che_context_p, vm_che_key_action_type type, VMUINT8 *key, VMINT key_len); + +/***************************************************************************** + * FUNCTION + * vm_che_set_iv + * DESCRIPTION + * Set initial vector for CBC or CTR or AES_F8 mode. CHE only stores the pointer address. + * The iv buffer should be kept by the user until the first block is computed. + * To avoid confusion, user can keep the buffer until the che_deinit is called. + * PARAMETERS + * che_context_p : [IN] CHE context + * iv : [IN] initial vector. the input has to be 4-byte alignment on ARM platform + * iv_len : [IN] initial vector length + * RETURN VALUES + * void + * EXAMPLE + * + * vm_stche context; + * vm_che_init(&context, VM_CHE_AES); + * vm_che_set_iv(&che_context, iv, 16); + * ... + * vm_che_deinit(&context); + * + *****************************************************************************/ +extern void vm_che_set_iv(vm_stche *che_context_p, VMUINT8 *iv, VMUINT iv_len); + +/***************************************************************************** + * DESCRIPTION + * API used to execute cipher and hash process function. + * Please pass the "type" parameter + * as the constant announced in vm_che_type enum. It doesn't allow passing variable. + * The dest buffer size should be refer to the RFC standard specification. + * The DES/AES in CBC/ECB mode will do the auto padding if application uses the CHE's auto padding, + * the destination buffer address has to be at least source_length + 1 DES block size(8 bytes) . + * Otherwise, there will be a memory corruption. If application doesn't want to use auto padding, + * it cannot set the last_block to "TRUE". That is to say, as long as the last_block is not set to + * TRUE, there will no auto padding. The auto padding CHE uses is PKCS#1 v15. This padding is standard + * padding used in PCKS#5. + * P.S. The input and output buffer should be different buffer. Don't use the same buffer. + * + * PARAMETERS + * che_context_p : [IN] CHE context + * type : [IN] che type (vm_che_type) + * mode : [IN] che operation mode (vm_che_operation_mode) + * act : [IN] che action (vm_che_action) + * source : [IN] source input data buffer (it has to be 4-byte alignment for DES and AES) + * dest : [OUT] destination buffer (it has to be 4-byte alignment for DES) + * source_length : [IN] source input buffer length + * last_block : [IN] TRUE: do the standard auto padding(PKCS#5). + * FLASE: don't do the standard auto padding(PKCS#5). + * If user wants the auto padding, s/he has to set the final to TRUE in its final block + * operation. On the contrary, if s/he doesn't want the auto padding, please do not set + * final to TRUE. + * RETURN VALUES + * 1 : CHE process successful + * 0 : CHE process fail + * EXAMPLE + * Symmetry Block Cipher Examples: + * + * 1. DES Encryption (CBC mode): + * The input, initial vector and destination address have to be in 4-byte alignment. + * + * With auto padding: + * + * vm_stche che_context; + * vm_che_init(&che_context, VM_CHE_DES); + * vm_che_key_action(&che_context, VM_CHE_SET_KEY, key, key_length); + * vm_che_set_iv(&che_context, init_vector, vec_length); + * vm_che_process(&che_context, VM_CHE_DES, VM_CHE_CBC , VM_CHE_ENC, src_buffer, dst_buffer, src_len, FALSE); + * ... + * //if the last segmemnt in source buffer is intended to be processed and we want to use the auto padding, + * //we set final to TRUE + * vm_che_process(&che_context, VM_CHE_DES, VM_CHE_CBC , VM_CHE_ENC, src_buffer, dst_buffer, src_len, TRUE); + * // do other operation + * ... + * //Deinitialize when all cipher operation is finish + * vm_che_deinit(&che_context); + * + * + * Without auto padding: + * + * vm_stche che_context; + * vm_che_init(&che_context, VM_CHE_DES); + * vm_che_key_action(&che_context, VM_CHE_SET_KEY, key, key_length); + * vm_che_set_iv(&che_context, init_vector, vec_length); + * vm_che_process(&che_context, VM_CHE_DES, VM_CHE_CBC , VM_CHE_ENC, src_buffer, dst_buffer, src_len, FALSE); + * ... + * //if the last segmemnt in source buffer is intended to be processed and we don't want the auto padding, + * //we set final to FALSE + * vm_che_process(&che_context, VM_CHE_DES, VM_CHE_CBC , VM_CHE_ENC, src_buffer, dst_buffer, src_len, FALSE); + * // do other operation + * ... + * //Deinitialize when all cipher operation is finish + * vm_che_deinit(&che_context); + * + * 2. DES Encryption (ECB mode): + * With auto padding: + * + * vm_stche che_context; + * vm_che_init(&che_context, VM_CHE_DES); + * vm_che_key_action(&che_context, VM_CHE_SET_KEY, key, key_length); + * vm_che_process(&che_context, VM_CHE_DES, VM_CHE_ECB , VM_CHE_ENC, src_buffer, dst_buffer, src_len, FALSE); + * ... + * //if the last segmemnt in source buffer is intended to be processed and we want to use the auto padding, + * //we set final to TRUE + * vm_che_process(&che_context, VM_CHE_DES, VM_CHE_ECB , VM_CHE_ENC, src_buffer, dst_buffer, src_len, TRUE); + * // do other operation + * ... + * //Deinitialize when all cipher operation is finish + * vm_che_deinit(&che_context); + * + * + * Without auto padding: + * + * vm_stche che_context; + * vm_che_init(&che_context, VM_CHE_DES); + * vm_che_key_action(&che_context, VM_CHE_SET_KEY, key, key_length); + * vm_che_process(&che_context, VM_CHE_DES, VM_CHE_ECB , VM_CHE_ENC, src_buffer, dst_buffer, src_len, FALSE); + * ... + * //if the last segmemnt in source buffer is intended to be processed and we don't want to use the + * //auto padding, we set final to TRUE + * vm_che_process(&che_context, VM_CHE_DES, VM_CHE_ECB , VM_CHE_ENC, src_buffer, dst_buffer, src_len, FALSE); + * // do other operation + * ... + * //Deinitialize when all cipher operation is finish + * vm_che_deinit(&che_context); + * + * 3. AES Encryption (Counter mode): + * Because this mode doesn't need padding, we don't care the "final" parameter in this mode. + * Its input data can not in block boundary size. + * + * vm_stche che_cntx; + * vm_che_init(&che_cntx, VM_CHE_AES); + * vm_che_key_action(&che_cntx, VM_CHE_SET_KEY, key, 16); + * vm_che_set_iv(&che_cntx, iv, 16); + * vm_che_process(&che_cntx, VM_CHE_AES, VM_CHE_CTR, VM_CHE_ENC, src_data, dst_data, src_len, TRUE); + * // do other operation + * ... + * //Deinitialize when all cipher operation is finish + * vm_che_deinit(&che_cntx); + * + * + * 4. AES Encryption (Key WRAP mode): + * The input data has to be in multiple of 64 bits block size. + * Because this mode doesn't need padding, we don't care the "final" parameter in this mode. + * Because one more block is generated for checking in KEY WRAP mode, + * the input and output buffer should be different one in KEY_WRAP and KEY_UNWRAP mode. + * + * vm_stche che_cntx; + * vm_che_init(&che_cntx, VM_CHE_AES); + * vm_che_key_action(&che_cntx, VM_CHE_SET_KEY, key, 16); + * vm_che_set_iv(&che_cntx, iv, 16); + * vm_che_process(&che_cntx, VM_CHE_AES, VM_CHE_KEY_WRAP, VM_CHE_ENC, src_data, dst_data, src_len, TRUE); + * // do other operation + * ... + * //Deinitialize when all cipher operation is finish + * vm_che_deinit(&che_cntx); + * + * + * 5. AES Encryption (CBC mode): + * The input and initial vector address have to be in 4-byte alignment. + * + * With auto padding: + * + * vm_stche che_cntx; + * vm_che_init(&che_cntx, VM_CHE_AES); + * vm_che_key_action(&che_cntx, VM_CHE_SET_KEY, key, 16); + * vm_che_set_iv(&che_cntx, iv, 16); + * vm_che_process(&che_cntx, VM_CHE_AES, VM_CHE_CBC, VM_CHE_ENC, src_data, dst_data, src_len, FALSE); + * //final block + * vm_che_process(&che_cntx, VM_CHE_AES, VM_CHE_CBC, VM_CHE_ENC, src_data, dst_data, src_len, TRUE); + * // do other operation + * ... + * //Deinitialize when all cipher operation is finish + * vm_che_deinit(&che_cntx); + * + * + * Without auto padding: + * + * vm_stche che_cntx; + * vm_che_init(&che_cntx, VM_CHE_AES); + * vm_che_key_action(&che_cntx, VM_CHE_SET_KEY, key, 16); + * vm_che_set_iv(&che_cntx, iv, 16); + * vm_che_process(&che_cntx, VM_CHE_AES, VM_CHE_CBC, VM_CHE_ENC, src_data, dst_data, src_len, FALSE); + * // final block + * vm_che_process(&che_cntx, VM_CHE_AES, VM_CHE_CBC, VM_CHE_ENC, src_data, dst_data, src_len, FALSE); + * // do other operation + * ... + * //Deinitialize when all cipher operation is finish + * vm_che_deinit(&che_cntx); + * + * 6. AES Encryption (ECB mode): + * The input address have to be in 4-byte alignment. + * + * With auto padding: + * + * vm_stche che_cntx; + * vm_che_init(&che_cntx, VM_CHE_AES); + * vm_che_key_action(&che_cntx, VM_CHE_SET_KEY, key, 16); + * vm_che_process(&che_cntx, VM_CHE_AES, VM_CHE_ECB, VM_CHE_ENC, src_data, dst_data, src_len, FALSE); + * //final block + * vm_che_process(&che_cntx, VM_CHE_AES, VM_CHE_ECB, VM_CHE_ENC, src_data, dst_data, src_len, TRUE); + * // do other operation + * ... + * //Deinitialize when all cipher operation is finish + * vm_che_deinit(&che_cntx); + * + * + * Without auto padding: + * + * vm_stche che_cntx; + * vm_che_init(&che_cntx, VM_CHE_AES); + * vm_che_key_action(&che_cntx, VM_CHE_SET_KEY, key, 16); + * vm_che_process(&che_cntx, VM_CHE_AES, VM_CHE_ECB, VM_CHE_ENC, src_data, dst_data, src_len, FALSE); + * //final block + * vm_che_process(&che_cntx, VM_CHE_AES, VM_CHE_ECB, VM_CHE_ENC, src_data, dst_data, src_len, FALSE); + * // do other operation + * ... + * //Deinitialize when all cipher operation is finish + * vm_che_deinit(&che_cntx); + * + * + * Symmetry Stream Cipher Example: + * + * 1. RC4 Encryption: + * Because this mode doesn't need padding, we don't care the "final" parameter in this mode. + * + * Use default RC4 mode: + * + * vm_stche che_ctx; + * vm_che_init(&che_ctx, VM_CHE_RC4); + * vm_che_key_action(&che_ctx, VM_CHE_SET_KEY, (kal_uint8 *)key, key_len); + * vm_che_process(&che_ctx, VM_CHE_RC4, VM_CHE_MODE_NULL, VM_CHE_ENC, (VMUINT8 *)input, + * (VMUINT8 *)output, (VMINT32)input_size, TRUE); + * // do other operation + * ... + * //Deinitialize when all cipher operation is finish + * vm_che_deinit(&che_ctx); + * + * + * Use CHE_SKIP mode: + * skip the first 256 byts key data because first 256 bytes are not random enough. + * + * vm_stche che_ctx; + * vm_che_init(&che_ctx, VM_CHE_RC4); + * vm_che_key_action(&che_ctx, VM_CHE_SET_KEY, (VMUINT8 *)key, key_len); + * vm_che_process(&che_ctx, VM_CHE_RC4, VM_CHE_SKIP, VM_CHE_ENC, (VMUINT8 *)input, + * (VMUINT8 *)output, (VMINT32)input_size, TRUE); + * // do other operation + * ... + * //Deinitialize when all cipher operation is finish + * vm_che_deinit(&che_ctx); + * + * + * Hash Operation: + * + * 1. MD5 Hash generation: + * we have to set the final block to TRUE for hash operation. The mode field is useless for hash algorithm. + * HASH doesn't have any mode options. Thus, we set it to VM_CHE_MODE_NULL. + * + * + * vm_stche che_context; + * VMUINT8 digest[16]; + * vm_che_init(&che_context, VM_CHE_MD5); + * vm_che_process(&che_context,VM_CHE_MD5,VM_CHE_MODE_NULL,VM_CHE_HASH,(kal_uint8*)input,digest,input_len, FALSE); + * ... + * vm_che_process(&che_context,VM_CHE_MD5,VM_CHE_MODE_NULL,VM_CHE_HASH,(kal_uint8*)input,digest,input_len, TRUE); + * // do other operation + * ... + * //Deinitialize when all hash operation is finish + * vm_che_deinit(&che_context); + * + * + * 2. SHA1 Hash generation: + * we have to set the final block to TRUE for hash operation. The mode field is useless for hash algorithm. + * HASH doesn't have any mode options. Thus, we set it to VM_CHE_MODE_NULL. + * + * + * vm_stche che_context; + * VMUINT8 digest[20]; + * vm_che_init(&che_context, VM_CHE_SHA1); + * vm_che_process(&che_context,VM_CHE_SHA1,VM_CHE_MODE_NULL,VM_CHE_HASH,(VMUINT8*)input,digest,input_len, FALSE); + * ... + * vm_che_process(&che_context,VM_CHE_SHA1,VM_CHE_MODE_NULL,VM_CHE_HASH,(VMUINT8*)input,digest,input_len, TRUE); + * vm_che_deinit(&che_context); + * // do other operation + * ... + * //Deinitialize when all hash operation is finish + * + * + * 3. HMAC MD5 generation: + * we have to set the final block to TRUE for HMAC operation because HMAC doesn't have padding consideartion for last block. + * The mode field is useless for HMAC algorithm. HMAC doesn't have any mode options. Thus, we set it to VM_CHE_MODE_NULL. + * + * + * vm_stche che_context; + * VMUINT8 digest[16]; + * vm_che_init(&che_context, VM_CHE_MAC_MD5); + * vm_che_key_action(&che_context, VM_CHE_SET_KEY, (VMUINT8*) key, key_len); + * vm_che_process(&che_context, VM_CHE_MAC_MD5, VM_CHE_MODE_NULL, VM_CHE_HASH, (VMUINT8 *) input, digest, input_len, FALSE); + * ... + * vm_che_process(&che_context, VM_CHE_MAC_MD5, VM_CHE_MODE_NULL, VM_CHE_HASH, (VMUINT8 *) input, digest, input_len, TRUE); + * // do other operation + * ... + * //Deinitialize when all hash operation is finish + * vm_che_deinit(&che_context); + * + * + * 4. SHA2 Hash generation: + * we have to set the final block to TRUE for hash operation. The mode field is useless for hash algorithm. + * HASH doesn't have any mode options. Thus, we set it to VM_CHE_MODE_NULL. + * + * + * vm_stche che_context; + * VMUINT8 digest[32]; + * vm_che_init(&che_context, VM_CHE_SHA256); + * vm_che_process(&che_context, VM_CHE_SHA256, VM_CHE_MODE_NULL, VM_CHE_HASH, (VMUINT8 *) input, digest, input_len, FALSE); + * ... + * vm_che_process(&che_context, VM_CHE_SHA256, VM_CHE_MODE_NULL, VM_CHE_HASH, (VMUINT8 *) input, digest, input_len, TRUE); + * // do other operation + * ... + * //Deinitialize when all hash operation is finish + * vm_che_deinit(&che_context); + * + * + * Public Key or Key Agreement: + * + * 1. Diffie-Hellman: + * The source and dest parameter is useless for DH. + * The output data is get through vm_che_key_action. + * + * vm_stche che_ctx_dh; + * VMUINT32 dh_secret_len; + * VMUINT8 *dh_secret_key = NULL; + * + * vm_che_init(&che_ctx_dh, VM_CHE_DH); + * vm_che_process(&che_ctx_dh, VM_CHE_DH, VM_CHE_MODE_NULL, VM_DH_INIT, NULL, NULL, 0, TRUE); + * // set the p and g. p and g must in binary format + * vm_che_key_action(&che_ctx_dh, VM_CHE_SET_DH_P, (VMUINT8*) P, P_Len); + * vm_che_key_action(&che_ctx_dh, VM_CHE_SET_DH_G, G, G_Len); + * // Compute self public B = (g^b mod p) and private (b) + * vm_che_process(&che_ctx_dh, VM_CHE_DH, VM_CHE_MODE_NULL, VM_DH_MAKE_PARAMS, NULL, NULL, 0, TRUE); + * // Set the peer public key (A) in binary format + * vm_che_key_action(&che_ctx_dh, VM_CHE_SET_DH_PEER_PUBLIC, (VMUINT8*)peer_public, peer_public_len); + * // calculate the shared secret: K + * vm_che_process(&che_ctx_dh, VM_VM_CHE_DH, CHE_MODE_NULL, VM_DH_CALC_SECRET, NULL, NULL, 0, TRUE); + * //get the shared secret key + * vm_che_key_action(&che_ctx_dh, VM_CHE_GET_DH_SECRET_LEN, (void*)&dh_secret_len, sizeof(int)); + * dh_secret_key = malloc(dh_secret_len); + * che_key_action(&che_ctx_dh, VM_CHE_GET_DH_SECRET, (VMUINT8*) dh_secret_key, dh_secret_len); + * //call deinit when all operations are finish + * vm_che_process(&che_ctx_dh, VM_CHE_DH, VM_CHE_MODE_NULL, DH_FREE, NULL, NULL, 0, TRUE); + * vm_che_deinit(&che_ctx_dh); + * + *****************************************************************************/ +extern VMUINT8 vm_che_process(vm_stche *che_context_p,vm_che_type type,vm_che_operation_mode mode, + vm_che_action act, VMUINT8 *source,VMUINT8 *dest,VMUINT source_length,VMUINT8 last_block); + + +/***************************************************************************** + * FUNCTION + * vm_che_rsa_public_encrypt + * DESCRIPTION + * This API is used when we want to use public key to encrypt the data. + * Application can specify the way of padding based PKCS#1 standard. + * If application doesn't want to do the padding, s/he can set the padding to + * VM_CHE_RSA_MODE_NULL. + * + * Based on PKCS#1v1.5 standard, the smallest padding size is 11 bytes. + * Thus, the destination buffer should be: + * Destination_buffer_len = input_data_len + 11(smallest padding data) + * In addition, the output buffer size is equal to the size of N. + * If the input data length is too large or destination buffer is too small, + * the error cause will be returned. The output buffer length will be checked only + * If the passed in length is not 0. If it is 0, this means user doesn't want to check + * the destination buffer length. + * The input and output buffer can be the same one. + * + * RSA valid public key length: + * 128 bits < Modulus (N) < 4096 bits + * 2 bits < public exponent (E) < 64 bits + * PARAMETERS + * ctx : [IN] CHE context + * src : [IN] source buffer + * src_len : [IN] source buffer length (the length sould < length of N) + * dst : [OUT] destination buffer (must pass in) + * dst_len : [IN/OUT] encrypted destination length. If user pass in non zero value, + * CHE will do the destination buffer length check. If the length + * smaller than the length of N. The error is returned. However, + * If user pass in value 0, che will not do the length checking. + * padding : [IN] the way of padding. Currently we only support PKCS#1v1.5 padding. + * If user doesn't want any padding, s/he can pass in VM_CHE_RSA_MODE_NULL. + * Please take reference of the enum vm_che_rsa_padding_mode_enum + * + * RETURN VALUES + * take the reference of vm_che_result_error_enum. + * VM_CHE_OK : success + * VM_CHE_ERROR : parameter error + * VM_CHE_KEY_CHK_FAIL : input key is not correct + * VM_CHE_INVALID_LENGTH : the input data length is too large or destination buffer is too small + * VM_CHE_OPERATION_FAIL : algorithm operation is failed + * SEE ALSO + * vm_che_rsa_private_decrypt + * EXAMPLE + * (a). Encrypt the data by public key without padding + * + * vm_stche che_ctx; + * //initialize + * vm_che_init(&che_ctx, VM_CHE_RSA); + * //Set modulus: N + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_N, modulusN, n_len); + * //Set public Exponent: E + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_E, pubExp, e_len); + * //Encrypt Data by the public key + * vm_che_rsa_public_encrypt(&che_ctx, src, src_len, dst, &dst_len, VM_CHE_RSA_MODE_NULL); + * // do other operation + * ... + * //Deinitialize when all RSA operation is finish + * vm_che_deinit(&che_ctx); + * + * + * (b). Encrypt the data by public key with PKCS#1v1.5 padding + * + * vm_stche che_ctx; + * //initialize + * vm_che_init(&che_ctx, VM_CHE_RSA); + * //Set modulus: N + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_N, modulusN, n_len); + * //Set public Exponent: E + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_E, pubExp, e_len); + * //Encrypt Data by the public key + * vm_che_rsa_public_encrypt(&che_ctx, src, src_len, dst, &dst_len, VM_CHE_RSA_PKCS1_V15); + * // do other operation + * ... + * //Deinitialize when all RSA operation is finish + * vm_che_deinit(&che_ctx); + * + *****************************************************************************/ +extern VMINT vm_che_rsa_public_encrypt(vm_stche *ctx, VMUINT8 *src, VMUINT src_len, VMUINT8 *dst, + VMUINT *dst_len, vm_che_rsa_padding_mode_enum padding); + + +/***************************************************************************** + * FUNCTION + * vm_che_rsa_private_encrypt + * DESCRIPTION + * This API is used when we want to use private key to encrypt the data. + * Application can specify the way of padding based PKCS#1 standard. + * If users don't want to do the padding, they can set the padding to + * VM_CHE_RSA_MODE_NULL. + * + * Based on PKCS#1v1.5 standard, the smallest padding size is 11 bytes. + * Thus, the destination buffer should be: + * Destination_buffer_len = input_data_len + 11(smallest padding data) + * In addition, the output buffer size is equal to the size of N. + * If the input data length is too large or destination buffer is too small, + * the error cause will be returned. The output buffer length will be checked only + * If the passed in length is not 0. If it is 0, this means user doesn't want to check + * the destination buffer length. + * The input and output buffer can be the same one. + * + * PARAMETERS + * ctx : [IN] CHE context + * src : [IN] source buffer + * src_len : [IN] source buffer length (the length sould < length of N) + * dst : [OUT] destination buffer (must pass in) + * dst_len : [IN/OUT] encrypted destination length. If user pass in non zero value, + * CHE will do the destination buffer length check. If the length + * smaller than the length of N. The error is returned. However, + * If user pass in value 0, che will not do the length checking. + * padding : [IN] the way of padding. Currently we only support PKCS#1v1.5 padding. + * If users don't want any padding, they can pass in VM_CHE_RSA_MODE_NULL. + * (vm_che_rsa_padding_mode_enum) + * + * RETURN VALUES + * take the reference of vm_che_result_error_enum. + * VM_CHE_OK : success + * VM_CHE_ERROR : parameter error + * VM_CHE_KEY_CHK_FAIL : input key is not correct + * VM_CHE_INVALID_LENGTH : the input data length is too large or destination buffer is too small + * VM_CHE_OPERATION_FAIL : algorithm operation is failed + * SEE ALSO + * vm_che_rsa_public_decrypt + * EXAMPLE + * (a). Encrypt the data by private key without padding + * We set the mode to VM_CHE_RSA_MODE_NULL to indicate that we don't + * encode the input data with any padding method + * + * vm_stche che_ctx; + * //initialize + * vm_che_init(&che_ctx, VM_CHE_RSA); + * //Set modulus: N + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_N, modulusN, n_len); + * //Set private key: D + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_D, privD, d_len); + * //Encrypt Data by the private key + * vm_che_rsa_private_encrypt(&che_ctx, src, src_len, dst, &dst_len, VM_CHE_RSA_MODE_NULL); + * // do other operation + * ... + * //Deinitialize when all RSA operation is finish + * vm_che_deinit(&che_ctx); + * + * + * (b). Encrypt the data by private key with PKCS#1v1.5 padding + * + * vm_stche che_ctx; + * //initialize + * vm_che_init(&che_ctx, VM_CHE_RSA); + * //Set modulus: N + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_N, modulusN, n_len); + * //Set private key: D + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_D, privD, d_len); + * //Encrypt Data by the private key + * vm_che_rsa_private_encrypt(&che_ctx, src, src_len, dst, &dst_len, VM_CHE_RSA_PKCS1_V15); + * // do other operation + * ... + * //Deinitialize when all RSA operation is finish + * vm_che_deinit(&che_ctx); + * + * + * (c). Encryption the data by the private key (CRT format) with PKCS1#v15 padding + * + * vm_stche che_ctx; + * // initialize + * vm_che_init(&che_ctx, VM_CHE_RSA); + * // set modulus: N + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_N, modulusN, n_len); + * // set P for private key checking + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_P, (VMUINT8 *)primeP, P_len); + * // set Q for private key checking + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_Q, (VMUINT8 *)primeQ, q_len); + * // Set private exponent: d mod (p-1) + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_dModPm1, dModPm1, dp_len); + * // Set private exponent: d mod (q-1) + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_dModQm1, dModQm1, 32); + * // Set coefficient Integer: inverse of q mod p + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_qInvModP, qInvModP, 32); + * //Encrypt Data by the private key + * vm_che_rsa_private_encrypt(&che_ctx, src, src_len, dst, &dst_len, VM_CHE_RSA_PKCS1_V15); + * // do other operation + * ... + * //Deinitialize when all RSA operation is finish + * vm_che_deinit(&che_ctx); + * + *****************************************************************************/ +extern VMINT vm_che_rsa_private_encrypt(vm_stche *ctx, VMUINT8 *src, VMUINT src_len, VMUINT8 *dst, + VMUINT *dst_len, vm_che_rsa_padding_mode_enum padding); + + +/***************************************************************************** + * FUNCTION + * vm_che_rsa_public_decrypt + * DESCRIPTION + * This API is used when we want to use public key to decrypt the data. + * Application can specify the way of padding based PCKS#1 standard. + * If users don't want to do the padding, they can set the padding to + * VM_CHE_RSA_MODE_NULL. + * If the input data is too large (> size of N), the error will be returned. + * If the input data is too small ( < smallest padding length(11)), + * the error will be returned as well. + * The input and output buffer can be the same one. + * + * RSA valid public key length: + * 128 bits < Modulus (N) < 4096 bits + * 2 bits < public exponent (E) < 64 bits + * PARAMETERS + * ctx : [IN] CHE context + * src : [IN] source buffer + * src_len : [IN] source buffer length (the length sould < length of N) + * dst : [OUT] destination buffer (must pass in) + * dst_len : [IN/OUT] encrypted destination length. If user pass in non zero value, + * CHE will do the destination buffer length check. If the length + * smaller than the length of N. The error is returned. However, + * If user pass in value 0, che will not do the length checking. + * padding : [IN] the way of padding. Currently we only support PKCS#1v1.5 padding. + * If users don't want any padding, they can pass in VM_CHE_RSA_MODE_NULL. + * (vm_che_rsa_padding_mode_enum) + * + * RETURN VALUES + * take the reference of vm_che_result_error_enum. + * VM_CHE_OK : success + * VM_CHE_ERROR : parameter error + * VM_CHE_KEY_CHK_FAIL : input key is not correct + * VM_CHE_INVALID_LENGTH : input data is too small or too long + * VM_CHE_OPERATION_FAIL : algorithm operation is failed + * SEE ALSO + * vm_che_rsa_private_encrypt + * EXAMPLE + * (a). Decrypt the data by public key without padding + * + * vm_stche che_ctx; + * //initialize + * vm_che_init(&che_ctx, VM_CHE_RSA); + * //Set modulus: N + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_N, modulusN, n_len); + * //Set public Exponent: E + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_E, pubExp, e_len); + * //Decrypt Data by the public key + * vm_che_rsa_public_decrypt(&che_ctx, src, src_len, dst, &dst_len, VM_CHE_RSA_MODE_NULL); + * // do other operation + * ... + * //Deinitialize when all RSA operation is finish + * vm_che_deinit(&che_ctx); + * + * + * (b). Decrypt the data by public key with PKCS#1v1.5 padding + * + * vm_stche che_ctx; + * //initialize + * vm_che_init(&che_ctx, VM_CHE_RSA); + * //Set modulus: N + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_N, modulusN, n_len); + * //Set public Exponent: E + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_E, pubExp, e_len); + * //Decrypt Data by the public key + * vm_che_rsa_public_decrypt(&che_ctx, src, src_len, dst, &dst_len, VM_CHE_RSA_PKCS1_V15); + * // do other operation + * ... + * //Deinitialize when all RSA operation is finish + * vm_che_deinit(&che_ctx); + * + *****************************************************************************/ +extern VMINT vm_che_rsa_public_decrypt(vm_stche *ctx, VMUINT8 *src, VMUINT src_len, VMUINT8 *dst, + VMUINT *dst_len, vm_che_rsa_padding_mode_enum padding); + + +/***************************************************************************** + * FUNCTION + * vm_che_rsa_private_decrypt + * DESCRIPTION + * This API is used when we want to use private key to decrypt the data. + * Application can specify the way of padding based PCKS#1 standard. + * If users don't want to do the padding, they can set the padding to + * VM_CHE_RSA_MODE_NULL. + * + * If the input data is too large (> size of N), the error will be returned. + * If the input data is too small ( < smallest padding length(11)), + * the error will be returned as well. + * The input and output buffer can be the same one. + * + * PARAMETERS + * ctx : [IN] CHE context + * src : [IN] source buffer + * src_len : [IN] source buffer length (the length sould < length of N) + * dst : [OUT] destination buffer (must pass in) + * dst_len : [IN/OUT] encrypted destination length. If user pass in non zero value, + * CHE will do the destination buffer length check. If the length + * smaller than the length of N. The error is returned. However, + * If user pass in value 0, che will not do the length checking. + * padding : [IN] the way of padding. Currently we only support PKCS#1v1.5 padding. + * If users don't want any padding, they can pass in VM_CHE_RSA_MODE_NULL. + * (vm_che_rsa_padding_mode_enum) + * + * RETURN VALUES + * take the reference of vm_che_result_error_enum. + * VM_CHE_OK : success + * VM_CHE_ERROR : parameter error + * VM_CHE_KEY_CHK_FAIL : input key is not correct + * VM_CHE_INVALID_LENGTH : input data is too small or too long + * VM_CHE_OPERATION_FAIL : algorithm operation is failed + * SEE ALSO + * vm_che_rsa_public_encrypt + * EXAMPLE + * (a). Decrypt the data by private key without padding + * We set the mode to VM_CHE_RSA_MODE_NULL to indicate that we don't encode the input data with any padding method + * + * vm_stche che_ctx; + * //initialize + * vm_che_init(&che_ctx, VM_CHE_RSA); + * //Set modulus: N + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_N, modulusN, n_len); + * //Set private key: D + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_D, privD, d_len); + * //Decrypt Data by the private key + * vm_che_rsa_private_decrypt(&che_ctx, src, src_len, dst, &dst_len, VM_CHE_RSA_MODE_NULL); + * // do other operation + * ... + * //Deinitialize when all RSA operation is finish + * vm_che_deinit(&che_ctx); + * + * + * (b). Decrypt the data by private key with PKCS#1v1.5 padding + * + * vm_stche che_ctx; + * //initialize + * vm_che_init(&che_ctx, VM_CHE_RSA); + * //Set modulus: N + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_N, modulusN, n_len); + * //Set private key: D + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_D, privD, d_len); + * //decrypt Data by the private key + * vm_che_rsa_private_decrypt(&che_ctx, src, src_len, dst, &dst_len, VM_CHE_RSA_PKCS1_V15); + * // do other operation + * ... + * //Deinitialize when all RSA operation is finish + * vm_che_deinit(&che_ctx); + * + * + * (c). Decrypt the data by private key (CRT format) with PKCS#1v1.5 padding + * + * vm_stche che_ctx; + * //initialize + * vm_che_init(&che_ctx, VM_CHE_RSA); + * // set modulus: N + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_N, modulusN, n_len); + * // set P for private key checking + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_P, (kal_uint8 *)primeP, P_len); + * // set Q for private key checking + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_Q, (kal_uint8 *)primeQ, q_len); + * // Set private exponent: d mod (p-1) + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_dModPm1, dModPm1, dp_len); + * // Set private exponent: d mod (q-1) + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_dModQm1, dModQm1, 32); + * // Set coefficient Integer: inverse of q mod p + * vm_che_key_action(&che_ctx, VM_CHE_SET_RSA_qInvModP, qInvModP, 32); + * //decrypt Data by the private key + * vm_che_rsa_private_decrypt(&che_ctx, src, src_len, dst, &dst_len, VM_CHE_RSA_PKCS1_V15); + * // do other operation + * ... + * //Deinitialize when all RSA operation is finish + * vm_che_deinit(&che_ctx); + * + *****************************************************************************/ +extern VMINT vm_che_rsa_private_decrypt(vm_stche *ctx, VMUINT8 *src, VMUINT src_len, VMUINT8 *dst, + VMUINT *dst_len, vm_che_rsa_padding_mode_enum padding); + +#ifdef __cplusplus +} +#endif + +#endif /* VMCHE_SDK_H_ */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmchset.h b/hardware/arduino/mtk/system/libmtk/include/vmchset.h new file mode 100644 index 00000000..24641fa3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmchset.h @@ -0,0 +1,332 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMCHSET_SDK_H_ +#define VMCHSET_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/* The maximum length of character conversion. */ +#define CONVERT_CHSET_MAX_LEN 4096 + +/***************************************************************************** + * FUNCTION + * vm_ucs2_to_gb2312 + * DESCRIPTION + * Converts the UCS2 string to GB2312 string. + * PARAMETERS + * dst : [OUT] Pointer to destination string. + * size : [IN] Size in bytes of destination. + * src : [IN] Pointer to input string. + * RETURNS + * The error code of the operation. + * RETURN VALUES + * 0 : If successful. + * -1 : If failed. + *****************************************************************************/ +VMINT vm_ucs2_to_gb2312(VMSTR dst, VMINT size, VMWSTR src); + +/***************************************************************************** + * FUNCTION + * vm_gb2312_to_ucs2 + * DESCRIPTION + * Converts the GB2312 string to UCS2 string. + * PARAMETERS + * dst : [OUT] Pointer to destination string. + * size : [IN] Size in bytes of destination. + * src : [IN] Pointer to input string. + * RETURNS + * The error code of the operation. + * RETURN VALUES + * 0 : If successful. + * -1 : If failed. + *****************************************************************************/ +VMINT vm_gb2312_to_ucs2(VMWSTR dst, VMINT size, VMSTR src); + +/***************************************************************************** + * FUNCTION + * vm_ucs2_to_ascii + * DESCRIPTION + * Converts the UCS2 string to ASCII string. + * PARAMETERS + * dst : [OUT] Pointer to destination string. + * size : [IN] Size in bytes of destination. + * src : [IN] Pointer to input string. + * RETURNS + * The error code of the operation. + * RETURN VALUES + * 0 : If successful. + * -1 : If failed. + *****************************************************************************/ +VMINT vm_ucs2_to_ascii(VMSTR dst, VMINT size, VMWSTR src); + +/***************************************************************************** + * FUNCTION + * vm_ascii_to_ucs2 + * DESCRIPTION + * Converts the ASCII string to UCS2 string. + * PARAMETERS + * dst : [OUT] Pointer to destination string. + * size : [IN] Size in bytes of destination. + * src : [IN] Pointer to input string. + * RETURNS + * The error code of the operation. + * RETURN VALUES + * 0 : If successful. + * -1 : If failed. + *****************************************************************************/ +VMINT vm_ascii_to_ucs2(VMWSTR dst, VMINT size, VMSTR src); + +/* Phone language */ +typedef enum +{ + LANG_UNKOWN = 0, /* Unkown language */ + GB = 1, /* Simplified Chinese */ + ENGLISH, /* ENGLISH */ + BIG5, /* Traditional Chinese */ + JAPANESE, /* JAPANESE */ + KOREAN, /* KOREAN */ + SPANISH, /* SPANISH */ + FRENCH, /* FRENCH */ + DANISH, /* DANISH */ + POLISH, /* POLISH */ + PORTUGUESE, /* PORTUGUESE */ + ALBANIAN, /* ALBANIAN */ + ICELANDIC, /* ICELANDIC */ + SERBIAN, /* SERBIAN */ + AZERBAIJANI, /* AZERBAIJANI */ + CATALAN, /* CATALAN */ + HAUSA, /* HAUSA */ + KAZAKH, /* KAZAKH */ + MACEDONIAN, /* MACEDONIAN */ + SESOTHO, /* SESOTHO */ + TAGALOG, /* TAGALOG */ + YORUBA, /* YORUBA */ + ITALIAN, /* ITALIAN */ + GERMAN, /* GERMAN */ + MALAY, /* MALAY */ + INDONESIAN, /* INDONESIAN */ + CZECH, /* CZECH */ + NORWEGIAN, /* NORWEGIAN */ + SLOVAK, /* SLOVAK */ + DUTCH, /* DUTCH */ + FINNISH, /* FINNISH */ + HUNGARIAN, /* HUNGARIAN */ + VIETNAMESE, /* VIETNAMESE */ + TURKISH, /* TURKISH */ + RUSSIAN, /* RUSSIAN */ + UKRAINIAN, /* UKRAINIAN */ + ARABIC, /* ARABIC */ + PERSIAN, /* PERSIAN */ + URDU, /* URDU */ + HEBREW, /* HEBREW */ + THAI, /* THAI */ + GREEK, /* GREEK */ + SWEDISH, /* SWEDISH */ + CROATIAN, /* CROATIAN */ + ROMANIAN, /* ROMANIAN */ + SLOVENIAN, /* SLOVENIAN */ + HINDI, /* HINDI */ + MARATHI, /* MARATHI */ + TAMIL, /* TAMIL */ + GUJARATI, /* GUJARATI */ + BENGALI, /* BENGALI */ + ASSAMESE, /* ASSAMESE */ + PUNJABI, /* PUNJABI */ + TELUGU, /* TELUGU */ + KANNADA, /* KANNADA */ + MALAYALAM, /* MALAYALAM */ + ORIYA, /* ORIYA */ + XHOSA, /* XHOSA */ + SWAHILI, /* SWAHILI */ + AFRIKAANS, /* AFRIKAANS */ + ZULU, /* ZULU */ + LITHUANIAN, /* LITHUANIAN */ + LATVIAN, /* LATVIAN */ + ESTONIAN, /* ESTONIAN */ + ARMENIAN, /* ARMENIAN */ + GEORGIAN, /* GEORGIAN */ + MOLDOVAN, /* MOLDOVAN */ + GALICIAN, /* GALICIAN */ + BASQUE, /* BASQUE */ + IGBO, /* IGBO */ + FILIPINO, /* FILIPINO */ + IRISH, /* IRISH */ + SA_SPANISH, /* SA_SPANISH */ + SA_PORTUGUESE, /* SA_PORTUGUESE */ + UK_ENGLISH, /* UK_ENGLISH */ + CA_FRENCH, /* CA_FRENCH */ + BULGARIAN /* BULGARIAN */ +} vm_language_t; + +/***************************************************************************** + * FUNCTION + * vm_get_language + * DESCRIPTION + * To get current language. + * RETURNS + * The current language. + * RETURN VALUES + * GB : Simplified Chinese. + * ENGLISH : English. + * BIG5 : Traditional Chinese. + * Other value : Please refer to vm_language_t. + *****************************************************************************/ +vm_language_t vm_get_language(void); + +/* Character sets */ +typedef enum +{ + VM_CHSET_BASE = 0, /* BASE */ + VM_CHSET_ASCII, /* ASCII */ + VM_CHSET_ARABIC_ISO, /* ARABIC_ISO */ + VM_CHSET_ARABIC_WIN, /* ARABIC_WIN */ + VM_CHSET_PERSIAN_CP1097, /* PERSIAN_CP1097 */ + VM_CHSET_PERSIAN_CP1098, /* PERSIAN_CP1098 */ + VM_CHSET_BALTIC_ISO, /* BALTIC_ISO */ + VM_CHSET_BALTIC_WIN, /* BALTIC_WIN */ + VM_CHSET_CEURO_ISO, /* CEURO_ISO */ + VM_CHSET_CEURO_WIN, /* CEURO_WIN */ + VM_CHSET_CYRILLIC_ISO, /* CYRILLIC_ISO */ + VM_CHSET_CYRILLIC_WIN, /* CYRILLIC_WIN */ + VM_CHSET_GREEK_ISO, /* GREEK_ISO */ + VM_CHSET_GREEK_WIN, /* GREEK_WIN */ + VM_CHSET_HEBREW_ISO, /* HEBREW_ISO */ + VM_CHSET_HEBREW_WIN, /* HEBREW_WIN */ + VM_CHSET_LATIN_ISO, /* LATIN_ISO */ + VM_CHSET_NORDIC_ISO, /* NORDIC_ISO */ + VM_CHSET_SEURO_ISO, /* SEURO_ISO */ + VM_CHSET_TURKISH_ISO, /* TURKISH_ISO */ + VM_CHSET_TURKISH_WIN, /* TURKISH_WIN */ + VM_CHSET_WESTERN_ISO, /* WESTERN_ISO */ + VM_CHSET_ARMENIAN_ISO, /* ARMENIAN_ISO */ + VM_CHSET_WESTERN_WIN, /* WESTERN_WIN */ + VM_CHSET_BIG5, /* BIG5 */ + VM_CHSET_GB2312, /* GB2312 */ + VM_CHSET_HKSCS, /* HKSCS */ + VM_CHSET_SJIS, /* SJIS */ + VM_CHSET_GB18030, /* GB18030 */ + VM_CHSET_UTF7, /* UTF7 */ + VM_CHSET_EUCKR, /* EUCKR */ + VM_CHSET_THAI_WIN, /* THAI_WIN */ + VM_CHSET_VIETNAMESE_WIN, /* VIETNAMESE_WIN */ + VM_CHSET_KOI8_R, /* KOI8_R */ + VM_CHSET_TIS_620, /* TIS_620 */ + VM_CHSET_UTF16LE, /* UTF16LE */ + VM_CHSET_UTF16BE, /* UTF16BE */ + VM_CHSET_UTF8, /* UTF8 */ + VM_CHSET_UCS2, /* UCS2 */ + VM_CHSET_TOTAL /* TOTAL */ +} vm_chset_enum; + +/* The return value of vm_chset_convert */ + +#define VM_CHSET_CONVERT_SUCCESS (0) /* If successful. */ +#define VM_CHSET_CONVERT_ERR_PARAM (-1) /* Parameter error. */ +#define VM_CHSET_CONVERT_SRC_UNSUPPORT_CHSET (-2) /* Character set used by input string is not supported. */ +#define VM_CHSET_CONVERT_DST_UNSUPPORT_CHSET (-3) /* Character set used by destination string is not supported. */ +#define VM_CHSET_CONVERT_FATAL_ERROR (-4) /* General failure. */ + +/***************************************************************************** + * FUNCTION + * vm_chset_convert + * DESCRIPTION + * Converts string between 2 character sets. (will add the terminate character) + * PARAMETERS + * src_type : [IN] Character set in which the input string is encoded. + * dest_type : [IN] Character set in which the destination string is encoded. + * src : [IN] Pointer to input string. + * dest : [OUT] Pointer to destination string. + * dest_size : [IN] Size in bytes of destination. + * RETURNS + * The error code of the operation. + * RETURN VALUES + * VM_CHSET_CONVERT_SUCCESS : If successful. + * VM_CHSET_CONVERT_ERR_PARAM : Parameter error. + * VM_CHSET_CONVERT_SRC_UNSUPPORT_CHSET : Character set used by input string is not supported. + * VM_CHSET_CONVERT_DST_UNSUPPORT_CHSET : Character set used by destination string is not supported. + * VM_CHSET_CONVERT_FATAL_ERROR : General failure. + *****************************************************************************/ +VMINT vm_chset_convert(vm_chset_enum src_type, vm_chset_enum dest_type, VMCHAR *src, VMCHAR *dest, VMINT dest_size); + +/***************************************************************************** + * FUNCTION + * vm_get_language_ssc + * DESCRIPTION + * Get curent language's ssc string + * PARAMETERS + * ssc : [OUT] SSC String + * RETURNS + * index of cur language + *****************************************************************************/ +extern VMINT32 vm_get_language_ssc(VMINT8 *ssc); + +/***************************************************************************** + * FUNCTION + * vm_get_current_lang_country_code + * DESCRIPTION + * To get current language's country code + * This is used to get current language's country code + * PARAMETERS + * void + * RETURNS + * country code + *****************************************************************************/ +VMUSTR vm_get_current_lang_country_code(void); + + +/***************************************************************************** + * FUNCTION + * vm_get_language_num + * DESCRIPTION + * To query support language number. + * PARAMETERS + * void + * RETURNS + * the language number. + *****************************************************************************/ +VMINT32 vm_get_language_num(void); + + +#ifdef __cplusplus +} +#endif + +#endif /* VMCHSET_SDK_H_ */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmconn.h b/hardware/arduino/mtk/system/libmtk/include/vmconn.h new file mode 100644 index 00000000..8ee00418 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmconn.h @@ -0,0 +1,1186 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMCONN_SDK_H +#define VMCONN_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + + +#define VM_MAX_SOCK_ADDR_LEN 28 + +/* Socket address struct */ +typedef struct +{ + VMINT16 addr_len; /* address length */ + VMUINT16 port; /* port number */ + VMUINT8 addr[VM_MAX_SOCK_ADDR_LEN]; /* address */ +} vm_sockaddr_struct; + + +/* only use when conbined with vm_dtacct_set */ +#define VM_APN_USER_DEFINE (6) + + +/* APN information struct */ +typedef struct +{ + VMINT apn_info_id; /* indicate use proxy or not, 1 means use */ + VMINT proxy_port; /* proxy port */ + VMCHAR operator_id[8]; /* empty string */ + VMCHAR operator_name[64]; /* empty string */ + VMCHAR proxy_ip[16]; /* proxy ip address */ + VMCHAR apn_proxy[32]; /* empty string */ + VMCHAR apn_no_proxy[32]; /* empty string */ + VMCHAR user_name[16]; /* proxy auth. ID */ + VMCHAR pass_word[16]; /* proxy auto. password */ +}vm_apn_info_ext; + + +/***************************************************************************** + * FUNCTION + * vm_is_support_wifi + * DESCRIPTION + * query wifi support. + * RETURNS + * support or not support wifi. + * RETURN VALUES + * TRUE : support wifi + * FALSE : not support wifi +*****************************************************************************/ +VMINT vm_is_support_wifi(void); + + +/***************************************************************************** + * FUNCTION + * vm_wifi_is_connected + * DESCRIPTION + * query wifi contect. + * RETURNS + * contected or not contected wifi. + * RETURN VALUES + * TRUE : wifi contect. + * FALSE : wifi not contected. +*****************************************************************************/ +VMINT vm_wifi_is_connected(void); + + +/***************************************************************************** + * FUNCTION + * vm_get_apn_info + * DESCRIPTION + * Get Apn info after network connected + * PARAMETERS + * current_apn_info : [OUT] apn info of current connection + * RETURNS + * 0 means successful + * RETURN VALUES + * 0 : successful +*****************************************************************************/ +VMINT vm_get_apn_info(vm_apn_info_ext *current_apn_info); + +/***************************************************************************** + * FUNCTION + * vm_get_default_apn_info + * DESCRIPTION + * get current default apn infomation. + * RETURNS + * avaliable or not. + * RETURN VALUES + * 0 sucess, else failure +*****************************************************************************/ +VMINT vm_get_default_apn_info( vm_apn_info_ext *apn_info); + + +#define VM_SOC_DNS_MAX_ADDR 5 + +/* Socket return codes, negative values stand for errors */ +typedef enum +{ + VM_E_SOC_SUCCESS = 0, /* success */ + VM_E_SOC_ERROR = -1, /* error */ + VM_E_SOC_WOULDBLOCK = -2, /* not done yet */ + VM_E_SOC_LIMIT_RESOURCE = -3, /* limited resource */ + VM_E_SOC_INVALID_SOCKET = -4, /* invalid socket */ + VM_E_SOC_INVALID_ACCOUNT = -5, /* invalid account id */ + VM_E_SOC_NAMETOOLONG = -6, /* address too long */ + VM_E_SOC_ALREADY = -7, /* operation already in progress */ + VM_E_SOC_OPNOTSUPP = -8, /* operation not support */ + VM_E_SOC_CONNABORTED = -9, /* Software caused connection abort */ + VM_E_SOC_INVAL = -10, /* invalid argument */ + VM_E_SOC_PIPE = -11, /* broken pipe */ + VM_E_SOC_NOTCONN = -12, /* socket is not connected */ + VM_E_SOC_MSGSIZE = -13, /* msg is too long */ + VM_E_SOC_BEARER_FAIL = -14, /* bearer is broken */ + VM_E_SOC_CONNRESET = -15, /* TCP half-write close, i.e., FINED */ + VM_E_SOC_DHCP_ERROR = -16, /* DHCP error */ + VM_E_SOC_IP_CHANGED = -17, /* IP has changed */ + VM_E_SOC_ADDRINUSE = -18, /* address already in use */ + VM_E_SOC_CANCEL_ACT_BEARER = -19 /* cancel the activation of bearer */ +} vm_soc_error_enum; + +/* dns query result struct */ +typedef struct +{ + VMUINT address[VM_SOC_DNS_MAX_ADDR]; /* ip address */ + VMINT num; + VMINT error_cause; /* vm_ps_cause_enum */ +}vm_soc_dns_result; +/* +VMINT vm_soc_get_host_by_name(const VMCHAR * host, + VMBYTE * addr, + VMBYTE * addr_len, + VMINT (*callback)(VMBYTE * addr, VMINT addr_len)); +*/ + +/***************************************************************************** + * FUNCTION + * vm_soc_get_host_by_name + * DESCRIPTION + * this function retrieves IP addresses associated with the specified host name. + * PARAMETERS + * apn : [IN] + * host : [IN] domain to be resolved. + * result : [OUT] DNS parsed result. + * callback : [IN] point to the callback. + * RETURNS + * success if 0, else failure. + * RETURN VALUES + * VM_E_SOC_SUCCESS : Get IP address successfully, result is filled. + * VM_E_SOC_WOULDBLOCK : wait response from network, result could be gotten from callback. + * VM_E_SOC_INVAL : invalid arguments: null domain_name, etc. + * VM_E_SOC_ERROR : unspecified error + * VM_E_SOC_LIMIT_RESOURCE : socket resources not available + * VM_E_SOC_INVALID_ACCOUNT : invalid data account id + * EXAMPLE + * + * VMINT vat_vmsock_gethost_cb(vm_soc_dns_result *dns) + * { + * return FALSE; + * } + * void vat_vmsock_gethost_1(VATExt *po) + * { + * VMINT ret = -1; + * VMINT apn = VM_TCP_APN_CMNET; + * vm_soc_dns_result dns; + * if (vm_wifi_is_connected()) { + * apn = VM_TCP_APN_WIFI; + * } + * ret = vm_soc_get_host_by_name(apn, "www.mediatek.com", &dns, vat_vmsock_gethost_cb); + * + * switch (ret) { + * case VM_E_SOC_SUCCESS: + * break; + * case VM_E_SOC_WOULDBLOCK: + * break; + * default: + * break; + * } + * } + * +*****************************************************************************/ +VMINT vm_soc_get_host_by_name(VMINT apn, + const VMCHAR * host, + vm_soc_dns_result * result, + VMINT (*callback)(vm_soc_dns_result *)); + +/***************************************************************************** + * FUNCTION + * vm_soc_get_host_by_name_ex + * DESCRIPTION + * this function retrieves IP addresses associated with the specified host name. + * PARAMETERS + * apn : [IN] + * host : [IN] domain to be resolved. + * result : [OUT] DNS parsed result. + * callback : [IN] point to the callback. + * RETURNS + * handle if more than 0, else failure. + * EXAMPLE + * + * VMINT vat_vmsock_gethost_cb_ex(VMINT handle, vm_soc_dns_result *dns, void *user_data) + * { + * return FALSE; + * } + * void vat_vmsock_gethost_ex(VATExt *po) + * { + * VMINT ret = -1; + * VMINT apn = VM_TCP_APN_CMNET; + * vm_soc_dns_result dns; + * if (vm_wifi_is_connected()) { + * apn = VM_TCP_APN_WIFI; + * } + * ret = vm_soc_get_host_by_name_ex(apn, "www.mediatek.com", &dns, vat_vmsock_gethost_cb_ex, NULL); + * + * switch (ret) { + * case VM_E_SOC_SUCCESS: + * break; + * case VM_E_SOC_WOULDBLOCK: + * break; + * default: + * break; + * } + * } + * +*****************************************************************************/ +VMINT vm_soc_get_host_by_name_ex(VMINT apn, + const VMCHAR * host, + vm_soc_dns_result * result, + VMINT (*callback)(VMINT, vm_soc_dns_result *, void *), void *user_data); +/***************************************************************************** + * FUNCTION + * vm_get_encoded_dtacct_id + * DESCRIPTION + * this function retrieves data account id. + * PARAMETERS + * apn : [IN] apn id, only support VM_TCP_APN_CMNET, VM_TCP_APN_WIFI + * dtacct_id : [OUT] point to data account id. + * RETURNS + * success if 0, else failure. + * RETURN VALUES + * VM_E_SOC_SUCCESS : Get IP address successfully, result is filled. + * VM_E_SOC_INVAL : invalid arguments: null domain_name, etc. + * VM_E_SOC_INVALID_ACCOUNT : invalid data account id + * EXAMPLE + * + * void vat_vmsock_dtacct_1(void) + * { + * VMINT ret = -1; + * VMINT apn = VM_TCP_APN_CMNET; + * VMUINT dtacct_id; + * + * if (vm_wifi_is_connected()) { + * apn = VM_TCP_APN_WIFI; + * } + * + * ret = vm_get_encoded_dtacct_id(apn, &dtacct_id); + * if (ret == VM_E_SOC_SUCCESS) { + * } + * else { + * } + * } + * +*****************************************************************************/ +VMINT vm_get_encoded_dtacct_id(VMINT apn, VMUINT * dtacct_id); + + + + + + +/* MAC address length */ +#define VM_WLAN_LOC_MAC_ADDR_LEN 6 +/* Maximum ap list number */ +#define VM_WLAN_LOC_MAX_AP_LIST_NUM 30 + +/* Wlan scan error */ +typedef enum +{ + VM_WLAN_LOC_ERR_LOGICAL = -7, /* wlan is inactive state */ + VM_WLAN_LOC_ERR_INTERNAL, /* Internal error */ + VM_WLAN_LOC_ERR_BUSY, /* Can't create a new scan job */ + VM_WLAN_LOC_ERR_BAD_PARAM, /* bad parameter */ + VM_WLAN_LOC_ERR_NO_RESOURCE, /* allocate resource failed */ + VM_WLAN_LOC_ERR_NOT_SUPPORT, /* project doesn't support wlan */ + VM_WLAN_LOC_ERR_NO_AUTHORIZATION, + VM_WLAN_LOC_ERR_SUCCESS = 0 +}vm_wlan_loc_error_t; + +/* Wlan scan result */ +typedef enum +{ + VM_WLAN_LOC_SCAN_RESULT_SUCCESS = 0, /* WLAN scan success */ + VM_WLAN_LOC_SCAN_RESULT_FAILED, /* WLAN scan failed */ + VM_WLAN_LOC_SCAN_RESULT_ABORTED, /* WLAN scan service is aborted */ + VM_WLAN_LOC_SCAN_RESULT_TOTAL +} vm_wlan_loc_scan_result_enum; + +/* wlan connected information struct */ +typedef struct +{ + VMUINT8 bssid[VM_WLAN_LOC_MAC_ADDR_LEN]; /* MAC address */ + VMINT rssi; /* rssi information */ +}vm_wlan_loc_supc_abm_bss_info_struct; + +typedef struct +{ + const vm_wlan_loc_supc_abm_bss_info_struct * ap_list[VM_WLAN_LOC_MAX_AP_LIST_NUM]; /* bss info array */ + VMINT handle; + vm_wlan_loc_scan_result_enum result; /* scan result enum */ + VMUINT8 ap_list_num;/* total num of searched ap list */ +}vm_wlan_loc_data_t; + + +/***************************************************************************** + * FUNCTION + * vm_wlan_loc_search + * DESCRIPTION + * The function is used to scan the AP list for applications. + * PARAMETERS + * callback : [IN] scan result callback notify function for APP + * user_data : [IN] application piggyback data + * RETURNS + * return value >= 0 : search handle id created successfully. + * return value < 0 : failure + * RETURN VALUES + * VM_WLAN_LOC_ERR_BUSY : busy, could retry later + * VM_WLAN_LOC_ERR_NO_RESOURCE : no avalible resource + * VM_WLAN_LOC_ERR_NOT_SUPPORT : platform dose not support + * EXAMPLE + * + * static VMINT g_wlan_hd; + * void vat_vmsock_wlan_search_cb(vm_wlan_loc_data_t *wlan_data, void *user_data) + * { + * switch (wlan_data->result) { + * case VM_WLAN_LOC_SCAN_RESULT_SUCCESS: + * { + * vm_wlan_loc_search_abort(g_wlan_hd); + * break; + * } + * case VM_WLAN_LOC_SCAN_RESULT_FAILED: + * vm_wlan_loc_search_abort(g_wlan_hd); + * break; + * case VM_WLAN_LOC_SCAN_RESULT_ABORTED: + * g_wlan_hd = -1; + * break; + * default: + * break; + * } + * } + * void vat_vmsock_wlan_search_1(void) + * { + * VMINT ret = -1; + * + * ret = vm_wlan_loc_search(vat_vmsock_wlan_search_cb, NULL); + * if (VM_WLAN_LOC_ERR_NOT_SUPPORT != ret && 0 <= ret) { + * g_wlan_hd = ret; + * } + * } + * +*****************************************************************************/ +VMINT vm_wlan_loc_search(void (*callback)(vm_wlan_loc_data_t * data, void * user_data), void * user_data); + +/***************************************************************************** + * FUNCTION + * vm_wlan_loc_search_abort + * DESCRIPTION + * The function is used to abort the scanning AP list process for applications. + * PARAMETERS + * handle : [IN] created handle id from calling vm_wlan_loc_search + * RETURNS + * success if 0, else failure. + * RETURN VALUES + * VM_WLAN_LOC_ERR_BAD_PARAM : invalid input param + * VM_WLAN_LOC_ERR_NO_RESOURCE : no avalible resource + * VM_WLAN_LOC_ERR_NOT_SUPPORT : platform dose not support + * EXAMPLE + * + * static VMINT g_wlan_hd; + * void vat_vmsock_wlan_search_cb(vm_wlan_loc_data_t *wlan_data, void *user_data) + * { + * switch (wlan_data->result) { + * case VM_WLAN_LOC_SCAN_RESULT_SUCCESS: + * { + * vm_wlan_loc_search_abort(g_wlan_hd); + * break; + * } + * case VM_WLAN_LOC_SCAN_RESULT_FAILED: + * vm_wlan_loc_search_abort(g_wlan_hd); + * break; + * case VM_WLAN_LOC_SCAN_RESULT_ABORTED: + * g_wlan_hd = -1; + * break; + * default: + * break; + * } + * } + * void vat_vmsock_wlan_search_1(void) + * { + * VMINT ret = -1; + * + * ret = vm_wlan_loc_search(vat_vmsock_wlan_search_cb, NULL); + * if (VM_WLAN_LOC_ERR_NOT_SUPPORT != ret && 0 <= ret) { + * g_wlan_hd = ret; + * } + * } + * + *****************************************************************************/ +VMINT vm_wlan_loc_search_abort(VMINT handle); + +/***************************************************************************** + * FUNCTION + * vm_wlan_loc_get_connected_info + * DESCRIPTION + * The function get info form ap which connected already + * PARAMETERS + * rssi : [OUT] rssi + * bssid : [OUT] bssid + * RETURNS + * success if 0, else failure. + * RETURN VALUES + * VM_WLAN_LOC_ERR_BAD_PARAM : invalid input param + * VM_WLAN_LOC_ERR_NOT_SUPPORT : platform dose not support + * VM_WLAN_LOC_ERR_LOGICAL : maybe not connected + * EXAMPLE + * + * void hl_wlan_get_conn_info(void) + * { + * vm_wlan_loc_supc_abm_bss_info_struct info; + * vm_wlan_loc_get_connected_info(&info); + * } + * +*****************************************************************************/ +VMINT vm_wlan_loc_get_connected_info(vm_wlan_loc_supc_abm_bss_info_struct * info); + +/* Preload app query and download states */ +typedef enum +{ + E_PRELOAD_QUERYING, /* Querying information */ + E_PRELOAD_AVAILABLE_UPDATE, /* There is available update */ + E_PRELOAD_NO_UPDATE, /* No update */ + E_PRELOAD_CONNECTING, /* Connecting network */ + E_PRELOAD_CONNECTED, /* Network connected */ + E_PRELOAD_DOWNLOADING, /* Downloading */ + E_PRELOAD_DOWNLOADED, /* App downloaded */ + E_PRELOAD_HOST_NOT_FOUND, /* host can not be found */ + E_PRELOAD_PIPE_CLOSED, /* Pipe is closed */ + E_PRELOAD_PIPE_BROKEN, /* Pipe is broken */ + E_PRELOAD_FAILURE, /* Other failed */ + E_PRELOAD_ERR_PATH, /* download destination path error */ + E_PRELOAD_ABORT, /* Action is abort */ +}vm_preload_state_e; + +/* Preload query information */ +typedef struct +{ + VMUINT app_id; /* app id */ +// VMCHAR ver[8]; +// VMCHAR imsi[32]; +// VMCHAR imei[32]; + VMCHAR * ua; /* User-Agent */ + /* + VMCHAR sc[16]; + VMBYTE skb; + VMBYTE stch; + VMBYTE sgs; + VMBYTE scs; + VMINT w; + VMINT h; + */ +}vm_preload_query_info_t; + +/* Common info */ +typedef struct +{ + vm_preload_state_e state; /* query or download states */ + void * user_data; /* user data */ +}vm_common_t; + + +/* +state in below +E_PRELOAD_DOWNLOADING, +E_PRELOAD_DOWNLOADED, +*/ +/* received data information */ +typedef struct +{ + vm_common_t head; /* Common info */ + VMINT received; /* received data size */ + VMINT total; /* Total data size */ +}vm_preload_recv_data_t; + +/***************************************************************************** + * FUNCTION + * vm_preload_query + * DESCRIPTION + * Query information of preload app + * PARAMETERS + * apn [IN] apn id + * url [IN] server url + * port [IN] server port + * info [IN] query information + * callback [IN] query result callback + * user_data [IN] user data + * RETURNS + * query handle if success. + * EXAMPLE + * + * static VMINT preload_handle; + * void callback(VMINT hdl,void * para) + * { + * vm_common_t * data = (vm_common_t *)para; + * + * if (E_PRELOAD_AVAILABLE_UPDATE == data->state) + * { + * vm_preload_download(hdl, get_app_tmp_path(), callback, NULL); + * } + * if (E_PRELOAD_DOWNLOADING == data->state) + * { + * vm_preload_recv_data_t * info = (vm_preload_recv_data_t *)para; + * vm_trace("PRELOAD [%d/%d]", info->received, info->total); + * } + * return; + * } + * void hl_preload(void) + * { + * static VMINT ret = 0; + * vm_preload_query_info_t info; + * + * info.app_id = 0x0100a4; + * info.ua = (VMCHAR*)vm_malloc(32); + * sprintf(info.ua, "app_id=%d&ver=%s", 0x0100a4, "0.0.1"); + * ret = vm_preload_query(VM_TCP_APN_CMNET, + * (const VMCHAR *)"http://www.mediatek.com/games/AppsUpdate", + * 80, + * (const vm_preload_query_info_t *)&info, + * callback, + * (void *)0x12341234); + * if (ret > 0) + * preload_handle = ret; + * } + * +*****************************************************************************/ +VMINT vm_preload_query(VMINT apn, + const VMCHAR * url, + VMINT port, + const vm_preload_query_info_t * info, + void (*callback)(VMINT hdl, void * para), + void * user_data); +/***************************************************************************** + * FUNCTION + * vm_preload_download_ex + * DESCRIPTION + * Download preload application + * PARAMETERS + * hdl [IN] preload query handle + * data [IN] destination path + * bDLA [IN] use download agent or not + * callback [IN] download state callback + * user_data [IN] user data + * RETURNS + * return 0 if success, else return error code. + * EXAMPLE + * + * static VMINT preload_handle; + * void callback(VMINT hdl,void * para) + * { + * vm_common_t * data = (vm_common_t *)para; + * + * if (E_PRELOAD_AVAILABLE_UPDATE == data->state) + * { + * vm_preload_download_ex(hdl, get_app_tmp_path(), FALSE, callback, NULL); + * } + * if (E_PRELOAD_DOWNLOADING == data->state) + * { + * vm_preload_recv_data_t * info = (vm_preload_recv_data_t *)para; + * vm_trace("PRELOAD [%d/%d]", info->received, info->total); + * } + * return; + * } + * void hl_preload(void) + * { + * static VMINT ret = 0; + * vm_preload_query_info_t info; + * + * info.app_id = 0x0100a4; + * info.ua = (VMCHAR*)vm_malloc(32); + * sprintf(info.ua, "app_id=%d&ver=%s", 0x0100a4, "0.0.1"); + * ret = vm_preload_query(VM_TCP_APN_CMNET, + * (const VMCHAR *)"http://www.mediatek.com/games/AppsUpdate", + * 80, + * (const vm_preload_query_info_t *)&info, + * callback, + * (void *)0x12341234); + * if (ret > 0) + * preload_handle = ret; + * } + * +*****************************************************************************/ +VMINT vm_preload_download_ex(VMINT hdl, const VMWCHAR * data, VMBOOL bDLA,void (*callback)(VMINT hdl, void * para), void * user_data); + +/***************************************************************************** + * FUNCTION + * vm_preload_download + * DESCRIPTION + * Download preload application + * PARAMETERS + * hdl [IN] preload query handle + * data [IN] destination path + * callback [IN] download state callback + * user_data [IN] user data + * RETURNS + * return 0 if success, else return error code. + * EXAMPLE + * + * static VMINT preload_handle; + * void callback(VMINT hdl,void * para) + * { + * vm_common_t * data = (vm_common_t *)para; + * + * if (E_PRELOAD_AVAILABLE_UPDATE == data->state) + * { + * vm_preload_download(hdl, get_app_tmp_path(), callback, NULL); + * } + * if (E_PRELOAD_DOWNLOADING == data->state) + * { + * vm_preload_recv_data_t * info = (vm_preload_recv_data_t *)para; + * vm_trace("PRELOAD [%d/%d]", info->received, info->total); + * } + * return; + * } + * void hl_preload(void) + * { + * static VMINT ret = 0; + * vm_preload_query_info_t info; + * + * info.app_id = 0x0100a4; + * info.ua = (VMCHAR*)vm_malloc(32); + * sprintf(info.ua, "app_id=%d&ver=%s", 0x0100a4, "0.0.1"); + * ret = vm_preload_query(VM_TCP_APN_CMNET, + * (const VMCHAR *)"http://www.mediatek.com/games/AppsUpdate", + * 80, + * (const vm_preload_query_info_t *)&info, + * callback, + * (void *)0x12341234); + * if (ret > 0) + * preload_handle = ret; + * } + * +*****************************************************************************/ +VMINT vm_preload_download(VMINT hdl, const VMWCHAR * data, void (*callback)(VMINT hdl, void * para), void * user_data); + +/***************************************************************************** + * FUNCTION + * vm_preload_cancel + * DESCRIPTION + * Cancel preload query + * PARAMETERS + * hdl [IN] preload query handle + * RETURNS + * return 0 if success, else return error code. + * EXAMPLE + * + * static VMINT preload_handle; + * void callback(VMINT hdl,void * para) + * { + * vm_common_t * data = (vm_common_t *)para; + * + * if (E_PRELOAD_AVAILABLE_UPDATE == data->state) + * { + * vm_preload_download(hdl, get_app_tmp_path(), callback, NULL); + * } + * if (E_PRELOAD_DOWNLOADING == data->state) + * { + * vm_preload_recv_data_t * info = (vm_preload_recv_data_t *)para; + * vm_trace("PRELOAD [%d/%d]", info->received, info->total); + * } + * return; + * } + * void hl_preload(void) + * { + * static VMINT ret = 0; + * vm_preload_query_info_t info; + * + * info.app_id = 0x0100a4; + * info.ua = (VMCHAR*)vm_malloc(32); + * sprintf(info.ua, "app_id=%d&ver=%s", 0x0100a4, "0.0.1"); + * ret = vm_preload_query(VM_TCP_APN_CMNET, + * (const VMCHAR *)"http://www.mediatek.com/games/AppsUpdate", + * 80, + * (const vm_preload_query_info_t *)&info, + * callback, + * (void *)0x12341234); + * if (ret > 0) + * preload_handle = ret; + * vm_preload_cancel(preload_handle); + * } + * +*****************************************************************************/ +VMINT vm_preload_cancel(VMINT hdl); + +/* network enum */ +typedef enum +{ + VM_NETWORK_NONE = 0, /* No bit-wise operation for none case */ + VM_GSM = 0x0100, /* GSM protocol */ + VM_WCDMA = 0x0200, /* WCDMA protocol */ + VM_NETWORK_END_OF_ENUM /* reserved */ +}vm_network_enum_t; + +/***************************************************************************** + * FUNCTION + * vm_srv_nw_info_get_protocol + * DESCRIPTION + * Get the protocol of current network. + * PARAMETERS + * sim_card : [IN] SIM index, eg: 0x1-SIM1, 0x2-SIM2 + * RETURNS + * vm_network_enum_t + * RETURN VALUES + * VM_GSM, VM_WCDMA, failure if less than 0 + * EXAMPLE + * + * void hl_nw_sample_1(void) + * { + * VMINT nw; + * nw = vm_srv_nw_info_get_protocol(0x1); + * } + * + *****************************************************************************/ +VMINT vm_srv_nw_info_get_protocol(VMINT sim_card); + +/* network capability enum */ +typedef enum +{ + VM_NETWORK_CAPABILITY_NONE = 0, + VM_GPRS = 0x0010, /* GPRS */ + VM_EDGE = 0x0020, /* EDGE */ + VM_HSDPA = 0x0040, /* HSDPA */ + VM_HSUPA = 0x0080, /* HSUPA */ + VM_NETWORK_CAPABILITY_END_OF_ENUM +} vm_network_capability_enum; + +/***************************************************************************** + * FUNCTION + * vm_srv_nw_info_get_protocol + * DESCRIPTION + * Query if current channel supports the capability. + * PARAMETERS + * sim : [IN] Which protocol layer of SIM + * type : [IN] Protocol capability. refer to vm_network_capability_enum + * RETURNS + * -1: no authorization + * -2: invalid param + * not support if 0, else support. + * EXAMPLE + * + * void hl_nw_sample_2(void) + * { + * VMINT nw; + * nw = vm_srv_nw_info_channel_supports(0x1, VM_HSDPA); + * } + * + *****************************************************************************/ +VMINT vm_srv_nw_info_channel_supports(VMINT sim_card, vm_network_capability_enum type); + + +typedef enum +{ + VM_NW_INFO_SA_SEARCHING, /* Searching network */ + VM_NW_INFO_SA_NO_SERVICE, /* No service */ + VM_NW_INFO_SA_LIMITED_SERVICE, /* Limited service, emergency call only */ + VM_NW_INFO_SA_FULL_SERVICE, /* Full service */ + + VM_NW_INFO_SA_END_OF_ENUM +} vm_nw_info_service_availability_enum_t; +/***************************************************************************** + * FUNCTION + * vm_srv_nw_info_get_service_availability + * DESCRIPTION + * Get the service availability status. + * If the network is disabled, the return value is invalid. + * PARAMETERS + * sim_card : [IN] SIM index, eg: 0x1-SIM1, 0x2-SIM2 + * RETURNS + * vm_nw_info_service_availability_enum_t + * RETURN VALUES + * VM_NW_INFO_SA_SEARCHING, etc, failure if less than 0 + * EXAMPLE + * + * void hl_nw_sample_1(void) + * { + * VMINT nw; + * nw = vm_nw_info_get_service_availability(0x1); + * } + * + *****************************************************************************/ +VMINT vm_srv_nw_info_get_service_availability(VMINT sim_card); + + +/***************************************************************************** + * FUNCTION + * vm_dtacct_set + * DESCRIPTION + * set the current data account info that got from vm_dtacct_select. if app need to do connection + * use this data account of the sim_id, VM_APN_USER_DEFINE should be passed as apn param. eg, + * vm_tcp_connect(xx, xxx, VM_APN_USER_DEFINE, xxxx); + * PARAMETERS + * sim_id : [IN] SIM index, eg: 0-SIM1, 1-SIM2, ... + * dtacct : [IN] account id + * RETURN VALUES + * success if 0, else failure. + * EXAMPLE + * + * VMINT hl_dtacct_cb(VMUINT32 dtacct) + * { + * vm_dtacct_set(0, dtacct); + * } + * void hl_dtacct_sample(void) + * { + * vm_dtacct_select(0, hl_dtacct_cb); + * } + * + *****************************************************************************/ +VMINT vm_dtacct_set(VMINT sim_id, VMUINT32 dtacct); + +/***************************************************************************** + * FUNCTION + * vm_dtacct_select + * DESCRIPTION + * show the current available data account list of the required sim_id. call back app when user selected + * one of them. app may record this data account value, for the vm_dtacct_set if necessary. + * PARAMETERS + * sim_id : [IN] SIM index, eg: 0-SIM1, 1-SIM2, ... + * dtacct : [IN] account id + * RETURN VALUES + * success if 0, else failure. + * EXAMPLE + * + * VMINT hl_dtacct_cb(VMUINT32 dtacct) + * { + * vm_dtacct_set(0, dtacct); + * } + * void hl_dtacct_sample(void) + * { + * vm_dtacct_select(0, hl_dtacct_cb); + * } + * + *****************************************************************************/ +VMINT vm_dtacct_select(VMINT sim_id, VMINT (*callback)(VMUINT32 dtacct)); + + + +typedef enum +{ + VM_RES_TYPE_TCP, + VM_RES_TYPE_UDP, + VM_RES_TYPE_HTTP, + VM_RES_TYPE_HTTPS +}vm_res_type_t; + +/***************************************************************************** + * FUNCTION + * vm_cbm_hold_bearer + * DESCRIPTION + * hold the bearer. + * PARAMETERS + * type : [IN] vm_res_type_t + * hdl : [IN] TCP : hdl = vm_tcp_connect + * UDP : hdl = vm_udp_create + * HTTP : hdl = vm_http_get_current_handle + * hdl = vm_http_fetch_handle + * HTTPS : channel id + * RETURN VALUES + * success if 0, failure if less than 0 + * EXAMPLE + * + * static VMINT g_tcp_hd; + * void tcp_cb(VMINT handle, VMINT event) + * { + * VMINT ret = 0; + * if (VM_TCP_EVT_CONNECTED == event || VM_TCP_EVT_CAN_WRITE == event) + * { + * ret = vm_cbm_hold_bearer(VM_RES_TYPE_TCP, handle); + * ret = vm_tcp_write(handle, "GET / HTTP/1.1\r\nHOST:www.mediate.com:80\r\n\r\n", strlen("GET / HTTP/1.1\r\nHOST:www.mediate.com:80\r\n\r\n")); + * } + * if (VM_TCP_EVT_CAN_READ == event) + * { + * VMCHAR buf[2048] = {0}; + * ret = vm_tcp_read(handle, buf, 2048); + * vm_tcp_close(handle); + * } + * } + * void handle_keyevt(VMINT event, VMINT keycode) { + * { + * if (VM_KEY_EVENT_UP == event) + * { + * if (VM_KEY_VOL_UP == keycode || + * VM_KEY_UP == keycode) + * { + * g_tcp_hd = vm_tcp_connect("http://www.mediatek.com", 80, VM_TCP_APN_CMNET, tcp_cb); + * } + * if (VM_KEY_VOL_DOWN == keycode || + * VM_KEY_DOWN == keycode) + * { + * vm_cbm_release_bearer(); + * } + * } + * } + * + *****************************************************************************/ +VMINT vm_cbm_hold_bearer(vm_res_type_t type, VMINT hdl); + +/***************************************************************************** + * FUNCTION + * vm_cbm_release_bearer + * DESCRIPTION + * hold the bearer. + * RETURN VALUES + * success if 0, failure if less than 0 + * EXAMPLE + * + * static VMINT g_tcp_hd; + * void tcp_cb(VMINT handle, VMINT event) + * { + * VMINT ret = 0; + * if (VM_TCP_EVT_CONNECTED == event || VM_TCP_EVT_CAN_WRITE == event) + * { + * ret = vm_cbm_hold_bearer(VM_RES_TYPE_TCP, handle); + * ret = vm_tcp_write(handle, "GET / HTTP/1.1\r\nHOST:www.mediate.com:80\r\n\r\n", strlen("GET / HTTP/1.1\r\nHOST:www.mediate.com:80\r\n\r\n")); + * } + * if (VM_TCP_EVT_CAN_READ == event) + * { + * VMCHAR buf[2048] = {0}; + * ret = vm_tcp_read(handle, buf, 2048); + * vm_tcp_close(handle); + * } + * } + * void handle_keyevt(VMINT event, VMINT keycode) { + * { + * if (VM_KEY_EVENT_UP == event) + * { + * if (VM_KEY_VOL_UP == keycode || + * VM_KEY_UP == keycode) + * { + * g_tcp_hd = vm_tcp_connect("http://www.mediatek.com", 80, VM_TCP_APN_CMNET, tcp_cb); + * } + * if (VM_KEY_VOL_DOWN == keycode || + * VM_KEY_DOWN == keycode) + * { + * vm_cbm_release_bearer(); + * } + * } + * } + * + *****************************************************************************/ +VMINT vm_cbm_release_bearer(void); + +/* Data account profile maximum size */ +#define VM_SRV_DTCNT_PROF_MAX (32) +/* Data account address maximum size */ +#define VM_SRV_DTCNT_IP_MAX (64) + +/* Data account information */ +typedef struct +{ + VMUINT8 APN[VM_SRV_DTCNT_PROF_MAX]; /* account name */ + VMUINT8 PrimaryAddr[VM_SRV_DTCNT_IP_MAX]; /* Primary DNS IP Address (ASCII) */ + VMUINT8 use_proxy; /* use proxy flag */ + VMUINT8 UserName[VM_SRV_DTCNT_PROF_MAX]; /* User string of a Data Account (ASCII) */ + VMUINT8 Passwd[VM_SRV_DTCNT_PROF_MAX]; /* Password for a Data Account (ASCII) */ + VMUINT8 px_addr[VM_SRV_DTCNT_IP_MAX]; /* proxy addr string IP format (ASCII)*/ + VMUINT16 px_port; /* proxy port */ +}vm_dtcnt_info_t; + +/***************************************************************************** + * FUNCTION + * vm_set_cust_apn_info + * DESCRIPTION + * set customized apn info. if successful, it will output data account(*dtacct) which value could be + * passed to 'vm_dtacct_set'. VM_APN_USER_DEFINE should be the param when do operation of network. + * PARAMETERS + * info : [IN] refer to vm_dtcnt_info_t + * dtacct : [OUT] data account id + * RETURN VALUES + * success if 0, else failure. + * EXAMPLE + * + * static VMINT g_hdl; + * void callback(VMINT handle, VMINT event) + * { + * vm_trace("cnt cb[%d][%d]", handle, event); + * } + * void handle_keyevt(VMINT event, VMINT keycode) { + * vm_dtcnt_info_t info = {0}; + * if (VM_KEY_EVENT_UP == event) + * { + * if (VM_KEY_UP == keycode || + * VM_KEY_VOL_UP == keycode) + * { + * VMUINT32 dtacct = 0; + * VMINT ret = 0; + * strcpy(info.APN, "cust apn"); + * strcpy(info.px_addr, "10.0.0.172"); + * info.px_port = 80; + * info.use_proxy = 1; + * ret = vm_set_cust_apn_info(&info, &dtacct); + * ret = vm_dtacct_set(0, dtacct); + * ret = vm_get_cust_apn_info(&info); + * if (0 != strcmp(info.px_addr, "0.0.0.0") && 0 != info.px_port) + * { + * ret = vm_tcp_connect((const char*)info.px_addr, info.px_port, 6, callback); + * if (ret >= 0) + * { + * g_hdl = ret; + * } + * } + * else + * { + * ret = vm_tcp_connect((const char*)"www.mediatek.com", 80, 6, callback); + * if (ret >= 0) + * { + * g_hdl = ret; + * } + * } + * ret = 0; + * } + * if (VM_KEY_DOWN == keycode || + * VM_KEY_VOL_DOWN == keycode) + * { + * VMINT ret = 0; + * ret = vm_get_cust_apn_info(&info); + * vm_tcp_close(g_hdl); + * ret = 0; + * } + * } + * } + * + *****************************************************************************/ +VMINT vm_set_cust_apn_info(const vm_dtcnt_info_t * info, VMUINT32 * dtacct); + +/***************************************************************************** + * FUNCTION + * vm_get_cust_apn_info + * DESCRIPTION + * get customized apn info. + * PARAMETERS + * info : [IN] refer to vm_dtcnt_info_t + * RETURN VALUES + * success if 0, else failure. + * EXAMPLE + * + * static VMINT g_hdl; + * void callback(VMINT handle, VMINT event) + * { + * vm_trace("cnt cb[%d][%d]", handle, event); + * } + * void handle_keyevt(VMINT event, VMINT keycode) { + * vm_dtcnt_info_t info = {0}; + * if (VM_KEY_EVENT_UP == event) + * { + * if (VM_KEY_UP == keycode || + * VM_KEY_VOL_UP == keycode) + * { + * VMUINT32 dtacct = 0; + * VMINT ret = 0; + * strcpy(info.APN, "cust apn"); + * strcpy(info.px_addr, "10.0.0.172"); + * info.px_port = 80; + * info.use_proxy = 1; + * ret = vm_set_cust_apn_info(&info, &dtacct); + * ret = vm_dtacct_set(0, dtacct); + * ret = vm_get_cust_apn_info(&info); + * if (0 != strcmp(info.px_addr, "0.0.0.0") && 0 != info.px_port) + * { + * ret = vm_tcp_connect((const char*)info.px_addr, info.px_port, 6, callback); + * if (ret >= 0) + * { + * g_hdl = ret; + * } + * } + * else + * { + * ret = vm_tcp_connect((const char*)"www.mediatek.com", 80, 6, callback); + * if (ret >= 0) + * { + * g_hdl = ret; + * } + * } + * ret = 0; + * } + * if (VM_KEY_DOWN == keycode || + * VM_KEY_VOL_DOWN == keycode) + * { + * VMINT ret = 0; + * ret = vm_get_cust_apn_info(&info); + * vm_tcp_close(g_hdl); + * ret = 0; + * } + * } + * } + * + *****************************************************************************/ +VMINT vm_get_cust_apn_info(vm_dtcnt_info_t * info); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_perfer + * DESCRIPTION + * disable wlan perfer. + * PARAMETERS + * disable : [IN] disable if no-zero, or else is default. + * RETURN VALUES + * success if 0, else failure. + * EXAMPLE + * + * static void tst_cb(VMINT i, VMINT j) + * { + * } + * void handle_keyevt(VMINT event, VMINT keycode) { + * + * VMINT ret = 0; + * VMUINT id; + * if (VM_KEY_EVENT_UP == event && + * VM_KEY_VOL_UP == keycode) + * { + * ret = vm_wlan_perfer(1); + * vm_get_encoded_dtacct_id(VM_TCP_APN_CMNET, &id); + * vm_trace("prefer 1[%d][0x%x]", ret, id); + * } + * if (VM_KEY_EVENT_UP == event && + * VM_KEY_VOL_UP == keycode) + * { + * ret = vm_wlan_perfer(0); + * vm_get_encoded_dtacct_id(VM_TCP_APN_CMNET, &id); + * vm_trace("prefer 0[%d][0x%x]", ret, id); + * } + * ret = vm_tcp_connect((VMCHAR*)"www.mediatek.com", 80, 1, tst_cb); + * vm_trace("connect [%d]", ret); + * } + * + *****************************************************************************/ +VMINT vm_wlan_perfer(VMINT disable); + +#ifdef __cplusplus +} +#endif + +#endif /* VMCONN_SDK_H */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmcontact.h b/hardware/arduino/mtk/system/libmtk/include/vmcontact.h new file mode 100644 index 00000000..4786fb08 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmcontact.h @@ -0,0 +1,402 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMPHONEBOOK_SDK_H_ +#define VMPHONEBOOK_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/* The maximum length of searching pattern string */ +#define VM_PHB_MAX_SEARCH_LENGTH 60 + +/* Returned basic error codes */ +typedef enum +{ + VM_PHB_REQ_NOT_READY = -2, /* Phonebook is not ready */ + VM_PHB_REQ_ERROR, /* Operation unsuccessful */ + VM_PHB_REQ_NO_ERROR /* Operation successful */ +} vm_phb_req_error_enum; + +/* Error codes */ +typedef enum +{ + VM_PHB_NAME_MODIFIED = 1, /* Name has been truncated due to length exceed SIM MAX name length. */ + VM_PHB_NO_ERROR = 0, /* Operation successful */ + VM_PHB_ERROR = -1, /* General failure */ + VM_PHB_NOT_READY = -2, /* Phonebook is not ready */ + VM_PHB_NUM_NOT_READY = -3, /* Search operation is not ready */ + VM_PHB_NOT_SUPPORT = -4, /* Phonebook not supported */ + VM_PHB_NOT_FOUND = -5, /* No contact found */ + VM_PHB_DATAMGR_BUSY = -6, /* Phonebook is busy */ + VM_PHB_STORAGE_FULL = -7, /* Storage is full */ + VM_PHB_NO_SIM_CARD = -8, /* No SIM card */ + VM_PHB_ADN_FORBID = -9, /* Failed to visit phonebook in SIM card */ + VM_PHB_OUT_OF_INDEX = -10, /* Invalid index */ + VM_PHB_NUMBER_TOO_LONG = -11, /* Invalid number */ + VM_PHB_BIRTHDAY_ERROR = -12 /* Invalid birthday format */ +} vm_phb_error_enum; + +/* Storage location of phonebook */ +typedef enum +{ + VM_PHB_STORAGE_LOC_SIM = 1, /* SIM card 1 */ + VM_PHB_STORAGE_LOC_PHONE, /* Phone */ + VM_PHB_STORAGE_LOC_SIM2, /* SIM card 2 */ + VM_PHB_STORAGE_LOC_SIM3, /* SIM card 3 */ + VM_PHB_STORAGE_LOC_SIM4, /* SIM card 4 */ + VM_PHB_STORAGE_LOC_BOTH /* Both SIM card and Phone */ +} vm_phb_storage_loc_enum; + +/* Search type */ +typedef enum +{ + VM_PHB_SEARCH_TYPE_NAME, /* Name */ + VM_PHB_SEARCH_TYPE_NUM /* Number */ +} vm_phb_search_type_enum; + +/* Phonebook contact position struct */ +typedef struct +{ + VMUSHORT index; /* Index: 1 - MAX index. It will not change the position of other contact when deleting a contact. */ + vm_phb_storage_loc_enum storage; /* Storage location of phonebook */ +} vm_phb_contact_pos_struct; + +#define VM_MAX_PHB_NAME_LENGTH 30 /* Max length of name */ +#define VM_MAX_PHB_NUMBER_LENGTH 40 /* Max length of number */ +#define VM_MAX_PHB_EMAIL_LENGTH 60 /* Max length of email */ +#define VM_MAX_PHB_COMPANY_LENGTH 20 /* Max length of company */ +#define VM_MAX_PHB_TITLE_LENGTH 20 /* Max length of title */ +#define VM_MAX_PHB_URL_LENGTH 128 /* Max length of url */ +#define VM_MAX_PHB_ADDRESS_LENGTH 25 /* Max length of address */ +#define VM_MAX_PHB_NOTE_LENGTH 30 /* Max length of note */ +#define VM_MAX_PHB_GROUP_NAME_LENGTH 20 /* Max length of group name */ + + /* Phonebook contact info struct, all the string are encoded by UCS2. */ +typedef struct +{ + vm_phb_contact_pos_struct pos; /* Contact position */ + VMUWCHAR name[VM_MAX_PHB_NAME_LENGTH + 1]; /* Contact name field (UCS2) */ + VMUWCHAR number[VM_MAX_PHB_NUMBER_LENGTH + 1 + 1]; /* Contact mobile number field (UCS2) */ + VMUWCHAR home_number[VM_MAX_PHB_NUMBER_LENGTH + 1 + 1]; /* Contact home number field (UCS2) */ + VMUWCHAR office_number[VM_MAX_PHB_NUMBER_LENGTH + 1 + 1]; /* Contact office number field (UCS2) */ + VMUWCHAR fax_number[VM_MAX_PHB_NUMBER_LENGTH + 1 + 1]; /* Contact fax number field (UCS2) */ + VMUWCHAR email_address[VM_MAX_PHB_EMAIL_LENGTH + 1]; /* Contact email field (UCS2) */ + VMUWCHAR email_address2[VM_MAX_PHB_EMAIL_LENGTH + 1]; /* Contact email2 field (UCS2) */ + VMUWCHAR company_name[VM_MAX_PHB_COMPANY_LENGTH + 1]; /* Contact company name field (UCS2) */ + VMUCHAR birth_day; /* Contact birthday-day field */ + VMUCHAR birth_mon; /* Contact birthday-month field */ + VMUINT16 birth_year; /* contact birthday-year field */ + VMUWCHAR title[VM_MAX_PHB_TITLE_LENGTH + 1]; /* Contact title field (UCS2) */ + VMUWCHAR url[VM_MAX_PHB_URL_LENGTH + 1]; /* Contact url field (UCS2) */ + VMUWCHAR adr_pobox[VM_MAX_PHB_ADDRESS_LENGTH + 1]; /* Contact address-pobox field (UCS2) */ + VMUWCHAR adr_extension[VM_MAX_PHB_ADDRESS_LENGTH + 1]; /* Contact address-extention field (UCS2) */ + VMUWCHAR adr_street[VM_MAX_PHB_ADDRESS_LENGTH + 1]; /* Contact address-street field (UCS2) */ + VMUWCHAR adr_city[VM_MAX_PHB_ADDRESS_LENGTH + 1]; /* Contact address-city field (UCS2) */ + VMUWCHAR adr_state[VM_MAX_PHB_ADDRESS_LENGTH + 1]; /* Contact address-state field (UCS2) */ + VMUWCHAR adr_postal_code[VM_MAX_PHB_ADDRESS_LENGTH + 1]; /* Contact address-postal code field (UCS2) */ + VMUWCHAR adr_country[VM_MAX_PHB_ADDRESS_LENGTH + 1]; /* Contact address-country field (UCS2) */ + VMUWCHAR note[VM_MAX_PHB_NOTE_LENGTH + 1]; /* Contact note field (UCS2) */ + VMUINT group_mask; /* Contact group field(bitmask), a contact can have multiple group id. (group_mask = 1<< group_id1 + 1<< group_id2 + ... . If group_mask=1, then group_id=0; if group_mask=3, then group_id=0 group_id=1) */ +} vm_phb_contact_struct; + +/* Phonebook group struct */ +typedef struct +{ + VMUINT group_id; /* Group id */ + VMWCHAR group_name[VM_MAX_PHB_GROUP_NAME_LENGTH + 1]; /* Group name */ +} vm_phb_group_struct; + +/***************************************************************************** + * + * + * FUNCTION + * vm_phb_callback_type + * DESCRIPTION + * Callback function type for phonebook operation. + * PARAMETERS + * result : [IN] Operation result, refer to vm_phb_error_enum. + * contact_ptr : [IN] Pointer to contact info, as a part of request data when sending request. + * RETURNS + * void + *****************************************************************************/ +typedef void (*vm_phb_callback_type) (VMINT result, vm_phb_contact_struct *contact_ptr); + +/* Phonebook contact add request info struct */ +typedef struct +{ + vm_phb_storage_loc_enum storage; /* Storage location of phonebook */ + vm_phb_contact_struct *contact_ptr; /* Phonebook contact info */ +} vm_phb_add_req_struct; + +/* Phonebook contact delete request info struct */ +typedef struct +{ + vm_phb_contact_pos_struct pos; /* Contact position */ +} vm_phb_delete_req_struct; + +/* Phonebook contact update request info struct */ +typedef struct +{ + vm_phb_contact_pos_struct pos; /* Contact position */ + vm_phb_contact_struct *contact_ptr; /* Phonebook contact info */ +} vm_phb_update_req_struct; + +/* Contact get request info struct */ +typedef struct +{ + vm_phb_contact_pos_struct pos; /* Contact position */ + vm_phb_contact_struct *contact_ptr; /* Phonebook contact info */ +} vm_phb_get_req_struct; + +/* Search contact request info struct */ +typedef struct +{ + VMWCHAR pattern_ucs2[VM_PHB_MAX_SEARCH_LENGTH]; /* Search pattern(UCS2) */ + vm_phb_search_type_enum search_type; /* Search type */ + vm_phb_contact_struct *contact_ptr; /* Pointer to contact info, this pointer will be returned by callback function */ +} vm_phb_search_req_struct; + + /* Search contact list request info struct */ +typedef struct +{ + VMWCHAR pattern_ucs2[VM_PHB_MAX_SEARCH_LENGTH]; /* Search pattern(UCS2) */ + vm_phb_search_type_enum search_type; /* Search type */ +} vm_phb_search_list_req_struct; + + /***************************************************************************** + * FUNCTION + * vm_phb_add_contact + * DESCRIPTION + * Add a phonebook contact. If you want to add multiple contacts, + * the next contact must be added after the callback function returns. + * PARAMETERS + * req_info : [IN] Contact's info. If added successfully, the content and location info can be obtained by the callback function. + * cb : [IN] Callback function. + * RETURNS + * The error code of the operation. Refer to vm_phb_req_error_enum. + *****************************************************************************/ +vm_phb_req_error_enum vm_phb_add_contact(vm_phb_add_req_struct *req_info, vm_phb_callback_type cb); + + /***************************************************************************** + * FUNCTION + * vm_phb_delete_contact + * DESCRIPTION + * Delete a phonebook contact. If you want to delete multiple contacts, + * the next contact must be deleted after the callback function returns. + * PARAMETERS + * req_info : [IN] Delete contact request info. + * cb : [IN] Callback function. + * RETURNS + * The error code of the operation. Refer to vm_phb_req_error_enum. + *****************************************************************************/ +vm_phb_req_error_enum vm_phb_delete_contact(vm_phb_delete_req_struct *req_info, vm_phb_callback_type cb); + + /***************************************************************************** + * FUNCTION + * vm_phb_update_contact + * DESCRIPTION + * Edit a phonebook contact. If you want to edit multiple contacts, + * the next contact must be edited after the callback function returns. + * PARAMETERS + * req_info : [IN] Contact's info. + * cb : [IN] Callback function. + * RETURNS + * The error code of the operation. Refer to vm_phb_req_error_enum. + *****************************************************************************/ +vm_phb_req_error_enum vm_phb_update_contact(vm_phb_update_req_struct *req_info, vm_phb_callback_type cb); + + /***************************************************************************** + * FUNCTION + * vm_phb_search_contact + * DESCRIPTION + * Search a contact by name or number. The matching contact of every searching is returned by callback function. + * PARAMETERS + * req_info : [IN] Search request info. + * cb : [IN] Callback function. + * RETURNS + * The error code of the operation. Refer to vm_phb_req_error_enum. + *****************************************************************************/ +vm_phb_req_error_enum vm_phb_search_contact(vm_phb_search_req_struct *req_info, vm_phb_callback_type cb); + + /***************************************************************************** + * FUNCTION + * vm_phb_search_contact_list + * DESCRIPTION + * Search contact list by name or number. The matching contact list will be filled to pos_array. + * PARAMETERS + * req_info : [IN] Search request info. + * pos_array : [OUT] Buffer to all the matching contacts. + * post_array_len : [IN] Buffer size. + * RETURNS + * The number of matching contacts. + *****************************************************************************/ +VMINT vm_phb_search_contact_list( + vm_phb_search_list_req_struct *req_info, + vm_phb_contact_pos_struct *pos_array, + VMINT post_array_len); + + /***************************************************************************** + * FUNCTION + * vm_phb_get_contact + * DESCRIPTION + * Get contact's info by position, and the info will be returned by callback function. + * PARAMETERS + * req_info : [IN] Pointer to request info. + * cb : [IN] Callback function. + * RETURNS + * The error code of the operation. Refer to vm_phb_req_error_enum. + *****************************************************************************/ +vm_phb_req_error_enum vm_phb_get_contact(vm_phb_get_req_struct *req_info, vm_phb_callback_type cb); + +/***************************************************************************** + * FUNCTION + * vm_phb_search_contact_syn + * DESCRIPTION + * Search a contact by name or number synchronously. + * PARAMETERS + * req_info : [IN] Pointer to request info. + * RETURNS + * The error code of the operation. Refer to vm_phb_req_error_enum. + *****************************************************************************/ +vm_phb_req_error_enum vm_phb_search_contact_syn(vm_phb_search_req_struct *req_info); + +/***************************************************************************** + * FUNCTION + * vm_phb_get_contact_syn + * DESCRIPTION + * Get contact's info by position synchronously. + * PARAMETERS + * req_info : [IN] Pointer to request info. + * RETURNS + * The error code of the operation. Refer to vm_phb_req_error_enum. + *****************************************************************************/ +vm_phb_req_error_enum vm_phb_get_contact_syn(vm_phb_get_req_struct *req_info); + + /***************************************************************************** + * FUNCTION + * vm_phb_get_total_contacts + * DESCRIPTION + * Get total number of contacts of phonebook. + * PARAMETERS + * storage : [IN] Storage location. + * RETURNS + * The total number of contacts. + * RETURN VALUES + * <0 : Get failed. + * >0 : The total number of contacts. + *****************************************************************************/ +VMINT vm_phb_get_total_contacts(vm_phb_storage_loc_enum storage); + + /***************************************************************************** + * FUNCTION + * vm_phb_get_used_contacts + * DESCRIPTION + * Get the stored contact list by location. + * PARAMETERS + * pos_array : [OUT] Buffer stores contact list. + * storage : [IN] Storage location. + * RETURNS + * The number of stored contacts. + * RETURN VALUES + * <0 : Operation failed. + * >0 : The number of stored contacts. + *****************************************************************************/ +VMINT vm_phb_get_used_contacts(vm_phb_contact_pos_struct *pos_array, vm_phb_storage_loc_enum storage); + +/***************************************************************************** + * FUNCTION + * vm_phb_get_used_contacts_count + * DESCRIPTION + * Get the number of stored contacts in phonebook storage. + * PARAMETERS + * storage : [IN] Storage location. + * RETURNS + * The number of stored contacts. + * RETURN VALUES + * <0 : Operation failed. + * >0 : The number of stored contacts. + *****************************************************************************/ +VMINT vm_phb_get_used_contacts_count(vm_phb_storage_loc_enum storage); + +/***************************************************************************** + * FUNCTION + * vm_phb_get_group_list_count + * DESCRIPTION + * Get the number of group in phonebook. + * PARAMETERS + * void + * RETURNS + * The number of group. + *****************************************************************************/ +VMINT vm_phb_get_group_list_count(void); + +/***************************************************************************** + * FUNCTION + * vm_phb_get_group_list + * DESCRIPTION + * Get group id list ordered by group name. + * PARAMETERS + * group_array : [OUT] Buffer stores group id list. + * group_array_len : [IN] Size of the buffer. + * RETURNS + * The number of group id. + *****************************************************************************/ +VMINT vm_phb_get_group_list(vm_phb_group_struct *group_array, VMINT group_array_len); + +/***************************************************************************** + * FUNCTION + * vm_phb_get_group_name_by_id + * DESCRIPTION + * Get group name by group id. + * PARAMETERS + * group_id : [IN] Group id. + * group_name : [OUT] Buffer stores group name. + * len : [IN] Size of the buffer. + * RETURN VALUES + * TRUE : If successful. + * FALSE : If unsuccessful. + *****************************************************************************/ +VMINT vm_phb_get_group_name_by_id(VMUINT group_id, VMWCHAR *group_name, VMINT len); + +#ifdef __cplusplus +} +#endif + +#endif /* VMPHONEBOOK_SDK_H_ */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmda.h b/hardware/arduino/mtk/system/libmtk/include/vmda.h new file mode 100644 index 00000000..b658c06f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmda.h @@ -0,0 +1,194 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmpromng.c + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * + * + * Author: + * ------- + * + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ + * $Log$ + * + * 04 18 2012 feng.lin + * [MAUI_03152588] MRE requirement of downloading and playing video file + * . + * + * 03 22 2012 feng.lin + * [MAUI_03152588] MRE requirement of downloading and playing video file + * . + * + * *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== + *******************************************************************************/ + +#ifndef VM_DA_SDK_H +#define VM_DA_SDK_H + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "vmsys.h" + +typedef enum +{ + VM_WPS_DL_STATUS_DOWNLOADING, /* downloading is in progress */ + VM_WPS_DL_STATUS_COMPLETE, /* complete downloading */ + VM_WPS_DL_STATUS_ABORT /* downloading is aborted */ +}vm_wps_dl_status_enum; + +typedef enum +{ + VM_WPS_OK, /* Success */ + VM_WPS_ERROR_UNKNOWN, /* Unknonw error */ + VM_WPS_ERROR_SEND, /* Fail to write content */ + VM_WPS_ERROR_INVALID_PARAM, /* Invalid parameters */ + VM_WPS_ERROR_INVALID_HEADER, /* Invalid headers */ + VM_WPS_ERROR_INVALID_CHANNEL_ID, /* Invalid channel ID */ + VM_WPS_ERROR_INVALID_REQUEST_ID, /* Invalid request ID */ + VM_WPS_ERROR_INVALID_SEQUENCE_NUM, /* Incorrect sequence number in MSG_ID_WPS_READ_CONTENT_REQ and MSG_ID_WPS_POST_CONTENT_RES */ + VM_WPS_ERROR_INVALID_DEFAULT_PROFILE, /* Invalid default profile */ + VM_WPS_ERROR_INACTIVE_CHANNEL, /* Inactive channel */ + VM_WPS_ERROR_INVALID_CONN_TYPE, /* Invalid connection type */ + VM_WPS_ERROR_NO_RESOURCE, /* Resource limitation */ + VM_WPS_ERROR_ACCESS_DENY, /* Access deny */ + VM_WPS_ERROR_PENDING_REQ_EXIST, /* Pending request exists */ + VM_WPS_ERROR_FILE_ACCESS, /* File system operation error */ + VM_WPS_ERROR_REQ_ABORT, /* Request aborted */ + VM_WPS_ERROR_NOT_FOUND, /* Not found */ + VM_WPS_ERROR_REQ_MSG_TOO_LARGE, /* Message header is too large */ + VM_WPS_ERROR_REQ_NOT_SUPPORT, /* Request is not supported */ + VM_WPS_ERROR_DNS_RESOLVE, /* DNS error */ + VM_WPS_ERROR_USE_PROXY, /* Proxy error */ + VM_WPS_ERROR_NOT_READY /* WPS is not ready yet */ +}vm_wps_result_error_enum; + +typedef enum +{ + VM_SRV_DA_DOWNLOAD_STOP = 0, /* download of operation */ + VM_SRV_DA_DOWNLOAD_PAUSE, /* pause of operation */ + VM_SRV_DA_DOWNLOAD_RESUME, /* resume of operation */ + + VM_SRV_DA_DOWNLOAD_STOP_END_OF_ENUM /* stop of operation */ +}vm_srv_da_download_cause_enum; + + +typedef struct +{ + VMINT hdl; + vm_wps_dl_status_enum status; + VMUINT32 curr_size; + VMUINT32 total_size; + VMWSTR savepath; + vm_wps_result_error_enum cause; + void *user_data; +} vm_srv_da_download_progress_struct; + +/* callback function for progress */ +typedef void (*vm_srv_da_http_progress_funcptr_type)(vm_srv_da_download_progress_struct * pgs); + +typedef struct +{ + const VMWCHAR *url;/*url for download [IN] */ + VMINT apn;/* apn, refer to vmsock.h, such as VM_TCP_APN_WIFI, VM_TCP_APN_CMNET... [IN] */ + VMINT show_confirm; /* show confirm or not, 0 show, else not [IN] */ + VMWSTR file_path; + void * user_data; + vm_srv_da_http_progress_funcptr_type dl_progress; /* callback of download progress [IN] */ +}vm_srv_da_start_download_struct; + +/* callback function for operation */ +typedef void (*vm_srv_da_http_op_funcptr_type)(VMINT hdl, vm_srv_da_download_cause_enum cause); + + +/****************************************************************************** + * FUNCTION + * vm_da_http_start_download + * DESCRIPTION + * start a download. + * PARAMETERS + * arg : [IN] refer to vm_srv_da_start_download_struct + * RETURNS + * VMINT job handle if > 0, failure if less than 0, + ******************************************************************************/ +VMINT vm_da_http_start_download(vm_srv_da_start_download_struct * arg); + +/****************************************************************************** + * FUNCTION + * vm_da_http_dl_operation + * DESCRIPTION + * operation of download agent. + * PARAMETERS + * hdl : [IN] download job handler + * cause : [IN] refer to vm_srv_da_download_cause_enum + * RETURNS + * VMINT 0 if successful, else failure + ******************************************************************************/ +VMINT vm_da_http_dl_operation(VMINT hdl, vm_srv_da_download_cause_enum cause); + +/****************************************************************************** + * FUNCTION + * vm_da_display_download_list + * DESCRIPTION + * display download list. + * RETURNS + * VMINT 0 if successful, else failure + ******************************************************************************/ +VMINT vm_da_display_download_list(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* VM_DA_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmdatetime.h b/hardware/arduino/mtk/system/libmtk/include/vmdatetime.h new file mode 100644 index 00000000..7c92f0ad --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmdatetime.h @@ -0,0 +1,185 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmdatetime_sdk.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * date time + * + * Author: + * ------- + * + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ +* *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== +*******************************************************************************/ +#ifndef VM_DATETIME_SDK_H +#define VM_DATETIME_SDK_H +#ifdef __cplusplus +extern "C"{ +#endif/*__cplusplus*/ +#include "vmsys.h" +/*vm_time_t*/ +typedef struct vm_time_t { + VMINT year; /*year*/ + VMINT mon; /* month, begin from 1 */ + VMINT day; /* day,begin from 1 */ + VMINT hour; /* house, 24-hour */ + VMINT min; /* minute */ + VMINT sec; /* second */ +} vm_time_t; + + +/***************************************************************************** + * FUNCTION + * vm_get_time + * DESCRIPTION + * get current system time + * PARAMETERS + * time : [OUT] time structure + * RETURNS + * if succeed, return 0, otherwise return -1 + *****************************************************************************/ +VMINT vm_get_time(vm_time_t* time); + +/***************************************************************************** + * FUNCTION + * vm_get_sys_time_zone + * DESCRIPTION + * get system time zone + * PARAMETERS + * void + * RETURNS + * GMT value + *****************************************************************************/ +float vm_get_sys_time_zone(void); + +/***************************************************************************** + * FUNCTION + * vm_get_curr_utc + * DESCRIPTION + * Get the time(the rtc time,not the utc) since the Epoch (00:00:00 UTC, January 1, 1970), + * measured in seconds.phase out, replace by vm_get_rtc() + * PARAMETERS + * utc : [OUT] point to the time in seconds. + * RETURNS + * if succeed, return 0, otherwise failure. + *****************************************************************************/ +VMINT vm_get_curr_utc(VMUINT * utc); + +/***************************************************************************** + * FUNCTION + * vm_get_rtc + * DESCRIPTION + * Get the time since the Epoch (00:00:00 UTC, January 1, 1970), + * measured in seconds. + * PARAMETERS + * utc : [OUT] point to the time in seconds. + * RETURNS + * if succeed, return 0, otherwise failure. + *****************************************************************************/ +VMINT vm_get_rtc(VMUINT * rtc); + +/***************************************************************************** + * FUNCTION + * vm_get_tick_count + * DESCRIPTION + * get millisecond number from the system power on till now + * PARAMETERS + * void + * RETURNS + * millisecond number from the system power on till now + *****************************************************************************/ +VMINT vm_get_tick_count(void); + +/* DOM-NOT_FOR_SDK-BEGIN */ +/***************************************************************************** + * FUNCTION + * get_today_from_2000 + * DESCRIPTION + * get the number of day from 2000/01/01 to now. + * RETURNS + * number of day, -1 means failed. + *****************************************************************************/ +VMINT get_today_from_2000(void); +/* DOM-NOT_FOR_SDK-END */ + +/***************************************************************************** + * FUNCTION + * vm_ust_get_current_time + * DESCRIPTION + * get microsecond from the system power on till now. + * RETURNS + * microsecond number from the system power on till now + * + * start = vm_ust_get_current_time(); + * + *****************************************************************************/ +VMUINT32 vm_ust_get_current_time(); + +/***************************************************************************** + * FUNCTION + * vm_ust_get_duration + * DESCRIPTION + * get the duration from start to end + * RETURNS + * the duration + * + * start = vm_ust_get_current_time(); + * ... + * end = vm_ust_get_current_time(); + * duration = vm_ust_get_duration(start,end); + * + *****************************************************************************/ + VMUINT32 vm_ust_get_duration(VMUINT32 start,VMUINT32 end); + +#ifdef __cplusplus +} +#endif/*__cplusplus*/ + +#endif/*VM_DATETIME_SDK_H*/ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmdcl.h b/hardware/arduino/mtk/system/libmtk/include/vmdcl.h new file mode 100644 index 00000000..c50ea597 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmdcl.h @@ -0,0 +1,517 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef __VM_DCL_H__ +#define __VM_DCL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + + +/***************************************************************************** + * DESCRIPTION + * VM_DCL_DEV is the type used to represent a special device such as UART,I2C,GPIO and so on. + * The value for every device group is defined in VM_DCL_DEV_T. + * The value of a special device is defined in the header file of the device. + *****************************************************************************/ +typedef VMUINT16 VM_DCL_DEV; +/***************************************************************************** + * DESCRIPTION + * VM_DCL_FLAGS is the type used to represent the flag that pass to the vm_dcl_open. + * The value depend on each special device. + *****************************************************************************/ +typedef VMUINT32 VM_DCL_FLAGS; + + + +/***************************************************************************** + * DESCRIPTION + * VM_DCL_OPTIONS is the type used to pass some special option to the read/write API. + * The value depend on each special device. + *****************************************************************************/ +typedef VMUINT32 VM_DCL_OPTIONS; + +/***************************************************************************** + * DESCRIPTION + * VM_DCL_HANDLE is the type used to record a specific device that opened by vm_dcl_open. + * This value will be pass to other API to tell the driver which device will response to the corresponding operation. + *****************************************************************************/ +typedef VMINT32 VM_DCL_HANDLE; +/*Represent invalid handle, returned by vm_dcl_open.*/ +#define VM_DCL_HANDLE_INVALID (-1) + + +/* VM_DCL_BUFF is the type of the buffer*/ +typedef VMUCHAR VM_DCL_BUFF; +/* VM_DCL_BUFF_LEN is the type of the buffer length*/ +typedef VMUINT32 VM_DCL_BUFF_LEN; + + +/***************************************************************************** + * DESCRIPTION + * VM_DCL_EVENT is the type used to represent event. + * The event usually represent a specific hardware condition changed, such as data transfer finished. + * This type value is used in asynchronous operations, please reference VM_DCL_EVENT_T + *****************************************************************************/ +typedef VMUINT32 VM_DCL_EVENT; + +/***************************************************************************** + * DESCRIPTION + * VM_DCL_CALLBACK is the prototype of the call back function. + * PARAMETERS + * parameter: [IN] This pointer is the data structure pointer that driver pass to user. + * The real type of this value should be VM_DCL_CB_ILM_DATA_T. + * The detail of this structure will be given by the driver. + * event: [IN] The event identify which condition that this call back triggered by. + *device_handle: [IN] This handle represent the device that trigger this callback. + * RETURNS + * The return value is void. + * + * RETURN VALUES + * None + * EXAMPLE + * + * //This example explain how to implement the callback. + * void uart_callback(void* parameter, VM_DCL_EVENT event, VM_DCL_HANDLE device_handle){ + * VM_DCL_CB_ILM_DATA_T* uart_para = (VM_DCL_CB_ILM_DATA_T*)parameter; + * if(VM_UART_READY_TO_READ==event){ + * vm_sio_ctrl_get_bytes_t* get_byte=(vm_sio_ctrl_get_bytes_t*)(uart_para->vm_local_para_ptr); + * vm_log_info("UART read callback!!!"); + * }else if(VM_UART_READY_TO_WRITE==event){ + * vm_sio_ctrl_put_bytes_t* put_byte = (vm_sio_ctrl_put_bytes_t*)(uart_para->vm_local_para_ptr); + * vm_log_info("UART write callback!!!"); + * }else{ + * vm_log_info("Wrong callback event!!!"); + * } + * } + * + *****************************************************************************/ +typedef void (*VM_DCL_CALLBACK)(void* parameter, VM_DCL_EVENT event, VM_DCL_HANDLE device_handle); + + +/***************************************************************************** + * DESCRIPTION + * VM_DCL_CTRL_CMD is the type used to represent the operation the driver need to do. + * The value of the type variable is depend on specific device driver. + * The detail please reference to the command enum of driver. + * Please find different command for difference driver: + * SIO: VM_DCL_SIO_CTRL_CMD + * I2C: VM_DCL_I2C_CTRL_CMD_T + * SPI: VM_SPI_IOCTL_CODE + * ADC: VM_DCL_ADC_CTRL_CMD_T + * GPIO: VM_DCL_GPIO_CTRL_CMD_T + * PMU: VM_DCL_PMU_CTRL_CMD_T + * EINT: VM_DCL_EINT_CMD_T + *****************************************************************************/ +typedef VMUINT32 VM_DCL_CTRL_CMD; + +/***************************************************************************** + * DESCRIPTION + * VM_DCL_STATUS is the type used to represent the status the driver returned. + * The meaning of the value please reference to VM_DCL_STATUS_T. + *****************************************************************************/ +typedef VMINT32 VM_DCL_STATUS; + +/***************************************************************************** +*This is the type used for callback transfer data from driver. +*The callback's parameter is always this type. +*Most of the time, the data send back by driver was wrapped in the vm_local_para_ptr, sometimes in vm_peer_buff_ptr. +*Different device driver has different specific type for these two parameter. +*****************************************************************************/ +typedef struct{ + void *vm_local_para_ptr; /* local_para pointer */ + void *vm_peer_buff_ptr; /* peer_buff pointer */ +}VM_DCL_CB_ILM_DATA_T; + +/* This used to represent the status of dcl operations.*/ +typedef enum +{ + VM_DCL_STATUS_OK = 0, /*Operation success*/ + VM_DCL_STATUS_FAIL = -1, /*Operation failed*/ + VM_DCL_STATUS_INVALID_CMD = -2, /*The command send to device is invalid*/ + VM_DCL_STATUS_UNSUPPORTED = -3, /*The device do not support the operation*/ + VM_DCL_STATUS_NOT_OPENED = -4, /*The device isn't open*/ + VM_DCL_STATUS_INVALID_EVENT = -5, /*The event is invalid*/ + VM_DCL_STATUS_INVALID_DCL_HANDLE = -6, /*The handle used to operate the device is invalid. The invalid handle returned by vm_dcl_open is another value.*/ + VM_DCL_STATUS_INVALID_CTRL_DATA = -7, /*The data used to control the device is invalid.*/ + VM_DCL_STATUS_INVALID_ARGUMENT = -9, /*The data used to control the device is invalid.*/ + VM_DCL_STATUS_ERROR_TIMEOUT = -10, /*Operation timeout.*/ + VM_DCL_STATUS_ERROR_CRCERROR = -11, /*CRC error.*/ + VM_DCL_STATUS_ERROR_READONLY = -12, /*device is readonly.*/ + VM_DCL_STATUS_ERROR_WRONG_STATE = -13, /*wrong state.*/ + VM_DCL_STATUS_INVALID_DEVICE = -14, /*invalid device.*/ + VM_DCL_STATUS_ALREADY_OPENED = -15, /*device is already opened.*/ + VM_DCL_STATUS_INVALID_OPERATION = -17, /*operation is invalid.*/ + VM_DCL_STATUS_DEVICE_NOT_EXIST = -18,/*device is not exist.*/ + VM_DCL_STATUS_DEVICE_IS_BUSY = -20,/*device is busy.*/ +} VM_DCL_STATUS_T; + +/***************************************************************************** +*This is the type used for vm_dcl_get_ownerid. +*This value may be have different meaning for the same value. +*So MUST use the vm_dcl_get_ownerid to get the correct value at runtime. +*****************************************************************************/ +typedef enum{ + VM_MODULE_START = 0,/*give the start number*/ + VM_MODULE_END = 0x1FF/*set the end number*/ +}VM_DCL_MODULE_TYPE_T; + + + +/***************************************************************************** +*This is the device number group enum. +*Each group device may have several devices. +*The specific device number please reference to the device driver. +*****************************************************************************/ +typedef enum +{ + VM_DCL_SIO_GROUP_START = 0, /*SIO(Uart,USB) device number starts. Please reference VM_DCL_SIO_DEV_T*/ + VM_DCL_I2C_GROUP_START = 0x100,/*I2C device number starts. Please reference VM_DCL_I2C_DEV_T*/ + VM_DCL_SPI_GROUP_START = 0x200, /*SPI device number starts. Please reference VM_DCL_SPI_DEV_T*/ + VM_DCL_ADC_GROUP_START = 0x300, /*ADC device number starts. Please reference VM_DCL_ADC_DEV_T*/ + VM_DCL_GPIO_GROUP_START = 0x400, /*GPIO device number starts. Please reference VM_DCL_GPIO_DEV_T*/ + VM_DCL_PWM_GROUP_START = 0x500, /*PWM device number starts. Please reference VM_DCL_PWM_DEV_T*/ + VM_DCL_PMU_GROUP_START = 0xB00, /*PMU device number starts. Please reference VM_DCL_PMU_DEV_T*/ + VM_DCL_EINT_GROUP_START = 0x1C00 /* EINT device number starts. Please reference VM_DCL_EINT_DEV_T*/ +} VM_DCL_DEV_T; + +/***************************************************************************** +*This is the event number group enum. +*Each group device may have several events. Some device may not need the event. +*The specific event number and the meaning please reference to the device driver. +*****************************************************************************/ +typedef enum +{ + VM_EVENT_NULL = 0, + VM_GPIO_EVENTS_START = 0x100, /*for GPIO*/ + VM_ADC_EVENTS_START = 0x600, /*for ADC, please reference VM_DCL_ADC_EVENT_T*/ + VM_I2C_EVENTS_START = 0x700, /*for I2C*/ + VM_SERIPORT_EVENTS_START = 0x1400, /*For SIO(include UART and USB), please reference VM_DCL_SIO_EVENT_T*/ + VM_SPI_EVENTS_START = 0x1500 , /*for SPI*/ + VM_EINT_EVENTS_START = 0x1600 /* for EINT , please reference VM_DCL_EINT_EVENT_T*/ +} VM_DCL_EVENT_T; + +/***************************************************************************** +* FUNCTION + * vm_dcl_open + * DESCRIPTION + * Open the device. Every device must be opened with this function before use it. + * The device number passed to this function was defined in device driver's header file. + * The returned handle is the device's identify which will be passed to the other functions at runtime. + * PARAMETERS + * device: [IN] The number of device, given by device driver. It's a 16 bits integer. + * flags: [IN] The parameter needed for the device. It's a 32 bits unsigned integer. Some driver may not need this. + * RETURNS + * The return value is the handle which record the information of corresponding device. + * + * RETURN VALUES + * DCL_HANDLE : The handle record the information of corresponding device. + * If the value of returned handle equal to VM_DCL_HANDLE_INVALID, the open operation failed. + * + * EXAMPLE + * + * DCL_HANDLE uart_handle; + * VM_DCL_MODULE_TYPE_T usr_id; + * usr_id = vm_dcl_get_ownerid(); + * //some device may not need the second parameter. + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * if(VM_DCL_HANDLE_INVALID==uart_handle) return; + * //Do something with the handle. + * +*****************************************************************************/ +VM_DCL_HANDLE vm_dcl_open(VM_DCL_DEV dev, VM_DCL_FLAGS flags); +/***************************************************************************** +* FUNCTION + * vm_dcl_control + * DESCRIPTION + * Send command to control the device. + * This function used to control the device after open the device successfully. + * The command tell the driver what to do and the arg will give the information needed for the control to driver. + * The command is defined in device driver's header file and represent different meaning even have the same value + * for different device. So the handle, command and arg must be match, otherwise the operation maybe given to wrong + * device or do wrong operation. + * This function maybe synchronous or asynchronous operation depending on which devices' which command. + * The details please reference to the command description in the specific driver's document. + * PARAMETERS + * device_handle: [IN] The device handle which returned by vm_dcl_open. + * cmd: [IN] The command used to control the device. The detail reference to the device document. + * arg: [IN] The argument used by the command. The detail reference to the device document. + * RETURNS + * The return value is status. The meaning reference to VM_DCL_STATUS_T; + * + * RETURN VALUES + * DCL_STATUS : The return value is status.The meaning reference to VM_DCL_STATUS_T; + * + * EXAMPLE + * + * DCL_STATUS status; + * vm_sio_ctrl_dcb_t config; + * VM_DCL_MODULE_TYPE_T usr_id; + * VM_DCL_HANDLE uart_handle; + * + * usr_id=vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * config.u4OwenrId = usr_id; + * config.rUARTConfig.fgDSRCheck = 0; + * config.rUARTConfig.u1DataBits = 8; + * config.rUARTConfig.u1FlowControl = VM_FC_NONE; + * config.rUARTConfig.u1Parity = VM_PA_NONE; + * config.rUARTConfig.u1StopBits = VM_SB_1; + * config.rUARTConfig.u4Baud = 115200; + * config.rUARTConfig.ucXoffChar = 0x13; + * config.rUARTConfig.ucXonChar = 0x11; + * status=vm_dcl_control(uart_handle,VM_SIO_CMD_SET_DCB_CONFIG,&config); + * +*****************************************************************************/ +VM_DCL_STATUS vm_dcl_control(VM_DCL_HANDLE device_handle,VM_DCL_CTRL_CMD cmd, void* arg); + + +/***************************************************************************** +* FUNCTION + * vm_dcl_close + * DESCRIPTION + * Close the device. After the device finished the operation, user should close the device. + * Pay attention to the device operation with callback. The device should not be closed before the callback finished. + * PARAMETERS + * device_handle: [IN] The device handle which returned by vm_dcl_open. + * RETURNS + * The return value is status. The meaning reference to VM_DCL_STATUS_T; + * + * RETURN VALUES + * VM_DCL_STATUS : The return value is status.The meaning reference to VM_DCL_STATUS_T; + * +* EXAMPLE + * + * status = vm_dcl_close(i2c_handle); + * +*****************************************************************************/ +VM_DCL_STATUS vm_dcl_close(VM_DCL_HANDLE device_handle); + /***************************************************************************** +* FUNCTION + * vm_dcl_read + * DESCRIPTION + * Read data from the device. This function may not be provided by the devices that don't transfer data. + * If the device have several ways to transfer data, this function may provide some of the methods, + * others can be done bye the vm_dcl_control. The details please reference to the specific device driver document. + * PARAMETERS + * device_handle: [IN] The device handle which returned by vm_dcl_open. + * buf: [IN] The buffer used to save data. + * read_len: [IN] The number of bytes that need to be read. + * returned_len: [OUT] The number of bytes that read by device after returned. + * options: [IN] The special options need by the device. The detail reference to the device document. + * RETURNS + * The return value is status. The meaning reference to VM_DCL_STATUS_T; + * + * RETURN VALUES + * VM_DCL_STATUS : The return value is status.The meaning reference to VM_DCL_STATUS_T; + * +* EXAMPLE + * + * VM_DCL_STATUS status; + * VM_DCL_BUFF data_buffer[1024]; + * VM_DCL_BUFF_LEN returned_len; + * VM_DCL_MODULE_TYPE_T usr_id; + * VM_DCL_HANDLE uart_handle; + * usr_id=vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * status = vm_dcl_read(uart_handle,(VM_DCL_BUFF*)data_buffer,1024,&returned_len,usr_id); + * +*****************************************************************************/ +VM_DCL_STATUS vm_dcl_read(VM_DCL_HANDLE device_handle, VM_DCL_BUFF* buf, VM_DCL_BUFF_LEN read_len, VM_DCL_BUFF_LEN* returned_len,VM_DCL_OPTIONS options); +/***************************************************************************** +* FUNCTION + * vm_dcl_write + * DESCRIPTION + * Write data to the device.This function may not be provided by the devices that don't transfer data. + * If the device have several ways to transfer data, this function may provide some of the methods, + * others can be done bye the vm_dcl_control. The details please reference to the specific device driver document. + * PARAMETERS + * device_handle: [IN] The device handle which returned by vm_dcl_open. + * buf: [IN] The buffer with data that to be written. + * write_len: [IN] The number of bytes that need to write. + * written_len: [OUT] The number of bytes that written by device after returned. + * options: [IN] The special options need by the device. The detail reference to the device document. + * RETURNS + * The return value is status. The meaning reference to VM_DCL_STATUS_T; + * + * RETURN VALUES + * VM_DCL_STATUS : The return value is status.The meaning reference to VM_DCL_STATUS_T; + * +* EXAMPLE + * + * VM_DCL_STATUS status; + * VM_DCL_BUFF data_buffer[1024]; + * VM_DCL_BUFF_LEN written_len; + * VM_DCL_MODULE_TYPE_T usr_id; + * VM_DCL_HANDLE uart_handle; + * usr_id=vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * status = vm_dcl_write(uart_handle,(VM_DCL_BUFF*)data_buffer,1024,&written,usr_id); + * +*****************************************************************************/ +VM_DCL_STATUS vm_dcl_write(VM_DCL_HANDLE device_handle,VM_DCL_BUFF* buf, VM_DCL_BUFF_LEN write_len, VM_DCL_BUFF_LEN* written_len,VM_DCL_OPTIONS options); + +/***************************************************************************** +* FUNCTION + * vm_dcl_registercallback + * DESCRIPTION + * Register event callback. Before the device to do asynchronous operations, the callback function for that operation + * should be registered. The implementation of the callback please reference to the document of the callback function prototype. + * PARAMETERS + * device_handle: [IN] The device handle which returned by vm_dcl_open. + * event: [IN] The event that will triger the callback. + * callback: [IN] callback function. + * parameter: [IN] user parameter. + * RETURNS + * The return value is status. + * + * RETURN VALUES + * VM_DCL_STATUS : The return value is status. + * +* EXAMPLE + * + * VM_DCL_STATUS status; + * VM_DCL_MODULE_TYPE_T usr_id; + * VM_DCL_HANDLE uart_handle; + * usr_id=vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * status=vm_dcl_registercallback(uart_handle,VM_UART_READY_TO_WRITE ,(VM_DCL_CALLBACK)uart_callback,(void *)NULL); + * +*****************************************************************************/ +VM_DCL_STATUS vm_dcl_registercallback(VM_DCL_HANDLE device_handle,VM_DCL_EVENT event, VM_DCL_CALLBACK callback,void* user_data); + +/***************************************************************************** +* FUNCTION + * vm_dcl_addlistenevent + * DESCRIPTION + * if you want listen mluti event then you can use vm_dcl_registercallback first, and use vm_dcl_addlistenevent to add all your events + * PARAMETERS + * device_handle: [IN] The device handle which returned by vm_dcl_open. + * event: [IN] The event that will triger the callback. + * callback: [IN] The number of bytes that need to write. + * user_data: [IN] The number of bytes that written by device after returned. + * RETURNS + * The return value is status. + * + * RETURN VALUES + * VM_DCL_STATUS : The return value is status. + * +* EXAMPLE + * + * status=vm_dcl_addlistenevent(uart_handle,VM_UART_READY_TO_READ,(void *)NULL); + * +*****************************************************************************/ +VM_DCL_STATUS vm_dcl_addlistenevent(VM_DCL_HANDLE device_handle,VM_DCL_EVENT event, void* user_data); + +/***************************************************************************** +* FUNCTION + * vm_dcl_get_ownerid + * DESCRIPTION + * Get the runtime environment identify of the user. Some device may need this. + * Most of the time this function's returned value need to be passed to the driver when the device do asynchronous operations. + * PARAMETERS + * No parameter. + * RETURNS + * The return value is the owner id. + * + * RETURN VALUES + * VM_DCL_MODULE_TYPE_T : the owner id. + * +* EXAMPLE + * + * VM_DCL_MODULE_TYPE_T usr_id; + * usr_id=vm_dcl_get_ownerid(); + * +*****************************************************************************/ +VM_DCL_MODULE_TYPE_T vm_dcl_get_ownerid(void); + +/***************************************************************************** + * FUNCTION + * vm_irq_mask + * DESCRIPTION + * This interface used in AP mode, Mask the I bit of the processor. Note this function must be used in pairs with vm_irq_restore. + * And more, the I bit mask time should not exceed 5ms. + * PARAMETERS + * + * RETURN VALUES + * mask status of the current I bit, it should be an input parameter of vm_irq_restore + * EXAMPLE + * + * VMUIN32 savedMask; + * savedMask = vm_irq_mask(); + * ... // your code need to protect + * vm_irq_restore(savedMask); + * + * + *****************************************************************************/ +VMUINT32 vm_irq_mask(); + +/***************************************************************************** + * FUNCTION + * vm_irq_restore + * DESCRIPTION + * This interface used in AP mode, restore the I bit of the processor. Note, this function must be used in pairs with vm_irq_mask. + * PARAMETERS + * saved_mask:[in] the return value of vm_irq_mask + * RETURN VALUES + * EXAMPLE + * + * VMUIN32 savedMask; + * savedMask = vm_irq_mask(); + * ... // your code need to protect + * vm_irq_restore(savedMask); + * + * + *****************************************************************************/ +void vm_irq_restore(VMUINT32 mask); + +#if 0 +#include "vmdcl_i2c.h" +#include "vmdcl_gpio.h" +#include "vmdcl_sio.h" +#include "vmdcl_spi.h" +#include "vmdcl_adc.h" +#include "vmdcl_pmu.h" +#include "vmdcl_eint.h" +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __VM_DCL_H__ */ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmdcl_adc.h b/hardware/arduino/mtk/system/libmtk/include/vmdcl_adc.h new file mode 100644 index 00000000..09b5a456 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmdcl_adc.h @@ -0,0 +1,101 @@ +#ifndef __VM_DCL_ADC_H__ +#define __VM_DCL_ADC_H__ + + +/*Define the dev for ADC module. Used in dcl_open*/ +typedef enum +{ + VM_DCL_ADC_START = VM_DCL_ADC_GROUP_START, + VM_DCL_ADC +}VM_DCL_ADC_DEV_T; + +/* DCL_CTRL_CMD for ADC */ +typedef enum +{ + VM_ADC_CMD_CREATE_OBJECT = 0x901, /* Get logic channel */ + VM_ADC_CMD_MODIFY_PARAM, /* Set measure parameters */ + VM_ADC_CMD_SEND_START, /* start to measure */ + VM_ADC_CMD_SEND_STOP, /* stop measure */ + VM_ADC_CMD_GET_CHANNEL /* get physical channel */ +}VM_DCL_ADC_CTRL_CMD_T; + +/* ADC event id */ +typedef enum +{ + VM_ADC_GET_RESULT = VM_ADC_EVENTS_START /* Get logic channel */ +}VM_DCL_ADC_EVENT_T; + + +/* For VM_ADC_CMD_CREATE_OBJECT command. */ +typedef struct +{ + VMUINT32 u4Period; /* Measurement period (Uint is in Tick) */ + VMUINT32 u4Sapid; + VM_DCL_MODULE_TYPE_T u1OwnerId; /* Indicate the module to for ADC driver to notify the result */ + VMUINT8 u1AdcChannel; /* To be measured physical ADC channel */ + VMUINT8 u1EvaluateCount; /* Measurement count */ + VMBOOL fgSendPrimitive; /* Whether to send message to owner module or NOT */ +}vm_adc_ctrl_create_object_t; + +/* For VM_ADC_CMD_MODIFY_PARAM command. */ +typedef struct +{ + VMUINT32 u4Period; /* Measurement period (Uint is in Tick) */ + VMUINT8 u1EvaluateCount; /* Measurement count */ +} vm_adc_ctrl_modify_param_t; + +/* For VM_ADC_CMD_SEND_START command. */ +typedef struct +{ + VM_DCL_MODULE_TYPE_T u1OwnerId; /* Indicate the module to for ADC driver to notify the result */ +} vm_adc_ctrl_send_start_t; + +/* For VM_ADC_CMD_SEND_STOP command. */ +typedef struct +{ + + VM_DCL_MODULE_TYPE_T u1OwnerId; /* Indicate the module to for ADC driver to notify the result */ +} vm_adc_ctrl_send_stop_t; + +/*ADC measure result */ +typedef struct { + VMUINT8 ref_count; + VMUINT16 msg_len; /* LOCAL_PARA_HDR */ + double adc_value; /* Indicate the measure raw data */ + VMINT32 adc_handle; + VMINT32 volt; /* Indicate the measure data (volt) */ + VMUINT8 adc_sche_id; +}vm_bmt_adc_measure_done_conf_struct; + +/* For VM_ADC_CMD_GET_CHANNEL command. */ +typedef enum { + VM_VBAT_ADC_CHANNEL = 0, + VM_VISENSE_ADC_CHANNEL, + VM_VBATTMP_ADC_CHANNEL, + VM_BATTYPE_ADC_CHANNEL, + VM_VCHARGER_ADC_CHANNEL, + VM_PCBTMP_ADC_CHANNEL, + VM_AUX_ADC_CHANNEL, + VM_CHR_USB_ADC_CHANNEL, + VM_OTG_VBUS_ADC_CHANNEL, + VM_RFTMP_ADC_CHANNEL, + VM_DCL_XP_ADC_CHANNEL, + VM_DCL_YP_ADC_CHANNEL, + VM_DCL_YM_ADC_CHANNEL, + VM_DCL_XM_ADC_CHANNEL, + VM_MAX_ADC_CHANNEL +} VM_ADC_CHANNEL_TYPE_ENUM; + +/* For VM_ADC_CMD_GET_CHANNEL command. */ +typedef struct +{ + VMUINT8 u1AdcPhyCh; + VMUINT16 u2AdcName; +}vm_adc_ctrl_get_physical_channel_t; + + + +#endif + + + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmdcl_eint.h b/hardware/arduino/mtk/system/libmtk/include/vmdcl_eint.h new file mode 100644 index 00000000..602ffc12 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmdcl_eint.h @@ -0,0 +1,124 @@ +#ifndef _VM_DCL_EINT_H_ +#define _VM_DCL_EINT_H_ + + +/****************************************************************** +* DESCRIPTION +* This enum define the device for eint module, used in vm_dcl_open as a parameter. +* To control EINTs, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vm_dcl.h" +* eint_handle = vm_dcl_open(VM_DCL_EINT,19); //We call vm_dcl_open to get a handle. 19 means eint19 +* +*******************************************************************/ +typedef enum +{ + VM_DCL_EINT_DEV_GROUP_START = VM_DCL_EINT_GROUP_START, /* EINT dev group start. */ + VM_DCL_EINT /* DCL EINT device. */ +}VM_DCL_EINT_DEV_T; + +/****************************************************************** +* DESCRIPTION +* This enum define the event for eint module. +* When user recieve this event, it means the specified EINT has triggerd an interrupt. +*******************************************************************/ +typedef enum +{ + VM_EVENT_EINT_TRIGGER = VM_EINT_EVENTS_START /* EINT trigger event. */ +}VM_DCL_EINT_EVENT_T; + + + +/****************************************************************** +* DESCRIPTION +* This enum define the eint control command, used in vm_dcl_open as a parameter. +* With different commands, user could control the different function of the EINTs. +* To control EINTs, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vm_dcl.h" +* VM_DCL_HANDLE eint_handle; // Declare a VM_DCL_HANDLE variable. +* vm_eint_ctrl_config_t eint_config; //Declare a vm_eint_ctrl_config_t variable. +* vm_eint_ctrl_set_sensitivity_t sens_data; //Declare a vm_eint_ctrl_set_sensitivity_t variable. +* vm_eint_ctrl_set_hw_deounce_t deboun_time; //Declare a vm_eint_ctrl_set_hw_deounce_t variable. +* eint_handle = vm_dcl_open(VM_DCL_EINT,19); // First, we call vm_dcl_open to get a handle. 19 means eint19 +* vm_dcl_control(eint_handle,VM_EINT_CMD_MASK,NULL); // Usually, before we config eint, we mask it firstly. +* vm_dcl_registercallback(eint_handle,EVENT_EINT_TRIGGER,(VM_DCL_CALLBACK)eint_callback,(void*)NULL ); // register callback function,Note: the last paramter fill NULL +* sens_data.sensitivity = 1; // 1 means level sensitive, 0 means edge sensitive. +* vm_dcl_control(eint_handle,VM_EINT_CMD_SET_SENSITIVITY,(void *)&sens_data); // set eint sensitivity +* deboun_time.debounce_time = 10; //Debounce time 10ms +* vm_dcl_control(eint_handle,VM_EINT_CMD_SET_HW_DEBOUNCE,(void *)&deboun_time); // Set debounce time +* eint_config.act_polarity = 0; // 1 means positive active, 0 means negative active. +* eint_config.debounce_en = 1; // 1 means enable hw debounce, 0 means disable. +* eint_config.auto_unmask = 1; // 1 means unmask after callback, 0 means not unmask, and user should unmask it themselves. +* vm_dcl_control(eint_handle,VM_EINT_CMD_CONFIG,(void *)&eint_config); // Please call this api finally, because we will unmask eint in this command. +* vm_dcl_control(eint_handle,VM_EINT_CMD_UNMASK,NULL); // call this function to unmask this eint. +* vm_dcl_close(eint_handle); // Finally, we call vm_dcl_close +* +*******************************************************************/ +typedef enum +{ + VM_EINT_CMD_GROUP_START = 0x1E00, /* EINT cmmand group start. */ + VM_EINT_CMD_CONFIG, /* EINT config command. */ + VM_EINT_CMD_SET_HW_DEBOUNCE, /* EINT set hardware debounce command. */ + VM_EINT_CMD_SET_POLARITY, /* EINT set polartiy command. */ + VM_EINT_CMD_SET_SENSITIVITY, /* EINT set sensitivity command. */ + VM_EINT_CMD_MASK, /* EINT mask command. */ + VM_EINT_CMD_UNMASK, /* EINT unmask command. */ +}VM_DCL_EINT_CMD_T; + + +/****************************************************************** +* DESCRIPTION +* This struct is for VM_EINT_CMD_CONFIG command,used in vm_dcl_control as parameter. +* With this command, you can config the attribute of a specified EINT. +* You can find the sample code in the description of VM_DCL_EINT_CMD_T. +* All commands have similar usage. +*******************************************************************/ +typedef struct +{ + VMUINT8 debounce_en; /* The value is 1 or 0. 1 means enable hw debounce, 0 means disable. */ + VMUINT8 act_polarity; /* The value is 1 0r 0. 1 means positive active, 0 means negative active. */ + VMUINT8 auto_unmask; /* The value is 1 or 0. 1 means unmask after callback, 0 means not unmask. user unmask it themselves. */ +} vm_eint_ctrl_config_t; + +/****************************************************************** +* DESCRIPTION +* This struct is for VM_EINT_CMD_SET_HW_DEBOUNCE command,used in vm_dcl_control as parameter. +* With this command, you can set the hw debounce time of a specified EINT. +* You can find the sample code in the description of VM_DCL_EINT_CMD_T. +* All commands have similar usage. +*******************************************************************/ +typedef struct +{ + VMUINT32 debounce_time; /* HW debounce time. the unit is 1ms. */ +}vm_eint_ctrl_set_hw_deounce_t; + +/****************************************************************** +* DESCRIPTION +* This struct is for VM_EINT_CMD_SET_POLARITY command,used in vm_dcl_control as parameter. +* With this command, you can set the polarity of a specified EINT. +* You can find the sample code in the description of VM_DCL_EINT_CMD_T. +* All commands have similar usage. +*******************************************************************/ +typedef struct +{ + VMUINT8 ACT_Polarity; /* The value is 1 0r 0. 1 means positive active, 0 means negative active. */ +}vm_eint_ctrl_set_polarity_t; + +/****************************************************************** +* DESCRIPTION +* This struct is for VM_EINT_CMD_SET_SENSITIVITY command,used in vm_dcl_control as parameter. +* With this command, you can set the sensitivity of a specified EINT. +* You can find the sample code in the description of VM_DCL_EINT_CMD_T. +* All commands have similar usage. +*******************************************************************/ +typedef struct +{ + VMUINT8 sensitivity; /* The value is 1 or 0. 1 means level sensitive,0 means edge sensitive. */ +}vm_eint_ctrl_set_sensitivity_t; + + + +#endif diff --git a/hardware/arduino/mtk/system/libmtk/include/vmdcl_gpio.h b/hardware/arduino/mtk/system/libmtk/include/vmdcl_gpio.h new file mode 100644 index 00000000..6a72b417 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmdcl_gpio.h @@ -0,0 +1,251 @@ +#ifndef __VM_DCL_GPIO_H_STRUCT__ +#define __VM_DCL_GPIO_H_STRUCT__ + +/****************************************************************** +* DESCRIPTION +* This enum defines the device for gpio module,used in vm_dcl_open as a parameter. +* To control GPIOs, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vm_dcl.h" +* VM_DCL_HANDLE gpio_handle; // Declare a VM_DCL_HANDLE variable. +* gpio_handle = vm_dcl_open(VM_DCL_GPIO,55); // Call vm_dcl_open to get a handle. 55 means gpio55 +* +*******************************************************************/ +typedef enum +{ + VM_DCL_GPIO_START = VM_DCL_GPIO_GROUP_START, /*GPIO device start*/ + VM_DCL_GPIO,/*This device is used to control GPIO normal function.*/ + VM_DCL_GPIO_CLK /*This device is used to control GPIO clk function.*/ +}VM_DCL_GPIO_DEV_T; + + +/****************************************************************** +* DESCRIPTION +* This enum is for GPIO_CMD_SET_CLK_OUT command,used in vm_dcl_control as parameter. +* Please refer the introduction of vm_gpio_ctrl_set_clk_out_t for more details. +*******************************************************************/ +typedef enum { + vm_mode_default = 0,/*The default mode is 0. User should refer to the GPIO datasheet to see the specified value*/ + vm_mode_f32k_ck = 0x82, /*Use this enum value to set the 32K clock out in a faster way*/ + vm_mode_max_num /*This value defines the max number of mode, do not exceed this value*/ + } vm_gpio_clk_mode; + + +/****************************************************************** +* DESCRIPTION +* This enum is for GPIO_CMD_SET_CLK_DIV,used in vm_dcl_control as parameter. +* Please refer the introduction of vm_gpio_ctrl_set_clk_div_t for more details. +*******************************************************************/ +typedef enum { + vm_div_max_num=16 /*This value defines the max number of div, do not exceed this value*/ +} vm_gpio_clk_div; + + +/****************************************************************** +* DESCRIPTION +* This enum define the control command for GPIO module,used in vm_dcl_control as parameter. +* With different commands, user could control the different function of the GPIOs. +* To control GPIOs, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vm_dcl.h" +* VM_DCL_HANDLE gpio_handle; // Declare a VM_DCL_HANDLE variable. +* vm_gpio_ctrl_read_t gpio_input_data; //Declare a variable for read IO. +* vm_gpio_ctrl_set_pupd_r0_r1_t pupd_r0r1_data; //Declare a vm_gpio_ctrl_set_pupd_r0_r1_t variable. +* gpio_handle = vm_dcl_open(VM_DCL_GPIO,55); // First, we call vm_dcl_open to get a handle. 55 means gpio55 +* vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_3,NULL); // we call vm_dcl_control to set gpio55 as mode3. +* vm_dcl_control(gpio_handle,VM_GPIO_CMD_READ,(void *)&gpio_input_data); // We call vm_dcl_control to read gpio55 . +* vm_dcl_control(gpio_handle,VM_GPIO_CMD_WRITE_HIGH,0); // we call vm_dcl_control to write gpio55 . +* pupd_r0r1_data.fgSetPupd = 1; // More details, please refer to the GPIO datasheet. +* pupd_r0r1_data.fgSetR0 = 1; // More details, please refer to the GPIO datasheet. +* pupd_r0r1_data.fgSetR1 = 0; // More details, please refer to the GPIO datasheet. +* vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_PUPD_R0_R1,(void *)&pupd_r0r1_data); //we call vm_dcl_control to set pupd of gpio55 . +* vm_dcl_close(gpio_handle); // Finally, we call vm_dcl_close +* +*******************************************************************/ +typedef enum +{ + VM_GPIO_CMD_READ = 1, /*Read data from GPIO Pin*/ + VM_GPIO_CMD_WRITE_LOW, /*Write low to GPIO pin,the GPIO pin will output low*/ + VM_GPIO_CMD_WRITE_HIGH, /*Write high to GPIO Pin,the GPIO pin will output high*/ + VM_GPIO_CMD_SET_MODE_0, /*Set GPIO mode as mode 0,user should refer to the GPIO datasheet to get the real meaning of MODE0*/ + VM_GPIO_CMD_SET_MODE_1, /*Set GPIO mode as mode 1,user should refer to the GPIO datasheet to get the real meaning of MODE1*/ + VM_GPIO_CMD_SET_MODE_2, /*Set GPIO mode as mode 2,user should refer to the GPIO datasheet to get the real meaning of MODE2*/ + VM_GPIO_CMD_SET_MODE_3, /*Set GPIO mode as mode 3,user should refer to the GPIO datasheet to get the real meaning of MODE3*/ + VM_GPIO_CMD_SET_MODE_4, /*Set GPIO mode as mode 4 ,only for chip support 4-bit mode*/ + VM_GPIO_CMD_SET_MODE_5, /*Set GPIO mode as mode 5,only for chip support 4-bit mode*/ + VM_GPIO_CMD_SET_MODE_6, /*Set GPIO mode as mode 6,only for chip support 4-bit mode*/ + VM_GPIO_CMD_SET_MODE_7, /*Set GPIO mode as mode 7,only for chip support 4-bit mode*/ + VM_GPIO_CMD_SET_MODE_8, /*Set GPIO mode as mode 8,only for chip support 4-bit mode*/ + VM_GPIO_CMD_SET_DIR_OUT, /*Set GPIO direction as output*/ + VM_GPIO_CMD_SET_DIR_IN, /*Set GPIO direction as input*/ + VM_GPIO_CMD_RETURN_MODE, /*Get current GPIO mode*/ + VM_GPIO_CMD_RETURN_DIR, /*Get current GPIO direction*/ + VM_GPIO_CMD_RETURN_OUT, /*Get current GPIO output level,0 means low level and 1 means high level*/ + VM_GPIO_CMD_ENABLE_PULL, /*Enable GPIO pull-up/pull-down */ + VM_GPIO_CMD_DISABLE_PULL, /*Disable GPIO pull-up/pull-down */ + VM_GPIO_CMD_SET_PULL_HIGH, /*Set GPIO as pull-up*/ + VM_GPIO_CMD_SET_PULL_LOW, /*Set GPIO as pull-down*/ + VM_GPIO_CMD_SET_DINV, /*Enable or disable GPIO data inversion*/ + VM_GPIO_CMD_RESERVED0, /*Reserved commond, don't use this command*/ + VM_GPIO_CMD_SET_CLK_OUT, /*Select the clock output source of GPIO*/ + VM_GPIO_CMD_SET_CLK_DIV, /*Set the clock division of the clock source*/ + VM_GPIO_CMD_RESERVED1, /*Reserved command, don't use this command*/ + VM_GPIO_CMD_RESERVED2, /*Reserved command, don't use this command*/ + VM_GPIO_CMD_RESERVED3, /*Reserved command, don't use this command*/ + VM_GPIO_CMD_RESERVED4, /*Reserved command, don't use this command*/ + VM_GPIO_CMD_RESERVED5, /*Reserved command, don't use this command*/ + VM_GPIO_CMD_RESERVED6, /*Reserved command, don't use this command*/ + VM_GPIO_CMD_RESERVED7, /*Reserved command, don't use this command*/ + VM_GPIO_CMD_RESERVED8, /*Reserved command, don't use this command*/ + VM_GPIO_CMD_RESERVED9, /*Reserved command, don't use this command*/ + VM_GPIO_CMD_RESERVED10, /*Reserved command, don't use this command*/ + VM_GPIO_CMD_RESERVED11, /*Reserved command, don't use this command*/ + VM_GPIO_CMD_RESERVED12, /*Reserved command, don't use this command*/ + VM_GPIO_CMD_RESERVED13, /*Reserved command, don't use this command*/ + VM_GPIO_CMD_RESERVED14, /*Reserved command, don't use this command*/ + VM_GPIO_CMD_SET_PUPD_R0_R1, /*set the special gpio's pull up/down register. User should refer to the GPIO datasheet*/ + VM_GPIO_CMD_SET_MODE_9, /*Set GPIO mode as mode 9,only for chip support 4-bit mode*/ + VM_GPIO_CMD_SET_MODE_10, /*Set GPIO mode as mode 10,only for chip support 4-bit mode*/ +}VM_DCL_GPIO_CTRL_CMD_T; + + +/****************************************************************** +* DESCRIPTION +* This struct is for GPIO_CMD_READ control command,used in vm_dcl_control as parameter. +* You can find the sample code in the description of VM_DCL_GPIO_CTRL_CMD_T. +*******************************************************************/ +typedef struct +{ + #define VM_GPIO_IO_HIGH 1 + #define VM_GPIO_IO_LOW 0 + VMUINT8 u1IOData; /* The returned value. 0 means the GPIO pin input level is low. 1 means level is high*/ +} vm_gpio_ctrl_read_t; + +/****************************************************************** +* DESCRIPTION +* This struct is for GPIO_CMD_RETURN_MODE control command,used in vm_dcl_control as parameter. +* With this command, you can get the current mode of a specified GPIOs. +* You can find the sample code in the description of VM_DCL_GPIO_CTRL_CMD_T. +* All commands have similar usage. +*******************************************************************/ +typedef struct +{ +#define VM_GPIO_MODE_0 0 +#define VM_GPIO_MODE_1 1 +#define VM_GPIO_MODE_2 2 +#define VM_GPIO_MODE_3 3 +#define VM_GPIO_MODE_4 4 +#define VM_GPIO_MODE_5 5 +#define VM_GPIO_MODE_6 6 +#define VM_GPIO_MODE_7 7 +#define VM_GPIO_MODE_8 8 + VMUINT8 u1RetMode; /*The returned mode value: 0, 1, 2, 3,4,5,6,7,8. Please refer to more details about what the mode number represents from GPIO datasheet*/ +} vm_gpio_ctrl_return_mode_t; + + +/****************************************************************** +* DESCRIPTION +* This struct is for GPIO_CMD_RETURN_DIR control command,used in vm_dcl_control as parameter. +* With this command, you can get the direction of a specified GPIOs. +* You can find the sample code in the description of VM_DCL_GPIO_CTRL_CMD_T. +* All commands have similar usage. +*******************************************************************/ +typedef struct +{ +#define VM_GPIO_DIR_IN 0 +#define VM_GPIO_DIR_OUT 1 + VMUINT8 u1RetDirData; /*The returned dir value: to return 0 means input, or 1 means output*/ +}vm_gpio_ctrl_return_dir_t; + +/****************************************************************** +* DESCRIPTION +* This struct is for GPIO_CMD_RETURN_OUT control command,used in vm_dcl_control as parameter. +* With this command, you can get the output level of a specified GPIOs. +* You can find the sample code in the description of VM_DCL_GPIO_CTRL_CMD_T. +* All commands have similar usage. +*******************************************************************/ +typedef struct +{ + VMUINT8 u1RetOutData;/*The returned value: 1 means gpio output level is high,0 means gpio output level is low */ +}vm_gpio_ctrl_return_out_t; + + +/****************************************************************** +* DESCRIPTION +* This struct is for FOR GPIO_CMD_SET_DINV control command,used in vm_dcl_control as parameter. +* With this command, you can set the data inversion funtion of a specified GPIOs. +* You can find the sample code in the description of VM_DCL_GPIO_CTRL_CMD_T. +* All commands have similar usage. +*******************************************************************/ +typedef struct +{ + VMBOOL fgSetDinv; /*This function only valid when the direction is input. 1 means enable this function. Get more information from datasheet*/ +}vm_gpio_ctrl_set_dinv_t; + +/****************************************************************** +* DESCRIPTION +* This struct is for GPIO_CMD_SET_PUPD_R0_R1 control command,used in vm_dcl_control as parameter. +* With this command, you can set the pupd,r0,r1 funtion of a specified GPIOs. +* You can find the sample code in the description of VM_DCL_GPIO_CTRL_CMD_T. +* All commands have similar usage. +*******************************************************************/ +typedef struct +{ + VMBOOL fgSetPupd; /*This function set the pull up/down resisters of some special GPIO pins. Different fgSetPupd,fgSetR0,fgSetR1 means defferent pull up/down resisters.Please get more details in datasheet.*/ + VMBOOL fgSetR0; /*This function set the pull up/down resisters of some special GPIO pins. Different fgSetPupd,fgSetR0,fgSetR1 means defferent pull up/down resisters.Please get more details in datasheet.*/ + VMBOOL fgSetR1; /*This function set the pull up/down resisters of some special GPIO pins. Different fgSetPupd,fgSetR0,fgSetR1 means defferent pull up/down resisters.Please get more details in datasheet.*/ +}vm_gpio_ctrl_set_pupd_r0_r1_t; + + +/****************************************************************** +* DESCRIPTION +* This struct is for GPIO_CMD_SET_CLK_OUT control command,used in vm_dcl_control as parameter. +* To control GPIOs, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vm_dcl.h" +* VM_DCL_HANDLE gpio_handle; // Declare a VM_DCL_HANDLE variable. +* vm_gpio_ctrl_set_clk_out_t clk_data; //Declare a vm_gpio_ctrl_set_clk_out_t variable. +* gpio_handle = vm_dcl_open(VM_DCL_GPIO_CLK,55);// Step1, we call vm_dcl_open to get a handle. 55 means gpio55. Notice the dev parameter is VM_DCL_GPIO_CLK. +* clk_data.u2ClkNum = 2;// More details, please refer to the GPIO datasheet. +* clk_data.u2Mode = 4; //More details, please refer to the GPIO datasheet. +* vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_CLK_OUT,(void *)&clk_data); // Step2, we call vm_dcl_control to set pupd of gpio55 . +* vm_dcl_close(gpio_handle); // Finally, we call vm_dcl_close +* +*******************************************************************/ +typedef struct +{ + VMUINT16 u2ClkNum; /*The clock register number in datasheet.*/ + vm_gpio_clk_mode u2Mode;/*The clock mode in datasheet.different mode means different source clock selected*/ +}vm_gpio_ctrl_set_clk_out_t; + + +/****************************************************************** +* DESCRIPTION +* This struct is for GPIO_CMD_SET_CLK_DIV control command,used in vm_dcl_control as parameter. +* To control GPIOs, you should use DCL(Driver Common Layer) APIs. +* Note,some platform do not have such functions and others may have. You should refer the datasheet before using GPIOs. +* EXAMPLE +* +* #include "vm_dcl.h" +* VM_DCL_HANDLE gpio_handle; // Declare a VM_DCL_HANDLE variable. +* vm_gpio_ctrl_set_clk_div_t clk_data; //Declare a vm_gpio_ctrl_set_clk_out_t variable. +* gpio_handle = vm_dcl_open(VM_DCL_GPIO_CLK,55);// Step1, we call vm_dcl_open to get a handle. 55 means gpio55. Notice the dev parameter is VM_DCL_GPIO_CLK. +* clk_data.u2ClkNum = 3;// More details, please refer to the GPIO datasheet. +* clk_data.u2Div = 2; //More details, please refer to the GPIO datasheet. +* vm_dcl_control(gpio_handle,GPIO_CMD_SET_CLK_DIV,(void *)&clk_data); // Step2, we call vm_dcl_control to set pupd of gpio55 . +* vm_dcl_close(gpio_handle); // Finally, we call vm_dcl_close +* +*******************************************************************/ +typedef struct +{ + VMUINT16 u2ClkNum; /*The clock register number in datasheet.*/ + vm_gpio_clk_div u2Div; /*The division value in datasheet.Please get more details in datasheet.*/ +}vm_gpio_ctrl_set_clk_div_t; + + +#endif + + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmdcl_i2c.h b/hardware/arduino/mtk/system/libmtk/include/vmdcl_i2c.h new file mode 100644 index 00000000..ad7ff78e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmdcl_i2c.h @@ -0,0 +1,359 @@ +#ifndef __VM_DCL_I2C_H__ +#define __VM_DCL_I2C_H__ + +/***************************************************************************** + * DESCRIPTION + * VM_DCL_I2C_OWNER indecates that this is the DEFAULT user when no users use + * i2c driver + *****************************************************************************/ +typedef enum +{ + VM_DUMMY_I2C_OWNER = 0xD +}VM_DCL_I2C_OWNER; + + +/***************************************************************************** + * DESCRIPTION + * VM_DCL_I2C_DEV_T indecates the deivce which use i2c module,*This enum + * define the dev for i2c module. Used in vm_dcl_open + * EXAMPLE + * + * VM_DCL_HANDLE i2c_handle; + * i2c_handle = vm_dcl_open(VM_DCL_I2C,0); + * if(VM_DCL_HANDLE_INVALID==i2c_handle) return; + * //Do something with the handle. + * + *****************************************************************************/ +typedef enum +{ + VM_DCL_I2C_START = VM_DCL_I2C_GROUP_START, /*I2C device start*/ + VM_DCL_I2C /*This device is for vm_dcl_open as a parameter.*/ +}VM_DCL_I2C_DEV_T; + + +/***************************************************************************** + * DESCRIPTION + * VM_DCL_I2C_TRANSACTION_MODE indecates the i2c Transaction Mode, user + * can select FAST or HIGH speed if need + * EXAMPLE + * + * VM_DCL_HANDLE i2c_handle; + * vm_i2c_ctrl_config_t conf_data; + * i2c_handle = vm_dcl_open(VM_DCL_I2C,0); + * if(VM_DCL_HANDLE_INVALID==i2c_handle) return; + *conf_data.Reserved0 = 0; + *conf_data.eTransactionMode = VM_DCL_I2C_TRANSACTION_FAST_MODE; + *conf_data.fgGetHandleWait = 0; + *conf_data.Reserved1 = 0; + *conf_data.u1DelayLen = 0; + *conf_data.u1SlaveAddress = 0x98; + *conf_data.u4FastModeSpeed = 400; + *conf_data.u4HSModeSpeed = 0; + *vm_dcl_control(i2c_handle,VM_I2C_CMD_CONFIG,(void *)&conf_data); + * //Do something with the handle. + * + *****************************************************************************/ +typedef enum +{ + VM_DCL_I2C_TRANSACTION_FAST_MODE, /* Fast Mode: < 400kbps */ + VM_DCL_I2C_TRANSACTION_HIGH_SPEED_MODE /* Hign Speed Mode: > 400kbps */ +}VM_DCL_I2C_TRANSACTION_MODE; + + +/***************************************************************************** + * DESCRIPTION + * VM_DCL_I2C_CTRL_CMD_T indecates tthe I2C control commands, user + * can select CMDS to control driver + * EXAMPLE + * + * VM_DCL_HANDLE i2c_handle; + * vm_i2c_ctrl_config_t conf_data; + * vm_i2c_ctrl_single_write_t write_data; + * VM_DCL_BUFF_LEN len; + * VMUINT8 i2c_write_data[2] = {0x56,0x78}; + * i2c_handle = vm_dcl_open(VM_DCL_I2C,0); + * if(VM_DCL_HANDLE_INVALID==i2c_handle) return; + * conf_data.Reserved0 = 0; + * conf_data.eTransactionMode = VM_DCL_I2C_TRANSACTION_FAST_MODE; + * conf_data.fgGetHandleWait = 0; + * conf_data.Reserved1 = 0; + * conf_data.u1DelayLen = 0; + * conf_data.u1SlaveAddress = 0x98; + * conf_data.u4FastModeSpeed = 400; + * conf_data.u4HSModeSpeed = 0; + * vm_dcl_control(i2c_handle,VM_I2C_CMD_CONFIG,(void *)&conf_data); + * write_data.pu1Data = i2c_write_data; + * write_data.u4DataLen = 2; + * vm_dcl_write(i2c_handle,(VM_DCL_BUFF*)i2c_write_data,2,&len,0); + * //Do something with the handle. + * + *****************************************************************************/ +typedef enum +{ + VM_I2C_CMD_GET_TRANSACTION_MODE = 0x901, /* Get transaction mode */ + VM_I2C_CMD_SET_TRANSACTION_SPEED, /* Set transaction speed */ + VM_I2C_CMD_SINGLE_WRITE, /* Single write of blocking mode */ + VM_I2C_CMD_SINGLE_READ, /* Single read of blocking mode */ + VM_I2C_CMD_CONT_WRITE, /* Continue write of blocking mode */ + VM_I2C_CMD_CONT_READ, /* Continue read of blocking mode */ + VM_I2C_CMD_WRITE_AND_READ, /* Write and read of blocking mode */ + VM_I2C_CMD_RESERVED0, /* Reserved command. Do not use it */ + VM_I2C_CMD_RESERVED1, /* Reserved command. Do not use it */ + VM_I2C_CMD_RESERVED2, /* Reserved command. Do not use it */ + VM_I2C_CMD_RESERVED3, /* Reserved command. Do not use it */ + VM_I2C_CMD_SET_SLAVE_ADDRESS, /* Set the slave address of sensor */ + VM_I2C_CMD_CONFIG /* Configure the i2c for read or writer */ +}VM_DCL_I2C_CTRL_CMD_T; + +/***************************************************************************** + * DESCRIPTION + * vm_i2c_ctrl_get_transaction_mode_t indecates I2C_CMD_GET_TRANSACTION_MODE command + * EXAMPLE + * + * VM_DCL_HANDLE i2c_handle; + * vm_i2c_ctrl_config_t conf_data; + * vm_i2c_ctrl_get_transaction_mode_t mode; + * i2c_handle = vm_dcl_open(VM_DCL_I2C,0); + * if(VM_DCL_HANDLE_INVALID==i2c_handle) return; + * conf_data.Reserved0 = 0; + * conf_data.eTransactionMode = VM_DCL_I2C_TRANSACTION_FAST_MODE; + * conf_data.fgGetHandleWait = 0; + * conf_data.Reserved1 = 0; + * conf_data.u1DelayLen = 0; + * conf_data.u1SlaveAddress = 0x98; + * conf_data.u4FastModeSpeed = 400; + * conf_data.u4HSModeSpeed = 0; + * vm_dcl_control(i2c_handle,VM_I2C_CMD_CONFIG,(void *)&conf_data); + * vm_dcl_control(i2c_handle,I2C_CMD_GET_TRANSACTION_MODE,(void *)&mode); + * //Do something with the handle. + * + *****************************************************************************/ +typedef struct +{ + VM_DCL_I2C_TRANSACTION_MODE eTransactionMode; /* Transaction mode */ +}vm_i2c_ctrl_get_transaction_mode_t; + + + +/***************************************************************************** + * DESCRIPTION + * vm_i2c_ctrl_set_transaction_speed_t indecates I2C_CMD_SET_TRANSACTION_SPEED command + * EXAMPLE + * + * VM_DCL_HANDLE i2c_handle; + * vm_i2c_ctrl_config_t conf_data; + * vm_i2c_ctrl_set_transaction_speed_t speed; + * i2c_handle = vm_dcl_open(VM_DCL_I2C,0); + * if(VM_DCL_HANDLE_INVALID==i2c_handle) return; + * conf_data.Reserved0 = 0; + * conf_data.eTransactionMode = VM_DCL_I2C_TRANSACTION_FAST_MODE; + * conf_data.fgGetHandleWait = 0; + * conf_data.Reserved1 = 0; + * conf_data.u1DelayLen = 0; + * conf_data.u1SlaveAddress = 0x98; + * conf_data.u4FastModeSpeed = 400; + * conf_data.u4HSModeSpeed = 0; + * vm_dcl_control(i2c_handle,VM_I2C_CMD_CONFIG,(void *)&conf_data); + * speed.eTransactionMode = VM_DCL_I2C_TRANSACTION_HIGH_SPEED_MODE; + * speed.u4FastModeSpeed = 800; + * speed.u4HSModeSpeed = 1; + * vm_dcl_control(i2c_handle,I2C_CMD_SET_TRANSACTION_SPEED,(void *)&speed); + * //Do something with the handle. + * + *****************************************************************************/ +typedef struct +{ + VM_DCL_I2C_TRANSACTION_MODE eTransactionMode; /* Transaction mode */ + VMUINT32 u4FastModeSpeed; /* Fast mode speed */ + VMUINT32 u4HSModeSpeed; /* High speed mode speed */ +}vm_i2c_ctrl_set_transaction_speed_t; + +/***************************************************************************** + * DESCRIPTION + * vm_i2c_ctrl_single_write_t,vm_i2c_ctrl_single_read_t indecates + * I2C_CMD_SINGLE_WRITE, I2C_CMD_SINGLE_READ command. + * EXAMPLE + * + * VM_DCL_HANDLE i2c_handle; + * vm_i2c_ctrl_config_t conf_data; + * vm_i2c_ctrl_single_write_t write_data; + * vm_i2c_ctrl_single_read_t read_data; + * VM_DCL_BUFF_LEN len; + * VMUINT8 i2c_write_data[2] = {0x56,0x78}; + * VMUINT8 i2c_read_data[2] = {0x0,0x0}; + * i2c_handle = vm_dcl_open(VM_DCL_I2C,0); + * if(VM_DCL_HANDLE_INVALID==i2c_handle) return; + * conf_data.Reserved0 = 0; + * conf_data.eTransactionMode = VM_DCL_I2C_TRANSACTION_FAST_MODE; + * conf_data.fgGetHandleWait = 0; + * conf_data.Reserved1 = 0; + * conf_data.u1DelayLen = 0; + * conf_data.u1SlaveAddress = 0x98; + * conf_data.u4FastModeSpeed = 400; + * conf_data.u4HSModeSpeed = 0; + * vm_dcl_control(i2c_handle,VM_I2C_CMD_CONFIG,(void *)&conf_data); + * write_data.pu1Data = i2c_write_data; + * write_data.u4DataLen = 2; + * vm_dcl_control(i2c_handle,I2C_CMD_SINGLE_WRITE,(void *)&write_data); + * read_data.pu1Data=i2c_read_data; + * read_data.u4DataLen = 2; + * vm_dcl_control(i2c_handle,I2C_CMD_SINGLE_READ,(void *)&read_data); + * //Do something with the handle. + * + *****************************************************************************/ +typedef struct +{ + VMUINT8 *pu1Data; /* Pointer to the buffer of data */ + VMUINT32 u4DataLen; /* Data length ,Note that this len should not exceed 8*/ +}vm_i2c_ctrl_single_write_t,vm_i2c_ctrl_single_read_t; + +/***************************************************************************** + * DESCRIPTION + * vm_i2c_ctrl_single_write_t,vm_i2c_ctrl_single_read_t indecates + * I2C_CMD_CONT_WRITE, I2C_CMD_CONT_READ command + * EXAMPLE + * + * VM_DCL_HANDLE i2c_handle; + * vm_i2c_ctrl_config_t conf_data; + * vm_i2c_ctrl_cont_write_t write_data; + * vm_i2c_ctrl_cont_read_t read_data; + * VM_DCL_BUFF_LEN len; + * VMUINT8 i2c_write_data[20] = {0x56,0x78,0x00}; + * VMUINT8 i2c_read_data[20] = {0x0}; + * i2c_handle = vm_dcl_open(VM_DCL_I2C,0); + * if(VM_DCL_HANDLE_INVALID==i2c_handle) return; + * conf_data.Reserved0 = 0; + * conf_data.eTransactionMode = VM_DCL_I2C_TRANSACTION_FAST_MODE; + * conf_data.fgGetHandleWait = 0; + * conf_data.Reserved1 = 0; + * conf_data.u1DelayLen = 0; + * conf_data.u1SlaveAddress = 0x98; + * conf_data.u4FastModeSpeed = 400; + * conf_data.u4HSModeSpeed = 0; + * vm_dcl_control(i2c_handle,VM_I2C_CMD_CONFIG,(void *)&conf_data); + * write_data.pu1Data = i2c_write_data; + * write_data.u4DataLen = 20; + * write_data.u4TransferNum = 1; + * vm_dcl_control(i2c_handle,I2C_CMD_SINGLE_WRITE,(void *)&write_data); + * read_data.pu1Data=i2c_read_data; + * read_data.u4DataLen = 20; + * read_data.u4TransferNum = 1; + * vm_dcl_control(i2c_handle,I2C_CMD_SINGLE_READ,(void *)&read_data); + * //Do something with the handle. + * + *****************************************************************************/ +typedef struct +{ + VMUINT8 *pu1Data; /* Pointer to the buffer of data */ + VMUINT32 u4DataLen; /* Data length of each transfer ,Note that this len should not exceed 8*/ + VMUINT32 u4TransferNum; /* Transfer number */ +}vm_i2c_ctrl_cont_write_t,vm_i2c_ctrl_cont_read_t; + + +/***************************************************************************** + * DESCRIPTION + * vm_i2c_ctrl_write_and_read_tindecates I2C_CMD_WRITE_AND_READ command command + * EXAMPLE + * + * VM_DCL_HANDLE i2c_handle; + * vm_i2c_ctrl_config_t conf_data; + * vm_i2c_ctrl_write_and_read_t write_and_read_data; + * vm_i2c_ctrl_cont_read_t read_data; + * VM_DCL_BUFF_LEN len; + * VMUINT8 i2c_write_data[20] = {0x56,0x78,0x00}; + * VMUINT8 i2c_read_data[20] = {0x0}; + * i2c_handle = vm_dcl_open(VM_DCL_I2C,0); + * if(VM_DCL_HANDLE_INVALID==i2c_handle) return; + * conf_data.Reserved0 = 0; + * conf_data.eTransactionMode = VM_DCL_I2C_TRANSACTION_FAST_MODE; + * conf_data.fgGetHandleWait = 0; + * conf_data.Reserved1 = 0; + * conf_data.u1DelayLen = 0; + * conf_data.u1SlaveAddress = 0x98; + * conf_data.u4FastModeSpeed = 400; + * conf_data.u4HSModeSpeed = 0; + * vm_dcl_control(i2c_handle,VM_I2C_CMD_CONFIG,(void *)&conf_data); + * write_and_read_data.pu1OutData = i2c_write_data; + * write_and_read_data.u4OutDataLen = 20; + * write_and_read_data.pu1InData = i2c_read_data; + * write_and_read_data.u4InDataLen = 20; + * vm_dcl_control(i2c_handle,I2C_CMD_WRITE_AND_READ,(void *)&write_and_read_data); + * //Do something with the handle. + * + *****************************************************************************/ + +typedef struct +{ + VMUINT8 *pu1InData; /* Pointer to the read data */ + VMUINT32 u4InDataLen; /* Read data length ,Note that this len should not exceed 8*/ + VMUINT8 *pu1OutData; /* Pointer to the write data */ + VMUINT32 u4OutDataLen; /* Write data length ,Note that this len should not exceed 8*/ +}vm_i2c_ctrl_write_and_read_t; + + +/***************************************************************************** + * DESCRIPTION + * vm_i2c_ctrl_set_slave_address_t indecates I2C_CMD_SET_SLAVE_ADDRESS command + * EXAMPLE + * + * VM_DCL_HANDLE i2c_handle; + * vm_i2c_ctrl_config_t conf_data; + * vm_i2c_ctrl_set_slave_address_t address_setting; + * i2c_handle = vm_dcl_open(VM_DCL_I2C,0); + * if(VM_DCL_HANDLE_INVALID==i2c_handle) return; + * conf_data.Reserved0 = 0; + * conf_data.eTransactionMode = VM_DCL_I2C_TRANSACTION_FAST_MODE; + * conf_data.fgGetHandleWait = 0; + * conf_data.Reserved1 = 0; + * conf_data.u1DelayLen = 0; + * conf_data.u1SlaveAddress = 0x98; + * conf_data.u4FastModeSpeed = 400; + * conf_data.u4HSModeSpeed = 0; + * vm_dcl_control(i2c_handle,VM_I2C_CMD_CONFIG,(void *)&conf_data); + * address_setting.u1SlaveAddress=0x98; + * vm_dcl_control(i2c_handle,I2C_CMD_GET_TRANSACTION_MODE,(void *)&address_setting); + * //Do something with the handle. + * + *****************************************************************************/ +typedef struct +{ + VMUINT8 u1SlaveAddress; /* Slave address */ +}vm_i2c_ctrl_set_slave_address_t; + + +/***************************************************************************** + * DESCRIPTION + * vm_i2c_ctrl_config_t indecates I2C_CMD_CONFIG command + * EXAMPLE + * + * VM_DCL_HANDLE i2c_handle; + * vm_i2c_ctrl_config_t conf_data; + * i2c_handle = vm_dcl_open(VM_DCL_I2C,0); + * if(VM_DCL_HANDLE_INVALID==i2c_handle) return; + *conf_data.Reserved0 = 0; + *conf_data.eTransactionMode = VM_DCL_I2C_TRANSACTION_FAST_MODE; + *conf_data.fgGetHandleWait = 0; + *conf_data.Reserved1 = 0; + *conf_data.u1DelayLen = 0; + *conf_data.u1SlaveAddress = 0x98; + *conf_data.u4FastModeSpeed = 400; + *conf_data.u4HSModeSpeed = 0; + *vm_dcl_control(i2c_handle,VM_I2C_CMD_CONFIG,(void *)&conf_data); + * //Do something with the handle. + * + *****************************************************************************/ +typedef struct +{ + VM_DCL_I2C_OWNER Reserved0; /* Reserved, please use 0 */ + VMBOOL fgGetHandleWait; /* KAL_TRUE: wait until I2C is idle; KAL_FALSE: do not wait */ + VMUINT8 u1SlaveAddress; /* Slave address */ + VMUINT8 u1DelayLen; /* Wait delay between consecutive transfers (the unit is half pulse width) */ + VM_DCL_I2C_TRANSACTION_MODE eTransactionMode; /* Fast mode or high speed mode */ + VMUINT32 u4FastModeSpeed; /* The transfer speed under fast mode. But even under high speed mode, you should alse configure this parameter */ + VMUINT32 u4HSModeSpeed; /* The transfer speed under high speed mode */ + VMBOOL Reserved1; /* Reserved,please always use 0 to fill this member. */ +} vm_i2c_ctrl_config_t; + +#endif + + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmdcl_pmu.h b/hardware/arduino/mtk/system/libmtk/include/vmdcl_pmu.h new file mode 100644 index 00000000..71c6e9a8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmdcl_pmu.h @@ -0,0 +1,269 @@ + +#ifndef __VM_DCL_PMU_H_STRUCT__ +#define __VM_DCL_PMU_H_STRUCT__ + + +/*Define the dev for PMU module. Used in dcl_open*/ +typedef enum +{ + VM_DCL_PMU_START = VM_DCL_PMU_GROUP_START, + VM_DCL_PMU +}VM_DCL_PMU_DEV_T; + + +/* Enum of VM_LDO/BUCK List */ +typedef enum +{ + VM_VA12, //VM_VA12 + VM_VRTC, //VM_VRTC + VM_VMIC, //VM_VMIC + VM_VAUDN, //VM_VAUDN + VM_VAUDP, //VM_VAUDP + VM_VRF28, //VM_VRF28 + VM_VRF=VM_VRF28, //VM_VRF + VM_VTCXO, //VM_VTCXO + VM_VA25, //VM_VA25 + VM_VCAMA, //VM_VCAMA + VM_VCAMD, //VM_VCAMD + VM_VCAM_IO, //VM_VCAM_IO + VM_VCAM_AF, //VM_VCAM_AF + VM_VIO28, //VM_VIO28 + VM_VUSB, //VM_VUSB + VM_VBT, //VM_VBT + VM_VSIM, //VM_VSIM + VM_VSIM1 = VM_VSIM, //VM_VSIM1 + VM_VSIM2, //VM_VSIM2 + VM_VIBR, //VM_VIBR + VM_VMC, //VM_VMC + VM_VMC1, //VM_VMC1 + VM_VCAMA2, //VM_VCAMA2 + VM_VCAMD2, //VM_VCAMD2 + VM_VFM, //VM_VFM + VM_VM12, //VM_VM12 + VM_VM12_1, //VM_VM12_1 + VM_VM12_2, //VM_VM12_2 + VM_VM12_INT, //VM_VM12_INT + VM_VCORE, //VM_VCORE + VM_VCORE2, //VM_VCORE2 + VM_VIO18, //VM_VIO18 + VM_VPA_SW, //VM_VPA_SW + VM_VPROC, //VM_VPROC + VM_VRF18, //VM_VRF18 + VM_VA, //VM_VA + VM_VA28 = VM_VA, //VM_VA28 + VM_VM, //VM_VM + VM_VSF, //VM_VSF + VM_VWIFI2V8, //VM_VWIFI2V8 + VM_VWIFI3V3, //VM_VWIFI3V3 + VM_V3GTX, //VM_V3GTX + VM_V3GRX, //VM_V3GRX + VM_VGP, //VM_VGP + VM_VGP2, //VM_VGP2 + VM_VSDIO, //VM_VSDIO + VM_VDIG, //VM_VDIG + VM_VBUS, //VM_VBUS + VM_VA1, //VM_VA1 + VM_VA2, //VM_VA2 + VM_VBACKUP, //VM_VBACKUP + VM_VM_PMU_LDO_BUCK_MAX //VM_VM_PMU_LDO_BUCK_MAX +}VM_PMU_LDO_BUCK_LIST_ENUM; + + +/* Enum of LDO/BUCK List */ +typedef enum +{ + VM_VGPIO0, + VM_VGPIO1, + VM_VGPIO2, + VM_VGPIO3, + VM_VGPIO4, + VM_VGPIO5, + VM_VGPIO6, + VM_VGPIO7, + VM_VGPIO8, + VM_VGPIO9, + VM_VGPIO10, + VM_VGPIO11, + VM_VGPIO12, + VM_VGPIO13, + VM_VGPIO14, + VM_VGPIO15, + VM_VGPIO16, + VM_VGPIO17, + VM_VGPIO18, + VM_VGPIO19, + VM_VGPIO20, + VM_VGPIO21, + VM_VGPIO22, + VM_VGPIO23, + VM_VGPIO24, + VM_VGPIO25, + VM_VGPIO26, + VM_VGPIO27, + VM_VGPIO28, + VM_VGPIO29, + VM_VGPIO30, + VM_VGPIO31, + VM_VGPIO32, + VM_VGPIO33, + VM_VGPIO34, + VM_VGPIO35, + VM_VGPIO36, + VM_VGPIO37, + VM_VGPIO38, + VM_VGPIO39, + VM_VGPIO40, + VM_VGPIO41, + VM_VGPIO42, + VM_VGPIO43, + VM_VGPIO44, + VM_VGPIO45, + VM_VGPIO46, + VM_VGPIO47, + VM_VGPIO48, + VM_VGPIO49, + VM_VGPIO50, + VM_VGPIO51, + VM_VGPIO52, + VM_VGPIO53, + VM_VGPIO54, + VM_VGPIO55, + VM_VGPIO56, + VM_VGPIO57, + VM_VGPIO58, + VM_VGPIO59, + VM_VGPIO60, + VM_VGPIO61, + VM_VGPIO62, + VM_VGPIO63, + VM_VGPIO64, + VM_VGPIO65, + VM_VGPIO66, + VM_VGPIO67, + VM_VGPIO68, + VM_VGPIO69, + VM_VGPIO70, + VM_VGPIO71, + VM_VGPIO72, + VM_VGPIO73, + VM_VGPIO74, + VM_VGPIO75, + VM_VGPIO76, + VM_VGPIO77, + VM_VGPIO78, + VM_VGPIO79, + VM_VGPIO80, + VM_VGPIO81, + VM_VGPIO82, + VM_VGPIO83, + VM_VGPIO84, + VM_VGPIO85, + VM_VGPIO86, + VM_VGPIO87, + VM_VGPIO88, + VM_VGPIO89, + VM_VGPIO90, + VM_VGPIO91, + VM_VGPIO92, + VM_VGPIO93, + VM_VGPIO94, + VM_VGPIO95, + VM_VGPIO96, + VM_VGPIO97, + VM_VGPIO98, + VM_VGPIO99, + VM_VGPIO100, + PMU_LDO_BUCK_GPIO_POWER_MAX +}VM_PMU_LDO_BUCK_GPIO_POWER_LIST_ENUM; + +/* PMU Driver command list */ +typedef enum +{ + VM_PMU_CTRL_CMD_LDO_BUCK_SET_EN = 0x2, /* Command to enable ldo/buck , use structure VM_PMU_CTRL_LDO_BUCK_SET_EN */ + VM_PMI_CTRL_CMD_LDO_BUCK_SET_GPIO_POWER_EN = 0x1006, /* command open gpio power */ + VM_KPLED_SET_EN = 3000 /* Command to enable kpled, use structure VM_PMU_CTRL_KPLED_SET_EN */ +}VM_DCL_PMU_CTRL_CMD_T; + + + /***************************************************************************** + * Description + * This struct is for VM_PMU_CTRL_CMD_LDO_BUCK_SET_EN command + * EXAMPLE + * + * //This example explain how to enable the LDO (example VM_VMC) + * VM_DCL_HANDLE handle; + * VM_PMU_CTRL_LDO_BUCK_SET_EN val; + * + * handle = vm_dcl_open(VM_DCL_PMU, 0); + * + * val.enable = KAL_TRUE; // enable , KAL_FLASE : disable + * val.mod = VM_VMC; // LDO + * + * vm_dcl_control(handle, VM_PMU_CTRL_LDO_BUCK_SET_EN, (void *)&val); + * vm_dcl_close(handle); + * + * + *****************************************************************************/ +typedef struct +{ + VM_PMU_LDO_BUCK_LIST_ENUM mod; /* LDO, please reference VM_PMU_LDO_BUCK_LIST_ENUM */ + VMBOOL enable; /* Enalbe or not */ +}VM_PMU_CTRL_LDO_BUCK_SET_EN; + + + /***************************************************************************** + * Description + * This struct is for VM_PMI_CTRL_CMD_LDO_BUCK_SET_GPIO_POWER_EN command + * EXAMPLE + * + * //This example explain how to enable gpio power (example VGPIO40) + * VM_DCL_HANDLE handle; + * VM_PMI_CTRL_CMD_LDO_BUCK_SET_GPIO_POWER_EN val; + * + * handle = vm_dcl_open(VM_DCL_PMU, 0); + * + * val.enable = KAL_TRUE; // enable , KAL_FLASE : disable + * val.mod = VM_VGPIO40; // gpio number + * + * vm_dcl_control(handle, VM_PMI_CTRL_CMD_LDO_BUCK_SET_GPIO_POWER_EN, (void *)&val); + * vm_dcl_close(handle); + * + * + *****************************************************************************/ + + typedef struct + { + VM_PMU_LDO_BUCK_GPIO_POWER_LIST_ENUM gpionum; + VMBOOL enable; + }PMU_CTRL_LDO_BUCK_SET_GPIO_POWER_EN; + + + /***************************************************************************** + * Description + * This struct is for VM_PMU_CTRL_KPLED_SET_EN command. + * EXAMPLE + * + * //This example explain how to enable the LDO (example VM_VMC) + * VM_DCL_HANDLE handle; + * VM_PMU_CTRL_KPLED_SET_EN val; + * + * handle = vm_dcl_open(VM_DCL_PMU, 0); + * + * val.enable = KAL_TRUE; // enable , KAL_FLASE : disable + * + * vm_dcl_control(handle, VM_PMU_CTRL_KPLED_SET_EN, (void *)&val); + * vm_dcl_close(handle); + * + * + *****************************************************************************/ + typedef struct + { + VMBOOL enable; /* Enable or not */ + }VM_PMU_CTRL_KPLED_SET_EN; + + + + + +#endif // #ifndef __VM_DCL_VM_PMU_H_PROTOTYPE__ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmdcl_pwm.h b/hardware/arduino/mtk/system/libmtk/include/vmdcl_pwm.h new file mode 100644 index 00000000..b0ce4f11 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmdcl_pwm.h @@ -0,0 +1,91 @@ +#ifndef _VM_DCL_PWM_H_ +#define _VM_DCL_PWM_H_ + + +/****************************************************************** +* DESCRIPTION +* This enum defines the device for PWM module,used in vm_dcl_open as a parameter. +* To control PWM, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vm_dcl.h" +* VM_DCL_HANDLE pwm_handle; // Declare a VM_DCL_HANDLE variable. +* pwm_handle = vm_dcl_open(VM_DCL_KPLED_PWM,0); // Call vm_dcl_open to get a handle. +* +*******************************************************************/ +typedef enum +{ + VM_DCL_PWM_START = VM_DCL_PWM_GROUP_START, /*PWM device start*/ + VM_DCL_KPLED_PWM, /*This device is used to control keypad LED PWM.*/ + + + VM_DCL_HW_PWM_GROUP_START = (VM_DCL_PWM_GROUP_START+0x20), + VM_DCL_PWM1, /* control pwm1 */ + VM_DCL_PWM_RESERVED2, /* Reserved, do not use. */ + VM_DCL_PWM_RESERVED3, /* Reserved, do not use. */ + VM_DCL_PWM4, /* control pwm4 */ +}VM_DCL_PWM_DEV_T; + +/****************************************************************** +* DESCRIPTION +* This enum define the control command for PWM module,used in vm_dcl_control as parameter. +* With different commands, user could control the different function of the PWM. +* To control PWM, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vm_dcl.h" +* VM_DCL_HANDLE pwm_handle; // Declare a VM_DCL_HANDLE variable. +* VM_PWM_LEVEL_T pwm_level_var; +* pwm_handle = vm_dcl_open(VM_DCL_KPLED_PWM,0); // First, we call vm_dcl_open to get a handle. the second parameter always fill 0. +* pwm_level_var.pwm_level = 2; +* vm_dcl_control(pwm_handle,VM_PWM_CMD_SET_LEVEL,(void *)(&pwm_level_var)); // we call vm_dcl_control to set the kpled full brightness. +* vm_dcl_close(pwm_handle); // Finally, we call vm_dcl_close +* +*******************************************************************/ + +typedef enum +{ + VM_PWM_CMD_START = 0xD06, /*For hw pwm control only*/ + VM_PWM_CMD_STOP = 0xD07, /*For hw pwm control only*/ + VM_PWM_CMD_SET_LEVEL = 0xD0C, /* for VM_DCL_KPLED_PWM only,nowadays, The keypad led only support 3 levels:0,1,2. 0 means stop pwm, 1 means 50% of brightness, 2 means 100% of brightness.*/ + VM_PWM_CMD_CONFIG = 0xD14, /*For hw pwm control only*/ + VM_PWM_CMD_SET_CLK = 0xD1B, /*For hw pwm control only*/ + VM_PWM_CMD_SET_COUNTER_AND_THRESHOLD = 0xD1C,/*For hw pwm control only*/ + +}VM_DCL_PWM_CTRL_CMD_T; + + +/****************************************************************** +* DESCRIPTION +* This struct is for VM_PWM_CMD_SET_LEVEL control command,used in vm_dcl_control as parameter. +* With this command, you can set the brightness of the keypad led PWM. +* You can find the sample code in the description of VM_DCL_PWM_CTRL_CMD_T. +* All commands have similar usage. +*******************************************************************/ + +typedef struct +{ + VMUINT8 pwm_level; /*nowadays, The keypad led only support 3 levels:0,1,2. 0 means stop pwm, 1 means 50% of brightness, 2 means 100% of brightness.*/ +}VM_PWM_LEVEL_T; + +typedef struct +{ + VMUINT32 freq; // the PWM channel output frequency. + VMUINT8 duty; // the duty cycle of the high level under the periodical output. +}VM_PWM_CONFIG_T; + +typedef struct +{ + VMUINT8 source_clk; // 0 means 13Mhz, 1means 32K + VMUINT8 source_clk_div; // 0 means 0 div, 1 means 2 div, 2 means 4 div, 3 means 8 div. +}VM_PWM_SET_CLOCK_T; + +typedef struct +{ + VMUINT16 counter; // 0 means 13Mhz, 1means 32K + VMUINT16 threshold; // 0 means 0 div, 1 means 2 div, 2 means 4 div, 3 means 8 div. +}VM_PWM_SET_COUNTER_THRESHOLD_T; + + +#endif + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmdcl_sio.h b/hardware/arduino/mtk/system/libmtk/include/vmdcl_sio.h new file mode 100644 index 00000000..29fc8497 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmdcl_sio.h @@ -0,0 +1,439 @@ +#ifndef __VM_DCL_SIO_H__ +#define __VM_DCL_SIO_H__ + +/***************************************************************************** + * DESCRIPTION + * vm_uart_ready_to_write_ind_struct is the meassge struct which inform + * user to write data ,user can get port information from this content + *****************************************************************************/ +typedef struct +{ + VMUINT8 ref_count; + VMUINT16 msg_len; /* LOCAL_PARA_HDR */ + VMUINT16 port; /*uart port*/ +}vm_uart_ready_to_write_ind_struct; + + +/***************************************************************************** + * DESCRIPTION + * vm_uart_ready_to_read_ind_struct is the meassge struct which inform + * user to write data ,user can get port information from this content + *****************************************************************************/ +typedef struct +{ + VMUINT8 ref_count; + VMUINT16 msg_len; /* LOCAL_PARA_HDR */ + VMUINT16 port; /*uart port*/ +}vm_uart_ready_to_read_ind_struct; + + +/***************************************************************************** + * DESCRIPTION + * VM_DCL_SIO_DEV_T is the seriport type ENUM, user can select one of + * the devices to use + * EXAMPLE + * + * DCL_HANDLE uart_handle; + * VM_DCL_MODULE_TYPE_T usr_id; + * usr_id = vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * if(VM_DCL_HANDLE_INVALID==uart_handle) return; + * //Do something with the handle. + * + *****************************************************************************/ +typedef enum +{ + vm_uart_port1 = VM_DCL_SIO_GROUP_START, /*uart port1*/ + vm_uart_port2, /*uart port2*/ + vm_uart_port3, /*uart port3*/ + vm_uart_port_reserved, /*uart reserved*/ + vm_usb_port1, /*usb port1*/ + vm_usb_port2 /*usb port2*/ +} VM_DCL_SIO_DEV_T; + + +/************************************************************************************************************ + * DESCRIPTION + * VM_DCL_SIO_EVENT_T is the event type ENUM, user can select one of + * the event to use, every event is matched with the callback user defined + * EXAMPLE + * + * DCL_HANDLE uart_handle; + * VM_DCL_MODULE_TYPE_T usr_id; + * usr_id = vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * if(VM_DCL_HANDLE_INVALID==uart_handle) return; + * vm_dcl_registercallback(uart_handle,VM_UART_READY_TO_WRITE ,(VM_DCL_CALLBACK)uart_callback,(void *)NULL); + * //uart_callback is defined by user + * + **************************************************************************************************************/ +typedef enum +{ + VM_UART_READY_TO_READ = VM_SERIPORT_EVENTS_START, /*uart read event*/ + VM_UART_READY_TO_WRITE /*uart write event*/ +} VM_DCL_SIO_EVENT_T; + + +/************************************************************************************************************ + * DESCRIPTION + * VM_DCL_SIO_CTRL_CMD is the CMD type ENUM, user can use VM_SIO_CMD_SET_DCB_CONFIG + * command to config uart driver + * EXAMPLE + * + * DCL_HANDLE uart_handle; + * VM_DCL_MODULE_TYPE_T usr_id; + * vm_sio_ctrl_dcb_t config; + * usr_id = vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * if(VM_DCL_HANDLE_INVALID==uart_handle) return; + * config.u4OwenrId = usr_id; + * config.rUARTConfig.fgDSRCheck = 0; + * config.rUARTConfig.u1DataBits = VM_LEN_8; + * config.rUARTConfig.u1FlowControl = VM_FC_NONE; + * config.rUARTConfig.u1Parity = VM_PA_NONE; + * config.rUARTConfig.u1StopBits = VM_SB_1; + * config.rUARTConfig.u4Baud = VM_UART_BAUD_115200; + * config.rUARTConfig.ucXoffChar = 0x13; + * config.rUARTConfig.ucXonChar = 0x11; + * vm_dcl_control(uart_handle,VM_SIO_CMD_SET_DCB_CONFIG,&config); + * //uart_callback is defined by user + * + **************************************************************************************************************/ + + typedef enum + { + VM_SIO_CMD_SET_DCB_CONFIG = 0xd /*uart setting*/ + }VM_DCL_SIO_CTRL_CMD; + + + +/***************************************************************************** + * DESCRIPTION + * VM_UART_BAUDRATE_T is the type of uart buadrate,which is a member of + * vm_sio_config_t + *****************************************************************************/ +typedef VMUINT32 VM_UART_BAUDRATE_T; + +/***************************************************************************** + * DESCRIPTION + * VM_UART_baudrate is the type of VMUINT32,which define the type UART BUADRATE + * user set + *****************************************************************************/ +typedef VMUINT32 VM_UART_baudrate; + +/***************************************************************************** + * DESCRIPTION + * VM_UART_PORT is the type of VMUINT16 ,which define the type UART_PORT + * user select + *****************************************************************************/ +typedef VMUINT16 VM_UART_PORT; + + + +/***************************************************************************** + * DESCRIPTION + * VM_UART_BAUD_XXX is the VALUE of VM_UART_BAUDRATE_T type,use can select one + * of these vaules to config + *****************************************************************************/ +#define VM_UART_BAUD_AUTO 0 /*AUTO BUADRATE*/ +#define VM_UART_BAUD_75 75 /*BUADRATE 75*/ +#define VM_UART_BAUD_150 150 /*BUADRATE 150*/ +#define VM_UART_BAUD_300 300 /*BUADRATE 300*/ +#define VM_UART_BAUD_600 600 /*BUADRATE 600*/ +#define VM_UART_BAUD_1200 1200 /*BUADRATE 1200*/ +#define VM_UART_BAUD_2400 2400 /*BUADRATE 2400*/ +#define VM_UART_BAUD_4800 4800 /*BUADRATE 4800*/ +#define VM_UART_BAUD_7200 7200 /*BUADRATE 7200*/ +#define VM_UART_BAUD_9600 9600 /*BUADRATE 9600*/ +#define VM_UART_BAUD_14400 14400 /*BUADRATE 14400*/ +#define VM_UART_BAUD_19200 19200 /*BUADRATE 19200*/ +#define VM_UART_BAUD_28800 28800 /*BUADRATE 28800*/ +#define VM_UART_BAUD_33900 33900 /*BUADRATE 33900*/ +#define VM_UART_BAUD_38400 38400 /*BUADRATE 38400*/ +#define VM_UART_BAUD_57600 57600 /*BUADRATE 57600*/ +#define VM_UART_BAUD_115200 115200 /*BUADRATE 115200*/ +#define VM_UART_BAUD_230400 230400 /*BUADRATE 230400*/ +#define VM_UART_BAUD_460800 460800 /*BUADRATE 460800*/ +#define VM_UART_BAUD_921600 921600 /*BUADRATE 921600*/ +#define VM_UART_BAUD_1500000 1500000 /*BUADRATE 1500000*/ + + +/************************************************************************************************************ + * DESCRIPTION + * VM_UART_BITS_PER_CHAR_T is the DATA_LENGTH type ENUM, user can set DATA_LENGTH + * to config uart driver + * EXAMPLE + * + * DCL_HANDLE uart_handle; + * VM_DCL_MODULE_TYPE_T usr_id; + * vm_sio_ctrl_dcb_t config; + * usr_id = vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * if(VM_DCL_HANDLE_INVALID==uart_handle) return; + * config.u4OwenrId = usr_id; + * config.rUARTConfig.fgDSRCheck = 0; + * config.rUARTConfig.u1DataBits = VM_LEN_8; + * config.rUARTConfig.u1FlowControl = VM_FC_NONE; + * config.rUARTConfig.u1Parity = VM_PA_NONE; + * config.rUARTConfig.u1StopBits = VM_SB_1; + * config.rUARTConfig.u4Baud = VM_UART_BAUD_115200; + * config.rUARTConfig.ucXoffChar = 0x13; + * config.rUARTConfig.ucXonChar = 0x11; + * vm_dcl_control(uart_handle,VM_SIO_CMD_SET_DCB_CONFIG,&config); + * //uart_callback is defined by user + * + **************************************************************************************************************/ +typedef enum { + VM_LEN_5=5, /* 5 DATA LENGTH*/ + VM_LEN_6, /* 6 DATA LENGTH*/ + VM_LEN_7, /* 7 DATA LENGTH*/ + VM_LEN_8 /* 8 DATA LENGTH*/ +} VM_UART_BITS_PER_CHAR_T; + + +/************************************************************************************************************ + * DESCRIPTION + * VM_UART_STOP_BITS_T is the STOP_BIT type ENUM, user can set STOP_BIT + * to config uart driver + * EXAMPLE + * + * DCL_HANDLE uart_handle; + * VM_DCL_MODULE_TYPE_T usr_id; + * vm_sio_ctrl_dcb_t config; + * usr_id = vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * if(VM_DCL_HANDLE_INVALID==uart_handle) return; + * config.u4OwenrId = usr_id; + * config.rUARTConfig.fgDSRCheck = 0; + * config.rUARTConfig.u1DataBits = VM_LEN_8; + * config.rUARTConfig.u1FlowControl = VM_FC_NONE; + * config.rUARTConfig.u1Parity = VM_PA_NONE; + * config.rUARTConfig.u1StopBits = VM_SB_1; + * config.rUARTConfig.u4Baud = VM_UART_BAUD_115200; + * config.rUARTConfig.ucXoffChar = 0x13; + * config.rUARTConfig.ucXonChar = 0x11; + * vm_dcl_control(uart_handle,VM_SIO_CMD_SET_DCB_CONFIG,&config); + * //uart_callback is defined by user + * + **************************************************************************************************************/ +typedef enum { + VM_SB_1=1, /* 1 STOP BIT*/ + VM_SB_2, /* 2 STOP BIT*/ + VM_SB_1_5 /* 3 STOP BIT*/ +} VM_UART_STOP_BITS_T; + + +/************************************************************************************************************ + * DESCRIPTION + * VM_UART_PARITY_T is the PARITY type ENUM, user can set PARITY + * to config uart driver + * EXAMPLE + * + * DCL_HANDLE uart_handle; + * VM_DCL_MODULE_TYPE_T usr_id; + * vm_sio_ctrl_dcb_t config; + * usr_id = vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * if(VM_DCL_HANDLE_INVALID==uart_handle) return; + * config.u4OwenrId = usr_id; + * config.rUARTConfig.fgDSRCheck = 0; + * config.rUARTConfig.u1DataBits = VM_LEN_8; + * config.rUARTConfig.u1FlowControl = VM_FC_NONE; + * config.rUARTConfig.u1Parity = VM_PA_NONE; + * config.rUARTConfig.u1StopBits = VM_SB_1; + * config.rUARTConfig.u4Baud = VM_UART_BAUD_115200; + * config.rUARTConfig.ucXoffChar = 0x13; + * config.rUARTConfig.ucXonChar = 0x11; + * vm_dcl_control(uart_handle,VM_SIO_CMD_SET_DCB_CONFIG,&config); + * //uart_callback is defined by user + * + **************************************************************************************************************/ +typedef enum { + VM_PA_NONE=0, + VM_PA_ODD, + VM_PA_EVEN, + VM_PA_MARK, + VM_PA_SPACE +} VM_UART_PARITY_T; + +/************************************************************************************************************ + * DESCRIPTION + * VM_UART_FLOW_CTRL_MODE_T is the FLOW CONTROL type ENUM, user can set flow control + * to config uart driver + * EXAMPLE + * + * DCL_HANDLE uart_handle; + * VM_DCL_MODULE_TYPE_T usr_id; + * vm_sio_ctrl_dcb_t config; + * usr_id = vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * if(VM_DCL_HANDLE_INVALID==uart_handle) return; + * config.u4OwenrId = usr_id; + * config.rUARTConfig.fgDSRCheck = 0; + * config.rUARTConfig.u1DataBits = VM_LEN_8; + * config.rUARTConfig.u1FlowControl = VM_FC_NONE; + * config.rUARTConfig.u1Parity = VM_PA_NONE; + * config.rUARTConfig.u1StopBits = VM_SB_1; + * config.rUARTConfig.u4Baud = VM_UART_BAUD_115200; + * config.rUARTConfig.ucXoffChar = 0x13; + * config.rUARTConfig.ucXonChar = 0x11; + * vm_dcl_control(uart_handle,VM_SIO_CMD_SET_DCB_CONFIG,&config); + * //uart_callback is defined by user + * + **************************************************************************************************************/ +typedef enum { + VM_FC_NONE=1, /*none flow control*/ + VM_FC_HW, /*hw flow control*/ + VM_FC_SW /*sw flow control*/ +} VM_UART_FLOW_CTRL_MODE_T; + + +/************************************************************************************************************ + * DESCRIPTION + * vm_sio_config_t is the seriport config type struct, which is one member of vm_sio_ctrl_dcb_t struct. + * user can set the members to config uart driver + * EXAMPLE + * + * DCL_HANDLE uart_handle; + * VM_DCL_MODULE_TYPE_T usr_id; + * vm_sio_ctrl_dcb_t config; + * usr_id = vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * if(VM_DCL_HANDLE_INVALID==uart_handle) return; + * config.u4OwenrId = usr_id; + * config.rUARTConfig.fgDSRCheck = 0; + * config.rUARTConfig.u1DataBits = VM_LEN_8; + * config.rUARTConfig.u1FlowControl = VM_FC_NONE; + * config.rUARTConfig.u1Parity = VM_PA_NONE; + * config.rUARTConfig.u1StopBits = VM_SB_1; + * config.rUARTConfig.u4Baud = VM_UART_BAUD_115200; + * config.rUARTConfig.ucXoffChar = 0x13; + * config.rUARTConfig.ucXonChar = 0x11; + * vm_dcl_control(uart_handle,VM_SIO_CMD_SET_DCB_CONFIG,&config); + * //uart_callback is defined by user + * + **************************************************************************************************************/ + typedef struct +{ + VM_UART_BAUDRATE_T u4Baud; /*baudrate-->like VM_UART_BAUD_150 or VM_UART_BAUD_1500000*/ + VMUINT8 u1DataBits; /*data bit--> VM_UART_BITS_PER_CHAR_T*/ + VMUINT8 u1StopBits; /*stop bit-->VM_UART_STOP_BITS_T*/ + VMUINT8 u1Parity; /*parity-->VM_UART_PARITY_T*/ + VMUINT8 u1FlowControl; /*flow control-->VM_UART_FLOW_CTRL_MODE_T*/ + VMUCHAR ucXonChar; /*SW Xon flow control-->if your HW not support SW flowcontrol,please write 0x0*/ + VMUCHAR ucXoffChar; /*SW Xoff flow control-->if your HW not support SW flowcontrol,please write 0x0*/ + VMBOOL fgDSRCheck; /*DSR check-->please write 0x0*/ +}vm_sio_config_t; + + +/************************************************************************************************************ + * DESCRIPTION + * vm_sio_config_t is the seriport config type struct, user can set the members + * to config uart driver + * EXAMPLE + * + * DCL_HANDLE uart_handle; + * VM_DCL_MODULE_TYPE_T usr_id; + * vm_sio_ctrl_dcb_t config; + * usr_id = vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * if(VM_DCL_HANDLE_INVALID==uart_handle) return; + * config.u4OwenrId = usr_id; + * config.rUARTConfig.fgDSRCheck = 0; + * config.rUARTConfig.u1DataBits = VM_LEN_8; + * config.rUARTConfig.u1FlowControl = VM_FC_NONE; + * config.rUARTConfig.u1Parity = VM_PA_NONE; + * config.rUARTConfig.u1StopBits = VM_SB_1; + * config.rUARTConfig.u4Baud = VM_UART_BAUD_115200; + * config.rUARTConfig.ucXoffChar = 0x13; + * config.rUARTConfig.ucXonChar = 0x11; + * vm_dcl_control(uart_handle,VM_SIO_CMD_SET_DCB_CONFIG,&config); + * //uart_callback is defined by user + * + **************************************************************************************************************/ + typedef struct +{ + VMUINT32 u4OwenrId; /*uart's owner id */ + vm_sio_config_t rUARTConfig; /*user config setting */ +} vm_sio_ctrl_dcb_t; + + + +/************************************************************************************************************ + * DESCRIPTION + * vm_sio_ctrl_open_t is the UART owner ID + * EXAMPLE + * + * DCL_HANDLE uart_handle; + * VM_DCL_MODULE_TYPE_T usr_id; + * vm_sio_ctrl_dcb_t config; + * usr_id = vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * if(VM_DCL_HANDLE_INVALID==uart_handle) return; + **************************************************************************************************************/ +typedef struct +{ + VMUINT32 u4OwenrId; /*uart's owner id */ +}vm_sio_ctrl_open_t; + + + +/************************************************************************************************************ + * DESCRIPTION + * vm_sio_ctrl_put_bytes_t is the struct of putting uart data. + * EXAMPLE + * + * DCL_HANDLE uart_handle; + * VM_DCL_MODULE_TYPE_T usr_id; + * vm_sio_ctrl_put_bytes_t data; + * vm_sio_ctrl_dcb_t config; + * usr_id = vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * if(VM_DCL_HANDLE_INVALID==uart_handle) return; + data.u2Length=2048; + data.u4OwenrId=usr_id; + data.puBuffaddr=data_buffer; + * vm_dcl_write(uart_handle,(VM_DCL_BUFF*)data_buffer,2048,&writen_len,usr_id); + **************************************************************************************************************/ +typedef struct +{ + VMUINT16 u2Length; /*uart's data length */ + VMUINT32 u4OwenrId; /*uart's owner id */ + VMUINT16 u2RetSize; /*uart's sent data size */ + VMUINT8* puBuffaddr; /*uart's buffer address */ +}vm_sio_ctrl_put_bytes_t; + + +/************************************************************************************************************ + * DESCRIPTION + * vm_sio_ctrl_get_bytes_t is the struct of getting uart data. + * EXAMPLE + * + * DCL_HANDLE uart_handle; + * VM_DCL_MODULE_TYPE_T usr_id; + * vm_sio_ctrl_put_bytes_t data; + * vm_sio_ctrl_dcb_t config; + * usr_id = vm_dcl_get_ownerid(); + * uart_handle = vm_dcl_open(vm_uart_port1,usr_id); + * if(VM_DCL_HANDLE_INVALID==uart_handle) return; + data.u2Length=2048; + data.u4OwenrId=usr_id; + data.puBuffaddr=data_buffer; + * vm_dcl_read(uart_handle,(VM_DCL_BUFF*)data_buffer,1024,&returned_len,usr_id); + **************************************************************************************************************/ +typedef struct +{ + VMUINT16 u2Length; /*uart's data length */ + VMUINT32 u4OwenrId; /*uart's owner id */ + VMUINT16 u2RetSize; /*uart's get data size */ + VMUINT8* puBuffaddr; /*uart's buffer address */ + VMUINT8* pustatus; /*uart's status */ + +}vm_sio_ctrl_get_bytes_t; + + +#endif + + + + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmdcl_spi.h b/hardware/arduino/mtk/system/libmtk/include/vmdcl_spi.h new file mode 100644 index 00000000..24f93c15 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmdcl_spi.h @@ -0,0 +1,523 @@ + +#ifndef __VM_DCL_SPI_H__ +#define __VM_DCL_SPI_H__ + + +/***************************************************************************** + * DESCRIPTION + * VM_SPI_MAX_PORT_NUM indecates that this is the max port number which + * spi driver support + *****************************************************************************/ +#define VM_SPI_MAX_PORT_NUM 2 + + +/***************************************************************************** + * DESCRIPTION + * VM_DCL_SPI_DEV_T is the spi type ENUM, user can select one of + * the devices to use + * EXAMPLE + * + * VM_DCL_HANDLE spi_handle; + * spi_handle = vm_dcl_open(vm_spi_port0,0); + * if(VM_DCL_HANDLE_INVALID==spi_handle) return; + * //Do something with the handle. + * + *****************************************************************************/ +typedef enum +{ + vm_spi_port0 = VM_DCL_SPI_GROUP_START, /*spi 1*/ + vm_spi_port1 + +} VM_DCL_SPI_DEV_T; + +/************************************************************************************************************************************* + * DESCRIPTION + * SPI IOCTL code definition. + * EXAMPLE + * + * VM_DCL_HANDLE spi_handle; + * vm_spi_config_para_t conf_data; + * spi_handle = vm_dcl_open(vm_spi_port0,0); + * if(VM_DCL_HANDLE_INVALID==spi_handle) return; + * conf_data.clk_high_time = 5; + * conf_data.clk_low_time = 5; + * conf_data.cs_hold_time = 15; + * conf_data.cs_idle_time = 15; + * conf_data.cs_setup_time= 15; + * conf_data.clk_polarity = VM_SPI_CPOL_B0; + * conf_data.clk_fmt = VM_SPI_CPHA_B0; + * conf_data.rx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.tx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.rx_msbf = VM_SPI_MSBF_MSB; + * conf_data.tx_msbf = VM_SPI_MSBF_MSB; + * vm_dcl_control(spi_handle,VM_SPI_IOCTL_SET_CONFIG_PARA,(void *)&conf_data); + * //Do something with the handle. + * + *************************************************************************************************************************************/ +typedef enum +{ + + + VM_SPI_IOCTL_GET_PARAM=0, /* Get the current SPI configuration parameters.*/ + + VM_SPI_IOCTL_QUERY_CAPABILITY=1, /* Get the capability of current SPI hardware.*/ + + VM_SPI_IOCTL_QUERY_MODE_SUPPORT=2, /* Query supported SPI modes.*/ + + VM_SPI_IOCTL_QUERY_CLOCK=3, /* Query SPI base clock.*/ + + VM_SPI_IOCTL_SET_MODE=4, /* Set and configure SPI mode.*/ + + VM_SPI_IOCTL_GET_MODE=5, /* Get SPI mode settings.*/ + + VM_SPI_IOCTL_SET_CONFIG_PARA=8, /* Set SPI driving current.*/ + + VM_SPI_IOCTL_WRITE_AND_READ=9 /* Set SPI write and read .*/ + +} VM_SPI_IOCTL_CODE; + + +/************************************************************************************************************************************* + * DESCRIPTION + * VM_SPI_HAL_MODE indicates that which mode and functions SPI HW supports, user often use DEASSERT or PAUSE mode + * ULTRA_HIGH and SLOW_DOWN is little used beacause of these are used to ajust the spi ratio of EMI bandwith.GET_TICK is to adjust + * clock timing in order ro device can sample spi master's clock correctly when speed is very high + *************************************************************************************************************************************/ + +typedef enum +{ + /* Deassert mode. SPI CS pin will be pulled low and high for each byte during transmission. */ + VM_SPI_MODE_DEASSERT, + /* Pause mode. SPI CS pin is pulled low and keeps until specific amount of transfers have been finished. */ + VM_SPI_MODE_PAUSE, + /* Ultra high mode. Raise DMA priority during DMA transmission. */ + VM_SPI_MODE_ULTRA_HIGH, + /* Slow down mode. Slow down SPI DMA speed during DMA transmission. */ + VM_SPI_MODE_SLOW_DOWN, + /* Get tick delay mode. This mode is used to tuning SPI timing. */ + VM_SPI_MODE_GET_TICK +} VM_SPI_HAL_MODE; + +/************************************************************************************************************************************* + * DESCRIPTION + * VM_SPI_GET_TICK_E is the ENUM that set GET_TICK_DELAY1 or GET_TICK_DELAY2 + * EXAMPLE + * + * VM_DCL_HANDLE spi_handle; + * vm_spi_mode_t spi_data; + * spi_handle = vm_dcl_open(vm_spi_port0,0); + * if(VM_DCL_HANDLE_INVALID==spi_handle) return; + * spi_data.mode=VM_SPI_MODE_GET_TICK; + * spi_data.bEnable=KAL_TRUE; + * spi_data.param=VM_SPI_GET_TICK_DELAY1; + * vm_dcl_control(spi_handle,VM_SPI_IOCTL_SET_MODE,(void *)&spi_data); + * //Do something with the handle. + * +*************************************************************************************************************************************/ +typedef enum +{ + /* Delay SCK for one clock. */ + VM_SPI_GET_TICK_DELAY1 = 1, + /* Delay SCK for two clocks. */ + VM_SPI_GET_TICK_DELAY2 = 2 +} VM_SPI_GET_TICK_E; + +/************************************************************************************************************************************* + * DESCRIPTION + * VM_SPI_MSBF_E indecates that SPI transimssion bit order definition + * EXAMPLE + * + * VM_DCL_HANDLE spi_handle; + * vm_spi_config_para_t conf_data; + * spi_handle = vm_dcl_open(vm_spi_port0,0); + * if(VM_DCL_HANDLE_INVALID==spi_handle) return; + * conf_data.clk_high_time = 5; + * conf_data.clk_low_time = 5; + * conf_data.cs_hold_time = 15; + * conf_data.cs_idle_time = 15; + * conf_data.cs_setup_time= 15; + * conf_data.clk_polarity = VM_SPI_CPOL_B0; + * conf_data.clk_fmt = VM_SPI_CPHA_B0; + * conf_data.rx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.tx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.rx_msbf = VM_SPI_MSBF_MSB; + * conf_data.tx_msbf = VM_SPI_MSBF_MSB; + * vm_dcl_control(spi_handle,VM_SPI_IOCTL_SET_CONFIG_PARA,(void *)&conf_data); + * //Do something with the handle. + * + *************************************************************************************************************************************/ +typedef enum +{ + /* Transfer LSB first. */ + VM_SPI_MSBF_LSB = 0, + /* Transfer MSB first. */ + VM_SPI_MSBF_MSB = 1 +} VM_SPI_MSBF_E; + +/************************************************************************************************************************************* + * DESCRIPTION + * VM_SPI_CPOL_E indecates that SPI clock polarity definition. + * EXAMPLE + * + * VM_DCL_HANDLE spi_handle; + * vm_spi_config_para_t conf_data; + * spi_handle = vm_dcl_open(vm_spi_port0,0); + * if(VM_DCL_HANDLE_INVALID==spi_handle) return; + * conf_data.clk_high_time = 5; + * conf_data.clk_low_time = 5; + * conf_data.cs_hold_time = 15; + * conf_data.cs_idle_time = 15; + * conf_data.cs_setup_time= 15; + * conf_data.clk_polarity = VM_SPI_CPOL_B0; + * conf_data.clk_fmt = VM_SPI_CPHA_B0; + * conf_data.rx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.tx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.rx_msbf = VM_SPI_MSBF_MSB; + * conf_data.tx_msbf = VM_SPI_MSBF_MSB; + * vm_dcl_control(spi_handle,VM_SPI_IOCTL_SET_CONFIG_PARA,(void *)&conf_data); + * //Do something with the handle. + * + *************************************************************************************************************************************/ +typedef enum +{ + /* CPOL = 0. */ + VM_SPI_CPOL_B0 = 0, + /* CPOL = 1. */ + VM_SPI_CPOL_B1 = 1 +} VM_SPI_CPOL_E; + + +/************************************************************************************************************************************* + * DESCRIPTION + * VM_SPI_CPHA_E indecates that SPI clock format definition. + * EXAMPLE + * + * VM_DCL_HANDLE spi_handle; + * vm_spi_config_para_t conf_data; + * spi_handle = vm_dcl_open(vm_spi_port0,0); + * if(VM_DCL_HANDLE_INVALID==spi_handle) return; + * conf_data.clk_high_time = 5; + * conf_data.clk_low_time = 5; + * conf_data.cs_hold_time = 15; + * conf_data.cs_idle_time = 15; + * conf_data.cs_setup_time= 15; + * conf_data.clk_polarity = VM_SPI_CPOL_B0; + * conf_data.clk_fmt = VM_SPI_CPHA_B0; + * conf_data.rx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.tx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.rx_msbf = VM_SPI_MSBF_MSB; + * conf_data.tx_msbf = VM_SPI_MSBF_MSB; + * vm_dcl_control(spi_handle,VM_SPI_IOCTL_SET_CONFIG_PARA,(void *)&conf_data); + * //Do something with the handle. + * + *************************************************************************************************************************************/ +typedef enum +{ + /* CPHA = 0. */ + VM_SPI_CPHA_B0 = 0, + /* CPHA = 1. */ + VM_SPI_CPHA_B1 = 1 +} VM_SPI_CPHA_E; + + +/************************************************************************************************************************************* + * DESCRIPTION + * VM_SPI_ENDIAN_E indecates that SPI data transfer byte order definition. + * EXAMPLE + * + * VM_DCL_HANDLE spi_handle; + * vm_spi_config_para_t conf_data; + * spi_handle = vm_dcl_open(vm_spi_port0,0); + * if(VM_DCL_HANDLE_INVALID==spi_handle) return; + * conf_data.clk_high_time = 5; + * conf_data.clk_low_time = 5; + * conf_data.cs_hold_time = 15; + * conf_data.cs_idle_time = 15; + * conf_data.cs_setup_time= 15; + * conf_data.clk_polarity = VM_SPI_CPOL_B0; + * conf_data.clk_fmt = VM_SPI_CPHA_B0; + * conf_data.rx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.tx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.rx_msbf = VM_SPI_MSBF_MSB; + * conf_data.tx_msbf = VM_SPI_MSBF_MSB; + * vm_dcl_control(spi_handle,VM_SPI_IOCTL_SET_CONFIG_PARA,(void *)&conf_data); + * //Do something with the handle. + * + *************************************************************************************************************************************/ + +typedef enum +{ + /* Use little endian. */ + VM_SPI_ENDIAN_LITTLE = 0, + /* Use big endian. */ + VM_SPI_ENDIAN_BIG = 1 +} VM_SPI_ENDIAN_E; + + + +/************************************************************************************************************************************* + * DESCRIPTION + * vm_spi_config_para_t indecates that SPI configuration parameters. + * EXAMPLE + * + * VM_DCL_HANDLE spi_handle; + * vm_spi_config_para_t conf_data; + * spi_handle = vm_dcl_open(vm_spi_port0,0); + * if(VM_DCL_HANDLE_INVALID==spi_handle) return; + * conf_data.clk_high_time = 5; + * conf_data.clk_low_time = 5; + * conf_data.cs_hold_time = 15; + * conf_data.cs_idle_time = 15; + * conf_data.cs_setup_time= 15; + * conf_data.clk_polarity = VM_SPI_CPOL_B0; + * conf_data.clk_fmt = VM_SPI_CPHA_B0; + * conf_data.rx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.tx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.rx_msbf = VM_SPI_MSBF_MSB; + * conf_data.tx_msbf = VM_SPI_MSBF_MSB; + * vm_dcl_control(spi_handle,VM_SPI_IOCTL_SET_CONFIG_PARA,(void *)&conf_data); + * //Do something with the handle. + * + *************************************************************************************************************************************/ +typedef struct +{ + /* CS setup time. Unit in count of SPI base clock. Range(0-255). + The chip select setup time = (cs_setup_time+1)*CLK_PERIOD, where CLK_PERIOD is the cycle time of the clock the SPI engine adopts. */ + VMUINT32 cs_setup_time; + /* CS hold time. Unit in count of SPI base clock. Range(0-255). + The chip select hold time = (cs_hold_time+1)*CLK_PERIOD. */ + VMUINT32 cs_hold_time; + /* CS idle time. Unit in count of SPI base clock. Range(0-255). + The chip select idle time between consecutive transaction = (cs_idle_time+1)*CLK_PERIOD. */ + VMUINT32 cs_idle_time; + /* SCK clock low time. Unit in count of SPI base clock. Range(0-255). + The SCK clock low time = (clk_low_time+1)*CLK_PERIOD. */ + VMUINT32 clk_low_time; + /* SCK clock high time. Unit in count of SPI base clock. Range(0-255). + The SCK clock high time = (clk_high_time+1)*CLK_PERIOD. */ + VMUINT32 clk_high_time; + /* Bit order setting for SPI output. */ + VM_SPI_MSBF_E tx_msbf; + /* Bit order setting for SPI input. */ + VM_SPI_MSBF_E rx_msbf; + /* Byte order setting for SPI output. */ + VM_SPI_ENDIAN_E tx_endian; + /* Byte order setting for SPI input. */ + VM_SPI_ENDIAN_E rx_endian; + /* SPI clock polarity. */ + VM_SPI_CPOL_E clk_polarity; + /* SPI clock format. */ + VM_SPI_CPHA_E clk_fmt; +} vm_spi_config_para_t; + +/************************************************************************************************************************************* + * DESCRIPTION + * VM_SPI_CTRL_WRITE_AND_READE_T indecates that SPI write and read operation. + * EXAMPLE + * + * VM_DCL_HANDLE spi_handle; + * vm_spi_config_para_t conf_data; + * spi_handle = vm_dcl_open(vm_spi_port0,0); + * if(VM_DCL_HANDLE_INVALID==spi_handle) return; + * conf_data.clk_high_time = 5; + * conf_data.clk_low_time = 5; + * conf_data.cs_hold_time = 15; + * conf_data.cs_idle_time = 15; + * conf_data.cs_setup_time= 15; + * conf_data.clk_polarity = VM_SPI_CPOL_B0; + * conf_data.clk_fmt = VM_SPI_CPHA_B0; + * conf_data.rx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.tx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.rx_msbf = VM_SPI_MSBF_MSB; + * conf_data.tx_msbf = VM_SPI_MSBF_MSB; + * VM_SPI_CTRL_WRITE_AND_READE_T write_and_read; + * write_and_read.pu1InData=in_buff; + * write_and_read.u4DataLen=10; + * write_and_read.pu1OutData=out_buff; + * write_and_read.uCount=1; + * vm_dcl_control(spi_handle,VM_SPI_IOCTL_SET_CONFIG_PARA,(void *)&conf_data); + * vm_dcl_control(spi_handle,VM_SPI_IOCTL_WRITE_AND_READ,(void *)&write_and_read); + * //Do something with the handle. + * + *************************************************************************************************************************************/ +typedef struct +{ + VMUINT8 *pu1InData; /* Pointer to the read data */ + VMUINT32 u4DataLen; /* Read data length */ + VMUINT8 *pu1OutData; /* Pointer to the write data */ + VMUINT32 uCount; /* Read data length */ +}VM_SPI_CTRL_WRITE_AND_READE_T; + +/************************************************************************************************************************************* + * DESCRIPTION + * vm_spi_capabilty_t indecates that SPI 's Capabilty which user can query,This structure is + * used as the parameter of VM_SPI_IOCTL_QUERY_CAPABILITY. + * EXAMPLE + * + * VM_DCL_HANDLE spi_handle; + * vm_spi_capabilty_t spi_data; + * spi_handle = vm_dcl_open(vm_spi_port0,0); + * if(VM_DCL_HANDLE_INVALID==spi_handle) return; + * vm_dcl_control(spi_handle,VM_SPI_IOCTL_QUERY_CAPABILITY,(void *)&spi_data); + * //Do something with the handle. + * + *************************************************************************************************************************************/ +typedef struct +{ + /* Minimum value for cs setup time. */ + VMUINT32 cs_setup_time_min; + /* Maximum value for cs setup time. */ + VMUINT32 cs_setup_time_max; + /* Minimum value for cs hold time. */ + VMUINT32 cs_hold_time_min; + /* Maximum value for cs hold time. */ + VMUINT32 cs_hold_time_max; + /* Minimum value for cs idle time. */ + VMUINT32 cs_idle_time_min; + /* Maximum value for cs idle time. */ + VMUINT32 cs_idle_time_max; + /* Minimum value for clock low time. */ + VMUINT32 clk_low_time_min; + /* Maximum value for clock low time. */ + VMUINT32 clk_low_time_max; + /* Minimum value for clock high time. */ + VMUINT32 clk_high_time_min; + /* Maximum value for clock high time. */ + VMUINT32 clk_high_time_max; + /* Minimum value for transfer length. */ + VMUINT32 transfer_length_min; + /* Maximum value for transfer length. */ + VMUINT32 transfer_length_max; + /* Minimum value for transfer count. */ + VMUINT32 transfer_count_min; + /* Maximum value for transfer count. */ + VMUINT32 transfer_count_max; + /* Minimum value for slow down threshold. */ + VMUINT32 slow_down_thresh_min; + /* Maximum value for slow down threshold. */ + VMUINT32 slow_down_thresh_max; + /* Minimum value for ultra high threshold. */ + VMUINT32 ultra_high_thresh_min; + /* Maximum value for ultra high threshold. */ + VMUINT32 ultra_high_thresh_max; + /* Minimum value for driving current. */ + VMUINT32 driving_current_min; + /* Maximum value for driving current. */ + VMUINT32 driving_current_max; +} vm_spi_capabilty_t; + + +/************************************************************************************************************************************* + * DESCRIPTION + * vm_spi_query_mode_t indecates that user can check which mode can SPI support, This structure is used as the parameter + * of VM_SPI_IOCTL_QUERY_MODE_SUPPORT. + * EXAMPLE + * + * VM_DCL_HANDLE spi_handle; + * vm_spi_query_mode_t spi_data; + * spi_handle = vm_dcl_open(vm_spi_port0,0); + * if(VM_DCL_HANDLE_INVALID==spi_handle) return; + * spi_data.mode=VM_SPI_MODE_PAUSE; + * vm_dcl_control(spi_handle,VM_SPI_IOCTL_QUERY_MODE_SUPPORT,(void *)&spi_data); + * //Do something with the handle. + * + *************************************************************************************************************************************/ +typedef struct +{ + /* [IN] Specify a SPI mode. */ + VM_SPI_HAL_MODE mode; + /* [OUT] Return whether the specific mode is supported. */ + VMBOOL bSupport; +} vm_spi_query_mode_t; + + +/************************************************************************************************************************************* + * DESCRIPTION + * vm_spi_query_mode_t indecates that user can check SPI 's clock, This structure is used as the parameter of VM_SPI_IOCTL_QUERY_CLOCK. + * It contains the clock frequency which is used to calculate SPI timing parameters. + * EXAMPLE + * + * VM_DCL_HANDLE spi_handle; + * vm_spi_query_clock_t spi_data; + * spi_handle = vm_dcl_open(vm_spi_port0,0); + * if(VM_DCL_HANDLE_INVALID==spi_handle) return; + * vm_dcl_control(spi_handle,VM_SPI_IOCTL_QUERY_CLOCK,(void *)&spi_data); + * //Do something with the handle. + * + *************************************************************************************************************************************/ +typedef struct +{ + /* [OUT] SPI base clock. Unit in MHz. */ + VMUINT32 clock; +} vm_spi_query_clock_t; + + + +/************************************************************************************************************************************* + * DESCRIPTION + * vm_spi_mode_t indecates that user can set/get SPI 's mode , This structure is used as the parameter of + * VM_SPI_IOCTL_SET_MODE and VM_SPI_IOCTL_GET_MODE. + * EXAMPLE + * + * VM_DCL_HANDLE spi_handle; + * vm_spi_mode_t spi_data; + * spi_handle = vm_dcl_open(vm_spi_port0,0); + * if(VM_DCL_HANDLE_INVALID==spi_handle) return; + spi_data.mode = SPI_MODE_DEASSERT; + spi_data.bEnable = KAL_TRUE; + * vm_dcl_control(spi_handle,SPI_IOCTL_SET_MODE,(void *)&spi_data); + * //Do something with the handle. + * + *************************************************************************************************************************************/ + +typedef struct +{ + /* [IN] Specify a SPI mode. */ + VM_SPI_HAL_MODE mode; + /* [IN/OUT] Specify whether the mode is enabled. + For SPI_IOCTL_SET_MODE, it is an input parameter. + For SPI_IOCTL_GET_MODE, it is an output parameter. + */ + VMBOOL bEnable; + /* [IN/OUT] The parameter for the specific mode. + The meaning of this parameter depends on the mode to be set/get. + */ + VMUINT32 Param; +} vm_spi_mode_t; + + +/************************************************************************************************************************************* + * DESCRIPTION + * spi read function and spi write function + * EXAMPLE + * + * VM_DCL_HANDLE spi_handle; + * vm_spi_config_para_t conf_data; + * vm_spi_mode_t spi_data; + * VMUINT8 write_buff[3] = {0}; + * VMUINT32 wrten_len; + * VMUINT8 read_buff[3] = {0}; + * VMUINT32 read_len; + * spi_handle = vm_dcl_open(vm_spi_port0,0); + * if(VM_DCL_HANDLE_INVALID==spi_handle) return; + * conf_data.clk_high_time = 5; + * conf_data.clk_low_time = 5; + * conf_data.cs_hold_time = 15; + * conf_data.cs_idle_time = 15; + * conf_data.cs_setup_time= 15; + * conf_data.clk_polarity = VM_SPI_CPOL_B0; + * conf_data.clk_fmt = VM_SPI_CPHA_B0; + * conf_data.rx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.tx_endian = VM_SPI_ENDIAN_LITTLE; + * conf_data.rx_msbf = VM_SPI_MSBF_MSB; + * conf_data.tx_msbf = VM_SPI_MSBF_MSB; + * vm_dcl_control(spi_handle,VM_SPI_IOCTL_SET_CONFIG_PARA,(void *)&conf_data); + * spi_data.mode = SPI_MODE_DEASSERT; + * spi_data.bEnable = KAL_FALSE; + * vm_dcl_control(spi_handle,SPI_IOCTL_SET_MODE,(void *)&spi_data); + * vm_dcl_write(spi_handle,write_buff,3,&wrten_len,(VMUINT32)0); + * vm_dcl_read(spi_handle,read_buffer,3,&returned_len,(VMUINT32)0); + * //Do something with the handle. + * + *************************************************************************************************************************************/ +#endif diff --git a/hardware/arduino/mtk/system/libmtk/include/vmdes.h b/hardware/arduino/mtk/system/libmtk/include/vmdes.h new file mode 100644 index 00000000..c2cd505e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmdes.h @@ -0,0 +1,116 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef _VM_DES_SDK_H_ +#define _VM_DES_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + + +/* DOM-NOT_FOR_SDK-BEGIN */ + +#define VMDESHANDLE VMINT + +#define DES_INVALID_HANDLE -1 +#define DES_OK 0 + +#define DES_BLOCK_SIZE 8 + +/***************************************************************************** + * FUNCTION + * vm_des_set_key (old usage, please use new interface of CHE, refer in vmche.h) + * DESCRIPTION + * set des key. + * PARAMETERS + * key : [IN] key. + * RETURNS + * des handle + *****************************************************************************/ +VMDESHANDLE vm_des_set_key( VMUINT8 key[8] ); + +/***************************************************************************** + * FUNCTION + * vm_des_encrypt (old usage, please use new interface of CHE, refer in vmche.h) + * DESCRIPTION + * encrypt the data. + * PARAMETERS + * handle : [IN] des handle from vm_des_set_key . + * input : [IN] input data. + * input_len : [IN] input data length. + * output_len : [OUT] output data length. + * RETURNS + * encrypt output data + *****************************************************************************/ +VMUINT8 * vm_des_encrypt( VMDESHANDLE handle, VMUINT8 * input, VMINT input_len, VMINT * output_len ); + +/***************************************************************************** + * FUNCTION + * vm_des_decrypt (old usage, please use new interface of CHE, refer in vmche.h) + * DESCRIPTION + * decrypt the data. + * PARAMETERS + * handle : [IN] des handle from vm_des_set_key . + * input : [IN] input data. + * input_len : [IN] input data length. + * output_len : [OUT] output data length. + * RETURNS + * decrypt output data + *****************************************************************************/ +VMUINT8 * vm_des_decrypt( VMDESHANDLE handle, VMUINT8 * input, VMINT input_len, VMINT * output_len ); + +/***************************************************************************** + * FUNCTION + * vm_des_reset_key (old usage, please use new interface of CHE, refer in vmche.h) + * DESCRIPTION + * This function is document type start handler. + * PARAMETERS + * handle : [IN] des handle from vm_des_set_key . + * RETURNS + * DES_INVALID_HANDLE : error + * DES_OK : ok + *****************************************************************************/ +VMINT vm_des_reset_key( VMDESHANDLE handle ); + +/* DOM-NOT_FOR_SDK-END */ + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_DES_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmdhcp.h b/hardware/arduino/mtk/system/libmtk/include/vmdhcp.h new file mode 100644 index 00000000..7b3be540 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmdhcp.h @@ -0,0 +1,185 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VM_DHCP_SDK_H_ +#define VM_DHCP_SDK_H_ + +#include "vmsys.h" + +/*---------------- DHCP Client APIs -------------------*/ + +/* DHCP Client Mode */ +typedef enum +{ + VM_DHCP_CLIENT_ON, // The feature that using DHCP to get an IP is available. + VM_DHCP_CLIENT_OFF, // The feature that using DHCP to get an IP is unavailable. + + VM_DHCP_CLIENT_END +}vm_dhcp_client_mode_enum; + +/***************************************************************************** + * FUNCTION + * vm_dhcp_client_set_mode + * DESCRIPTION + * This function is used to set the client mode. + * PARAMETERS + * mode : [IN] vm_dhcp_client_mode_enum + * RETURN VALUES + * TRUE Setting succeeds. + * FALSE Setting fails. + *****************************************************************************/ +VMINT vm_dhcp_client_set_mode(VMUINT32 mode); + + +/***************************************************************************** + * FUNCTION + * vm_dhcp_client_get_mode + * DESCRIPTION + * This function is used to get the client mode. + * PARAMETERS + * + * RETURN VALUES + * >=0 Current client mode in dhcp_client_mode_enum. + * <0 Getting fails. + *****************************************************************************/ +VMINT vm_dhcp_client_get_mode(void); + + + +/*---------------- DHCP Server APIs -------------------*/ + +#define VM_DHCPD_DOT_IP_MAX_LEN 15 + +/****************************************************************************/ +/* Enum */ +/****************************************************************************/ +typedef enum +{ + VM_DHCP_SERVER_ON, // Response to clients' requests. + VM_DHCP_SERVER_OFF, // Won't resonse to any client's request. + + VM_DHCP_SERVER_END +}vm_dhcp_server_mode_enum; + +/****************************************************************************/ +/* Struct */ +/****************************************************************************/ +typedef struct +{ + VMUINT8 start_ip_addr[VM_DHCPD_DOT_IP_MAX_LEN + 1]; // start ip address + VMUINT8 end_ip_addr[VM_DHCPD_DOT_IP_MAX_LEN + 1]; // end ip address + VMUINT8 gateway_ip_addr[VM_DHCPD_DOT_IP_MAX_LEN + 1]; // gateway ip address + VMUINT8 subnet_mask[VM_DHCPD_DOT_IP_MAX_LEN + 1]; // subnet mask + VMUINT32 default_lease_tm; // default lease time. +} vm_dhcp_server_config_struct; + +/****************************************************************************/ +/* API */ +/****************************************************************************/ +/***************************************************************************** + * FUNCTION + * vm_dhcp_server_set_mode + * DESCRIPTION + * This function is used to set the server mode. + * PARAMETERS + * mode : [IN] vm_dhcp_server_mode_enum + * RETURN VALUES + * TRUE Setting succeeds. + * FALSE Setting fails. + *****************************************************************************/ +VMINT vm_dhcp_server_set_mode(VMUINT32 mode); + + +/***************************************************************************** + * FUNCTION + * vm_dhcp_server_get_mode + * DESCRIPTION + * This function is used to get the server mode. + * PARAMETERS + * + * RETURN VALUES + * >=0 Current server mode in dhcp_server_mode_enum. + * <0 Getting fails. + *****************************************************************************/ +VMINT vm_dhcp_server_get_mode(void); + + +/***************************************************************************** + * FUNCTION + * vm_dhcp_server_set_param + * DESCRIPTION + * This function is used to set the parameters for DHCP server, when the phone is in AP mode. + * The configurable parameters are start ip, end ip, gateway ip and the default lease time. + * DNS and default domain name are gotten from 3G, which can't be configed by customer. + * + * There are some restrictions for the input parameter, when server_on is set to be true. + * Firstly, start_ip_addr, end_ip_addr, and gateway_ip_addr should be in the same subnet. + * Secondly, gateway_ip_addr should be out of the range defined by start_ip_addr and end_ip_addr. + * If any restriction mentioned above is broken, default values will be used. + * + * The format for the IP address is dot format, such as "xxx.xxx.xxx.xxx". The unit for default_lease_tm is + * second. Default lease time will be used, if DHCP client doesn't request certain lease time, . + * If the members in dhcp_server_config_struct are not set or are set improperly, default values will be used. + * + * Default values for the members in dhcp_server_config_struct. + * start_ip_addr 192.168.1.10 + * end_ip_addr 192.168.1.250 + * gateway_ip_addr 192.168.1.1 + * subnet_mask 255.255.255.0 + * default_lease_tm 3600 + * + * PARAMETERS + * param : [IN] + * RETURN VALUES + * TRUE Setting succeeds. + * FALSE Setting fails. + *****************************************************************************/ +VMINT vm_dhcp_server_set_param(vm_dhcp_server_config_struct *param); + + +/***************************************************************************** + * FUNCTION + * dhcp_server_get_param + * DESCRIPTION + * This function is used to get DHCP server parameters, when phone is in AP mode and parameters have been set. + * PARAMETERS + * param : [OUT] + * RETURN VALUES + * TRUE Getting succeeds. + * FALSE Getting fails. + *****************************************************************************/ +VMINT vm_dhcp_server_get_param(vm_dhcp_server_config_struct *param); + +#endif /* VM_DHCP_SDK_H_ */ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmdns.h b/hardware/arduino/mtk/system/libmtk/include/vmdns.h new file mode 100644 index 00000000..ab553ffa --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmdns.h @@ -0,0 +1,60 @@ +#ifndef VM_DNS_SDK_H_ +#define VM_DNS_SDK_H_ + +#include "vmsys.h" + +/*---------------- DHCP Client APIs -------------------*/ + +/* DNS status */ +typedef enum +{ + VM_STATE_STARTING, + VM_STATE_RUNNING, + VM_STATE_STOPPING, + VM_STATE_STOPED, + VM_STATE_ERROR +}vm_dns_state; + + +/***************************************************************************** + * FUNCTION + * vm_dns_start + * DESCRIPTION + * This function is used to start DNS function + * PARAMETERS + * port : dns server listen port + * config_path : config file of author dns server + * domain_path : records file of customized domian-IP + * RETURN VALUES + * -1 is failed + *****************************************************************************/ +VMINT vm_dns_start(VMUINT32 port, VMCHAR *config_path, VMCHAR *domain_path); + + +/***************************************************************************** + * FUNCTION + * vm_dns_stop + * DESCRIPTION + * This function is used to stop DNS functions + * PARAMETERS + * + * RETURN VALUES + * -1 is failed + *****************************************************************************/ +VMINT vm_dns_stop(void); + + +/***************************************************************************** + * FUNCTION + * vm_dns_get_state + * DESCRIPTION + * This function is used to get DNS status + * PARAMETERS + * + * RETURN VALUES + * vm_dns_state + *****************************************************************************/ +VMINT vm_dns_get_state(void); + + +#endif /* VM_DNS_SDK_H_ */ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmeditor.h b/hardware/arduino/mtk/system/libmtk/include/vmeditor.h new file mode 100644 index 00000000..c69c2ec2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmeditor.h @@ -0,0 +1,886 @@ +/******************************************************************************* +* Modification Notice: +* -------------------------- +* This software is modified by MediaTek Inc. and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*******************************************************************************/ + + /******************************************************************************* + * Filename: + * --------- + * vmeditor_sdk.h + * + * Project: + * -------- + * Maui_Software + * + * Description: + * ------------ + * Inline editor APIs + * + * Author: + * ------- + * Keith Chen + * + *============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ + * $Log$ + * + * 07 09 2014 liu.cheng + * [MAUI_03508170] [Wearable_Phase2] VM_GRAPH_ID_3 of ID_14~15.vxp is crashing + * . + * + * 09 03 2012 hongtao.liu + * [MAUI_03230059] [RenRenV2.0][Renren_QVGA_Key_2M_20120829.vxp]ÒÑÊäÈëµÄĠÊşĊĊÏ˘ÏÔʲğÍêĠû + * add new API : vm_editor_show_from_start. + * + * 07 14 2012 hongtao.liu + * [MAUI_03213274] [ARTMicroBlogV3Vxp_HVGA_0707.vxp]ת·˘Î˘²İÊħ£ĴÓĤ¸highlight×îÇ°ĉ + * add API : vm_editor_show_from_first_line + * + * 06 27 2012 hongtao.liu + * [MAUI_03112870] Check in MRE editor + * add vm_editor_get_cursor_index, vm_editor_set_cursor_index, vm_editor_insert_string, vm_editor_set_default_text. + * + * 06 05 2012 hongtao.liu + * [MAUI_03191785] [MRE][Inline Editor] check in MRE Editor + * + * add api : vm_editor_set_imui_background_filler and vm_editor_set_update_text_with_cursor_rect_callback + * + * + * 05 25 2012 hongtao.liu + * [MAUI_03191785] [MRE][Inline Editor] check in MRE Editor + * check in MRE Editor + * + * + *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================ + *******************************************************************************/ +#ifndef VMEDITOR_SDK_H_ +#define VMEDITOR_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" +#include "vmgraph.h" +#include "vmio.h" +#include "vminput.h" + +/***************************************************************************** +* Define +*****************************************************************************/ +/* Enum values which are used to describe different types of softkey. */ +typedef enum +{ + VM_LEFT_SOFTKEY, /* Is an enum value which represents the left softkey */ + VM_RIGHT_SOFTKEY, /* Is an enum value which represents the right softkey */ + VM_CENTER_SOFTKEY, /* Is an enum value which represents the center softkey */ + + /* DOM-NOT_FOR_SDK-BEGIN */ + VM_MAX_SOFTKEYS /* Is the max count of all softkeys */ + /* DOM-NOT_FOR_SDK-END */ +} VM_SOFTKEY_ENUM; + +typedef enum +{ + VM_EDITOR_NO_BORDER, + VM_EDITOR_SINGLE_BORDER, + VM_EDITOR_DOUBLE_BORDER, + VM_EDITOR_BORDER_END +} VM_EDITOR_BORDER_TYPE; + +/* + * The 24 bits of input type are internally divided two parts + * 1. 0-19 bit are used for generic cases (Currently 18 bits out of which are being used) + * 2. 20-24 bit are used for external input types for special scenarios + */ +typedef enum +{ + VM_INPUT_TYPE_NONE = 0, + VM_INPUT_TYPE_NUMERIC = 0x1, /* For Number only */ + VM_INPUT_TYPE_PHONE_NUMBER = (0x1 << 1), /* For Phone Number */ + VM_INPUT_TYPE_DECIMAL_NUMERIC = (0x1 << 2), /* For Number with Decimal */ + VM_INPUT_TYPE_SIGNED_NUMERIC = (0x1 << 3), /* For Signed Numbers */ + VM_INPUT_TYPE_SIGNED_DECIMAL_NUMERIC = (0x1 << 4), /* For Signed Numbers with Decimal */ + VM_INPUT_TYPE_URL = (0x1 << 5), /* For url input */ + VM_INPUT_TYPE_QUICK_SEARCH = (0x1 << 6), /* For quick search */ + VM_INPUT_TYPE_SENTENCE = (0x1 << 7), /* all kind of character are allowed */ + VM_INPUT_TYPE_ENGLISH_SENTENCE = (0x1 << 8), /* only English character are allowed. */ + VM_INPUT_TYPE_USER_SPECIFIC = (0x1 << 9), /* App defines the input method it wants */ + VM_INPUT_TYPE_KEYPAD_NUMERIC = (0x1 << 10), /* For all numbers mapped on keyboard 0-9 * and # */ + VM_INPUT_TYPE_SIM_NUMERIC = (0x1 << 11), /* for numeric input with + and * */ + VM_INPUT_TYPE_ENGLISH_SENTENCE_UPPERCASE = (0x1 << 12), /* English with Uppercase */ + VM_INPUT_TYPE_ENGLISH_SENTENCE_LOWERCASE = (0x1 << 13), /* English with Lowercase */ + VM_INPUT_TYPE_EMAIL = (0x01 << 14), /* For Email Input */ + VM_INPUT_TYPE_PHONE_NUMBER_WILDCHAR = (0x01 << 15), /* For Phone number with + , p , w and ? */ + VM_INPUT_TYPE_NUMERIC_SYMBOL = (0x01 << 16), /* For number input with symbold allowed */ + VM_INPUT_TYPE_ASCII_CHAR = (0x01 << 17), /* ALL ASCII Characters */ + VM_INPUT_TYPE_NO_TITLECASE_SENTENCE = (0x01 << 18), /* All characters , but no titlecase */ + VM_INPUT_TYPE_SAT_NUMERIC_PASSWORD = (VM_INPUT_TYPE_KEYPAD_NUMERIC | 0x800000), + VM_INPUT_TYPE_DECIMAL_NUMERIC_PASSWORD = (VM_INPUT_TYPE_DECIMAL_NUMERIC | 0x800000), + VM_INPUT_TYPE_SIGNED_NUMERIC_PASSWORD = (VM_INPUT_TYPE_SIGNED_NUMERIC | 0x800000), + VM_INPUT_TYPE_SIGNED_DECIMAL_NUMERIC_PASSWORD = (VM_INPUT_TYPE_SIGNED_DECIMAL_NUMERIC | 0x800000), + VM_INPUT_TYPE_NUMERIC_PASSWORD = (VM_INPUT_TYPE_NUMERIC | 0x800000), + VM_INPUT_TYPE_ALPHANUMERIC_PASSWORD = (VM_INPUT_TYPE_ENGLISH_SENTENCE | VM_INPUT_TYPE_NUMERIC_SYMBOL | 0x800000), + VM_INPUT_TYPE_ASCII_PASSWORD = (VM_INPUT_TYPE_ASCII_CHAR | 0x800000), + VM_INPUT_TYPE_MULTITAP_SENTENCE = (0x200000 | VM_INPUT_TYPE_SENTENCE), + VM_INPUT_TYPE_END +} vm_input_type_enum; + +typedef enum +{ + VM_EDITOR_MESSAGE_NONE = 0x0, + VM_EDITOR_MESSAGE_REDRAW_FLOATING_UI, + VM_EDITOR_MESSAGE_ACTIVATE, + VM_EDITOR_MESSAGE_DEACTIVATE, + VM_EDITOR_MESSAGE_REDRAW_IMUI_RECTANGLE, + VM_EDITOR_MESSAGE_END +} vm_editor_message_id_enum; + +typedef enum +{ + VM_EDITOR_SINGLELINE, + VM_EDITOR_MULTILINE, + VM_EDITOR_END +} VM_EDITOR_TYPE; + +typedef struct +{ + VMINT32 x; + VMINT32 y; + VMINT32 width; + VMINT32 height; +} vm_editor_rect; + +typedef struct +{ + VMUINT32 message_id; + vm_editor_rect rect; /* floating UI rectangle or IMUI rectangle */ +} vm_editor_message_struct, *vm_editor_message_struct_p; + +typedef struct +{ + VMUINT8 bold; + VMUINT8 italic; + VMUINT8 underline; + VMUINT8 size; +} vm_editor_font_attribute; + +typedef struct +{ + VMINT32 x1, y1, x2, y2; +} vm_editor_rect_points, *vm_editor_rect_points_p; + +/***************************************************************************** + * FUNCTION + * Soft key callback function. + * DESCRIPTION + * This callback will be invoke when the soft key be pressed. + * PARAMETERS + * void + * RETURNS + * void + *****************************************************************************/ +typedef void (*vm_soft_key_handle_funcptr) (void); + +// TODO: VM_EDITOR_MESSAGE_DEACTIVATE param?? +/***************************************************************************** + * FUNCTION + * IME callback function. + * DESCRIPTION + * This Call back is used to receive IME message, message id refer to vm_editor_message_id_enum. + * 1. When floating UI overlap the editor, we send message VM_EDITOR_MESSAGE_REDRAW with parameters: + * msg_ptr->param_0 : 1 + * msg_ptr->param_1 : (vm_editor_rect *)floating UI rectangle + * In this case, you do not need to redraw the whole screen, only need to redraw the affected area(previous floating UI rectangle). + * 2. When application call vm_editor_activate(), we send message VM_EDITOR_MESSAGE_ACTIVATE with parameters: + * msg_ptr->param_0 : reserved + * msg_ptr->param_1 : reserved + * 3. When application call vm_editor_deactivate(), we send message VM_EDITOR_MESSAGE_DEACTIVATE with parameters: + * msg_ptr->param_0 : 1 + * msg_ptr->param_1 : reserved + * 4. When Virtual Keypad(VK) update status, we send message VM_EDITOR_MESSAGE_VK_STATUS with parameters: + * msg_ptr->param_0 : VK width + * msg_ptr->param_1 : VK height + * PARAMETERS + * editor_handle : [IN] Is the editor handle + * msg_ptr : [IN] Is the message pointer + * RETURNS + * Reserved (PLease return 0 now). + *****************************************************************************/ +typedef VMUINT32(*vm_editor_message_funcptr) (VMINT32 editor_handle, vm_editor_message_struct_p msg_ptr); + +/***************************************************************************** + * FUNCTION + * Text update callback function. + * DESCRIPTION + * This callback will be invoke when User input a charactor. + * PARAMETERS + * text : [IN] Point to the begin of the input string. + * cursor : [IN] Point to the current cusor position. + * text_length : [IN] Length of the input string. + * RETURNS + * void + *****************************************************************************/ +typedef void (*vm_update_text_funcptr) (VMUINT8 *text, VMUINT8 *cursor, VMINT32 text_length); + +/***************************************************************************** + * FUNCTION + * Text update with cursor rect callback function + * DESCRIPTION + * This callback will be invoked when user input or delete a charactor. + * The difference between this callback and vm_update_text_funcptr is: + * vm_update_text_funcptr will be invoked before editor redraw. + * vm_update_text_with_cursor_rect_funcptr will be invoked after editor redraw. + * PARAMETERS + * text : [IN] Point to the begin of the input string. + * cursor : [IN] Point to the current cursor position. + * text_length : [IN] length of the input string. + * cursor_rect_points : [IN] rect of the cursor. + * RETURNS + * void + *****************************************************************************/ +typedef void (*vm_update_text_with_cursor_rect_funcptr)( + VMUINT8 *text, + VMUINT8 *cursor, + VMINT32 text_length, + vm_editor_rect_points_p cursor_rect_points); + +/***************************************************************************** + * FUNCTION + * callback function to draw imui background + * DESCRIPTION + * draw imui background + * PARAMETERS + * x1 : [IN] x-coordination of top-left point. + * y1 : [IN] y-coordination of top-left point. + * x2 : [IN] x-coordination of down-right point. + * y2 : [IN] y-coordination of down-right point. + * RETURNS + * void + *****************************************************************************/ +typedef void (*vm_draw_imui_background_funcptr)(VMINT32 x1, VMINT32 y1, VMINT32 x2, VMINT32 y2); + +/***************************************************************************** + * FUNCTION + * vm_editor_create + * DESCRIPTION + * Creates an editor, it will use some application's heap memory. + * For single line editor, it will malloc 550Byte; For multiple line editor, it will malloc xxxByte. + * PARAMETERS + * editor_type [IN] Is the editor type + * x [IN] Is the left-top corner (x coordinate) + * y [IN] Is the left-top corner (y coordinate) + * width [IN] Is the width of the editor + * height [IN] Is the height of the editor + * text_buffer [IN] Is the text buffer the editor should use (pre-allocated) + * text_buffer_size [IN] Is the text buffer size in Bytes + * is_disable_softkey [IN] Disable softkey or not + * layer_handle [IN] Is the layer handle + * RETURNS + * NULL : Failed to create editor. + * Other : If successful. + *****************************************************************************/ +VMINT32 vm_editor_create( + VM_EDITOR_TYPE editor_type, + VMINT32 x, + VMINT32 y, + VMINT32 width, + VMINT32 height, + VMUWSTR text_buffer, + VMINT32 text_buffer_size, + VMBOOL is_disable_softkey, + VM_GDI_HANDLE layer_handle); + +/***************************************************************************** + * FUNCTION + * vm_editor_close + * DESCRIPTION + * Close the editor, it will free the editor memory in this API. + * Application must call this API before exit or go to background, if not, there will be memory leak. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * RETURNS + * void + *****************************************************************************/ +void vm_editor_close(VMINT32 editor_handle); + +/***************************************************************************** + * FUNCTION + * vm_editor_set_IME + * DESCRIPTION + * To set IME input type, input mode and callback function. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * input_type [IN] Is the input type, refer to vm_input_type_enum + * input_mode_array [IN] Is the input mode set, can pass null to use default mode set. + * If want to use user defined input mode list, + * 1. You need to set input_type as VM_INPUT_TYPE_USER_SPECIFIC. + * 2. Application need to use global array variable and end with VM_INPUT_MODE_NONE. + * 3. The max length of the array can not more than 10. + * Example: + * static vm_input_mode_enum my_input_modes_lower_first[] + * { + * VM_INPUT_MODE_MULTITAP_LOWERCASE_ABC, + * VM_INPUT_MODE_MULTITAP_UPPERCASE_ABC, + * VM_INPUT_MODE_123, + * VM_INPUT_MODE_SM_PINYIN, + * VM_INPUT_MODE_NONE + * }; + * default_input_mode [IN] Is the default input mode + * ime_callback [IN] Is the ime callback function + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_IME( + VMINT32 editor_handle, + VMUINT32 input_type, + vm_input_mode_enum *input_mode_array, + vm_input_mode_enum default_input_mode, + vm_editor_message_funcptr ime_callback); + +/***************************************************************************** + * FUNCTION + * vm_editor_set_softkey + * DESCRIPTION + * Set editor softkey. Only send key press event to application, other key event will be discarded. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * s [IN] Is the label + * key [IN] Is softkey type + * f [IN] Is the softkey handle + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_softkey(VMINT32 editor_handle, VMUWSTR s, VM_SOFTKEY_ENUM key, vm_soft_key_handle_funcptr f); + +/***************************************************************************** + * FUNCTION + * vm_editor_get_softkey_height + * DESCRIPTION + * Get editor softkey height. + * PARAMETERS + * void + * RETURNS + * Soft key height. + *****************************************************************************/ +VMUINT32 vm_editor_get_softkey_height(void); + +/***************************************************************************** + * FUNCTION + * vm_editor_show + * DESCRIPTION + * Display the editor (not flush to screen). + * PARAMETERS + * editor_handle [IN] Is the editor handle + * RETURNS + * void + *****************************************************************************/ +void vm_editor_show(VMINT32 editor_handle); + +/***************************************************************************** + * FUNCTION + * vm_editor_set_multiline_text_font + * DESCRIPTION + * Set multi line editor input text font. Recommended that use font_size_t type to define size. + * If use number directly, you need to check if the phone support vector font. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * text_font [IN] Is the text font + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_multiline_text_font(VMINT32 editor_handle, vm_editor_font_attribute text_font); + +/***************************************************************************** + * FUNCTION + * vm_editor_get_font_attribute + * DESCRIPTION + * Get editor font attribute. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * text_font [OUT] Is the text font + * RETURNS + * void + *****************************************************************************/ +void vm_editor_get_font_attribute(VMINT32 editor_handle, vm_editor_font_attribute *text_font); + +/***************************************************************************** + * FUNCTION + * vm_editor_set_bg_image + * DESCRIPTION + * Set the normal and focuss image pointers for image background + * (there are two styles of background: image background and rectangle background) + * PARAMETERS + * editor_handle [IN] Is the editor handle + * focus_image [IN] Is the focuss image + * normal_image [IN] Is the normal image + * focus_image_size [IN] Is the focuss image size + * normal_image_size [IN] Is the normal image size + * RETURNS + * 0 : If successful. + * -1 : Parameter error. + * -2 : Focus image type error. + * -3 : Normal image type error. + *****************************************************************************/ +VMINT32 vm_editor_set_bg_image( + VMINT32 editor_handle, + VMUINT8 *focus_image, + VMUINT8 *normal_image, + VMINT32 focus_image_size, + VMINT32 normal_image_size); + +/***************************************************************************** + * FUNCTION + * vm_editor_set_bg_border_style + * DESCRIPTION + * Set border style for rectangle background + * (there are two styles of background: image background and rectangle background) + * PARAMETERS + * editor_handle [IN] Is the editor handle + * border_width [IN] Is the border width(no border/single border/double border) + * border_normal_color [IN] Is the border color of normal style + * border_focuss_color [IN] Is the border color of focuss style + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_bg_border_style( + VMINT32 editor_handle, + VM_EDITOR_BORDER_TYPE border_width, + VMUINT16 border_normal_color, + VMUINT16 border_focuss_color); + +/***************************************************************************** + * FUNCTION + * vm_editor_set_margin + * DESCRIPTION + * Set margin for editor + * (for singleline, align center along y direction, so no need to set top/down margin) + * PARAMETERS + * editor_handle [IN] Is the editor handle + * top [IN] Top >0: set new value; -1: use default value + * down [IN] Down >0: set new value; -1: use default value + * left [IN] Left >0: set new value; -1: use default value + * right [IN] Right >0: set new value; -1: use default value + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_margin(VMINT32 editor_handle, VMINT32 top, VMINT32 down, VMINT32 left, VMINT32 right); + +/***************************************************************************** + * FUNCTION + * vm_editor_set_layer_handle + * DESCRIPTION + * Set editor layer handle + * PARAMETERS + * editor_handle [IN] Is the editor handle + * layer_handle [IN] Is the layer handle + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_layer_handle(VMINT32 editor_handle, VM_GDI_HANDLE layer_handle); + +/***************************************************************************** + * FUNCTION + * vm_editor_set_update_text_callback + * DESCRIPTION + * Set update text call back. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * update_text_callback [IN] Is update text callback + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_update_text_callback(VMINT32 editor_handle, vm_update_text_funcptr update_text_callback); + +/***************************************************************************** + * FUNCTION + * vm_editor_set_update_text_with_cursor_rect_callback + * DESCRIPTION + * set update text with cursor rect callback. + * notice that this callback will be invoked after editor redraw. + * PARAMETERS + * editor_handle : [IN] the editor handle. + * update_text_with_cursor_rect_callback : [IN] update text with cursor rect callback. + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_update_text_with_cursor_rect_callback( + VMINT32 editor_handle, + vm_update_text_with_cursor_rect_funcptr update_text_with_cursor_rect_callback); + +/***************************************************************************** + * FUNCTION + * vm_editor_set_pos + * DESCRIPTION + * Move the editor and show. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * x [IN] Is the left-top corner + * y [IN] Is the left-top corner + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_pos(VMINT32 editor_handle, VMINT32 x, VMINT32 y); + +/***************************************************************************** + * FUNCTION + * vm_editor_get_pos + * DESCRIPTION + * Get editor position. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * x [OUT] Is the left-top corner + * y [OUT] Is the left-top corner + * RETURNS + * void + *****************************************************************************/ +void vm_editor_get_pos(VMINT32 editor_handle, VMINT32 *x, VMINT32 *y); + +/***************************************************************************** + * FUNCTION + * vm_editor_set_size + * DESCRIPTION + * Resize the editor and show. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * width [IN] Is the width of the editor + * height [IN] Is the height of the editor + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_size(VMINT32 editor_handle, VMINT32 width, VMINT32 height); + +/***************************************************************************** + * FUNCTION + * vm_editor_get_size + * DESCRIPTION + * Get the editor size. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * width [OUT] Is the width of the editor + * height [OUT] Is the height of the editor + * RETURNS + * void + *****************************************************************************/ +void vm_editor_get_size(VMINT32 editor_handle, VMINT32 *width, VMINT32 *height); + +/***************************************************************************** + * FUNCTION + * vm_editor_set_text + * DESCRIPTION + * Set the text show in the editor. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * text_buffer [IN] Is the text buffer + * text_size [IN] Is the text buffer size(byte) + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_text(VMINT32 editor_handle, VMUWSTR text_buffer, VMINT32 text_size); + +/***************************************************************************** + * FUNCTION + * vm_editor_get_text + * DESCRIPTION + * Get the input text of the editor. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * text_buffer [IN/OUT] Is the text buffer + * text_size [IN] Is the text buffer size(byte) + * RETURNS + * VMINT32: text length + *****************************************************************************/ +VMINT32 vm_editor_get_text(VMINT32 editor_handle, VMUWSTR text_buffer, VMINT32 text_size); + +/***************************************************************************** + * FUNCTION + * vm_editor_set_text_color + * DESCRIPTION + * set text color + * PARAMETERS + * editor_handle [IN] Is the editor handle + * text_color [IN] Is the text color + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_text_color(VMINT32 editor_handle, VMUINT16 text_color); + +/***************************************************************************** + * FUNCTION + * wgui_editor_set_cursor_color + * DESCRIPTION + * set cursor color + * PARAMETERS + * editor_handle [IN] Is the editor handle + * cursor_color [IN] Is the cursor color + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_cursor_color(VMINT32 editor_handle, VMUINT16 cursor_color); + +/***************************************************************************** + * FUNCTION + * vm_editor_activate + * DESCRIPTION + * Activate the editor. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * is_vk_default_on [IN] If TRUE, the VK will be on when active the editor; + * If FALSE, the VK will be not on when active the editor, you need extra tap to show VK. + * RETURNS + * void + *****************************************************************************/ +void vm_editor_activate(VMINT32 editor_handle, VMBOOL is_vk_default_on); + +/***************************************************************************** + * FUNCTION + * vm_editor_deactivate + * DESCRIPTION + * Deactivate the editor. + * If application state switch to inactive/background/unload, must call this API. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * RETURNS + * void + *****************************************************************************/ +void vm_editor_deactivate(VMINT32 editor_handle); + +/***************************************************************************** + * FUNCTION + * vm_editor_get_active_editor + * DESCRIPTION + * Get current active editor. + * PARAMETERS + * void + * RETURNS + * The active editor handle. + *****************************************************************************/ +VMINT32 vm_editor_get_active_editor(void); + +/***************************************************************************** + * FUNCTION + * vm_editor_get_fit_height + * DESCRIPTION + * Get the fit editor height. This API only used to calculate single line editor height. + * For text_font_size, you can use font_size_t type to define the size or use number directly. + * PARAMETERS + * vertical_margin_size [IN] Is the vertical margin size + * text_font_size [IN] Is the text font size + * RETURNS + * editor height. + *****************************************************************************/ +VMINT32 vm_editor_get_fit_height(VMUINT8 vertical_margin_size, VMUINT8 text_font_size); + +/***************************************************************************** + * FUNCTION + * vm_editor_get_indicator_height + * DESCRIPTION + * Get indicator height. + * PARAMETERS + * void + * RETURNS + * Indicator height. + *****************************************************************************/ +VMINT32 vm_editor_get_indicator_height(void); + +/***************************************************************************** + * FUNCTION + * vm_editor_save + * DESCRIPTION + * Save the history info of the editor. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * RETURNS + * void + *****************************************************************************/ +void vm_editor_save(VMINT32 editor_handle); + +/***************************************************************************** + * FUNCTION + * vm_editor_restore + * DESCRIPTION + * Restore the history info to the editor. + * PARAMETERS + * editor_handle [IN] Is the editor handle + * RETURNS + * void + *****************************************************************************/ +void vm_editor_restore(VMINT32 editor_handle); + +/***************************************************************************** +* FUNCTION +* vm_editor_is_draw_floating_indicator +* DESCRIPTION +* Set if draw ime floating indicator. +* PARAMETERS +* is_draw_floating_indicator [IN] if draw ime floating indicator +* RETURNS +* void +*****************************************************************************/ +void vm_editor_is_draw_floating_indicator(VMBOOL is_draw_floating_indicator); + +/***************************************************************************** + * FUNCTION + * vm_editor_redraw_floating_ui_within_rect + * DESCRIPTION + * Redraw ime floating ui within given rectangle area. + * PARAMETERS + * rect [IN] Is the given rectangle area + * RETURNS + * void + *****************************************************************************/ +void vm_editor_redraw_floating_ui_within_rect(vm_editor_rect rect); + +/***************************************************************************** + * FUNCTION + * vm_editor_redraw_ime_screen + * DESCRIPTION + * Redraw ime UIs(floating ui and fixed ui). + * PARAMETERS + * void + * RETURNS + * void + *****************************************************************************/ +void vm_editor_redraw_ime_screen(void); + +/***************************************************************************** + * FUNCTION + * vm_editor_get_extra_imui_layer_handler + * DESCRIPTION + * get extra imui layer handler (like handwriting drawn layer). + * PARAMETERS + * void + * RETURNS + * Layer handle. + *****************************************************************************/ +VM_GDI_HANDLE vm_editor_get_extra_imui_layer_handler(void); + +/***************************************************************************** + * FUNCTION + * vm_editor_draw_imui_background_filler + * DESCRIPTION + * set the callback function to draw imui background + * PARAMETERS + * draw_imui_background_callback : [IN] the callback to draw imui background. + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_imui_background_filler(vm_draw_imui_background_funcptr draw_imui_background_callback); + +/***************************************************************************** + * FUNCTION + * vm_editor_insert_string + * DESCRIPTION + * insert string. + * PARAMETERS + * editor_handle : [IN] the handle of editor. + * str : [IN] string to be inserted. + * len : [IN] length of string. + * RETURNS + * the length of string actually inserted. + *****************************************************************************/ +VMINT32 vm_editor_insert_string(VMINT32 editor_handle, VMUWSTR str, VMINT32 len); + +/***************************************************************************** + * FUNCTION + * vm_editor_set_cursor_index + * DESCRIPTION + * set editor cursor index + * PARAMETERS + * editor_handle : [IN] the handle of editor. + * cursor_index : [IN] the cursor index + * RETURNS + * void + *****************************************************************************/ +void vm_editor_set_cursor_index(VMINT32 editor_handle, VMINT32 cursor_index); + +/***************************************************************************** + * FUNCTION + * vm_editor_get_cursor_index + * DESCRIPTION + * get editor cursor index + * PARAMETERS + * editor_handle : [IN] the handle of editor. + * RETURNS + * the cursor index. + *****************************************************************************/ +VMINT32 vm_editor_get_cursor_index(VMINT32 editor_handle); + +/***************************************************************************** +* FUNCTION +* vm_editor_set_default_text +* DESCRIPTION +* set default text. +* PARAMETERS +* editor_handle : [IN] the handle of editor. +* default_text_buffer : [IN] the buffer that stores default text. +* RETURNS +* void +*****************************************************************************/ +void vm_editor_set_default_text(VMINT32 editor_handle, VMUWSTR default_text_buffer); + +/***************************************************************************** +* FUNCTION +* vm_editor_show_from_first_line +* DESCRIPTION +* jump to start to show from the first line of multiline editor. +* PARAMETERS +* editor_handle : [IN] handle of the editor. +* RETURNS +* void +*****************************************************************************/ +void vm_editor_show_from_first_line(VMINT32 editor_handle); + +/***************************************************************************** +* FUNCTION +* vm_editor_show_from_start +* DESCRIPTION +* for multi-line editor, show from the first line. +* for single-line editor, show from the first charactor. +* PARAMETERS +* editor_handle : [IN] handle of the editor. +* RETURNS +* void +*****************************************************************************/ +void vm_editor_show_from_start(VMINT32 editor_handle); + +#ifdef __cplusplus +} +#endif + +#endif /* VMEDITOR_SDK_H_ */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmemcmd.h b/hardware/arduino/mtk/system/libmtk/include/vmemcmd.h new file mode 100644 index 00000000..4fc265a4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmemcmd.h @@ -0,0 +1,98 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmemcmd_sdk.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * driver bridge header file + * + * Author: + * ------- + * diangang.qin(mtk81217) + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ +* *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== +*******************************************************************************/ +#ifndef VM_EMCMD_SDK_H +#define VM_EMCMD_SDK_H +#ifdef __cplusplus +extern "C"{ +#endif/*__cplusplus*/ + +#include "vmsys.h" + +/*vm_emcmd_enum*/ +typedef enum +{ + VM_EMCMD_NO_ERROR = 0,//operator suceed + VM_EMCMD_GET_MEM_FAIL = -1,//memory is not enough + VM_EMCMD_ERR_OTHERS = -65535,// other errors + VM_EMCMD_ERR_END = -65536//end mark +}vm_emcmd_enum; + +/* callback function at_cmd */ +typedef VMINT (*VM_EM_CMD_CB)(void *data); + +/***************************************************************************** + * FUNCTION + * vm_em_send_command + * DESCRIPTION + * this is for send em cmd + * PARAMETERS + * atCmdStr: [IN]the cmd string + * atcmd_cb:[IN]the cmd cb + * RETURNS + * vm_emcmd_enum:return VM_EMCMD_NO_ERROR, success, othersize, fail + *****************************************************************************/ +extern vm_emcmd_enum vm_em_send_command(VMCHAR *atCmdStr, VM_EM_CMD_CB atcmd_cb); + +#ifdef __cplusplus +} +#endif/*__cplusplus*/ + +#endif/*VM_EMCMD_SDK_H*/ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmfota.h b/hardware/arduino/mtk/system/libmtk/include/vmfota.h new file mode 100644 index 00000000..4abe4a90 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmfota.h @@ -0,0 +1,203 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmfota_sdk.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * fota header file + * + * Author: + * ------- + * jianying.li(mtk81091) + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ +* *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== +*******************************************************************************/ +#ifndef VM_FOTA_SDK_H +#define VM_FOTA_SDK_H +#ifdef __cplusplus +extern "C"{ +#endif/*__cplusplus*/ +#include "vmsys.h" + +/*vm_srv_funet_flag_enum*/ +typedef enum +{ + VM_SRV_FUNET_FLAG_SUCCESS,//VM_SRV_FUNET_FLAG_SUCCESS + VM_SRV_FUNET_FLAG_FAIL_DEL_CBR_UPDATING_INFO,//VM_SRV_FUNET_FLAG_FAIL_DEL_CBR_UPDATING_INFO + VM_SRV_FUNET_FLAG_ERASE_MARKER_BLOCK,//VM_SRV_FUNET_FLAG_ERASE_MARKER_BLOCK + VM_SRV_FUNET_FLAG_WRITE_MARKER_BLOCK,//VM_SRV_FUNET_FLAG_WRITE_MARKER_BLOCK + VM_SRV_FUNET_FLAG_NO_DL_PACKAGE_FOUND,//VM_SRV_FUNET_FLAG_NO_DL_PACKAGE_FOUND + VM_SRV_FUNET_FLAG_FLASH_INIT_FAIL//VM_SRV_FUNET_FLAG_FLASH_INIT_FAIL +} vm_srv_funet_flag_enum; + +/*vm_srv_funet_update_type_enum*/ +typedef enum +{ + VM_SRV_FUNET_UPDATE_FULL,//VM_SRV_FUNET_UPDATE_FULL + VM_SRV_FUNET_UPDATE_PARTIAL//VM_SRV_FUNET_UPDATE_PARTIAL +} vm_srv_funet_update_type_enum; + +/*vm_fudiffnet_update_type_enum*/ +typedef enum +{ + VM_FUDIFFNET_UPDATE_FULL,//VM_FUDIFFNET_UPDATE_FULL + VM_FUDIFFNET_UPDATE_PARTIAL//VM_FUDIFFNET_UPDATE_PARTIAL +}vm_fudiffnet_update_type_enum; + +/*vm_fudiffnet_flag_enum*/ +typedef enum +{ + VM_FUDIFFNET_FLAG_SUCCESS,//VM_FUDIFFNET_FLAG_SUCCESS + VM_FUDIFFNET_FLAG_FAIL_DEL_CBR_UPDATING_INFO,//VM_FUDIFFNET_FLAG_FAIL_DEL_CBR_UPDATING_INFO + VM_FUDIFFNET_FLAG_ERASE_MARKER_BLOCK,//VM_FUDIFFNET_FLAG_ERASE_MARKER_BLOCK + VM_FUDIFFNET_FLAG_WRITE_MARKER_BLOCK,//VM_FUDIFFNET_FLAG_WRITE_MARKER_BLOCK + VM_FUDIFFNET_FLAG_NO_DL_PACKAGE_FOUND,//VM_FUDIFFNET_FLAG_NO_DL_PACKAGE_FOUND + VM_FUDIFFNET_FLAG_FLASH_INIT_FAIL//VM_FUDIFFNET_FLAG_FLASH_INIT_FAIL +} vm_fudiffnet_flag_enum; +/*vm_fudiffnet_update_ret_enum*/ +typedef enum +{ + VM_FUDIFFNET_NO_UPDATE,//VM_FUDIFFNET_NO_UPDATE + VM_FUDIFFNET_UPDATE_SUCCESS,//VM_FUDIFFNET_UPDATE_SUCCESS + VM_FUDIFFNET_UPDATE_FAIL//VM_FUDIFFNET_UPDATE_FAIL +}vm_fudiffnet_update_ret_enum; + +/***************************************************************************** + * FUNCTION + * vm_srv_funet_trigger + * DESCRIPTION + * Trigger bootloader to update. + * PARAMETERS + * file_name [IN] FOTA update package + * update_type [IN] Full update or partial update + * RETURNS + * vm_srv_funet_flag_enum: update flag return + *****************************************************************************/ +extern vm_srv_funet_flag_enum vm_srv_funet_trigger(VMWCHAR * file_name, vm_srv_funet_update_type_enum update_type); + +/***************************************************************************** + * FUNCTION + * vm_fudiffnet_trigger + * DESCRIPTION + * Trigger bootloader to update differential package. + * PARAMETERS + * update_type [IN] Full update or partial update + * RETURNS + * vm_fudiffnet_flag_enum: update flag return + * EXAMPLE + * + *if (VM_FUDIFFNET_FLAG_SUCCESS == vm_fudiffnet_trigger(VM_FUDIFFNET_UPDATE_PARTIAL)) + *{ + * ... + *} + *else + *{ + * ... + *} + * + * + *****************************************************************************/ +extern vm_fudiffnet_flag_enum vm_fudiffnet_trigger(vm_fudiffnet_update_type_enum update_type); + +/***************************************************************************** + * FUNCTION + * vm_fudiffnet_get_fota_result + * DESCRIPTION + * get update result from update_info file. + * PARAMETERS + * N/A + * RETURNS + * vm_fudiffnet_update_ret_enum + * EXAMPLE + * + * vm_fudiffnet_update_ret_enum ret = VM_FUDIFFNET_NO_UPDATE; + * + * ret = vm_fudiffnet_get_fota_result(); + * if (VM_FUDIFFNET_UPDATE_SUCCESS == ret) + * { + * ... + * } + * else if(VM_FUDIFFNET_UPDATE_FAIL == ret) + * { + * vm_log_info( "fota update failed."); + * } + * else if(VM_FUDIFFNET_NO_UPDATE == ret) + * { + * vm_log_info( "fota no update."); + * } + * + *****************************************************************************/ +extern vm_fudiffnet_update_ret_enum vm_fudiffnet_get_fota_result(void); + +/***************************************************************************** + * FUNCTION + * vm_fudiffnet_get_firmware_path + * DESCRIPTION + * get firmware path + * PARAMETERS + * N/A + * RETURNS + * VMWCHAR* + * EXAMPLE + * + * VMWCHAR* firmware_path = NULL; + * firmware_path = vm_fudiffnet_get_firmware_path(); + * + *****************************************************************************/ +extern VMWCHAR* vm_fudiffnet_get_firmware_path(void); +#ifdef __cplusplus +} +#endif/*__cplusplus*/ + +#endif/*VM_FOTA_SDK_H*/ + + + + + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmftpd.h b/hardware/arduino/mtk/system/libmtk/include/vmftpd.h new file mode 100644 index 00000000..b204a1bb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmftpd.h @@ -0,0 +1,150 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmftpd_sdk.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * + * + * Author: + * ------- + * + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ +* *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== +*******************************************************************************/ +#ifndef VM_FTPD_SDK_H +#define VM_FTPD_SDK_H +#ifdef __cplusplus +extern "C"{ +#endif/*__cplusplus*/ +#include "vmsys.h" + +/* vm_ftpsrv_error_enum */ +typedef enum +{ + VM_FTPSRV_ERR_NO_ERROR = 0, //operator suceed + VM_FTPSRV_ERR_STATE_ERROR = -1, //state of ftp is mess + VM_FTPSRV_ERR_GET_MEM_FAIL = -2, //memory is not enough + VM_FTPSRV_ERR_CONNECT_NETWORK_FAIL = -3, //net work is not ready + VM_FTPSRV_ERR_FD_INIT_FAIL = -4, //file disciptor init fail + VM_FTPSRV_ERR_GET_HOSTNAME_FAIL = -5, //invalid host name + VM_FTPSRV_ERR_SRV_INIT_FAIL = -6, //server init fail + VM_FTPSRV_ERR_ERROR_FD_NUMBER = -7, //file diciptor abnormal + VM_FTPSRV_ERR_OTHERS = -65535, // other errors + VM_FTPSRV_ERR_CODE = -65536 //end mark. +}vm_ftpsrv_error_enum; + + +/***************************************************************************** + * FUNCTION + * vm_inet_ftpd_start + * DESCRIPTION + * this is for lauch ftp server + * PARAMETERS + * port : [IN] + * root_dir : [IN] + * RETURNS + * vm_ftpsrv_error_enum + * EXAMPLE + * + * if (vm_inet_ftpd_start(21, "C:\\@ftp") == VM_FTPSRV_ERR_NO_ERROR) + * { + * // do relate action + * } + * + *****************************************************************************/ +extern vm_ftpsrv_error_enum vm_inet_ftpd_start(VMUINT32 port, VMCHAR* root_dir); + + +/***************************************************************************** + * FUNCTION + * vm_inet_ftpd_stop + * DESCRIPTION + * this is for stop ftp server + * PARAMETERS + * RETURNS + * vm_ftpsrv_error_enum + * + * EXAMPLE + * + * if (vm_inet_ftpd_stop() == VM_FTPSRV_ERR_NO_ERROR) + * { + * // do relate action + * } + * + *****************************************************************************/ +extern vm_ftpsrv_error_enum vm_inet_ftpd_stop(void); + +/***************************************************************************** + * FUNCTION + * vm_inet_ftpd_restart + * DESCRIPTION + * this is for restart ftp server + * PARAMETERS + * port : [IN] + * root_dir : [IN] + * RETURNS + * vm_ftpsrv_error_enum + * + * EXAMPLE + * + * if (vm_inet_ftpd_restart(21, "C:\\@ftp") == VM_FTPSRV_ERR_NO_ERROR) + * { + * // do relate action + * } + * + *****************************************************************************/ +extern vm_ftpsrv_error_enum vm_inet_ftpd_restart(VMUINT32 port, VMCHAR* root_dir); + + +#ifdef __cplusplus +} +#endif/*__cplusplus*/ + +#endif/*VM_FTPD_SDK_H*/ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmgettag.h b/hardware/arduino/mtk/system/libmtk/include/vmgettag.h new file mode 100644 index 00000000..bbdd8f16 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmgettag.h @@ -0,0 +1,321 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMTAG_SDK_H_ +#define VMTAG_SDK_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmio.h" +#include "vmsys.h" + +#define MULTI_TAG_MAX 10 + +#define PPID 1 +#define USAGE_MODE 2 +#define PARAM 3 +#define PRICE 4 +#define TRIAL 5 +#define CN_NAME 6 +#define DEVELOPER 7 +#define SERIAL_NUM 8 +#define VERSION 9 +#define ICON 10 + + +#define GET_TAG_TRUE 1 /* get tag success */ +#define GET_TAG_ERROR 0 /* read tag error */ +#define GET_TAG_INSUFFICIENT_BUF (-1) /* memory not enough */ +#define GET_TAG_NULL_BUF (-2) /* buffer size is zero */ +#define GET_TAG_NOT_FOUND (-3) /* not find this tag */ +#define GET_TAG_FILE_ERROR (-4) /* read file error */ +#define GET_TAG_NOT_A_LIST_TAG (-5) /* tag id is not corrent */ +#define GET_TAG_LANG_NOT_FOUND (-6) /* not find language id */ +#define GET_TAG_CACHE_ERROR (-7) /* file seek error */ + +/* multi tag stucture */ +typedef struct multi_tag_t +{ + VMINT tag_id[MULTI_TAG_MAX]; /* tag id array, max size is 10 */ + VMINT tag_len[MULTI_TAG_MAX]; /* tag lenth array, max size is 10 */ + VMUCHAR * tag_content[MULTI_TAG_MAX]; /* tag content pointer array, max size is 10 */ +} MULTI_TAG; + +/***************************************************************************** + * FUNCTION + * vm_get_vm_tag + * DESCRIPTION + * get one tag from file or preload file, this support file in file system and in ROM. + * PARAMETERS + * filename : [IN] file name, if it is preload file, it should be @:\xx.rom format. + * tag_num : [IN] tag id, refer tag define in vmcert.h. + * buf : [OUT] tag value. + * buf_size : [OUT] tag value size. + * RETURNS + * get tag success or not. + * RETURN VALUES + * GET_TAG_TRUE : get tag success. + * GET_TAG_NOT_FOUND : not find this tag. + * GET_TAG_ERROR : read tag error. + * GET_TAG_INSUFFICIENT_BUF : buffer size is error. + * SEE ALSO + * vm_get_vm_tag_from_rom + * EXAMPLE + * (a). get tag and know the tag size + * + * VMINT file_type; + * VMINT buffSize = 4; // tag size is 4 + * + * if (vm_get_vm_tag(filename, VM_CE_INFO_FILE_TYPE, (void*)&liner_type, &buffSize) != GET_TAG_TRUE) + * { + * // get tag error + * } + * else + * { + * // get tag success + * } + * + * + * (b). get tag and don't know the tag size + * + * VMUINT8* tagName; + * VMINT buffSize; + * + * // get tag size + * if (vm_get_vm_tag(fileName, VM_CE_INFO_NAME, NULL, &bufSize) == GET_TAG_TRUE) + * { + * tagName = (VMUINT8 *)vm_calloc(bufSize + 1); + * + * if(tagName) + * { + * if(vm_get_vm_tag(fileName, VM_CE_INFO_NAME, tagName, &bufSize) != GET_TAG_TRUE) + * { + * vm_free(tagName); // failed + * } + * } + * } + * .... + * // free it when no use + * vm_free(tagName); + * +*****************************************************************************/ +VMINT vm_get_vm_tag(short* filename,int tag_num, void* buf ,int* buf_size); + + +/***************************************************************************** + * FUNCTION + * vm_get_multi_tags + * DESCRIPTION + * get some tags from file or preload file, max size refer to MULTI_TAG_MAX + * PARAMETERS + * filename : [IN] file name, if it is preload file, it should be @:\xx.rom format. + * tag_req : [IN & OUT] tag id and value. + * RETURNS + * get tags success or not. + * RETURN VALUES + * GET_TAG_TRUE : get tag success. + * GET_TAG_NOT_FOUND : not find this tag. + * GET_TAG_ERROR : read tag error. + * SEE ALSO + * vm_get_vm_tag + * EXAMPLE + * + * MULTI_TAG multi_tag; + * memset(&multi_tag, 0, sizeof(MULTI_TAG)); + * multi_tag. tag_id[0] = VM_CE_INFO_APP_ID; + * multi_tag. tag_id[1] = VM_CE_INFO_CERT_ID; + * multi_tag. tag_id[2] = VM_CE_INFO_NAME; + * + * // get tag size + * if (vm_get_multi_tags(fileName, &multi_tag) == GET_TAG_TRUE) + * { + * multi_tag. tag_content[0] = (VMUINT8 *)vm_calloc(multi_tag. tag_len[0] + 1); + * multi_tag. tag_content[1] = (VMUINT8 *)vm_calloc(multi_tag. tag_len[1] + 1); + * multi_tag. tag_content[2] = (VMUINT8 *)vm_calloc(multi_tag. tag_len[2] + 1); + * + * if(tagName) + * { + * if(vm_get_multi_tags(fileName, &multi_tag) != GET_TAG_TRUE) + * { + * // failed + * vm_free(multi_tag. tag_content[0] ); + * vm_free(multi_tag. tag_content[1] ); + * vm_free(multi_tag. tag_content[2] ); + * } + * } + * } + * .... + * // free them when no use + * vm_free(multi_tag. tag_content[0] ); + * vm_free(multi_tag. tag_content[1] ); + * vm_free(multi_tag. tag_content[2] ); + * +*****************************************************************************/ +VMINT vm_get_multi_tags( short* filename, MULTI_TAG* tag_req); + + +/***************************************************************************** + * FUNCTION + * vm_get_tag_by_lang_id + * DESCRIPTION + * get a tag from tag id and language id. + * PARAMETERS + * filename : [IN] file name, if it is preload file, it should be @:\xx.rom format. + * tag_num : [IN] tag id, refer tag define in vmcert.h. + * lang_id : [IN] lang id. + * buf : [OUT] tag value. + * buf_size : [OUT] tag value size. + * RETURNS + * get a tag success or not. + * RETURN VALUES + * GET_TAG_TRUE : get tag success. + * GET_TAG_ERROR : get tag error. + * GET_TAG_NOT_FOUND : not find this tag. + * GET_TAG_LANG_NOT_FOUND : not find language id. + * GET_TAG_NOT_A_LIST_TAG : tag id is not corrent. + * GET_TAG_FILE_ERROR : read tag error from file. + * GET_TAG_INSUFFICIENT_BUF : buffer size is error. + * GET_TAG_NULL_BUF : buffer size is zero + * EXAMPLE + * get app's english (language id is 44, this id can be get from reseditor) name + * + * VMUINT8* tagName; + * VMINT buffSize; + * + * if (vm_get_tag_by_lang_id(fileName, VM_CE_INFO_MULTI_NAME_LIST, NULL, &buffSize, 44) == GET_TAG_TRUE) + * { + * tagName = (VMUINT8 *)vm_calloc(bufSize + 1); + * vm_get_tag_by_lang_id(fileName, VM_CE_INFO_MULTI_NAME_LIST, tagName, &buffSize, 44); + * } + * + +*****************************************************************************/ +VMINT vm_get_tag_by_lang_id( short* filename, int tag_num, void* buf, int* buf_size, int lang_id ); + + +/***************************************************************************** + * FUNCTION + * vm_get_multi_tags_by_lang_id + * DESCRIPTION + * get tags from tag id and language id. + * PARAMETERS + * filename : [IN] file name, if it is preload file, it should be @:\xx.rom format. + * lang_id : [IN] lang id. + * tag_req : [IN & OUT] tag id and value. + * RETURNS + * get tags success or not. + * RETURN VALUES + * GET_TAG_TRUE : get tag success. + * GET_TAG_ERROR : get tag error. + * GET_TAG_LANG_NOT_FOUND : not find language id. + * GET_TAG_INSUFFICIENT_BUF : there is no enough memroy. + * EXAMPLE + * + * MULTI_TAG multi_tag; + * memset(&multi_tag, 0, sizeof(MULTI_TAG)); + * multi_tag. tag_id[0] = VM_CE_INFO_NAME_LIST; + * multi_tag. tag_id[1] = VM_CE_INFO_DESC_LIST; + * multi_tag. tag_id[2] = VM_CE_INFO_ZIMO_LIST; + * + * // get tag size + * if (vm_get_multi_tags_by_lang_id(fileName, &multi_tag, 44) == GET_TAG_TRUE) + * { + * multi_tag. tag_content[0] = (VMUINT8 *)vm_calloc(multi_tag. tag_len[0] + 1); + * multi_tag. tag_content[1] = (VMUINT8 *)vm_calloc(multi_tag. tag_len[1] + 1); + * multi_tag. tag_content[2] = (VMUINT8 *)vm_calloc(multi_tag. tag_len[2] + 1); + * + * if(tagName) + * { + * if(vm_get_multi_tags_by_lang_id(fileName, &multi_tag, 44) != GET_TAG_TRUE) + * { + * // failed + * vm_free(multi_tag. tag_content[0] ); + * vm_free(multi_tag. tag_content[1] ); + * vm_free(multi_tag. tag_content[2] ); + * } + * } + * } + * .... + * // free them when no use + * vm_free(multi_tag. tag_content[0] ); + * vm_free(multi_tag. tag_content[1] ); + * vm_free(multi_tag. tag_content[2] ); + * +*****************************************************************************/ +VMINT vm_get_multi_tags_by_lang_id( short* filename, MULTI_TAG * tag_req, int lang_id ); + + +/***************************************************************************** + * FUNCTION + * vm_get_vm_tag_from_rom + * DESCRIPTION + * get a tag from rom. + * PARAMETERS + * rom : [IN] the address of preload app. + * tag_num : [IN] tag id, refer tag define in vmcert.h. + * buf : [OUT] tag value. + * buf_size : [OUT] tag value size. + * RETURNS + * get tag success or not. + * RETURN VALUES + * GET_TAG_TRUE : get tag success. + * GET_TAG_NOT_FOUND : not find this tag. + * GET_TAG_ERROR : read tag error. + * GET_TAG_INSUFFICIENT_BUF : buffer size is error. + * SEE ALSO + * vm_get_vm_tag + * EXAMPLE + * + * VMUINT8* tagName; + * VMINT buffSize; + * + * if (vm_get_vm_tag_from_rom(address, VM_CE_INFO_IMSI, NULL, &buffSize) == GET_TAG_TRUE) + * { + * tagName = (VMUINT8 *)vm_calloc(bufSize + 1); + * vm_get_vm_tag_from_rom(fileName, VM_CE_INFO_IMSI, tagName, &buffSize); + * } + * +*****************************************************************************/ +VMINT vm_get_vm_tag_from_rom(VMUINT8* rom, int tag_num, void* buf , int* buf_size); + + +#ifdef __cplusplus +} +#endif + +#endif /* VMTAG_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmgfxold.h b/hardware/arduino/mtk/system/libmtk/include/vmgfxold.h new file mode 100644 index 00000000..53287309 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmgfxold.h @@ -0,0 +1,680 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + + +#ifndef VMCPT_SDK_H_ +#define VMCPT_SDK_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" +#include "vmgraph.h" +#include "vmlog.h" + +/* vmgraph.h*/ + +/****************************************************************************** +* FUNCTION +* vm_graphic_lock +* DESCRIPTION +* create layer and set clip region. clip region is full screen. +* PARAMETERS +* void +* RETURNS +* void +*****************************************************************************/ +void vm_graphic_lock(void); + + + +/****************************************************************************** +* FUNCTION +* vm_graphic_unlock +* DESCRIPTION +* blt the layer to LCD and delete layer +* PARAMETERS +* void +* RETURNS +* void +*****************************************************************************/ +void vm_graphic_unlock(void); + + + +/****************************************************************************** +* FUNCTION +* vm_graphic_get_buffer +* DESCRIPTION +* get the layer buffer +* PARAMETERS +* void +* RETURNS +* the layer buffer pointer +*****************************************************************************/ +VMUINT8 * vm_graphic_get_buffer(void); + + + +/****************************************************************************** +* FUNCTION +* vm_graphic_flush_buffer +* DESCRIPTION +* blt the layer to LCD. +* PARAMETERS +* void +* RETURNS +* void +*****************************************************************************/ +void vm_graphic_flush_buffer(void); + + +/****************************************************************************** +* FUNCTION +* vm_initialize_screen_buffer +* DESCRIPTION +* create base layer(if not exist) and reset clip region to full screen. +* PARAMETERS +* void +* RETURNS +* void +*****************************************************************************/ +void vm_initialize_screen_buffer(void); + + + +/****************************************************************************** +* FUNCTION +* vm_finalize_screen_buffer +* DESCRIPTION +* delete base layer. +* PARAMETERS +* void +* RETURNS +* void +*****************************************************************************/ +void vm_finalize_screen_buffer(void); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_draw_gif +* DESCRIPTION +* decode the gif image to base layer +* PARAMETERS +* gif : [IN] image data pointer +* gif_len : [IN]image data length +* x : [IN]x offset of source start position +* y : [IN]y offset of source start position +* width : [IN]source image width +* height : [IN]source image height +* frame_index : [IN]frame index of gif image +* RETURNS +* always return 0, make no sense +*****************************************************************************/ +VMINT vm_graphic_draw_gif(VMUINT8* gif, VMINT gif_len, VMINT x, VMINT y, VMINT width, VMINT height, VMINT frame_index); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_bitblt +* DESCRIPTION +* draw the resource to base layer +* PARAMETERS +* resid : [IN] resource id +* x : [IN] x offset of destination +* y : [IN] y offset of destination +* RETURNS +* always return -1, make no sense +*****************************************************************************/ +VMINT vm_graphic_bitblt(VMINT resid, int x, int y); + + + +/****************************************************************************** +* FUNCTION +* vm_graphic_drawtext +* DESCRIPTION +* draw the text to base layer +* PARAMETERS +* x : [IN] x offset of destination +* y : [IN] y offset of destination +* s : [IN] to be shown string buffer pointer +* length : [IN] string length +* color : [IN] string color +* RETURNS +* void +*****************************************************************************/ +void vm_graphic_drawtext(VMINT x, VMINT y, VMWSTR s, VMINT32 length, VMINT color); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_setpixel +* DESCRIPTION +* draw the point to base layer +* PARAMETERS +* x : [IN] x offset of destination +* y : [IN] y offset of destination +* color : [IN] point color +* RETURNS +* void +*****************************************************************************/ +void vm_graphic_setpixel(VMINT x, VMINT y, VMINT color); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_drawline +* DESCRIPTION +* draw the line to base layer +* PARAMETERS +* x0 : [IN] x offset of start position +* y0 : [IN] y offset of start position +* x1 : [IN] x offset of end position +* y1 : [IN] y offset of end position +* color : [IN] line color +* RETURNS +* void +*****************************************************************************/ +void vm_graphic_drawline(VMINT x0, VMINT y0, VMINT x1, VMINT y1, VMINT color); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_drawrect +* DESCRIPTION +* draw the rect to base layer +* PARAMETERS +* x : [IN] x offset of start position +* y : [IN] y offset of start position +* width : [IN] rect width +* height : [IN] rect height +* color : [IN] rect color +* RETURNS +* void +*****************************************************************************/ +void vm_graphic_drawrect(VMINT x, VMINT y, VMINT width, VMINT height, VMINT color); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_fillrect +* DESCRIPTION +* draw the filled rect to base layer +* PARAMETERS +* x : [IN] x offset of start position +* y : [IN] y offset of start position +* width : [IN] rect width +* height : [IN] rect height +* color : [IN] rect color +* RETURNS +* void +*****************************************************************************/ +void vm_graphic_fillrect(VMINT x, VMINT y, int width, int height, int color); + + +/* vmddraw.h*/ + +/****************************************************************************** + * FUNCTION + * vm_dd_initialize_clip_rect + * DESCRIPTION + * get layer buffer and set clip region to the full screen size + * PARAMETERS + * void + * RETURNS + * void + *****************************************************************************/ +void vm_dd_initialize_clip_rect(void); + + + +/****************************************************************************** + * FUNCTION + * vm_dd_set_clip + * DESCRIPTION + * set the clip region + * PARAMETERS + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * width : [IN] clip region width + * height : [IN] clip region height + * RETURNS + * void + *****************************************************************************/ +void vm_dd_set_clip(VMINT x, VMINT y, VMINT width, VMINT height); + + + +/****************************************************************************** + * FUNCTION + * vm_dd_initialize_clip_rect + * DESCRIPTION + * reset clip region to the full screen size + * PARAMETERS + * void + * RETURNS + * void + *****************************************************************************/ +void vm_dd_reset_clip(void); + + +/****************************************************************************** + * FUNCTION + * vm_dd_blt_all_cutting_frames + * DESCRIPTION + * reduce the image to appointed size + * PARAMETERS + * buf : [IN] destination buffer + * source_surface : [IN] source buffer + * x_num : [IN] resized width + * y_num : [IN] resized height + * width : [IN] source width + * height : [IN] source height + * RETURNS + * void + *****************************************************************************/ +void vm_dd_blt_all_cutting_frames(VMBYTE *buf, VMBYTE *source_surface, VMINT x_num, VMINT y_num, VMINT width, VMINT height); + + +/****************************************************************************** + * FUNCTION + * vm_dd_img_flood + * DESCRIPTION + * draw the appointed frame index image to destination buffer + * PARAMETERS + * buf : [IN] destination buffer + * x_dst : [IN] x offset of destination + * y_dst : [IN] y offset of destination + * source_surface : [IN] source buffer + * width : [IN] source width + * height : [IN] source height + * frame_index : [IN]frame index + * RETURNS + * void + *****************************************************************************/ +void vm_dd_img_flood(VMBYTE *buf, VMINT x_dst, VMINT y_dst,VMBYTE *source_surface, VMINT width, VMINT height, VMINT frame_index); + + +/****************************************************************************** + * FUNCTION + * vm_dd_copy + * DESCRIPTION + * copy the appointed frame index/mirror mode/position image to destination buffer + * PARAMETERS + * buf : [IN] destination buffer + * x_dest : [IN] x offset of destination + * y_dest : [IN] y offset of destination + * source_surface : [IN] source buffer + * x_src : [IN]x offset of source + * y_src : [IN]y offset of source + * width : [IN] source width + * height : [IN] source height + * frame_index : [IN]frame index + * direction : [IN] copy direction, means mirror direction + * RETURNS + * void + *****************************************************************************/ +void vm_dd_copy(VMBYTE *buf, VMINT x_dest, VMINT y_dest, VMBYTE *source_surface, VMINT x_src, VMINT y_src, VMINT width, VMINT height, VMINT frame_index, VMINT direction); + + +/****************************************************************************** + * FUNCTION + * vm_dd_flood_4_regional + * DESCRIPTION + * copy the appointed frame index image to destination buffer twice, vertical alignment + * PARAMETERS + * buf : [IN] destination buffer + * x_dst : [IN] x offset of destination + * y_dst : [IN] y offset of destination + * source_surface : [IN] source buffer + * width : [IN] source width + * height : [IN] source height + * frame_index : [IN]frame index + * RETURNS + * void + *****************************************************************************/ +void vm_dd_flood_4_regional(VMBYTE *buf, VMINT x_dst, VMINT y_dst,VMBYTE *source_surface, VMINT width, VMINT height, VMINT frame_index); + + +/****************************************************************************** + * FUNCTION + * vm_dd_load_image + * DESCRIPTION + * image decode + * PARAMETERS + * img : [IN] source image buffer + * img_len : [IN] source image length + * RETURNS + * if succeed ,return pointer of decoded data, otherwise return NULL + *****************************************************************************/ +VMUINT8* vm_dd_load_image(VMUINT8 *img, VMINT img_len); + + +/****************************************************************************** + * FUNCTION + * vm_dd_get_img_property + * DESCRIPTION + * get the appointed frame property + * PARAMETERS + * img : [IN] source image buffer + * frame_index : [IN] source image index + * RETURNS + * frame property structure pointer + *****************************************************************************/ +struct frame_prop * vm_dd_get_img_property(VMUINT8 *img, VMUINT8 frame_index); + + +/****************************************************************************** + * FUNCTION + * vm_dd_get_frame_number + * DESCRIPTION + * get the gif image frame number + * PARAMETERS + * img : image pointer + * RETURNS + * frame number + *****************************************************************************/ +VMINT vm_dd_get_frame_number(VMUINT8 *img); + + +/****************************************************************************** + * FUNCTION + * vm_dd_clean + * DESCRIPTION + * clean the buffer with the appointed color + * PARAMETERS + * buf : [IN] buffer pointer + *color16 : [IN] color value + * RETURNS + * void + *****************************************************************************/ +void vm_dd_clean(VMUINT8* buf, VMUINT16 color16); + + + +/****************************************************************************** + * FUNCTION + * vm_dd_active_layer + * DESCRIPTION + * active layer handle + * PARAMETERS + * handle : [IN] layer handle + * RETURNS + * void + *****************************************************************************/ +void vm_dd_active_layer(VMINT handle); + + +/****************************************************************************** + * FUNCTION + * vm_graph_drawtext + * DESCRIPTION + * show string to base layer + * PARAMETERS + * x : [IN] x offset of destination + * y : [IN] y offset of destination + * s : [IN] string pointer + * length : [IN] string length + * color : [IN] string color + * RETURNS + * void + *****************************************************************************/ +void vm_graph_drawtext(VMINT x, VMINT y, VMWSTR s, VMINT32 length, VMUINT16 color); + + +/****************************************************************************** + * FUNCTION + * vm_graph_release_surface + * DESCRIPTION + * free buffer + * PARAMETERS + * off_surface : [IN]buffer pointer + * RETURNS + * void + *****************************************************************************/ +void vm_graph_release_surface(VMUINT8 * off_surface); + + +/****************************************************************************** + * FUNCTION + * vm_graph_create_custom_buf + * DESCRIPTION + * create canvas + * PARAMETERS + * width : [IN] buffer width + * height : [IN] buffer height + * RETURNS + * buffer pointer + *****************************************************************************/ +VMUINT8 * vm_graph_create_custom_buf(VMINT width, VMINT height); + + +/****************************************************************************** + * FUNCTION + * vm_graph_delete_custom_buf + * DESCRIPTION + * delete canvas + * PARAMETERS + * custom_buf : [IN] canvas handle, it means buffer pointer + * RETURNS + * void + *****************************************************************************/ +void vm_graph_delete_custom_buf(VMUINT8 * custom_buf); + + +/****************************************************************************** + * FUNCTION + * vm_graph_move + * DESCRIPTION + * copy buffer from source to destination + * PARAMETERS + * screen_buf : [IN] destination buffer pointer + * x_dest : [IN] x offset of destination + * y_dest : [IN] y offset of destination + * custom_buf : [IN] source buffer pointer + * x_src : [IN]x offset of source + * y_src : [IN]y offset of source + * width : [IN]source width + * height : [IN]source height + * RETURNS + * void + *****************************************************************************/ +void vm_graph_move(VMBYTE *screen_buf, VMINT x_dest, VMINT y_dest, VMBYTE *custom_buf, VMINT x_src, VMINT y_src, VMINT width, VMINT height); + + +/* define vm_graphic_set_text_clip, only for compatible with older version */ +#define vm_graphic_set_text_clip vm_graphic_set_clip + +/* define vm_graphic_reset_text_clip, only for compatible with older version */ +#define vm_graphic_reset_text_clip vm_graphic_reset_clip +/* define vm_dd_clean_ex, only for compatible with older version */ +#define vm_dd_clean_ex vm_dd_clean + +/* define vm_dd_copy_ex, only for compatible with older version */ +#define vm_dd_copy_ex vm_dd_copy + +/* define vm_dd_setpixel_ex, only for compatible with older version */ +#define vm_dd_setpixel_ex vm_graphic_set_pixel + +/* define vm_dd_setpixel, only for compatible with older version */ +#define vm_dd_setpixel vm_graphic_set_pixel + +/* define vm_dd_getpixel_ex, only for compatible with older version */ +#define vm_dd_getpixel_ex vm_graphic_get_pixel + +/* define vm_dd_getpixel, only for compatible with older version */ +#define vm_dd_getpixel vm_graphic_get_pixel + +/* define vm_dd_line_ex, only for compatible with older version */ +#define vm_dd_line_ex vm_graphic_line + +/* define vm_dd_line, only for compatible with older version */ +#define vm_dd_line vm_graphic_line + +/* define vm_dd_rect_ex, only for compatible with older version */ +#define vm_dd_rect_ex vm_graphic_rect + +/* define vm_dd_rect, only for compatible with older version */ +#define vm_dd_rect vm_graphic_rect + +/* define vm_dd_fillrect_ex, only for compatible with older version */ +#define vm_dd_fillrect_ex vm_graphic_fill_rect + +/* define vm_dd_fillrect, only for compatible with older version */ +#define vm_dd_fillrect vm_graphic_fill_rect + +/* define vm_dd_blt_ex, only for compatible with older version */ +#define vm_dd_blt_ex vm_graphic_blt + +/* define vm_dd_blt, only for compatible with older version */ +#define vm_dd_blt vm_graphic_blt + +/* define vm_dd_rotate_ex, only for compatible with older version */ +#define vm_dd_rotate_ex vm_graphic_rotate + +/* define vm_dd_rotate, only for compatible with older version */ +#define vm_dd_rotate vm_graphic_rotate + +/* define vm_dd_mirror_ex, only for compatible with older version */ +#define vm_dd_mirror_ex vm_graphic_mirror + +/* define vm_dd_mirror, only for compatible with older version */ +#define vm_dd_mirror vm_graphic_mirror + +/* define vm_dd_blt_with_opacity, only for compatible with older version */ +#define vm_dd_blt_with_opacity vm_graphic_blt_ex + +/* define vm_graph_initialize, only for compatible with older version */ +#define vm_graph_initialize vm_initialize_screen_buffer + +/* define vm_graph_finalize, only for compatible with older version */ +#define vm_graph_finalize vm_finalize_screen_buffer + +/* define vm_graph_get_buffer, only for compatible with older version */ +#define vm_graph_get_buffer vm_graphic_get_buffer + +/* define vm_graph_flush_buffer, only for compatible with older version */ +#define vm_graph_flush_buffer vm_graphic_flush_buffer + +/* define vm_graph_initialize_clip_rect, only for compatible with older version */ +#define vm_graph_initialize_clip_rect vm_dd_initialize_clip_rect + +/* define vm_graph_blt_all_cutting_frames, only for compatible with older version */ +#define vm_graph_blt_all_cutting_frames vm_dd_blt_all_cutting_frames + +/* define vm_graph_img_flood, only for compatible with older version */ +#define vm_graph_img_flood vm_dd_img_flood + +/* define vm_graph_copy, only for compatible with older version */ +#define vm_graph_copy vm_dd_copy + +/* define vm_graph_load_image, only for compatible with older version */ +#define vm_graph_load_image vm_dd_load_image + +/* define vm_graph_get_img_property, only for compatible with older version */ +#define vm_graph_get_img_property vm_dd_get_img_property + +/* define vm_graph_get_frame_number, only for compatible with older version */ +#define vm_graph_get_frame_number vm_dd_get_frame_number + +/* define vm_graph_clean, only for compatible with older version */ +#define vm_graph_clean vm_dd_clean + +/* define vm_graph_get_bits_per_pixel, only for compatible with older version */ +#define vm_graph_get_bits_per_pixel vm_graphic_get_bits_per_pixel + +/* define vm_graph_set_clip, only for compatible with older version */ +#define vm_graph_set_clip vm_graphic_set_clip + +/* define vm_graph_reset_clip, only for compatible with older version */ +#define vm_graph_reset_clip vm_graphic_reset_clip + +/* define vm_graphic_reset_text_clip, only for compatible with older version */ +#define vm_graph_get_screen_width vm_graphic_get_screen_width + +/* define vm_graph_get_screen_height, only for compatible with older version */ +#define vm_graph_get_screen_height vm_graphic_get_screen_height + +/* define vm_graph_get_character_height, only for compatible with older version */ +#define vm_graph_get_character_height vm_graphic_get_character_height + +/* define vm_graph_get_character_width, only for compatible with older version */ +#define vm_graph_get_character_width vm_graphic_get_character_width + +/* define vm_graph_measure_character, only for compatible with older version */ +#define vm_graph_measure_character vm_graphic_measure_character + +/* define vm_graph_get_string_width, only for compatible with older version */ +#define vm_graph_get_string_width vm_graphic_get_string_width + +/* define vm_graph_set_font, only for compatible with older version */ +#define vm_graph_set_font vm_graphic_set_font + +/* define vm_graph_setpixel, only for compatible with older version */ +#define vm_graph_setpixel vm_graphic_set_pixel + +/* define vm_graph_getpixel, only for compatible with older version */ +#define vm_graph_getpixel vm_graphic_get_pixel + +/* define vm_graph_line, only for compatible with older version */ +#define vm_graph_line vm_graphic_line + +/* define vm_graph_rect, only for compatible with older version */ +#define vm_graph_rect vm_graphic_rect + +/* define vm_graph_fillrect, only for compatible with older version */ +#define vm_graph_fillrect vm_graphic_fill_rect + +/* define vm_graph_blt, only for compatible with older version */ +#define vm_graph_blt vm_graphic_blt + +/* define vm_graph_rotate, only for compatible with older version */ +#define vm_graph_rotate vm_graphic_rotate + +/* define vm_graph_mirror, only for compatible with older version */ +#define vm_graph_mirror vm_graphic_mirror + +/* define vm_graph_draw_gif, only for compatible with older version */ +#define vm_graph_draw_gif vm_graphic_draw_gif + +#ifdef __cplusplus +} +#endif + +#endif /* VMCPT_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmgps.h b/hardware/arduino/mtk/system/libmtk/include/vmgps.h new file mode 100644 index 00000000..3d482f3e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmgps.h @@ -0,0 +1,352 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMGPS_SDK_H_ +#define VMGPS_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/*GPS open result status*/ +typedef enum{ + VM_GPS_OPEN_MEMORY_LESS = -2 , /*memory not enough*/ + VM_GPS_OPEN_RES_LESS = -1 , /*lack of resource*/ + VM_GPS_OPEN_SUCCESS = 0, /*Open successfully, need waiting callback */ + VM_GPS_OPEN_ALREADY_OPEN = 1 /*Already open*/ +} vm_gps_open_state_enum; + +/*GPS close result status*/ +typedef enum{ + VM_GPS_CLOSE_FAILED = -1, /*Close failed*/ + VM_GPS_CLOSE_SUCCESS = 0, /*Close successfully*/ + VM_GPS_CLOSE_STILL_APP_USE_DATA = 1 /*GPS information still used by other application*/ +} vm_gps_close_state_enum; + +/*GPS set mode result status*/ +typedef enum{ + VM_GPS_SET_MODE_NOT_OPEN = -1, /*GPS not opened, please open it first*/ + VM_GPS_SET_MODE_CLOSE_SUCCESS = 0, /*set mode successfully*/ + VM_GPS_SET_PARAM_SUCCESS = 1 /*set mode successfully*/ +} vm_gps_setmode_state_enum; + +/*GPS type. This type dependent your GPS chip. 3336 only support VM_GPS_ONLY. */ +typedef enum +{ + VM_GPS_ONLY, /* GPS_ONLY */ + VM_GPS_GLONASS, /* GPS+GLONASS */ + VM_GPS_BEIDOU, /* GPS+BEIDOU */ + VM_GPS_TYPE_END +} vm_gps_type_enum; + +#define VM_MAX_GPGGA_SENTENCE_LENGTH 100 +#define VM_MAX_GPGSA_SENTENCE_LENGTH 80 +#define VM_MAX_GPRMC_SENTENCE_LENGTH 100 +#define VM_MAX_GPVTG_SENTENCE_LENGTH 80 +#define VM_MAX_GPGSV_SENTENCE_LENGTH 400 +#define VM_MAX_GLGSV_SENTENCE_LENGTH 400 +#define VM_MAX_BDGSV_SENTENCE_LENGTH 400 +#define VM_MAX_BDGSA_SENTENCE_LENGTH 80 +#define VM_MAX_GLGSA_SENTENCE_LENGTH 80 + +/*GPS data structure */ +typedef struct +{ + VMUINT8 GPGGA[VM_MAX_GPGGA_SENTENCE_LENGTH+1]; /* GGA data */ + VMUINT8 GPGSA[VM_MAX_GPGSA_SENTENCE_LENGTH+1]; /* GSA data */ + VMUINT8 GPRMC[VM_MAX_GPRMC_SENTENCE_LENGTH+1]; /* RMC data */ + VMUINT8 GPVTG[VM_MAX_GPVTG_SENTENCE_LENGTH+1]; /* VTG data */ + VMUINT8 GPGSV[VM_MAX_GPGSV_SENTENCE_LENGTH+1]; /* GSV data */ + VMUINT8 GLGSV[VM_MAX_GLGSV_SENTENCE_LENGTH+1]; /* GLONASS GSV data */ + VMUINT8 GLGSA[VM_MAX_GLGSA_SENTENCE_LENGTH+1]; /* GLONASS GSA data */ + VMUINT8 BDGSV[VM_MAX_BDGSV_SENTENCE_LENGTH+1]; /* BD GSV data */ + VMUINT8 BDGSA[VM_MAX_BDGSA_SENTENCE_LENGTH+1]; /* BD GSA data */ +} vm_gps_sentence_info; + +/*GPS start mode status. Only for test.*/ +typedef enum +{ + VM_GPS_START_MODE_NULL, + VM_GPS_HOT_START, /* To test GPS hot start */ + VM_GPS_WARM_START, /* To test GPS warm start */ + VM_GPS_COLD_START, /* To test GPS cold start */ + VM_GPS_FULL_START, /* To test GPS full start */ + VM_GPS_START_TYPE_END +}vm_gps_mode_enum; + +/*GPS start set parameter*/ +typedef enum +{ + VM_GPS_CMD_SET_LOCATION_REPORT_PERIOD = 1, /* Set GPS positioning period of normal mode. The minimun is 1s. */ + VM_GPS_CMD_SET_LOCATION_REPORT_PREIOD_SLEEP_WORK, /* Set GPS positioning period of low power mode (Sleep First Mode). GPS will power off firstly in positioning cycle. And then willl auto power on to get position before period timer out.*/ + VM_GPS_CMD_SET_LOCATION_REPORT_PREIOD_WROK_SLEEP, /* Set GPS positioning period of low power mode (Work First Mode). GPS will power on to get position. And then will power off for low power. After period timer out will power on again. */ + VM_GPS_CMD_SET_ASSIST_DATA_FOR_FAST_FIXED, /* Set GPS assist data for ast fixed. */ + VM_GPS_CMD_SET_END +} vm_gps_set_param_enum; + +/*GPS assist data*/ +typedef struct +{ + VMUINT16 u2YEAR ; /* > 2000 */ + VMUINT8 u1MONTH; /* 1~12 */ + VMUINT8 u1DAY; /* 1~31*/ + VMUINT8 u1HOUR; /* 0~23*/ + VMUINT8 u1MIN; /* 0~59*/ + VMUINT8 u1SEC; /* 0~59*/ +}vm_gps_assist_data_cfg; + +/*GPS callback message*/ +typedef enum +{ + VM_GPS_OPEN_CNF, /* GPS open confirm msg, data is the result of success of not */ + VM_GPS_SET_MODE_CNF, /* GPS set mode confirm msg, data is the result of success of not */ + VM_GPS_CLOSE_CNF, /* GPS close confirm msg, data is the result of success of not, LINKIT app cannot receive this msg now */ + VM_GPS_SENTENCE_DATA, /* GPS data receive msg, the data is the GPS sentence data, refer vm_gps_sentence_info */ + VM_GPS_SET_PARAM_CNF /* GPS set parameter confirm msg, data is the result of success of not */ +}vm_gps_msg_type_enum; + + +typedef void (*VM_GPS_CAlLBACK_FUNC)(VMINT msg, void* data); + +/***************************************************************************** +* FUNCTION + * vm_gps_open + * DESCRIPTION + * Open GPS. This funtion will also open UART port. + * PARAMETERS + * period [IN] period of update data, must be 1, now + * call_back [IN] callback function, will be invoked when get the message of vm_gps_msg_type_enum. + * RETURNS + * result of open operation. + * RETURN VALUES + * VM_GPS_OPEN_SUCCESS : Open successfully. + * VM_GPS_OPEN_ALREADY_OPEN : Already open. + * VM_GPS_OPEN_MEMORY_LESS : memory not enough + * VM_GPS_OPEN_RES_LESS : lack of resource + * + * Example + * + * + * vm_gps_sentence_info g_info + * + * static void vm_gps_callback(VMINT msg, void* data) + * { + * switch(msg) + * { + * case VM_GPS_OPEN_CNF: + * { + * VMINT result = (VMINT)data; + * if(result == 0) + * { + * // open success + * // if need you can set mode + * // vm_gps_set_mode(); + * } + * else + * { + * // open failed + * } + * } + * break; + * case VM_GPS_CLOSE_CNF: + * // app cannot receive this msg now, ignore this. + * break; + * case VM_GPS_SET_MODE_CNF: + * { + * VMINT result = (VMINT)data; + * if(result == 0) + * // set mode success + * else + * // set mode failed + * } + * break; + * case VM_GPS_SENTENCE_DATA: + * { + * // copy data + * memcpy(&g_info, (vm_gps_sentence_info*)data, sizeof(vm_gps_sentence_info)); + * + * // deal with the data + * } + * break; + * } + * } + * + * int vm_gps_test(void) + * { + * VMINT result; + * result = vm_gps_open( 1, VM_GPS_ONLY, vm_gps_callback); + * + * if(result == VM_GPS_OPEN_SUCCESS) + * { + * // this is first time to open GPS, need to get the message VM_GPS_OPEN_CNF + * } + * else if(result == VM_GPS_OPEN_ALREADY_OPEN) + * { + * // GPS had been opened before, can get data, no need to wait VM_GPS_OPEN_CNF + * // if need you can set mode + * // vm_gps_set_mode(); + * } + * else + * { + * // open failed + * } + * } + * + * + * void handle_sysevt(VMINT message, VMINT param) + * { + * switch (message) + * { + * case VM_MSG_CREATE: + * { + * VMINT result; + * result = vm_gps_open( 1, VM_GPS_ONLY, vm_gps_callback); + * + * if(result == VM_GPS_OPEN_SUCCESS) + * { + * // this is first time to open GPS, need to get the message VM_GPS_OPEN_CNF + * } + * else if(result == VM_GPS_OPEN_ALREADY_OPEN) + * { + * // GPS had been opened before, can get data, no need to wait VM_GPS_OPEN_CNF + * // if need you can set mode + * // vm_gps_set_mode(); + * } + * else + * { + * // open failed + * } + * } + * break; + * case VM_MSG_QUIT: + * vm_gps_close(); + * break; + * break; + * } + * } + * } + * + * + *****************************************************************************/ +VMINT vm_gps_open(VMUINT period, vm_gps_type_enum type, VM_GPS_CAlLBACK_FUNC callback); + +/***************************************************************************** +* FUNCTION + * vm_gps_close + * DESCRIPTION + * Close GPS. This funtion will close GPS if there is no other application use GPS. + * RETURNS + * result of close operation. + * RETURN VALUES + * VM_GPS_CLOSE_SUCCESS : Close successfully. + * VM_GPS_CLOSE_STILL_APP_USE_DATA : GPS information still used by other application + * VM_GPS_CLOSE_FAILED : Close failed. + * + * Example + * + * please refer vm_gps_open + * +*****************************************************************************/ +VMINT vm_gps_close(void); + +/***************************************************************************** +* FUNCTION + * vm_gps_set_mode + * DESCRIPTION + * set GPS start mode. This API is only for test. Please don't use it in normal usage. + * PARAMETERS + * mode [IN] start mode of GPS, please refer vm_gps_mode_enum type + * RETURNS + * result of close operation. + * RETURN VALUES + * VM_GPS_SET_MODE_CLOSE_SUCCESS : set mode successfully. + * VM_GPS_SET_MODE_NOT_OPEN : GPS not opened, need open it. + * + * Example + * + * please refer vm_gps_open + * +*****************************************************************************/ +VMINT vm_gps_set_mode(vm_gps_mode_enum mode); + +/***************************************************************************** +* FUNCTION + * vm_gps_set_param + * DESCRIPTION + * set GPS parameter + * PARAMETERS + * mode [IN] set parameter of GPS, please refer vm_gps_param_enum type + * value [IN] parameter value + * RETURNS + * result of the operation. + * RETURN VALUES + * 0 : set mode successfully. + * -1 : GPS not opened, need open it. + * + * Example + * + * + * void set_param(void) + * { + * // If you need set gps assist data. + * vm_gps_assist_data_cfg cfg; + * cfg.u2YEAR = 2000; + * cfg.u1MONTH = 7; + * cfg.u1DAY = 22; + * cfg.u1HOUR = 10; + * cfg.u1MIN = 10; + * cfg.u1SEC = 10; + * vm_gps_set_param(VM_GPS_CMD_SET_ASSIST_DATA_FOR_FAST_FIXED, &cfg); + * + * // If you need set GPS normal mode and positioning period. + * vm_gps_set_param(VM_GPS_CMD_SET_LOCATION_REPORT_PERIOD, 1); + * // If you need set GPS low power mode (Sleep first mode) and positioning period. + * vm_gps_set_param(VM_GPS_CMD_SET_LOCATION_REPORT_PREIOD_SLEEP_WORK, 60); + * // If you need set GPS low power mode (Work first mode) and positioning period. + * vm_gps_set_param(VM_GPS_CMD_SET_LOCATION_REPORT_PREIOD_WROK_SLEEP, 60); + * } + * + * +*****************************************************************************/ +VMINT vm_gps_set_param(vm_gps_set_param_enum param, VMUINT32 value); + +#ifdef __cplusplus +} +#endif + +#endif /* VMGPS_SDK_H_ */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmgraph.h b/hardware/arduino/mtk/system/libmtk/include/vmgraph.h new file mode 100644 index 00000000..70d84355 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmgraph.h @@ -0,0 +1,2676 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMGRAPHIC_SDK_H_ +#define VMGRAPHIC_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/* GDI return code */ +typedef enum +{ + VM_GDI_ERR_BASE_LAYER_EXIST = -17, //baselayer exist when set wallpaper + VM_GDI_FONTSIZE_NOT_SUPPORT = -16, //self define size not support + VM_GDI_ERR_NOT_SUPPORT_ROTATE = -15, + VM_GDI_MIBR_ERR = -14, /*general MIBR error*/ + VM_GDI_MIBR_RES_ERR, /*GDI MIBR resource error*/ + VM_GDI_MIBR_NOT_FORE, /*APP is not in foreground status*/ + VM_GDI_MIBR_NO_RES, /*no resource */ + VM_GDI_ERR_PLATFORM_DECODE_FAILED, /*platform decode error*/ + VM_GDI_ERR_BASE_LAYER_NOT_EXIST, /*base layer not exist*/ + VM_GDI_ERR_UNSUPPORT_IMAGE_TYPE, /*decode image type no support*/ + VM_GDI_ERR_MALLOC_FAILED, /*can not malloc memory*/ + VM_GDI_ERR_LAYER_BIND, /*layer bind with canvas error*/ + VM_GDI_ERR_FREE_RES, /*free resource error*/ + VM_GDI_ERR_CREATE_LAYER_FAILED, /*create layer fail*/ + VM_GDI_ERR_CREATE_CANVAS_FAILED, /*general MIBR fail*/ + VM_GDI_ERR_WRONG_PARAM, /*parameter error*/ + VM_GDI_FAILED, /*general GDI error*/ + VM_GDI_SUCCEED /*general GDI succeed*/ +}vm_graphic_result; + +/*GDI rotate type*/ +typedef enum +{ + VM_GDI_ROTATE_NORMAL = 0, /*rotate 0 degree*/ + VM_GDI_ROTATE_90 = 0x01, /*rotate 90 degree*/ + VM_GDI_ROTATE_180 = 0x02, /*rotate 180 degree*/ + VM_GDI_ROTATE_270 = 0x03, /*rotate 270 degree*/ + VM_GDI_MIRROR = 0x80, /*mirror*/ + VM_GDI_MIRROR_ROTATE_90 = 0x81,/*mirror 90 degree*/ + VM_GDI_MIRROR_ROTATE_180 = 0x82,/*mirror 180 degree*/ + VM_GDI_MIRROR_ROTATE_270 = 0x83/*mirror 270 degree*/ +}vm_graphic_rotate_value; + + +/*GDI gradient paint style*/ +typedef enum +{ + VM_GDI_GP_HOR = 0, /*horizon*/ + VM_GDI_GP_VER, /*vertical*/ + VM_GDI_GP_DIA, /*lean 45 degree */ + VM_GDI_GP_DIA_INV, /*de-lean 45 degree*/ + VM_GDI_GP_FLIP /*from middle to edge*/ +}vm_graphic_gp_style; + +/*screen rotate type enum*/ +typedef enum +{ + VM_GRAPHIC_SCREEN_ROTATE_0=0, + VM_GRAPHIC_SCREEN_ROTATE_90,//1 + VM_GRAPHIC_SCREEN_ROTATE_180,//2 + VM_GRAPHIC_SCREEN_ROTATE_270,//3 + VM_GRAPHIC_SCREEN_ROTATE_MIRROR_0,//4 + VM_GRAPHIC_SCREEN_ROTATE_MIRROR_90,//5 + VM_GRAPHIC_SCREEN_ROTATE_MIRROR_180,//6 + VM_GRAPHIC_SCREEN_ROTATE_MIRROR_270,//7 + VM_GRAPHIC_SCREEN_ROTATE_MAX_TYPE//8 +} vm_graphic_screen_rotate_value; + + +typedef enum +{ + VM_FONT_ENGINE_ERROR = -1, + VM_FONT_ENGINE_NO_ERROR = 0, + VM_FONT_ENGINE_NO_TRUNCATION, + VM_FONT_ENGINE_TRUNCATION, + VM_FONT_ENGINE_ERROR_NULL_STRING, + VM_FONT_ENGINE_ZERO_LENGTH, + VM_FONT_ENGINE_ERROR_NO_TRUNCATION_AVAILABLE, + VM_FONT_ENGINE_END_OF_ENUM +} vm_font_engine_error_message_enum; + +/* + *This macro is not work now,just keep for compatibility. + */ +#define MAX_BLT_LAYER (4) +/* GDI_RESULT define*/ +#define VM_GDI_RESULT VMINT + +/* GDI_HANDLE define*/ +#define VM_GDI_HANDLE VMINT + +/* max layer width*/ +#define MAX_LAYER_WIDTH (65535) + +/*max layer height*/ +#define MAX_LAYER_HEIGHT (65535) + +/*max layer count*/ +#define MAX_LAYER (16) + + +/*max layer number when flatten to other layer or canvas*/ +#define MAX_FLATTEN_LAYER (4) + +/*max multiples when enlarge image */ +#define MAX_PIXEL_ENLARGE (512) + +/*the offset from the canvas beginning to the image data*/ +#define CANVAS_BUF_OFFSET (VM_CANVAS_SIGNATURE_SIZE + VM_CANVAS_FRAME_PROPERTY_SIZE) + +/*layer or canvas attribute: no transparent color*/ +#define VM_NO_TRANS_COLOR (-1) + + +/* RGB565 white color */ +#define VM_COLOR_WHITE (0XFFFF) + +/* RGB565 black color */ +#define VM_COLOR_BLACK (0X0000) + +/* RGB565 red color */ +#define VM_COLOR_RED (0XF800) + +/* RGB565 green color */ +#define VM_COLOR_GREEN (0X07E0) + +/* RGB565 blue color */ +#define VM_COLOR_BLUE (0X001F) + +/* get color value from RGB value */ +#define VM_RGB(r, g, b) ((b << 16) + (g << 8) + r) + +/* get RGB32 color value (BGRA) from ARGB value */ +#define VM_RGB32_ARGB(a, r, g, b) ((b << 24) + (g << 16) + (r << 8) + a) + +/* get RGB565 color value from ARGB value, the same as VM_COLOR_888_TO_565(r, g, b) */ +#define VM_RGB565_ARGB(a, r, g, b) (((r & 0xf8) + ((g & 0xe0) >> 5)) << 8) + ((g & 0x1c) << 3) + (b >> 3) + +/* get a RGB32 value of int type (BGRA) from 565 color*/ +#define VM_COLOR_RGB565_TO_RGB32(color16) ((color16 & 0x001F) << 27) + ((color16 & 0x07E0) << 13) + ((color16 & 0xF800)) + +/* get 565 color from a value of int type */ +#define VM_COLOR_INT_TO_565(i) ((i & 0xf8) << 8) + ((i & 0xfc00) >> 5) + ((i & 0xf80000) >> 19) + +/* convert color format from 888 to 565 */ +#define VM_COLOR_888_TO_565(r, g, b) (((r & 0xf8) + ((g & 0xe0) >> 5)) << 8) + ((g & 0x1c) << 3) + (b >> 3) + +/* convert color format from 565 to 888 */ +#define VM_COLOR_565_TO_888(color16) ((color16 & 0x001F) << 19) + ((color16 & 0x07E0) << 5) + ((color16 & 0xF800) >> 8) + +/* get Red value from a rgb value */ +#define VM_COLOR_GET_RED(color16) ((color16 & 0xF800) >> 8) + +/* get Green value from a rgb value */ +#define VM_COLOR_GET_GREEN(color16) ((color16 & 0x07E0) >> 3) + +/* get Blue value from a rgb value */ +#define VM_COLOR_GET_BLUE(color16) ((color16 & 0x001F) << 3) + +#define VM_CANVAS_DATA_OFFSET (32) + +typedef void (*vm_graphic_screen_rotate_event_callback)(VMINT, VMINT); // 1:envent 2:inside/outside|| horizontal/vertical + + +/*clip region*/ +typedef struct clip_rect{ + VMINT16 left; /*x offset at begin*/ + VMINT16 top; /*y offset at begin*/ + VMINT16 right; /*x offset at end*/ + VMINT16 bottom; /*y offset at end*/ + VMBYTE flag; /* flag = 0: the clip region is invalid; flag =1: the clip region is valid*/ +}clip_rect; + + +/* single frame info for gif image */ +struct frame_prop +{ + VMUINT8 flag; /* marker to show it is frame beginning */ + VMUINT8 is_resize; /* if resize */ + VMUINT16 left; /* x offset */ + VMUINT16 top; /* y offset */ + VMUINT16 width; /*image width */ + VMUINT16 height; /* image height*/ + VMUINT16 delay_time; /* the interval between two frames*/ + VMUINT8 trans_color_index; /* reserved*/ + VMUINT16 trans_color; /* transparent color*/ + VMUINT32 offset; /* current frame size , unit:byte */ +}; + +/*image property*/ +typedef struct _vm_graphic_imgprop +{ + VMINT width; /*image widtg*/ + VMINT height; /*image height*/ +}vm_graphic_imgprop; + +/*character infomation*/ +typedef struct _vm_graphic_char_info +{ + VMINT dwidth; /*the real width of the character, can be used for typeset*/ + VMINT width; /*the width of the character, not include padding*/ + VMINT height; /*the height of the character*/ + VMINT ascent; /*base line*/ + VMINT descent; /*the length from the character bottom to the baseline*/ +}vm_graphic_char_info; + +/* font size */ +typedef enum { + VM_SMALL_FONT, /*small font*/ + VM_MEDIUM_FONT, /*medium font*/ + VM_LARGE_FONT /*large font*/ +} font_size_t; + +/*create mode of layer */ +typedef enum{ + VM_BASE_LAYER = 1, /*create base layer*/ + VM_FAST_LAYER , /*create fast layer(no need to malloc memory*/ + VM_BUF, /*create layer using outside memory*/ + VM_CREATE_CANVAS /*create layer, and create canvas at the same time*/ +}vm_layer_mode; + +/*property of canvas*/ +typedef enum{ + VM_CANVAS_LEFT = 1, /*x offset*/ + VM_CANVAS_TOP, /*y offset*/ + VM_CANVAS_WIDTH, /*canvas width*/ + VM_CANVAS_HEIGHT, /*canvas height*/ + VM_CANVAS_CF, /*canvas color format*/ + VM_CANVAS_DATASIZE /*canvas data size*/ +}vm_canvas_prop; + + +/*point structure*/ +typedef struct _vm_graphic_point{ + VMINT16 x; /*x offset*/ + VMINT16 y; /*y offset*/ +}vm_graphic_point; + +/*color structure*/ +typedef struct _vm_graphic_color{ + VMUINT vm_color_565; /*color value in 565 style*/ + VMUINT vm_color_888; /*color value in 888 style*/ +}vm_graphic_color; + + +typedef struct _vm_graphic_color_argb{ + VMUINT8 a; /* alpha */ + VMUINT8 r; /* red */ + VMUINT8 g; /* green */ + VMUINT8 b; /* blue */ +}vm_graphic_color_argb; + + +/*pen structure*/ +typedef struct _vm_graphic_pen{ + VMBYTE cycle; /*the length of one cycle*/ + VMBYTE *bitvalues;/*the value of one cycle ,example:VMBYTE bitvalues[] = {1,1,1,0,0}; + vm_graphic_pen pen; + pen.cycle = sizeof(bitvalues); + pen.bitvalues = bitvalues; */ +}vm_graphic_pen; + + +typedef enum +{ + VM_GRAPHIC_COLOR_FORMAT_16, /* 16-bit, rgb 565 */ + VM_GRAPHIC_COLOR_FORMAT_24, /* 24-bit, B,G,R 8,8,8 */ + VM_GRAPHIC_COLOR_FORMAT_32, /* 32-bit, B,G,R,A 8,8,8,8 */ + VM_GRAPHIC_COLOR_FORMAT_32_PARGB, /* 32-bit, PB,PG,PR,A 8,8,8,8 */ + VM_GRAPHIC_COLOR_FORMAT_END +} vm_graphic_color_famat_enum; + + +typedef VMUINT8 vm_graphic_color_famat; + + +typedef enum +{ + VM_FRM_SCREEN_ROTATE_0, + VM_FRM_SCREEN_ROTATE_90, + VM_FRM_SCREEN_ROTATE_180, + VM_FRM_SCREEN_ROTATE_270, + VM_FRM_SCREEN_ROTATE_MIRROR_0, + VM_FRM_SCREEN_ROTATE_MIRROR_90, + VM_FRM_SCREEN_ROTATE_MIRROR_180, + VM_FRM_SCREEN_ROTATE_MIRROR_270, + VM_FRM_SCREEN_ROTATE_MAX_TYPE +} vm_frm_screen_rotate_enum; + +typedef enum { + VM_NON_CACHEABLE, + VM_CACHEABLE, +} vm_cacheable_t; + + + +/***************************************************************************** + * FUNCTION + * vm_graphic_get_screen_width + * DESCRIPTION + * get the screen width + * PARAMETERS + * void + * RETURNS + * the width of the screen + *****************************************************************************/ +VMINT vm_graphic_get_screen_width(void); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_get_screen_height + * DESCRIPTION + * get the screen height + * PARAMETERS + * void + * RETURNS + * the height of the screen + *****************************************************************************/ +VMINT vm_graphic_get_screen_height(void); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_create_layer + * DESCRIPTION + * Create layer.layer is the simulation for LCD. + * using this api, user can create two layers at most, and user needn't to require additional memory for it. + * layer 0: same with LCD's size and position. it means, top left coordination must be (0,0), width = screen width and height = screen height + * layer 1: user can set the opacity, position,size(can not larger than LCD's size). + * the two layers can be merged with the appointed opacity + * PARAMETERS + * x : [IN]x_top left coordination + * y : [IN]y_top left coordination + * width : [IN] the width of the layer, the unit:pixel + * height : [IN]the height of the layer, the unit:pixel + * trans_color : [IN]the transparent color. -1 means no transparent color. + * RETURNS + * if succeed, return the layer handle, if fail, return the error code + * EXAMPLE + * VMINT layer_hdl[2] = {0}; + * layer_hdl[0] = vm_graphic_create_layer(0, 0, vm_graphic_get_screen_width(), vm_graphic_get_screen_height(), VM_NO_TRANS_COLOR); + * //user can draw on the layer + * vm_graphic_line_ex( layer_hdl[0],0,0,100,100); + * .... + * // when need to show it to the LCD + * vm_graphic_flush_layer( layer_hdl[0], 1); + * //when no more use the layer, delete it + * vm_graphic_delete_layer(layer_hdl[0]); + *****************************************************************************/ +VMINT vm_graphic_create_layer(VMINT x, VMINT y, VMINT width, VMINT height, VMINT trans_color); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_delete_layer + * DESCRIPTION + * delete the layer created by vm_graphic_create_layer. user can release the layer when app exits + * PARAMETERS + * handle : [IN] the layer handle to be deleted + * RETURNS + * if succeed, return VM_GDI_SUCCEED. otherwise, return error code + *****************************************************************************/ +VMINT vm_graphic_delete_layer(VMINT handle); + + + +/***************************************************************************** + * FUNCTION + * vm_graphic_active_layer + * DESCRIPTION + * active layer. all the GDI operation is valid only to the active layer. + * PARAMETERS + * handle : [IN]the layer handle to be actived.if the layer handle is wrong, system will not change, it means + * current active layer will not change + * RETURNS + * if succeed, return VM_GDI_SUCCEED. otherwise, return error code + *****************************************************************************/ +VMINT vm_graphic_active_layer(VMINT handle); + + + +/***************************************************************************** + * FUNCTION + * vm_graphic_get_layer_buffer + * DESCRIPTION + * get the appointed layer's buffer + * PARAMETERS + * handle : [IN]layer handle + * RETURNS + * if succeed, return buffer address. otherwise, return NULL + *****************************************************************************/ +VMUINT8* vm_graphic_get_layer_buffer (VMINT handle); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_clear_layer_bg + * DESCRIPTION + * clean the layer with the transparent color. the color is same as the trans_color used in vm_graphic_create_layer() + * PARAMETERS + * handle : [IN]layer handle + * RETURNS + * if succeed, return VM_GDI_SUCCEED. otherwise, return VM_GDI_FAILED + *****************************************************************************/ +VMINT vm_graphic_clear_layer_bg (VMINT handle); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_flush_layer + * DESCRIPTION + * flatten layers to one layer and blt to LCD. Only call this API does app can update LCD + * PARAMETERS + * layer_handles : [IN] the pointer of layer array + * count : [IN] layer number that to be flushed. if the number is larger than max layer count (get by vm_graphic_get_blt_layer_count()), + * just use the max layer count + * RETURNS + * if succeed, return VM_GDI_SUCCEED. otherwise, return error code + *****************************************************************************/ +VMINT vm_graphic_flush_layer(VMINT* layer_handles, VMINT count); + +/***************************************************************************** + * FUNCTION + * vm_graphic_flush_layer_non_block + * DESCRIPTION + * flatten layers to one layer and blt to LCD non block. + * PARAMETERS + * layer_handles : [IN] the pointer of layer array + * count : [IN] layer number that to be flushed. if the number is larger than max layer count (get by vm_graphic_get_blt_layer_count()), + * just use the max layer count + * RETURNS + * if succeed, return VM_GDI_SUCCEED. otherwise, return error code + *****************************************************************************/ +VMINT vm_graphic_flush_layer_non_block(VMINT* layer_handles, VMINT count); + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_layer_count + * DESCRIPTION + * get the max layer number of current platform + * PARAMETERS + * void + * RETURNS + * the max layer number + *****************************************************************************/ + + +VMINT vm_graphic_get_layer_count(void); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_layer_position + * DESCRIPTION + * get the layer position + * PARAMETERS + * handle : [IN] layer handle + * x : [OUT] x_top left coordination + * y : [OUT] y_top left coordination + * width : [OUT] layer width + * height : [OUT] layer height + * RETURNS + * if succeed, return VM_GDI_SUCCEED,otherwise return error code + *****************************************************************************/ +VMINT vm_graphic_get_layer_position(VMINT handle, VMINT *x, VMINT *y, VMINT *width, VMINT *height); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_set_layer_opacity + * DESCRIPTION + * set the layer opacity. value range:[0,100], 0 means the layer is transparent. + * PARAMETERS + * handle : [IN] layer handle + * percent : [IN] the percent of opacity + * RETURNS + * if succeed, return VM_GDI_SUCCEED,otherwise return error code + *****************************************************************************/ +VMINT vm_graphic_set_layer_opacity(VMINT handle, VMINT percent); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_bits_per_pixel + * DESCRIPTION + * get the byte number of one pixel in current platform + * PARAMETERS + * void + * RETURNS + * the number of byte + *****************************************************************************/ +VMINT vm_graphic_get_bits_per_pixel(void); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_pixel + * DESCRIPTION + * get the color of the appointed point in the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the point + * y : [IN] y offset of the point + * RETURNS + * the color of the point + *****************************************************************************/ +VMUINT16 vm_graphic_get_pixel(VMUINT8 *buf, VMINT x, VMINT y); + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_pixel_cf + * DESCRIPTION + * get the color of the appointed point in the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the point + * y : [IN] y offset of the point + * RETURNS + * the color of the point, the color value include a, r, g, b value + *****************************************************************************/ +vm_graphic_color_argb vm_graphic_get_pixel_cf(VMUINT8 *buf, VMINT x, VMINT y); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_set_pixel + * DESCRIPTION + * draw a point on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the point + * y : [IN] y offset of the point + * color : [IN] color of the point + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_set_pixel(VMUINT8 *buf, VMINT x,VMINT y, VMUINT16 color); + +/****************************************************************************** + * FUNCTION + * vm_graphic_set_pixel_cf + * DESCRIPTION + * draw a point on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the point + * y : [IN] y offset of the point + * color : [IN] color of the point, the color value include a, r, g, b value + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_set_pixel_cf(VMUINT8 *buf, VMINT x, VMINT y, vm_graphic_color_argb* color); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_line + * DESCRIPTION + * draw a line on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the start point + * y : [IN] y offset of the start point + * x : [IN] x offset of the end point + * y : [IN] y offset of the end point + *color : [IN] color of the line + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_line(VMUINT8 *buf, VMINT x0, VMINT y0, VMINT x1, VMINT y1, VMUINT16 color); + +/****************************************************************************** + * FUNCTION + * vm_graphic_line_cf + * DESCRIPTION + * draw a line on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the start point + * y : [IN] y offset of the start point + * x : [IN] x offset of the end point + * y : [IN] y offset of the end point + *color : [IN] color of the line, the color value include a, r, g, b value + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_line_cf(VMUINT8 *buf, VMINT x0, VMINT y0, VMINT x1, VMINT y1, vm_graphic_color_argb* color); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_rect + * DESCRIPTION + * draw a rect on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the start point + * y : [IN] y offset of the start point + * width : [IN] width of the rect + * height : [IN] height of the rect + *color : [IN] color of the rect + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_rect(VMUINT8 *buf, VMINT x, VMINT y, VMINT width, VMINT height, VMUINT16 color); + +/****************************************************************************** + * FUNCTION + * vm_graphic_rect_cf + * DESCRIPTION + * draw a rect on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the start point + * y : [IN] y offset of the start point + * width : [IN] width of the rect + * height : [IN] height of the rect + *color : [IN] color of the rect, the color value include a, r, g, b value + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_rect_cf(VMUINT8 *buf, VMINT x, VMINT y, VMINT width, VMINT height, vm_graphic_color_argb* color); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_fill_rect + * DESCRIPTION + * draw a filled rect on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the start point + * y : [IN] y offset of the start point + * width : [IN] width of the rect + * height : [IN] height of the rect + * line_color : [IN] color of the frame + * back_color : [IN] color of the filled + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_fill_rect(VMUINT8 *buf, VMINT x, VMINT y, VMINT width, VMINT height, VMUINT16 line_color, VMUINT16 back_color); + +/****************************************************************************** + * FUNCTION + * vm_graphic_fill_rect_cf + * DESCRIPTION + * draw a filled rect on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the start point + * y : [IN] y offset of the start point + * width : [IN] width of the rect + * height : [IN] height of the rect + * line_color : [IN] color of the frame, the color value include a, r, g, b value + * back_color : [IN] color of the filled, the color value include a, r, g, b value + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_fill_rect_cf(VMUINT8 *buf,VMINT x,VMINT y,VMINT width,VMINT height,vm_graphic_color_argb* line_color,vm_graphic_color_argb* back_color); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_roundrect + * DESCRIPTION + * draw a round rectangle on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the start point + * y : [IN] y offset of the start point + * width : [IN] width of the round rectangle + * height : [IN] height of the round rectangle + * corner_width : [IN] radius of the rounded angle. the value must less than half of width, if not, the api will have no effect + * color : [IN] color of the round rectangle + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_roundrect (VMUINT8 * buf, VMINT x, VMINT y, VMINT width, VMINT height, VMINT corner_width, VMUINT16 color); + +/****************************************************************************** + * FUNCTION + * vm_graphic_roundrect_cf + * DESCRIPTION + * draw a round rectangle on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the start point + * y : [IN] y offset of the start point + * width : [IN] width of the round rectangle + * height : [IN] height of the round rectangle + * corner_width : [IN] radius of the rounded angle. the value must less than half of width, if not, the api will have no effect + * color : [IN] color of the round rectangle, the color value include a, r, g, b value + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_roundrect_cf (VMUINT8 * buf, VMINT x, VMINT y, VMINT width, VMINT height, VMINT corner_width, vm_graphic_color_argb* color); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_fill_roundrect + * DESCRIPTION + * draw a filled round rectangle on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the start point + * y : [IN] y offset of the start point + * width : [IN] width of the round rectangle + * height : [IN] height of the round rectangle + * corner_width : [IN] radius of the rounded angle. the value must less than half of width, if not, the api will have no effect + * color : [IN] color of the filled round rectangle + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_fill_roundrect (VMUINT8 * buf, VMINT x, VMINT y, VMINT width, VMINT height, VMINT corner_width, VMUINT16 color); + +/****************************************************************************** + * FUNCTION + * vm_graphic_fill_roundrect_cf + * DESCRIPTION + * draw a filled round rectangle on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the start point + * y : [IN] y offset of the start point + * width : [IN] width of the round rectangle + * height : [IN] height of the round rectangle + * corner_width : [IN] radius of the rounded angle. the value must less than half of width, if not, the api will have no effect + * color : [IN] color of the filled round rectangle, the color value include a, r, g, b value + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_fill_roundrect_cf (VMUINT8 * buf, VMINT x, VMINT y, VMINT width, VMINT height, VMINT corner_width, vm_graphic_color_argb* color); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_ellipse + * DESCRIPTION + * draw a ellipse on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the start point + * y : [IN] y offset of the start point + * width : [IN] width of the ellipse + * height : [IN] height of the ellipse + * color : [IN] color of the ellipse + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_ellipse (VMUINT8 * buf, VMINT x, VMINT y, VMINT width, VMINT height, VMUINT16 color); + +/****************************************************************************** + * FUNCTION + * vm_graphic_ellipse_cf + * DESCRIPTION + * draw a ellipse on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the start point + * y : [IN] y offset of the start point + * width : [IN] width of the ellipse + * height : [IN] height of the ellipse + * color : [IN] color of the ellipse, the color value include a, r, g, b value + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_ellipse_cf(VMUINT8* buf, VMINT x, VMINT y, VMINT width, VMINT height, vm_graphic_color_argb* color); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_fill_ellipse + * DESCRIPTION + * draw a filled ellipse on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the start point + * y : [IN] y offset of the start point + * width : [IN] width of the ellipse + * height : [IN] height of the ellipse + * color : [IN] color of the filled ellipse + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_fill_ellipse (VMUINT8 * buf, VMINT x, VMINT y, VMINT width, VMINT height, VMUINT16 color); + +/****************************************************************************** + * FUNCTION + * vm_graphic_fill_ellipse_cf + * DESCRIPTION + * draw a filled ellipse on the appointed position of the buffer + * PARAMETERS + * buf : [IN] buffer pointer + * x : [IN] x offset of the start point + * y : [IN] y offset of the start point + * width : [IN] width of the ellipse + * height : [IN] height of the ellipse + * color : [IN] color of the filled ellipse, the color value include a, r, g, b value + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_fill_ellipse_cf(VMUINT8* buf, VMINT x, VMINT y, VMINT width, VMINT height, vm_graphic_color_argb* color); + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_create_canvas + * DESCRIPTION + * create canvas + * PARAMETERS + * width : [IN] width of the canvas + * height : [IN] height of the height + * RETURNS + * if succeed, return the canvas handle, otherwise, return error code + * EXAMPLE + * hcanvas = vm_graphic_create_canvas(width, height); + * if(hcanvas>0) + * { + * //get the destination pointer of the data to be displayed + * frame_buffer = (VMUINT8*)hcanvas + VM_CANVAS_SIGNATURE_SIZE + VM_CANVAS_FRAME_PROPERTY_SIZE; + * //use the buffer to create layer + * layer_handle = vm_graphic_create_layer_ex(0, 0, vm_graphic_get_screen_width(), vm_graphic_get_screen_height(), VM_NO_TRANS_COLOR,VM_BUF,frame_buffer); + * //the following operation is same with vm_graphic_create_layer + * } + * else + * { + * //error handle + * } + * + *****************************************************************************/ +VMINT vm_graphic_create_canvas(VMINT width, VMINT height); + +/****************************************************************************** + * FUNCTION + * vm_graphic_create_canvas_cf + * DESCRIPTION + * create canvas + * PARAMETERS + * cf : [IN] color format + * width : [IN] width of the canvas + * height : [IN] height of the height + * RETURNS + * if succeed, return the canvas handle, otherwise, return error code + * EXAMPLE + * hcanvas = vm_graphic_create_canvas(width, height); + * if(hcanvas>0) + * { + * //get the destination pointer of the data to be displayed + * frame_buffer = (VMUINT8*)hcanvas + VM_CANVAS_SIGNATURE_SIZE + VM_CANVAS_FRAME_PROPERTY_SIZE; + * //use the buffer to create layer + * layer_handle = vm_graphic_create_layer_ex(0, 0, vm_graphic_get_screen_width(), vm_graphic_get_screen_height(), VM_NO_TRANS_COLOR,VM_BUF,frame_buffer); + * //the following operation is same with vm_graphic_create_layer + * } + * else + * { + * //error handle + * } + * + *****************************************************************************/ +VMINT vm_graphic_create_canvas_cf(vm_graphic_color_famat cf, VMINT width, VMINT height); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_release_canvas + * DESCRIPTION + * release the resource created by vm_graphic_create_canvas or vm_graphic_load_image + * PARAMETERS + * hcanvas : [IN] canvas handle + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_release_canvas(VMINT hcanvas); + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_canvas_buffer + * DESCRIPTION + * get the pointer of the canvas's display buffer + * PARAMETERS + * hcanvas : [IN] canvas handle + * RETURNS + * the pointer of the canvas's display buffer + *****************************************************************************/ +VMUINT8* vm_graphic_get_canvas_buffer(VMINT hcanvas); + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_canvas_buffer_size + * DESCRIPTION + * get the size of the canvas's display buffer + * PARAMETERS + * hcanvas : [IN] canvas handle + * RETURNS + * the size of the canvas's display buffer + *****************************************************************************/ +VMINT vm_graphic_get_canvas_buffer_size (VMINT hcanvas); + +/****************************************************************************** + * FUNCTION + * vm_graphic_load_image + * DESCRIPTION + * image decode, and draw the decoded image to the new-created canvas. + * PARAMETERS + * img : [IN] pointer of source image data + * img_len : [IN] image length + * RETURNS + * the pointer of the canvas's display buffer + *****************************************************************************/ +VMINT vm_graphic_load_image(VMUINT8 *img, VMINT img_len); + +/****************************************************************************** + * FUNCTION + * vm_graphic_load_image_cf + * DESCRIPTION + * image decode, and draw the decoded image to the new-created canvas. + * PARAMETERS + * cf : [IN] color format + * img : [IN] pointer of source image data + * img_len : [IN] image length + * RETURNS + * the pointer of the canvas's display buffer + *****************************************************************************/ +VMINT vm_graphic_load_image_cf(vm_graphic_color_famat cf, VMUINT8 *img_data, VMINT img_len); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_img_property + * DESCRIPTION + * get the appointed frame property of the image + * PARAMETERS + * hcanvas : [IN] canvas handle which hold the decoded image data + * frame_index : [IN] frameindex ,begin from 0 + * RETURNS + * the pointer of the image property structure + *****************************************************************************/ +struct frame_prop * vm_graphic_get_img_property(VMINT hcanvas, VMUINT8 frame_index); + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_img_buffer + * DESCRIPTION + * get the appointed frame buffer of the image + * PARAMETERS + * hcanvas : [IN] canvas handle which hold the decoded image data + * frame_index : [IN] frameindex ,begin from 0 + * RETURNS + * the pointer of the image buffer poniter + *****************************************************************************/ +VMUINT8* vm_graphic_get_img_buffer(VMINT hcanvas, VMUINT8 frame_index); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_frame_number + * DESCRIPTION + * get the frame number of the image + * PARAMETERS + * hcanvas : [IN] canvas handle which hold the decoded image data,get by vm_graphic_load_image() + * RETURNS + * frame number + *****************************************************************************/ +VMINT vm_graphic_get_frame_number(VMINT hcanvas); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_blt + * DESCRIPTION + * copy the data from the souce display buffer to the destination buffer. just copy, no merge. + * the destination can be LCD buffer or canvas display buffer + * PARAMETERS + * dst_disp_buf : [IN] destination buffer pointer + * x_dest : [IN] x offset of destination position + * y_dest : [IN] y offset of destination position + * src_disp_buf : [IN] source buffer pointer + * x_src : [IN] x offset of source position + * y_src : [IN] y offset of source position + * width : [IN] the image width + * height : [IN] the image height + * frame_index : [IN] frame number + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_blt(VMBYTE * dst_disp_buf, VMINT x_dest, VMINT y_dest, VMBYTE * src_disp_buf, + VMINT x_src, VMINT y_src, VMINT width, VMINT height, VMINT frame_index); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_blt_ex + * DESCRIPTION + * copy the data from the souce display buffer to the destination buffer. merge with the destination data using the alpha value. + * the destination can be LCD buffer or canvas display buffer + * PARAMETERS + * dst_disp_buf : [IN] destination buffer pointer + * x_dest : [IN] x offset of destination position + * y_dest : [IN] y offset of destination position + * src_disp_buf : [IN] source buffer pointer + * x_src : [IN] x offset of source position + * y_src : [IN] y offset of source position + * width : [IN] the image width + * height : [IN] the image height + * frame_index : [IN] frame number + * alpha : [IN]the value of transparent,value range [0,255], 0 means completely transparent + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_blt_ex(VMBYTE * dst_disp_buf, VMINT x_dest, VMINT y_dest, VMBYTE * src_disp_buf, + VMINT x_src, VMINT y_src, VMINT width, VMINT height, VMINT frame_index, VMINT alpha); + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_character_height + * DESCRIPTION + * get current font height, for dot character, it is precise. for vector font,it is usually higher than + * single character, it is the string height. + * PARAMETERS + * void + * RETURNS + * the height of the font + *****************************************************************************/ +VMINT vm_graphic_get_character_height(void); + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_character_width + * DESCRIPTION + * get current character width, for dot character, it is precise. for vector font, it isn't include the + * padding between characters + * PARAMETERS + * c : [IN] character vlue + * RETURNS + * the width of the character + *****************************************************************************/ +VMINT vm_graphic_get_character_width(VMWCHAR c); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_string_width + * DESCRIPTION + * get the width of the appointed string + * PARAMETERS + * str : [IN]string pointer + * RETURNS + * the width of the string + *****************************************************************************/ +VMINT vm_graphic_get_string_width(VMWSTR str); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_string_height + * DESCRIPTION + * get the string of the appointed string + * PARAMETERS + * str : [IN]string pointer + * RETURNS + * the height of the string + *****************************************************************************/ +VMINT vm_graphic_get_string_height(VMWSTR str); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_measure_character + * DESCRIPTION + * get the width and height of the appointed character. Unit:pixel + * PARAMETERS + * c : [IN]the value of character + *width : [OUT]character width + *height : [OUT]character height + * RETURNS + * if succeed, return VM_GDI_SUCCEED,otherwise, return error code + *****************************************************************************/ +VMINT vm_graphic_measure_character(VMWCHAR c, VMINT *width, VMINT *height); + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_character_info + * DESCRIPTION + * get the info of the appointed character + * PARAMETERS + * c : [IN]the value of character + * char_info : [OUT]character infomation + * RETURNS + * if succeed, return VM_GDI_SUCCEED,otherwise, return error code + *****************************************************************************/ + +VMINT vm_graphic_get_character_info(VMWCHAR c, vm_graphic_char_info *char_info); + +/****************************************************************************** + * FUNCTION + * vm_graphic_set_font + * DESCRIPTION + * set font size + * PARAMETERS + * size : [IN]font size + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_set_font(font_size_t size); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_textout + * DESCRIPTION + * show text to the display buffer. font size is defined by vm_graphic_set_font(),defaul value is VM_MEDIUM_FONT + * PARAMETERS + * disp_buf : [IN] display buffer pointer + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * s : [IN] string pointer + * length : [IN] string length + * color : [IN] string color + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_textout (VMUINT8* disp_buf, VMINT x, VMINT y, VMWSTR s, VMINT length, VMUINT16 color); + +/****************************************************************************** + * FUNCTION + * vm_graphic_textout_cf + * DESCRIPTION + * show text to the display buffer. font size is defined by vm_graphic_set_font(),defaul value is VM_MEDIUM_FONT + * PARAMETERS + * disp_buf : [IN] display buffer pointer + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * s : [IN] string pointer + * length : [IN] string length + * color : [IN] string color, the color value include a, r, g, b value + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_textout_cf (VMUINT8* disp_buf, VMINT x, VMINT y, VMWSTR s, VMINT length, vm_graphic_color_argb* color); + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_textout_by_baseline + * DESCRIPTION + * show text to the display buffer according baseline. font size is defined by vm_graphic_set_font(),defaul value is VM_MEDIUM_FONT + * PARAMETERS + * disp_buf : [IN] display buffer pointer + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * s : [IN] string pointer + * length : [IN] string length + * color : [IN] string color + * baseline : [IN] the baseline to be aligned + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_textout_by_baseline (VMUINT8* disp_buf, VMINT x, VMINT y, VMWSTR s, VMINT length, VMUINT16 color,VMINT baseline); + +/****************************************************************************** + * FUNCTION + * vm_graphic_textout_by_baseline_cf + * DESCRIPTION + * show text to the display buffer according baseline. font size is defined by vm_graphic_set_font(),defaul value is VM_MEDIUM_FONT + * PARAMETERS + * disp_buf : [IN] display buffer pointer + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * s : [IN] string pointer + * length : [IN] string length + * color : [IN] string color, the color value include a, r, g, b value + * baseline : [IN] the baseline to be aligned + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_textout_by_baseline_cf (VMUINT8* disp_buf, VMINT x, VMINT y, VMWSTR s, VMINT length, vm_graphic_color_argb* color,VMINT baseline); + +/****************************************************************************** + * FUNCTION + * vm_graphic_set_clip + * DESCRIPTION + * set clip region. any GDI operation out of the clip region will have no effect. It is a global value, when the aim changes, the clip region + * must be reset. + * PARAMETERS + * x1 : [IN] x offset of top left position + * y1 : [IN] y offset of top left + * x2 : [IN] x offset of bottom right position + * y2 : [IN] y offset of bottom right position + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_set_clip(VMINT x1, VMINT y1, VMINT x2, VMINT y2); + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_reset_clip + * DESCRIPTION + * reset clip region to the full screen size + * PARAMETERS + * void + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_reset_clip(void); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_flush_screen + * DESCRIPTION + * notify system to re-paint screen. once APP calls the API, system will send VM_PAINT to the callback fuction registered + * by vm_reg_sysevt_callback + * PARAMETERS + * void + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_flush_screen(void); + + +/*rotate value :90 degree*/ +#define VM_ROTATE_DEGREE_90 (90) + +/*rotate value :180 degree*/ +#define VM_ROTATE_DEGREE_180 (180) + +/*rotate value :270 degree*/ +#define VM_ROTATE_DEGREE_270 (270) + + +/****************************************************************************** + * FUNCTION + * vm_graphic_rotate + * DESCRIPTION + * rotate image with the appointed angel to the destinate buffer. + * PARAMETERS + * buf : [IN] destinate buffer + * x_des : [IN]x offset of destination + * y_des : [IN]y offset of destination + * src_buf : [IN]source buffer + * frame_index :[IN]frame index + * degrees :[IN]the value of clockwise angle,only valid with the value VM_ROTATE_DEGREE_90,VM_ROTATE_DEGREE_180 + * VM_ROTATE_DEGREE_270. + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_rotate(VMBYTE *buf, VMINT x_des, VMINT y_des, + VMBYTE *src_buf, VMINT frame_index, VMINT degrees); + + +/*Mirror direction:x */ +#define VM_MIRROR_X (0) + +/*Mirror direction:y */ +#define VM_MIRROR_Y (1) + +/****************************************************************************** + * FUNCTION + * vm_graphic_mirror + * DESCRIPTION + * mirror the image to the destination with the appointed direction + * PARAMETERS + * buf : [IN] destinate buffer + * x_des : [IN] x offset of destination + * y_des : [IN] y offset of destination + * src_buf : [IN] source buffer + * frame_index : [IN] frame index + * direction : [IN] the mirror direction ,only valid with the value VM_MIRROR_X,VM_MIRROR_Y + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_mirror(VMBYTE *buf, VMINT x_des, VMINT y_des, VMBYTE *src_buf, VMINT frame_index, VMINT direction); + + + +/****************************************************************************** + * FUNCTION + * vm_reg_res_provider + * DESCRIPTION + * APP can use it to register its own resource get function. if the app self-define resource is saved as array, app can operate it by ID using the + * callback function + * PARAMETERS + * fp : resource callback function pointer + * RETURNS + * void + *****************************************************************************/ + void vm_reg_res_provider(VMUINT8* (*fp)(VMINT resid, VMINT* len)); + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_create_layer_ex + * DESCRIPTION + * create layer using varies modes,before create other layers, base layer must be created firstly. + * PARAMETERS + * x : [IN] x offset of layer position + * y : [IN] y offset of layer position + * width : [IN]layer width + * height : [IN] layer height + * mode : [IN] creation mode + * VM_BASE_LAYER: create base layer. if existed, new attribute will override the old. + * VM_FAST_LAYER create fast layer( no need additional memory),if existed, new attribute will override the old. + * VM_BUF: create layer using the canvas buffer. the buffer must be gotten from vm_create_canvas. the canvas + * and buffer are mapped automatically. if re-create layer using the same memory , will return error code + * VM_CREATE_CANVAS: create a new canvas , at the same time , create a new layer with the canvas buffer. + * the canvas and buffer are mapped automatically. + * buf : [IN] only valid when mode = VM_BUF, the buffer pointer + * RETURNS + * if succeed, return the layer handle ,otherwise, return error code + *****************************************************************************/ +VM_GDI_HANDLE vm_graphic_create_layer_ex(VMINT x, VMINT y, VMINT width, VMINT height, VMINT trans_color,VMINT mode,VMUINT8 * buf); + +/****************************************************************************** + * FUNCTION + * vm_graphic_create_layer_cf + * DESCRIPTION + * create layer using varies modes,before create other layers, base layer must be created firstly. + * PARAMETERS + * cf : [IN] color format + * x : [IN] x offset of layer position + * y : [IN] y offset of layer position + * width : [IN]layer width + * height : [IN] layer height + * mode : [IN] creation mode + * VM_BASE_LAYER: create base layer. if existed, new attribute will override the old. + * VM_FAST_LAYER create fast layer( no need additional memory),if existed, new attribute will override the old. + * VM_BUF: create layer using the canvas buffer. the buffer must be gotten from vm_create_canvas. the canvas + * and buffer are mapped automatically. if re-create layer using the same memory , will return error code + * VM_CREATE_CANVAS: create a new canvas , at the same time , create a new layer with the canvas buffer. + * the canvas and buffer are mapped automatically. + * buf : [IN] only valid when mode = VM_BUF, the buffer pointer + * buf_size: [IN] only valid when mode = VM_BUF, the buffer size + * RETURNS + * if succeed, return the layer handle ,otherwise, return error code + *****************************************************************************/ +VM_GDI_HANDLE vm_graphic_create_layer_cf(vm_graphic_color_famat cf, VMINT x, VMINT y, VMINT width, VMINT height, vm_graphic_color_argb* trans_color, VMINT mode, VMUINT8 *buf, VMINT buf_size); + +/****************************************************************************** + * FUNCTION + * vm_graphic_create_layer_cf_double + * DESCRIPTION + * create layer using varies modes,before create other layers, base layer must be created firstly. + * PARAMETERS + * cf : [IN] color format + * x : [IN] x offset of layer position + * y : [IN] y offset of layer position + * width : [IN]layer width + * height : [IN] layer height + * mode : [IN] creation mode + * VM_BASE_LAYER: create base layer. if existed, new attribute will override the old. + * VM_FAST_LAYER create fast layer( no need additional memory),if existed, new attribute will override the old. + * VM_BUF: create layer using the canvas buffer. the buffer must be gotten from vm_create_canvas. the canvas + * and buffer are mapped automatically. if re-create layer using the same memory , will return error code + * VM_CREATE_CANVAS: create a new canvas , at the same time , create a new layer with the canvas buffer. + * the canvas and buffer are mapped automatically. + * buf : [IN] only valid when mode = VM_BUF, the buffer pointer + * buf_size: [IN] only valid when mode = VM_BUF, the buffer size + * buf1 : [IN] only valid when mode = VM_BUF, the another buffer pointer + * buf_size_1: [IN] only valid when mode = VM_BUF, the another buffer size + * RETURNS + * if succeed, return the layer handle ,otherwise, return error code + *****************************************************************************/ +VM_GDI_HANDLE vm_graphic_create_layer_cf_double(vm_graphic_color_famat cf, VMINT x, VMINT y, VMINT width, VMINT height, vm_graphic_color_argb* trans_color, VMINT mode, VMUINT8 *buf, VMINT buf_size, VMUINT8 *buf1, VMINT buf_size_1); + +/****************************************************************************** + * FUNCTION + * vm_graphic_layer_toggle_double + * DESCRIPTION + * swap the two buffer of the layer. + * PARAMETERS + * handle : [IN] layer handle + * RETURNS + * if succeed, return success ,otherwise, return error code + *****************************************************************************/ +VM_GDI_RESULT vm_graphic_layer_toggle_double(VMINT handle); + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_release_canvas_ex + * DESCRIPTION + * release the canvas handle. if the canvas maps with layer (it means using this canvas buffer to create a layer), the layer will + * be deleted at the same time. + * PARAMETERS + * hcanvas : [IN] canvas handle + * RETURNS + * if succeed, return VM_GDI_SUCCEED ,otherwise, return error code + *****************************************************************************/ +VM_GDI_RESULT vm_graphic_release_canvas_ex(VMINT hcanvas); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_flatten_canvas + * DESCRIPTION + * merge several canvas display buffer to active layer and release the canvases and them own layers. the canvas buffers must + * map with layer, otherwise, their can not be merged. the MAX number of merged canvases is 4. + * PARAMETERS + * hcanvas : [IN] canvas handle array + * count : [IN] cavas number + * RETURNS + * if succeed, return VM_GDI_SUCCEED ,otherwise, return error code + *****************************************************************************/ +VM_GDI_RESULT vm_graphic_flatten_canvas(VMINT *hcanvas,VMINT count); + +/****************************************************************************** + * FUNCTION + * vm_graphic_flatten_canvas + * DESCRIPTION + * merge several canvas display buffer to active layer. the canvas buffers must + * map with layer, otherwise, their can not be merged. the MAX number of merged canvases is 4. + * PARAMETERS + * hcanvas : [IN] canvas handle array + * count : [IN] cavas number + * RETURNS + * if succeed, return VM_GDI_SUCCEED ,otherwise, return error code + *****************************************************************************/ +VM_GDI_RESULT vm_graphic_flatten_canvas_ex(VMINT *hcanvas,VMINT count); + +/****************************************************************************** + * FUNCTION + * vm_graphic_flatten_layer + * DESCRIPTION + * merge several layer to active layer and release layers. active layer will not be released. the MAX number of merged layers is 4. + * PARAMETERS + * hhandle : [IN] layer handle array + * count : [IN] layer number + * RETURNS + * if succeed, return VM_GDI_SUCCEED ,otherwise, return error code + *****************************************************************************/ +VM_GDI_RESULT vm_graphic_flatten_layer(VMINT *hhandle,VMINT count); + +/****************************************************************************** + * FUNCTION + * vm_graphic_flatten_layer + * DESCRIPTION + * merge several layer to active layer. the MAX number of merged layers is 4. + * PARAMETERS + * hhandle : [IN] layer handle array + * count : [IN] layer number + * RETURNS + * if succeed, return VM_GDI_SUCCEED ,otherwise, return error code + *****************************************************************************/ +VM_GDI_RESULT vm_graphic_flatten_layer_ex(VMINT *hhandle,VMINT count); + +/****************************************************************************** + * FUNCTION + * vm_graphic_resize_layer + * DESCRIPTION + * resize layer size. after resize, the layer need to be re-draw. new width and height can not be larger than the origion's. + * PARAMETERS + * handle : [IN] layer handle + * width : [IN] new layer width + * height : [IN] new layer height + * RETURNS + * if succeed, return VM_GDI_SUCCEED ,otherwise, return error code + *****************************************************************************/ +VM_GDI_RESULT vm_graphic_resize_layer(VMINT handle,VMINT width,VMINT height); + + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_setpen + * DESCRIPTION + * set pen attribute + * PARAMETERS + * pen : [IN] pen pointer + * RETURNS + * if succeed, return VM_GDI_SUCCEED ,otherwise, return error code + *****************************************************************************/ +VM_GDI_RESULT vm_graphic_setpen(vm_graphic_pen *pen); + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_getpen + * DESCRIPTION + * get pen attribute + * PARAMETERS + * void + * RETURNS + * pen attribute structure + *****************************************************************************/ +vm_graphic_pen vm_graphic_getpen(void); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_setcolor + * DESCRIPTION + * set global color + * PARAMETERS + * color : [IN] color pointer + * RETURNS + * if succeed, return VM_GDI_SUCCEED ,otherwise, return error code + *****************************************************************************/ +VM_GDI_RESULT vm_graphic_setcolor(vm_graphic_color* color); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_setcolor + * DESCRIPTION + * set global color + * PARAMETERS + * void + * RETURNS + * return global color + *****************************************************************************/ +vm_graphic_color vm_graphic_getcolor(void); + +/****************************************************************************** + * FUNCTION + * vm_graphic_setcolor_argb + * DESCRIPTION + * set global color + * PARAMETERS + * color : [IN] color pointer, the color value include a, r, g, b value + * RETURNS + * if succeed, return VM_GDI_SUCCEED ,otherwise, return error code + *****************************************************************************/ +VM_GDI_RESULT vm_graphic_setcolor_argb(vm_graphic_color_argb* color); + +/****************************************************************************** + * FUNCTION + * vm_graphic_getcolor_argb + * DESCRIPTION + * set global color + * PARAMETERS + * void + * RETURNS + * return global color, the color value include a, r, g, b value + *****************************************************************************/ +vm_graphic_color_argb vm_graphic_getcolor_argb(void); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_set_pixel_ex + * DESCRIPTION + * draw point on the layer + * PARAMETERS + * handle : [IN] layer handle + * x1 : [IN] x offset of start position + * y1 : [IN] y offset of start position + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_set_pixel_ex(VMINT handle,VMINT x1,VMINT y1); + +/****************************************************************************** + * FUNCTION + * vm_graphic_line_ex + * DESCRIPTION + * draw line on the layer, not using pen + * PARAMETERS + * handle : [IN] layer handle + * x1 : [IN] x offset of start position + * y1 : [IN] y offset of start position + * x2 : [IN] x offset of end position + * y2 : [IN] y offset of end position + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_line_ex(VMINT handle,VMINT x1,VMINT y1,VMINT x2,VMINT y2); + + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_line_style + * DESCRIPTION + * draw line with style. before using this API, vm_graphic_set_pen must be called, otherwise the operation will have no effection + * PARAMETERS + * handle : [IN] layer handle + * x1 : [IN] x offset of start position + * y1 : [IN] y offset of start position + * x2 : [IN] x offset of end position + * y2 : [IN] y offset of end position + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_line_style(VMINT handle,VMINT x1,VMINT y1,VMINT x2,VMINT y2); + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_roundrect_ex + * DESCRIPTION + * draw round rectangle on the layer. + * PARAMETERS + * handle : [IN] layer handle + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * width : [IN] round rectangle width + * height : [IN] round rectangle height + * frame_width : [IN] radius of the rounded angle. the value must less than half of width, if not, the api will have no effect + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_roundrect_ex(VMINT handle, VMINT x, VMINT y, VMINT width, VMINT height, VMINT frame_width); + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_rect_ex + * DESCRIPTION + * draw rect on the layer. + * PARAMETERS + * handle : [IN] layer handle + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * width : [IN] rect width + * height : [IN] rect height + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_rect_ex(VMINT handle, VMINT x, VMINT y, VMINT width, VMINT height); + + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_ellipse_ex + * DESCRIPTION + * draw ellipse on the layer. + * PARAMETERS + * handle : [IN] layer handle + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * width : [IN] ellipse width + * height : [IN] ellipse height + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_ellipse_ex(VMINT handle, VMINT x, VMINT y, VMINT width, VMINT height); + + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_polygon + * DESCRIPTION + * draw polygon on the layer. + * PARAMETERS + * handle : [IN] layer handle + * point : [IN] point coordination array + * npoint : [IN] point number + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_polygon(VMINT handle, vm_graphic_point *point,VMINT npoint); + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_fill_roundrect_ex + * DESCRIPTION + * draw round rectangle on the layer. + * PARAMETERS + * handle : [IN] layer handle + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * width : [IN] round rectangle width + * height : [IN] round rectangle height + * frame_width : [IN] radius of the rounded angle. the value must less than half of width, if not, the api will have no effect + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_fill_roundrect_ex(VMINT handle, VMINT x, VMINT y, VMINT width, VMINT height, VMINT frame_width); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_fill_rect_ex + * DESCRIPTION + * draw filled rect on the layer. + * PARAMETERS + * handle : [IN] layer handle + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * width : [IN] rect width + * height : [IN] rect height + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_fill_rect_ex(VMINT handle, VMINT x, VMINT y, VMINT width, VMINT height); + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_fill_ellipse_ex + * DESCRIPTION + * draw ellipse on the layer. + * PARAMETERS + * handle : [IN] layer handle + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * width : [IN] ellipse width + * height : [IN] ellipse height + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_fill_ellipse_ex(VMINT handle, VMINT x, VMINT y, VMINT width, VMINT height); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_polygon + * DESCRIPTION + * draw filled polygon on the layer. + * PARAMETERS + * handle : [IN] layer handle + * point : [IN] point coordination array + * npoint : [IN] point number + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_fill_polygon(VMINT handle, vm_graphic_point *point,VMINT npoints); + + + + +/****************************************************************************** + * FUNCTION + * vm_graphic_gradient_paint_rect + * DESCRIPTION + * draw gradient_paint_rect on the layer. + * PARAMETERS + * handle : [IN] layer handle + * x1 : [IN] x offset of top left position + * y1 : [IN] y offset of top left position + * x2 : [IN] x offset of bottom right position + * y2 : [IN] y offset of bottom right position + * color_start : [IN]start color of gradient color + * color_end : [IN] end colorof gradient color + * style : [IN] paint style + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_gradient_paint_rect(VMINT handle, VMINT x1, VMINT y1, VMINT x2, VMINT y2, vm_graphic_color color_start, vm_graphic_color color_end,vm_graphic_gp_style style); + + +/****************************************************************************** + * FUNCTION + * vm_graphic_get_layer_clip + * DESCRIPTION + * get layer clip region. + * PARAMETERS + * handle : [IN] layer handle + * curcliprect : [OUT] region structure pointer + * RETURNS + * if succeed, return VM_GDI_SUCCEED, otherwise, return error code + *****************************************************************************/ +VM_GDI_RESULT vm_graphic_get_layer_clip(VMINT handle,clip_rect * curcliprect); + + + +/****************************************************************************** +* FUNCTION +* vm_graphic_set_layer_clip +* DESCRIPTION +* set layer clip region. it will affect the global setting +* PARAMETERS +* handle : [IN] layer handle +* x1 : [IN] x offset of top left position + * y1 : [IN] y offset of top left position + * x2 : [IN] x offset of bottom right position + * y2 : [IN] y offset of bottom right position + +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VM_GDI_RESULT vm_graphic_set_layer_clip(VMINT handle,VMINT16 x1,VMINT16 y1,VMINT16 x2,VMINT16 y2); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_translate_layer +* DESCRIPTION +* move the layer to the new position +* PARAMETERS +* handle : [IN] layer handle +* tx : [IN] x offset of new position + * ty : [IN] y offset of new position +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VM_GDI_RESULT vm_graphic_translate_layer(VMINT handle , VMINT tx, VMINT ty); + + + + +/****************************************************************************** +* FUNCTION +* vm_graphic_rotate_layer +* DESCRIPTION +* rotate the layer +* PARAMETERS +* handle : [IN] layer handle +* rotatevalue : [IN] degree of angle,now, valid value is VM_GDI_ROTATE_90,VM_GDI_ROTATE_180 ,VM_GDI_ROTATE_270 +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VM_GDI_RESULT vm_graphic_rotate_layer(VMINT handle, vm_graphic_rotate_value rotatevalue); + + + +/****************************************************************************** +* FUNCTION +* vm_graphic_load_image_resized +* DESCRIPTION +* resize image to appointed size +* PARAMETERS +* img_data : [IN] image data buffer pointer +* img_len : [IN] image length +* width : [IN] image new width +* height : [IN] image new height +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VM_GDI_RESULT vm_graphic_load_image_resized(VMUINT8 *img_data, VMINT img_len,VMINT width,VMINT height); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_load_image_resized_cf +* DESCRIPTION +* resize image to appointed size +* PARAMETERS +* cf : [IN] color format +* img_data : [IN] image data buffer pointer +* img_len : [IN] image length +* width : [IN] image new width +* height : [IN] image new height +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VMINT vm_graphic_load_image_resized_cf(vm_graphic_color_famat cf, VMUINT8 *img_data, VMINT img_len,VMINT width,VMINT height); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_load_gif_resized_by_percent +* DESCRIPTION +* enlarge gif image +* PARAMETERS +* img_data : [IN] image data buffer pointer +* img_len : [IN] image length +* percent : [IN] the percent of enlarge +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VMINT vm_graphic_load_gif_resized_by_percent(VMUINT8 *img_data, VMINT img_len,VMINT percent); + +/****************************************************************************** +* FUNCTION +* vm_graphic_load_gif_resized_by_percent_cf +* DESCRIPTION +* enlarge gif image +* PARAMETERS +* cf : [IN] color format +* img_data : [IN] image data buffer pointer +* img_len : [IN] image length +* percent : [IN] the percent of enlarge +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VMINT vm_graphic_load_gif_resized_by_percent_cf(vm_graphic_color_famat cf, VMUINT8 *img_data, VMINT img_len,VMINT percent); + +/****************************************************************************** + * FUNCTION + * vm_graphic_load_gif_frame + * DESCRIPTION + * gif image decode, and draw the decoded image frame (from start_frame_index to end_frame_index) to the new-created canvas. + * PARAMETERS + * img : [IN] pointer of source image data + * img_len : [IN] image length + * start_frame_index : [IN] the first frame of the gif image to be decoded + * end_frame_index : [IN] the last frame of the gif image to be decoded + * RETURNS + * the pointer of the canvas's display buffer + *****************************************************************************/ +VMINT vm_graphic_load_gif_frame(VMUINT8 *img_data, VMINT img_len, VMINT start_frame_index, VMINT end_frame_index); + +/****************************************************************************** + * FUNCTION + * vm_graphic_load_gif_frame_cf + * DESCRIPTION + * gif image decode, and draw the decoded image frame (from start_frame_index to end_frame_index) to the new-created canvas. + * PARAMETERS + * cf : [IN] color format + * img : [IN] pointer of source image data + * img_len : [IN] image length + * start_frame_index : [IN] the first frame of the gif image to be decoded + * end_frame_index : [IN] the last frame of the gif image to be decoded + * RETURNS + * the pointer of the canvas's display buffer + *****************************************************************************/ +VMINT vm_graphic_load_gif_frame_cf(vm_graphic_color_famat cf, VMUINT8 *img_data, VMINT img_len, VMINT start_frame_index, VMINT end_frame_index); + +/****************************************************************************** +* FUNCTION +* vm_graphic_load_gif_frame_resized +* DESCRIPTION +* resize image to appointed size +* PARAMETERS +* img_data : [IN] image data buffer pointer +* img_len : [IN] image length +* width : [IN] image new width +* height : [IN] image new height +* start_frame_index : [IN] the first frame of the gif image to be decoded +* end_frame_index : [IN] the last frame of the gif image to be decoded +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VMINT vm_graphic_load_gif_frame_resized(VMUINT8 *img_data, VMINT img_len,VMINT width,VMINT height, VMINT start_frame_index, VMINT end_frame_index); + +/****************************************************************************** +* FUNCTION +* vm_graphic_load_gif_frame_resized_cf +* DESCRIPTION +* resize image to appointed size +* PARAMETERS +* cf : [IN] color format +* img_data : [IN] image data buffer pointer +* img_len : [IN] image length +* width : [IN] image new width +* height : [IN] image new height +* start_frame_index : [IN] the first frame of the gif image to be decoded +* end_frame_index : [IN] the last frame of the gif image to be decoded +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VMINT vm_graphic_load_gif_frame_resized_cf(vm_graphic_color_famat cf, VMUINT8 *img_data, VMINT img_len,VMINT width,VMINT height, VMINT start_frame_index, VMINT end_frame_index); + +/****************************************************************************** +* FUNCTION +* vm_graphic_load_gif_frame_resized_by_percent +* DESCRIPTION +* enlarge gif image +* PARAMETERS +* img_data : [IN] image data buffer pointer +* img_len : [IN] image length +* percent : [IN] the percent of enlarge +* start_frame_index : [IN] the first frame of the gif image to be decoded +* end_frame_index : [IN] the last frame of the gif image to be decoded +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VMINT vm_graphic_load_gif_frame_resized_by_percent(VMUINT8 *img_data, VMINT img_len,VMINT percent, VMINT start_frame_index, VMINT end_frame_index); + +/****************************************************************************** +* FUNCTION +* vm_graphic_load_gif_frame_resized_by_percent_cf +* DESCRIPTION +* enlarge gif image +* PARAMETERS +* cf : [IN] color format +* img_data : [IN] image data buffer pointer +* img_len : [IN] image length +* percent : [IN] the percent of enlarge +* start_frame_index : [IN] the first frame of the gif image to be decoded +* end_frame_index : [IN] the last frame of the gif image to be decoded +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VMINT vm_graphic_load_gif_frame_resized_by_percent_cf(vm_graphic_color_famat cf, VMUINT8 *img_data, VMINT img_len,VMINT percent, VMINT start_frame_index, VMINT end_frame_index); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_get_blt_layer_count +* DESCRIPTION +* get the MAX layer count that can be drawn +* PARAMETERS +* void +* RETURNS +* MAX layer count that can be drawn +*****************************************************************************/ +VMINT vm_graphic_get_blt_layer_count(void); + + + + +/****************************************************************************** +* FUNCTION +* vm_font_set_font_size +* DESCRIPTION +* set font size. Recommended that use font_size_t type to define size. if use number directly, the UI may be diffrent from dot character with vector font +* PARAMETERS +* size : [IN] font size +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VM_GDI_RESULT vm_font_set_font_size(VMINT size); + + +/****************************************************************************** +* FUNCTION +* vm_font_set_font_style +* DESCRIPTION +* set font style . valid only to vector font +* PARAMETERS +* bold : [IN]wether to bold, value:TRUE or FALSE +* italic : [IN]wether to italic, value:TRUE or FALSE +* underline: wether to underline, value:TRUE or FALSE +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VM_GDI_RESULT vm_font_set_font_style(VMINT bold,VMINT italic,VMINT underline); + + + +/****************************************************************************** +* FUNCTION +* vm_graphic_textout_to_layer +* DESCRIPTION +* draw text on the layer +* PARAMETERS +* handle: layer handle +* x : [IN]x offset of start position +* y : [IN]y offset of start position +* s : [IN]string pointer +* length : [IN]string length +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VM_GDI_RESULT vm_graphic_textout_to_layer (VMINT handle, VMINT x, VMINT y, VMWSTR s, VMINT length); + +/****************************************************************************** +* FUNCTION +* vm_graphic_get_string_baseline +* DESCRIPTION +* get the baseline of the string +* PARAMETERS +* string : [IN] string pointer +* RETURNS +* baseline of the string +*****************************************************************************/ +VMINT vm_graphic_get_string_baseline(VMWSTR string); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_textout_to_layer_by_baseline +* DESCRIPTION +* show the string to the layer according baseline +* PARAMETERS +* handle: layer handle +* x : [IN]x offset of start position +* y : [IN]y offset of start position +* s : [IN] string pointer +* length: [IN] the length of the string +* baseline: [IN]the baseline of the string +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VM_GDI_RESULT vm_graphic_textout_to_layer_by_baseline (VMINT handle, VMINT x, VMINT y, VMWSTR s, VMINT length,VMINT baseline); + +/****************************************************************************** +* FUNCTION +* vm_graphic_canvas_set_trans_color +* DESCRIPTION +* set canvas transparent color . when use vm_graphic_blt_ex, the color will take effect +* PARAMETERS +* hcanvas : [IN] canvas handle +* trans_color : [IN]transparent color value, -1 means no transparent color +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VM_GDI_RESULT vm_graphic_canvas_set_trans_color(VMINT hcanvas, VMINT trans_color); + +/****************************************************************************** +* FUNCTION +* vm_graphic_canvas_set_trans_color_argb +* DESCRIPTION +* set canvas transparent color . when use vm_graphic_blt_ex, the color will take effect +* PARAMETERS +* hcanvas : [IN] canvas handle +* trans_color : [IN]transparent color value, NULL means no transparent color, the color value include a, r, g, b value +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VM_GDI_RESULT vm_graphic_canvas_set_trans_color_argb(VMINT hcanvas, vm_graphic_color_argb* trans_color); + + + +/****************************************************************************** +* FUNCTION +* vm_graphic_layer_set_trans_color +* DESCRIPTION +* set layer transparent color . +* PARAMETERS +* hhandle : [IN]layer handle +* trans_color : [IN] transparent color value, -1 means no transparent color +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VM_GDI_RESULT vm_graphic_layer_set_trans_color(VMINT hhandle, VMINT trans_color); + +/****************************************************************************** +* FUNCTION +* vm_graphic_layer_set_trans_color_argb +* DESCRIPTION +* set layer transparent color . +* PARAMETERS +* hhandle : [IN]layer handle +* trans_color : [IN] transparent color value, NULL means no transparent color, the color value include a, r, g, b value +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return error code +*****************************************************************************/ +VM_GDI_RESULT vm_graphic_layer_set_trans_color_argb(VMINT hhandle, vm_graphic_color_argb* trans_color); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_is_use_vector_font +* DESCRIPTION +* query current platform whether support vector font . +* PARAMETERS +* void +* RETURNS +* if support, return TRUE, otherwise, return FALSE +*****************************************************************************/ +VMINT vm_graphic_is_use_vector_font(void); + +/****************************************************************************** +* FUNCTION +* vm_graphic_draw_abm_text +* DESCRIPTION +* draw bitmap font according to bitmap array. +* PARAMETERS +* handle : [IN] layer handle +* x : [IN] x position of the to be drawn string +* y : [IN] y position of the to be drawn string +* color : [IN]the color of font +* font_data : [IN] font array info +* font_width : [IN] character width +* font_height : [IN] character height +* RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return others +*****************************************************************************/ +VM_GDI_RESULT vm_graphic_draw_abm_text(VMINT handle, VMINT x, VMINT y, VMINT color,VMUINT8* font_data,VMINT font_width,VMINT font_height); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_show_theme_background +* DESCRIPTION +* show theme background. +* PARAMETERS +* void +* RETURNS +* void +*****************************************************************************/ +void vm_graphic_show_theme_background(void); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_show_left_softkey +* DESCRIPTION +* show left softkey. +* PARAMETERS +* void +* RETURNS +* void +*****************************************************************************/ +void vm_graphic_show_left_softkey(void); + + +/****************************************************************************** +* FUNCTION +* vm_graphic_show_right_softkey +* DESCRIPTION +* show right softkey. +* PARAMETERS +* void +* RETURNS +* void +*****************************************************************************/ +void vm_graphic_show_right_softkey(void); + + +//======================================================================== + +/****************************************************************************** +* FUNCTION +* vm_graphic_is_r2l_state +* DESCRIPTION +* +* PARAMETERS + +* RETURNS +* if yes, return 1, otherwise, return 0 +*****************************************************************************/ +VMINT vm_graphic_is_r2l_state(void); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_get_char_num_in_width + * DESCRIPTION + * To get char number in specified width and gap + * This function only work for non-complicated langauge. + * It means that the language process is not processed in the function. + * PARAMETERS + * String : [IN] The string content + * width : [IN] The specifed width to display the string. + * checklinebreak : [IN] To check line break or not. + * gap [IN] The gap between each character + * RETURNS + * The number of character could be displayed in the specified width. + *****************************************************************************/ +VMUINT vm_graphic_get_char_num_in_width(VMWCHAR* string, VMUINT width, VMINT checklinebreak, VMUINT gap); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_get_char_num_in_width_ex + * DESCRIPTION + * To get char number in specified width and gap + * This function only work for non-complicated langauge. + * It means that the language process is not processed in the function. + * PARAMETERS + * String : [IN] The string content + * width : [IN] The specifed width to display the string. + * checklinebreak : [IN] To check line break or not. + * gap [IN] The gap between each character + * RETURNS + * The number of character could be displayed in the specified width. + *****************************************************************************/ +VMUINT vm_graphic_get_char_num_in_width_ex(VMWCHAR* string, VMUINT width, VMINT checklinebreak, VMUINT gap); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_draw_gif_image_from_memory + * DESCRIPTION + * PARAMETERS + * dest_layer_handle [IN] layer handle + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * img_data : [IN] data pointer + * img_len : [IN] length of image data + * frameIdx : [IN] frame id + * RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return others + *****************************************************************************/ +VMINT vm_graphic_draw_gif_image_from_memory(VM_GDI_HANDLE dest_layer_handle,VMINT x,VMINT y,VMUINT8* img_data,VMINT img_len, VMINT frameIdx); + +/***************************************************************************** + * FUNCTION + * vm_graphic_draw_image_from_memory + * DESCRIPTION + * PARAMETERS + * dest_layer_handle [IN] layer handle + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * img_data : [IN] data pointer + * img_len : [IN] length of image data + * RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return others + *****************************************************************************/ +VMINT vm_graphic_draw_image_from_memory(VM_GDI_HANDLE dest_layer_handle,VMINT x,VMINT y,VMUINT8* img_data,VMINT img_len); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_set_alpha_blending_layer + * DESCRIPTION + * PARAMETERS + * layer_handle [IN] layer handle, pass -1 means restore alpha blending layer + * RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return others + *****************************************************************************/ + +VMINT vm_graphic_set_alpha_blending_layer(VMINT layer_handle); + + +/***************************************************************************** + * FUNCTION + * vm_get_string_width_height_ex + * DESCRIPTION + * PARAMETERS + * string [IN] string pointer + * gap : [IN] gap between characters + * n : [IN] string length + * pWidth : [OUT] width + * pHeight : [OUT] height + * max_width : [IN] the width for the string + * checkLineBreak : [IN] check line break or not + * checkCompleteWord : [IN] check complete word or not + * RETURNS +* how many character can draw in given width + *****************************************************************************/ + +VMUINT vm_get_string_width_height_ex( + VMWCHAR* string, + VMINT gap, + VMINT n, + VMINT *pWidth, + VMINT *pHeight, + VMINT max_width, + VMUINT8 checkLineBreak, + VMUINT8 checkCompleteWord); + +/***************************************************************************** + * FUNCTION + * vm_graphic_show_truncated_text + * DESCRIPTION + * PARAMETERS + * dest_layer_handle [IN] layer handle + * x : [IN] offset x + * y : [IN] offset y + * xwidth : [IN] width for drawing string + * st : [IN] string to show + * truncated_symbol : [IN] truncated symbol, for example,"..." + * bordered : [IN] border or not + * color : [IN] color + * RETURNS +* Error Message + *****************************************************************************/ + + +vm_font_engine_error_message_enum vm_graphic_show_truncated_text(VM_GDI_HANDLE dest_layer_handle, + VMINT x, + VMINT y, + VMINT xwidth, + VMWCHAR *st, + VMWCHAR *truncated_symbol, + VMINT bordered, + VMUINT16 color); + +/***************************************************************************** + * FUNCTION + * vm_graphic_draw_resized_image_from_memory + * DESCRIPTION + * PARAMETERS + * dest_layer_handle [IN] layer handle + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * resized_width : [IN] resized width + * resized_height : [IN] resized height + * img_data : [IN] data pointer + * img_len : [IN] length of image data + * RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return others + *****************************************************************************/ + +VMINT vm_graphic_draw_resized_image_from_memory(VM_GDI_HANDLE dest_layer_handle,VMINT x,VMINT y,VMINT resized_width,VMINT resized_height,VMUINT8* img_data,VMINT img_len); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_draw_resized_gif_image_from_memory + * DESCRIPTION + * PARAMETERS + * dest_layer_handle [IN] layer handle + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * resized_width : [IN] resized width + * resized_height : [IN] resized height + * img_data : [IN] data pointer + * img_len : [IN] length of image data + * frameIdx : [IN] frame id + * RETURNS +* if succeed, return VM_GDI_SUCCEED, otherwise, return others + *****************************************************************************/ + +VMINT vm_graphic_draw_resized_gif_image_from_memory(VM_GDI_HANDLE dest_layer_handle,VMINT x,VMINT y,VMINT resized_width,VMINT resized_height,VMUINT8* img_data,VMINT img_len, VMINT frameIdx); + +/***************************************************************************** + * FUNCTION + * vm_graphic_set_blt_layer + * DESCRIPTION + * PARAMETERS + * layer_handles : [IN] the pointer of layer array + * count : [IN] layer number that to be flushed. + * RETURNS + * if succeed, return VM_GDI_SUCCEED. otherwise, return error code + *****************************************************************************/ + +VMINT vm_graphic_set_blt_layer(VMINT* layer_handles, VMINT count); + +/***************************************************************************** + * FUNCTION + * vm_graphic_get_blt_layer + * DESCRIPTION + * PARAMETERS + * count : [OUT] layer number that to be flushed. + * RETURNS + * layer handles array pointer + *****************************************************************************/ + +VMINT* vm_graphic_get_blt_layer( VMINT* count); + +/***************************************************************************** + * FUNCTION + * vm_graphic_get_img_property_ex + * DESCRIPTION + * PARAMETERS + * RETURNS + * error code + *****************************************************************************/ +VM_GDI_RESULT vm_graphic_get_img_property_ex(VMUINT8 *img_data, VMINT img_len,vm_graphic_imgprop * img_prop); + +/***************************************************************************** + * FUNCTION + * vm_graphic_get_img_property_from_file + * DESCRIPTION + * PARAMETERS + * RETURNS + * error code + *****************************************************************************/ +VM_GDI_RESULT vm_graphic_get_img_property_from_file(const VMWSTR filename, vm_graphic_imgprop * img_prop); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_get_character_height_ex + * DESCRIPTION + * PARAMETERS + * RETURNS + * the character height + *****************************************************************************/ + +VMINT vm_graphic_get_character_height_ex(VMUWCHAR c); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_get_highest_char_height_of_all_language + * DESCRIPTION + * PARAMETERS + * RETURNS + * the highest character height of all language + *****************************************************************************/ +VMINT vm_graphic_get_highest_char_height_of_all_language(void); + +/***************************************************************************** + * FUNCTION + * vm_frm_screen_rotate + * DESCRIPTION + * PARAMETERS + * RETURNS + *****************************************************************************/ +void vm_frm_screen_rotate(vm_frm_screen_rotate_enum rotation); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_get_char_height_alllang + * DESCRIPTION + * Get maximum char height regardless of language for the font size + * PARAMETERS + * size [IN] font size + * RETURNS + * return char height + *****************************************************************************/ +VMINT vm_graphic_get_char_height_alllang(VMINT size); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_draw_image_from_file + * DESCRIPTION + * PARAMETERS + * dest_layer_handle [IN] layer handle + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * filename : [IN] file name + * RETURNS + * if succeed, return VM_GDI_SUCCEED, otherwise, return others + *****************************************************************************/ +VMINT vm_graphic_draw_image_from_file(VM_GDI_HANDLE dest_layer_handle, VMINT x, VMINT y, const VMWSTR filename); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_draw_resized_image_from_file + * DESCRIPTION + * PARAMETERS + * dest_layer_handle [IN] layer handle + * x : [IN] x offset of start position + * y : [IN] y offset of start position + * resized_width : [IN] resized width + * resized_height : [IN] resized height + * filename : [IN] file name + * RETURNS + * if succeed, return VM_GDI_SUCCEED, otherwise, return others + *****************************************************************************/ +VMINT vm_graphic_draw_resized_image_from_file(VM_GDI_HANDLE dest_layer_handle, VMINT x, VMINT y, VMINT resized_width, VMINT resized_height, const VMWSTR filename); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_flush_layer_ex + * DESCRIPTION + * flatten layers to one layer and blt to LCD for some region. + * PARAMETERS + * layer_handles : [IN] the pointer of layer array + * count : [IN] layer number that to be flushed. if the number is larger than max layer count (get by vm_graphic_get_blt_layer_count()), + * just use the max layer count + * x1 : [IN] x offset of top left position + * y1 : [IN] y offset of top left position + * x2 : [IN] x offset of bottom right position + * y2 : [IN] y offset of bottom right position + * RETURNS + * if succeed, return VM_GDI_SUCCEED. otherwise, return error code + *****************************************************************************/ +VMINT vm_graphic_flush_layer_ex(VMINT* layer_handles, VMINT count, VMINT x1, VMINT y1, VMINT x2, VMINT y2); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_flush_layer_non_block_ex + * DESCRIPTION + * flatten layers to one layer and blt to LCD for some region with non-blocking way. + * PARAMETERS + * layer_handles : [IN] the pointer of layer array + * count : [IN] layer number that to be flushed. if the number is larger than max layer count (get by vm_graphic_get_blt_layer_count()), + * just use the max layer count + * x1 : [IN] x offset of top left position + * y1 : [IN] y offset of top left position + * x2 : [IN] x offset of bottom right position + * y2 : [IN] y offset of bottom right position + * RETURNS + * if succeed, return VM_GDI_SUCCEED. otherwise, return error code + *****************************************************************************/ +VMINT vm_graphic_flush_layer_non_block_ex(VMINT* layer_handles, VMINT count, VMINT x1, VMINT y1, VMINT x2, VMINT y2); + + + +/***************************************************************************** + * FUNCTION + * vm_graphic_get_char_baseline_alllang + * DESCRIPTION + * Get maximum char baseline regardless of language for the font size + * PARAMETERS + * size [IN] font size + * RETURNS + * return char baseline + *****************************************************************************/ +VMINT vm_graphic_get_char_baseline_alllang(VMINT size); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_get_layer_buffer_size + * DESCRIPTION + * Get buffer size of the layer + * PARAMETERS + * handle [IN] layer handle + * RETURNS + * return laeyr buffer size + *****************************************************************************/ +VMINT vm_graphic_get_layer_buffer_size(VMINT handle); + +/***************************************************************************** + * FUNCTION + * vm_graphic_is_dynamic_switch_cacheable_region + * DESCRIPTION + * query whether the memory is dynamic switch cacheable + * PARAMETERS + * vaddr [IN] the memory start address + * len [IN] the memory size + * RETURNS + * If the can dynamic switch cacheable, return 1; otherwise, return 0 + *****************************************************************************/ +VMINT vm_graphic_is_dynamic_switch_cacheable_region(void * vaddr, VMUINT len); + +/***************************************************************************** + * FUNCTION + * vm_graphic_dynamic_switch_cacheable_region + * DESCRIPTION + * dynamic switch the memory cacheable attribute + * PARAMETERS + * vaddr [IN] the pointer to the memory start address, the memory start address will be changed after switch + * len [IN] the memory size + * cacheable [IN] the cacheable attribute. If it is VM_NON_CACHEABLE, switch the memory from cache to non cache; if it is VM_CACHEABLE, switch the memory from non cache to cache + * NOTE + * 1. The memory must be dynamic switch cacheable, otherwise ASSERT + * 2. Only the whole base layer or fast layer buffer can be dynamic switch cacheable + * RETURNS + * Always return 1; if something abnormal, ASSERT directly + *****************************************************************************/ +VMINT vm_graphic_dynamic_switch_cacheable_region(void **vaddr, VMUINT len, VMUINT cacheable); + +/***************************************************************************** + * FUNCTION + * vm_graphic_2d_linear_transform + * DESCRIPTION + * hw linear transform. + * PARAMETERS + * src_handle : [IN] layer to resize + * sx : [IN] x of left-top cornor of resize region + * sy : [IN] y of left-top cornor of resize region + * sw : [IN] width of resize region + * sh : [IN] height of resize region + * dx : [IN] x of left-top cornor of output region + * dy : [IN] y of left-top cornor of output region + * dw : [IN] width of output region + * dh : [IN] height of output region + * RETURNS + * void + *****************************************************************************/ +VM_GDI_RESULT vm_graphic_2d_linear_transform(VMINT src_handle, VMINT sx,VMINT sy,VMINT sw,VMINT sh,VMINT dx,VMINT dy,VMINT dw,VMINT dh); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/hardware/arduino/mtk/system/libmtk/include/vmhttp.h b/hardware/arduino/mtk/system/libmtk/include/vmhttp.h new file mode 100644 index 00000000..d50d09f4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmhttp.h @@ -0,0 +1,966 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMHTTP_SDK_H_ +#define VMHTTP_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +#ifdef WIN32 + typedef unsigned int SOCKET_T; +#else + typedef int SOCKET_T; +#endif + + +/* Default user-agent when send http req */ +#define USER_AGENT "HTTP4MRE/1.3.0(MRE)" + +/* size of http req, include http head and body */ +#define HTTP_REQUEST_BUFSIZE (4096) + +/* HTTP response head size, do not include body */ +#define HTTP_RESPONSE_HEADSIZE (8192) + +/* HTTP cache size, enhance the read speed */ +#define HTTP_CACHE_SIZE (5 * 1024) + +/* HTTP state, get get remote host name , param is not used */ +#define HTTP_STATE_GET_HOSTNAME (1) + +/* HTTP state, connecting to the host , param is not used */ +#define HTTP_STATE_CONNECTING (2) + +/* HTTP state, send the http req , param is percent of sending */ +#define HTTP_STATE_SENDING (3) + +/* HTTP state, receive status , param is not used */ +#define HTTP_STATE_RECV_STATUS (4) + +/* HTTP state, receive heads , param is not used */ +#define HTTP_STATE_RECV_HEADS (5) + +/* HTTP state, receive body , param is not used */ +#define HTTP_STATE_RECV_BODY (6) + +/* HTTP session structure */ +struct http_session_t { + SOCKET_T s; /* SOCKET handle */ + char url[255]; /* Req URL */ + char host[100]; /* Host name */ + VMUINT8 ip_addr[4]; /* Host IP address */ + VMUINT8 ip_addr_len; /* Length of IP */ + int port; /* Server Port, default is 80 */ + int nreqbuf; /* length of Req Buffer */ + char reqbuf[HTTP_REQUEST_BUFSIZE]; /* Req buffer */ + int res_code; /* HTTP response code, <0 means TCP failded */ + int nresbuf; /* HTTP response Head length */ + VMUINT8 resbuf[HTTP_RESPONSE_HEADSIZE]; /* HTTP response Head buffer */ + int nresbody; /* HTTP response Body length */ + VMUINT8* resbody; /* HTTP response Body buffer */ + void (*hook)(int, void*); /* HTTP callback func, app provide this */ + VMWCHAR lasterr[50]; /* Last error string */ +}; +typedef struct http_session_t http_session_t; + + +/* HTTP head structure */ +struct http_head_t { + char name[20]; /* Name of head */ + char value[100]; /* Value of head */ +}; +typedef struct http_head_t http_head_t; + + +/* HTTP request stucture */ +struct http_request_t { + char url[255]; /* Address URL */ + int nhead; /* Count of request head */ + http_head_t *heads; /* Array pointer of of request head */ + int nbody; /* size of request body (byte) */ + char* body; /* pointer of request body */ +}; +typedef struct http_request_t http_request_t; + + +/******************************************************************************************* + * + * FUNCTION + * vm_http_request + * Description + * Start a http request, it's an async method, http response will return from callback function + * Parameters + * request : [IN] HTTP request pointer, the structure can be local variable + * session : [IN/OUT] HTTP session pointer, the structure should be global memory + * Returns + * 0 is successful, otherwise will return following error code: + * ASYN_HTTP_REQ_NOT_SUPPORT_METHOD + * ASYN_HTTP_REQ_NOT_SUPPORT_HTTP_COMM + * ASYN_HTTP_REQ_ONLY_SUPPORT_PROXY + * ASYN_HTTP_REQ_NOT_ENOUGH_RESOURCE + * ASYN_HTTP_REQ_URL_FORMAT_ERROR + * EXAMPLE + * + * http_session_t g_hl_ses; + * void hl_http_req(void) + * { + * http_request_t req; + * int ret; + * memset(&req, 0, sizeof(http_request_t)); + * memset(&g_hl_ses, 0, sizeof(http_session_t)); + * strcpy(req.url, "http://www.mediatek.com/"); + * g_hl_ses.hook = hl_http_hook; + * ret = vm_http_request(&req, &g_hl_ses); + * } + * + *******************************************************************************************/ +int vm_http_request(http_request_t *request, http_session_t *session); + + +/******************************************************************************************* + * + * FUNCTION + * get_http_head + * Description + * Get head in HTTP response + * Parameters + * session : [IN] HTTP request session + * name : [IN] HTTP head name + * value : [IN/OUT] The buffer to store HTTP head value, the maximum size needed is 512 bytes + * Returns + * 0 is successful, otherwise will return error code: -1 + * EXAMPLE + * + * void hl_http_hook(int state, void *ses) + * { + * http_session_t *p_ses; + * int ret; + * char date[512]; + * p_ses = (http_session_t*)ses; + * ret = get_http_head(p_ses, "Date", date); + * } + * + *******************************************************************************************/ +int get_http_head(http_session_t* session, const char* name, char* value); + + +/******************************************************************************************* + * + * FUNCTION + * get_http_head_number + * Description + * Get Head number + * Parameters + * session : [IN] HTTP session pointer + * Returns + * number of head + * EXAMPLE + * + * void hl_http_hook(int state, void *ses) + * { + * http_session_t *p_ses; + * int ret; + * p_ses = (http_session_t*)ses; + * ret = get_http_head_number(p_ses); + * } + * + *******************************************************************************************/ +int get_http_head_number(http_session_t* session); + + +/******************************************************************************************* + * + * FUNCTION + * get_http_head_by_index + * Description + * Get Head name and value by the index + * Parameters + * session : [IN] HTTP request session + * index : [IN] HTTP head index + * name : [IN/OUT] HTTP head name buffer, the maximum size needed is 255 bytes. + * value : [IN/OUT] HTTP head value, the maximum size needed is 512 bytes + * Returns + * 0 is successful, otherwise will return error code: -1 + * EXAMPLE + * + * void hl_http_hook(int state, void *ses) + * { + * http_session_t *p_ses; + * int ret; + * char name[255], value[512]; + * p_ses = (http_session_t*)ses; + * ret = get_http_head_by_index(p_ses, 0, name, value); + * } + * + *******************************************************************************************/ +int get_http_head_by_index(http_session_t* session, int index, char* name, char* value); + + +/******************************************************************************************* + * + * FUNCTION + * vm_cancel_all_http_sessions + * Description + * Cancel all https sessions, created TCP link will be closed. will not send callback to app after closed + * Parameters + * void + * Returns + * void + * EXAMPLE + * + * void hl_http_hook(int state, void *ses) + * { + * http_session_t *p_ses; + * int ret; + * char name[255], value[512]; + * p_ses = (http_session_t*)ses; + * ret = get_http_head_by_index(p_ses, 0, name, value); + * vm_cancel_asyn_http_req(g_hl_http_hd); + * vm_cancel_all_http_sessions(); + * + * } + * + *******************************************************************************************/ +void vm_cancel_all_http_sessions(void); + + +/******************************************************************************************* + * + * FUNCTION + * vm_reg_http_notification + * Description + * Register HTTP status call back function. + * Parameters + * f : [IN] status callback function, state is current state, param is the different meaning in different status, please check Define of HTTP_STATE_XXXX + * Returns + * void + * EXAMPLE + * + * void hl_http_noti(VMINT state, VMINT param) + * { + * char perc[6]; + * switch(state) + * { + * case HTTP_STATE_SENDING: + * vm_sprintf(perc, "%d%%", param); + * break; + * default: + * break; + * } + * } + * void hl_http_req(void) + * { + * http_request_t req; + * int ret; + * memset(&req, 0, sizeof(http_request_t)); + * memset(&g_hl_ses, 0, sizeof(http_session_t)); + * strcpy(req.url, "http://www.mediatek.com/"); + * g_hl_ses.hook = hl_http_hook; + * vm_reg_http_notification(hl_http_noti); + * ret = vm_http_request(&req, &g_hl_ses); + * } + * + *******************************************************************************************/ +void vm_reg_http_notification(void (*f)(VMINT state, VMINT param)); + + +/******************************************************************************************* + * + * FUNCTION + * vm_enable_proxy + * Description + * Enable/Disalbe HTTP proxy, it's a global setting for MRE env. + * Parameters + * use_proxy : [IN] TRUE is use proxy, FALSE is not use Proxy + * Returns + * void + *******************************************************************************************/ +void vm_enable_proxy(VMINT use_proxy); + + +/* HTTP request method enum */ +typedef enum { + GET = 1, + POST, + HEAD, + PUT, + DELETE, + TRACE, + CONNECT +}HTTP_METHOD; + +/* asyn_http_req_t.use_proxy param enum*/ +typedef enum +{ + HTTP_USE_CMNET = 0, /* use cmnet APN to connect */ + HTTP_USE_CMWAP, /* use cmwap APN to connect */ + HTTP_USE_CMNET_PRIORITY, /* If can't find any cmnet's APN, will use cmwap APN */ + HTTP_USE_CMWAP_PRIORITY, /* If can't find any cmwap's APN, will use cmnet APN */ + HTTP_USE_WIFI /* Use WIFI to connect */ +} VM_HTTP_PROXY_TYPE; + + +/* Async http request structure, enhance http_request */ +typedef struct asyn_http_req_t { + HTTP_METHOD req_method; /* HTTP_METHOD */ + VMUINT8 use_proxy; /* VM_HTTP_PROXY_TYPE */ + http_request_t* http_request; /* Old http request */ +}asyn_http_req_t; + + + +/* return value of vm_asyn_http_req, HTTP req success, will sent an async request */ +#define ASYN_HTTP_REQ_ACCEPT_SUCCESS (0) + +/* return value of vm_asyn_http_req, Do not support current method */ +#define ASYN_HTTP_REQ_NOT_SUPPORT_METHOD (1) + +/* return value of vm_asyn_http_req, Do not support HTTP stack */ +#define ASYN_HTTP_REQ_NOT_SUPPORT_HTTP_COMM (2) + +/* return value of vm_asyn_http_req, only support proxy mode */ +#define ASYN_HTTP_REQ_ONLY_SUPPORT_PROXY (3) + +/* return value of vm_asyn_http_req, only one HTTP request should be sent, before it finished, could not start another again. */ +#define ASYN_HTTP_REQ_NOT_ENOUGH_RESOURCE (4) + +/* return value of vm_asyn_http_req, URL format error */ +#define ASYN_HTTP_REQ_URL_FORMAT_ERROR (5) + + +/******************************************************************************************* + * + * FUNCTION + * vm_asyn_http_req + * Description + * Start a http request, it's async function. + * Parameters + * request : [IN] HTTP request, if it's nULL, will return success, but HTTP stack will do nothing. + * http_hook : [IN] Call back function, + * http_state_notify : [IN] HTTP status notify function + * Returns + * return ASYN_HTTP_REQ_ACCEPT_SUCCESS if success, or return error code, please check define of ASYN_HTTP_REQ_XXX + * EXAMPLE + * + * void hl_asyn_http_req(void) + * { + * asyn_http_req_t asyn_req; + * http_request_t req; + * int ret; + * memset(&req, 0, sizeof(http_request_t)); + * strcpy(req.url, "http://www.mediatek.com/"); + * asyn_req.http_request = &req; + * asyn_req.req_method = GET; + * asyn_req.use_proxy = HTTP_USE_CMNET; + * ret = vm_asyn_http_req(&asyn_req, hl_http_hook, hl_asyn_http_noti); + * } + * + *******************************************************************************************/ +VMINT vm_asyn_http_req(asyn_http_req_t *request, void (*http_hook)(VMINT, void*), + void (*http_state_notify)(VMINT state, VMINT param, void* session)); + +/* Get HANDLE successful */ +#define VM_GET_AHH_SUCCESS (0) + +/* Can't found the handle */ +#define VM_GET_AHH_NO_COMM (-1) + +/* Paramter error */ +#define VM_GET_AHH_ERROR_PARAM (-2) + + +/******************************************************************************************* + * + * FUNCTION + * vm_get_asyn_http_req_handle + * Description + * Get async request handle + * Parameters + * request : [IN] HTTP request. + * handle : [IN] http handle. + * Returns + * Is get it successful + * VM_GET_AHH_SUCCESS Get HANDLE successful + * VM_GET_AHH_NO_COMM Can't found the handle + * VM_GET_AHH_ERROR_PARAM Paramter error + * Example + * + * { + * http_request_t internal_req; + * + * req.http_request = &internal_req; + * req.req_method = GET; + * internal_req.nhead = internal_req.nbody = 0; + * strcpy(internal_req.url, "http://www.mediatek.com"); + * + * if (vm_asyn_http_req(&req, http_hook_callback, http_state_callback) == ASYN_HTTP_REQ_ACCEPT_SUCCESS) + * { + * VMINT handle = 0; + * vm_get_asyn_http_req_handle(&req, &handle); // Get the handle + * } + * } + * + *******************************************************************************************/ +VMINT vm_get_asyn_http_req_handle(asyn_http_req_t* request, VMINT* handle); + + + +/* return value of vm_cancel_asyn_http_req, Cancel request success */ +#define VM_CAH_REQ_SUCCESS (0) + +/* return value of vm_cancel_asyn_http_req, Could not found the reqeust */ +#define VM_CAH_REQ_NO_COMM (-1) + + +/******************************************************************************************* + * + * FUNCTION + * vm_cancel_asyn_http_req + * Description + * Cancel one http request + * Parameters + * handle : [IN] http handle, could get it from vm_get_asyn_http_req_handle + * Returns + * VM_CAH_REQ_SUCCESS Cancel request success + * VM_CAH_REQ_NO_COMM Could not found the reqeust + * EXAMPLE + * + * void hl_http_hook(int state, void *ses) + * { + * http_session_t *p_ses; + * int ret; + * char name[255], value[512]; + * p_ses = (http_session_t*)ses; + * ret = get_http_head_by_index(p_ses, 0, name, value); + * vm_cancel_asyn_http_req(g_hl_http_hd); + * vm_cancel_all_http_sessions(); + * + * } + * + *******************************************************************************************/ +VMINT vm_cancel_asyn_http_req(VMINT handle); + + +/******************************************************************************************* + * + * FUNCTION + * vm_url_encode_gb2312 + * Description + * GB2312 to URL encode + * Parameters + * dst : [OUT] Dest buffer + * size : [IN] Dest buffer size(byte) + * src : [IN] Source buffer + * Returns + * size of dest string(byte), do not include \0. + * EXAMPLE + * + * static void hl_http_encode_url(void) + * { + * VMSTR src = "http://www.²âÊÔ.com"; + * VMCHAR des[255]; + * int ret; + * ret = vm_url_encode_gb2312(des,sizeof(des), src); + * } + * + *******************************************************************************************/ +VMUINT vm_url_encode_gb2312(VMSTR dst, VMUINT size, const VMSTR src); + + +/******************************************************************************************* + * + * FUNCTION + * vm_url_decode_gb2312 + * Description + * URL to GB2312 decode + * Parameters + * dst : [OUT] Dest buffer + * size : [IN] Dest buffer size(byte) + * src : [IN] Source buffer + * Returns + * size of dest string(byte), do not include \0. + * EXAMPLE + * + * static void hl_http_decode_url(void) + * { + * VMSTR src = "http%3a%2f%2fwww.%b2%e2%ca%d4.com"; + * VMCHAR des[255]; + * int ret; + * ret = vm_url_decode_gb2312(des, sizeof(des), src); + * } + * + *******************************************************************************************/ +VMUINT vm_url_decode_gb2312(VMSTR dst, VMUINT size, VMSTR src); + + +/******************************************************************************************* + * + * FUNCTION + * http_data_receiver + * Description + * HTTP reponse callback function typedef + * Parameters + * handle : [IN] HTTP handle + * p : [IN] Not used + * Returns + * >0 total length, 0 block, <0 error code. + *******************************************************************************************/ +typedef VMINT(*http_data_receiver)(VMINT handle, void* p); + + +/******************************************************************************************* + * + * FUNCTION + * vm_http_reg_receiver + * Description + * Register receiver + * Parameters + * handle : [IN] HTTP handle + * reciever : [IN] Receive data callback + * Returns + * Is successful + * EXAMPLE + * + * void hl_http_fetch(void) + * { + * asyn_http_req_t asyn_req; + * http_request_t req; + * int ret; + * + * memset(&req, 0, sizeof(http_request_t)); + * strcpy(req.url, "http://www.mediatek.com"); + * asyn_req.http_request = &req; + * asyn_req.req_method = GET; + * if (vm_wifi_is_connected()) { + * asyn_req.use_proxy = HTTP_USE_WIFI; + * } + * else { + * asyn_req.use_proxy = HTTP_USE_CMNET_PRIORITY; + * } + * g_hl_http_hd = vm_http_fetch_handle(ASYN_HTTP_REQ, &asyn_req); + * vm_http_reg_receiver(g_hl_http_hd, hl_data_recv); + * ret = vm_asyn_http_req(&asyn_req, NULL, hl_asyn_http_noti); + * } + * + *******************************************************************************************/ +VMINT vm_http_reg_receiver(VMINT handle, http_data_receiver reciever); + + +/******************************************************************************************* + * + * FUNCTION + * vm_http_recv_data + * Description + * Receive HTTP Data + * Parameters + * handle : [IN] HTTP handle + * data : [IN] Buffer pointer + * len : [IN] Buffer size + * Returns + * Received data size + * EXAMPLE + * + * VMINT hl_data_recv(VMINT handle, void* p) + * { + * VMINT ret; + * VMUINT8 data[1024]; + * ret = vm_http_recv_data(handle, data, 1024); + * return TRUE; + * } + * + *******************************************************************************************/ +VMINT vm_http_recv_data(VMINT handle, VMUINT8* data, VMINT len); + + +/******************************************************************************************* + * + * FUNCTION + * http_data_sender + * Description + * Callback function of HTTP data callback + * Parameters + * handle : [IN] HTTP handle + * p : [IN] Not used + * Returns + * >0 total length, 0 block, <0 error code. + *******************************************************************************************/ +typedef VMINT(*http_data_sender)(VMINT handle, void* p); + + +/******************************************************************************************* + * + * FUNCTION + * vm_http_reg_sender + * Description + * Register HTTP datacall back function + * Parameters + * handle : [IN] HTTP handle + * sender : [IN] Callback function + * Returns + * Is successful + * EXAMPLE + * + * void hl_http_fetch(void) + * { + * asyn_http_req_t asyn_req; + * http_request_t req; + * int ret; + * + * memset(&req, 0, sizeof(http_request_t)); + * strcpy(req.url, "http://www.mediatek.com"); + * asyn_req.http_request = &req; + * asyn_req.req_method = GET; + * if (vm_wifi_is_connected()) { + * asyn_req.use_proxy = HTTP_USE_WIFI; + * } + * else { + * asyn_req.use_proxy = HTTP_USE_CMNET_PRIORITY; + * } + * g_hl_http_hd = vm_http_fetch_handle(ASYN_HTTP_REQ, &asyn_req); + * vm_http_reg_sender(g_hl_http_hd, hl_data_sender); + * ret = vm_asyn_http_req(&asyn_req, NULL, hl_asyn_http_noti); + * } + * + *******************************************************************************************/ +VMINT vm_http_reg_sender(VMINT handle, http_data_sender sender); + + +/******************************************************************************************* + * + * FUNCTION + * vm_http_send_data + * Description + * Send HTTP data, use this after send http request + * Parameters + * handle : [IN] HTTP handle + * data : [IN] Buffer of HTTP data + * len : [IN] Length of HTTP data + * Returns + * Is successful + * EXAMPLE + * + * VMINT hl_data_sender(VMINT handle, void* p) + * { + * VMUINT8 data[1024]; + * strcpy(data, "Data data data..."); + * vm_http_send_data(g_hl_http_hd, data, strlen(data)); + * } + * + *******************************************************************************************/ +VMINT vm_http_send_data(VMINT handle, VMUINT8* data, VMINT len); + + +/******************************************************************************************* + * + * FUNCTION + * vm_http_add_header + * Description + * Add http head, APP need to provide name and value memory, call this before start the request. + * max length of name+value is 400 bytes + * Parameters + * handle : [IN] HTTP handle + * name : [IN] name of head + * value : [IN] value of head + * Returns + * Is successful + * EXAMPLE + * + * void hl_http_fetch(void) + * { + * asyn_http_req_t asyn_req; + * http_request_t req; + * int ret; + * + * memset(&req, 0, sizeof(http_request_t)); + * strcpy(req.url, "http://www.mediatek.com"); + * asyn_req.http_request = &req; + * asyn_req.req_method = GET; + * if (vm_wifi_is_connected()) { + * asyn_req.use_proxy = HTTP_USE_WIFI; + * } + * else { + * asyn_req.use_proxy = HTTP_USE_CMNET_PRIORITY; + * } + * g_hl_http_hd = vm_http_fetch_handle(ASYN_HTTP_REQ, &asyn_req); + * vm_http_reg_receiver(g_hl_http_hd, hl_data_recv); + * vm_http_add_header(g_hl_http_hd, "Keep-Alive", "115"); + * vm_http_add_header(g_hl_http_hd, "Connection", "keep-alive"); + * ret = vm_asyn_http_req(&asyn_req, NULL, hl_asyn_http_noti); + * } + * + *******************************************************************************************/ +VMINT vm_http_add_header(VMINT handle, VMCHAR* name, VMCHAR* value); + + +/******************************************************************************************* + * + * FUNCTION + * vm_http_set_body + * Description + * Set HTTP request URL, URL max length is 400 bytes + * Parameters + * handle : [IN] HTTP handle + * url : [IN] URL pointer, app need to handle this buffer by itself. + * len : [IN] URL size + * Returns + * Is successful + * EXAMPLE + * + * void hl_http_fetch(void) + * { + * asyn_http_req_t asyn_req; + * http_request_t req; + * int ret; + * + * memset(&req, 0, sizeof(http_request_t)); + * strcpy(req.url, "http://www.mediatek.com"); + * asyn_req.http_request = &req; + * asyn_req.req_method = GET; + * if (vm_wifi_is_connected()) { + * asyn_req.use_proxy = HTTP_USE_WIFI; + * } + * else { + * asyn_req.use_proxy = HTTP_USE_CMNET_PRIORITY; + * } + * g_hl_http_hd = vm_http_fetch_handle(ASYN_HTTP_REQ, &asyn_req); + * vm_http_set_url(g_hl_http_hd, "http://www.mediatek.com", strlen("http://www.mediatek.com")); + * ret = vm_asyn_http_req(&asyn_req, hl_http_hook, hl_asyn_http_noti); + * } + * + *******************************************************************************************/ +VMINT vm_http_set_url(VMINT handle, VMCHAR* url, VMINT len); + + +/******************************************************************************************* + * + * FUNCTION + * vm_http_set_body + * Description + * Set HTTP request body, before start the request, free memory of data after request is sent + * Parameters + * handle : [IN] HTTP handle + * data : [IN] Body pointer, could be NULL, then body will upload by callback function + * len : [IN] Body size, will write to head's content-length section. + * Returns + * Is successful + * EXAMPLE + * + * void hl_http_fetch(void) + * { + * asyn_http_req_t asyn_req; + * http_request_t req; + * int ret; + * + * memset(&req, 0, sizeof(http_request_t)); + * strcpy(req.url, "http://www.mediatek.com"); + * asyn_req.http_request = &req; + * asyn_req.req_method = POST; + * if (vm_wifi_is_connected()) { + * asyn_req.use_proxy = HTTP_USE_WIFI; + * } + * else { + * asyn_req.use_proxy = HTTP_USE_CMNET_PRIORITY; + * } + * g_hl_http_hd = vm_http_fetch_handle(ASYN_HTTP_REQ, &asyn_req); + * vm_http_reg_sender(g_hl_http_hd, hl_data_sender); + * vm_http_set_body(g_hl_http_hd, "Body body body...", strlen("Body body body...")); + * ret = vm_asyn_http_req(&asyn_req, hl_http_hook, hl_asyn_http_noti); + * } + * + *******************************************************************************************/ +VMINT vm_http_set_body(VMINT handle, VMUINT8* data, VMINT len); + + +typedef enum { + ASYN_HTTP_REQ = 0, + HTTP_REQUEST +} HTTP_HANDLE_TYPE; + + +/******************************************************************************************* + * + * FUNCTION + * vm_http_fetch_handle + * Description + * Get a valid HTTP, use it when need to config HTTP request by vm_set_http_header(), vm_set_http_body() + * Parameters + * type : [IN] Type of get http handle + * p : [IN] pointer of asyn_http_req_t + * Returns + * HTTP handle + * EXAMPLE + * + * void hl_http_fetch(void) + * { + * asyn_http_req_t asyn_req; + * http_request_t req; + * int ret; + * + * memset(&req, 0, sizeof(http_request_t)); + * strcpy(req.url, "http://www.mediatek.com"); + * asyn_req.http_request = &req; + * asyn_req.req_method = POST; + * if (vm_wifi_is_connected()) { + * asyn_req.use_proxy = HTTP_USE_WIFI; + * } + * else { + * asyn_req.use_proxy = HTTP_USE_CMNET_PRIORITY; + * } + * g_hl_http_hd = vm_http_fetch_handle(ASYN_HTTP_REQ, &asyn_req); + * vm_http_reg_sender(g_hl_http_hd, hl_data_sender); + * ret = vm_asyn_http_req(&asyn_req, hl_http_hook, hl_asyn_http_noti); + * } + * + *******************************************************************************************/ +VMINT vm_http_fetch_handle(VMINT type, void* p); + + +/******************************************************************************************* + * + * FUNCTION + * vm_http_get_current_handle + * Description + * Get the current handle + * Parameters + * void + * Returns + * HTTP handle + * EXAMPLE + * + * void hl_http_fetch(void) + * { + * asyn_http_req_t asyn_req; + * http_request_t req; + * int ret; + * VMINT cur_hd; + * memset(&req, 0, sizeof(http_request_t)); + * strcpy(req.url, "http://www.mediatek.com"); + * asyn_req.http_request = &req; + * asyn_req.req_method = POST; + * if (vm_wifi_is_connected()) { + * asyn_req.use_proxy = HTTP_USE_WIFI; + * } + * else { + * asyn_req.use_proxy = HTTP_USE_CMNET_PRIORITY; + * } + * g_hl_http_hd = vm_http_fetch_handle(ASYN_HTTP_REQ, &asyn_req); + * cur_hd = vm_http_get_current_handle(); + * } + * + *******************************************************************************************/ +VMINT vm_http_get_current_handle(void); + + +/******************************************************************************************* + * + * FUNCTION + * vm_http_set_current_handle + * Description + * Set the current handle + * Parameters + * handle : [IN] HTTP handle need to be handle + * Returns + * HTTP handle + * EXAMPLE + * + * void hl_http_fetch(void) + * { + * asyn_http_req_t asyn_req; + * http_request_t req; + * int ret; + * VMINT cur_hd; + * memset(&req, 0, sizeof(http_request_t)); + * strcpy(req.url, "http://www.mediatek.com"); + * asyn_req.http_request = &req; + * asyn_req.req_method = POST; + * if (vm_wifi_is_connected()) { + * asyn_req.use_proxy = HTTP_USE_WIFI; + * } + * else { + * asyn_req.use_proxy = HTTP_USE_CMNET_PRIORITY; + * } + * cur_hd = vm_http_fetch_handle(ASYN_HTTP_REQ, &asyn_req); + * g_hl_http_hd = vm_http_set_current_handle(cur_hd - 1); + * } + * + *******************************************************************************************/ +VMINT vm_http_set_current_handle(VMINT handle); + + +/******************************************************************************************* + * + * FUNCTION + * vm_http_free_handle + * Description + * Release all resource of HTTP, use it after HTTP operate or after cancel the request + * Parameters + * handle : [IN] HTTP handle + * Returns + * void + * EXAMPLE + * + * void hl_http_fetch(void) + * { + * asyn_http_req_t asyn_req; + * http_request_t req; + * int ret; + * VMINT cur_hd; + * memset(&req, 0, sizeof(http_request_t)); + * strcpy(req.url, "http://www.mediatek.com"); + * asyn_req.http_request = &req; + * asyn_req.req_method = POST; + * if (vm_wifi_is_connected()) { + * asyn_req.use_proxy = HTTP_USE_WIFI; + * } + * else { + * asyn_req.use_proxy = HTTP_USE_CMNET_PRIORITY; + * } + * cur_hd = vm_http_fetch_handle(ASYN_HTTP_REQ, &asyn_req); + * ret = vm_asyn_http_req(&asyn_req, hl_http_hook, hl_asyn_http_noti); + * vm_http_free_handle(g_hl_http_hd); + * } + * + *******************************************************************************************/ +void vm_http_free_handle(VMINT handle); + +#ifdef __cplusplus +} +#endif + +#endif /*VMHTTP_SDK_H_*/ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmhttpd.h b/hardware/arduino/mtk/system/libmtk/include/vmhttpd.h new file mode 100644 index 00000000..ed6d238e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmhttpd.h @@ -0,0 +1,359 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmhttpd_sdk.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * LinkIt app and http task communicate header file + * + * Author: + * ------- + * jianying.li(mtk81091) + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ +* *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== +*******************************************************************************/ +#ifndef VM_HTTPD_SDK_H +#define VM_HTTPD_SDK_H +#ifdef __cplusplus +extern "C"{ +#endif/*__cplusplus*/ +#include "vmsys.h" +/*VM_CGI_MAX_PARAM*/ +/*VM_CGI_MAX_COMMAND_LINE_LEN*/ +#define VM_CGI_MAX_COMMAND_LINE_LEN 250 + +/*vm_httpsrv_error_enum*/ +typedef enum +{ + VM_HTTPSRV_ERR_NO_ERROR = 0,//operator suceed + VM_HTTPSRV_ERR_STATE_ERROR = -1,//state of http is mess + VM_HTTPSRV_ERR_GET_MEM_FAIL = -2,//memory is not enough + VM_HTTPSRV_ERR_CONNECT_NETWORK_FAIL = -3,//network is not ready + VM_HTTPSRV_ERR_FD_INIT_FAIL = -4,//file disciptor init fail + VM_HTTPSRV_ERR_GET_HOSTNAME_FAIL = -5,//invalid host name + VM_HTTPSRV_ERR_SRV_INIT_FAIL = -6,//server init fail + VM_HTTPSRV_ERR_ERROR_FD_NUMBER = -7,//file diciptor abnormal + VM_HTTPSRV_ERR_OTHERS = -65535,// other errors + VM_HTTPSRV_ERR_CODE = -65536//end mark +}vm_httpsrv_error_enum; +/*the struct of app parameter */ +typedef struct vm_cgi_app_param +{ + VMINT8 command_line[VM_CGI_MAX_COMMAND_LINE_LEN];// memory for string which was reference by argv +} vm_cgi_app_param; + +/*the struct of the parameter with system message VM_MSG_HTTPD */ +typedef struct vm_cgi_launch_param +{ + VMUINT32 hc_handle; //http connection handler, actually, a pointer to hc + vm_cgi_app_param param;//used by app, this struct is fill with command line, which is comes from client +}vm_cgi_launch_param; + +/***************************************************************************** + * FUNCTION + * vm_inet_httpd_start + * DESCRIPTION + * this is for launch http server + * PARAMETERS + * port: [IN]the port to start + * root_dir:[IN] the root dir + * cgi_pattern:[IN] the cgi pattern + * RETURNS + * httpsrv_error_enum:return VM_HTTPSRV_ERR_NO_ERROR, success, othersize, fail + * EXAMPLE + * + * vm_inet_httpd_start(80, "C:\\@httpsrv", "**.vxp"); + * + *****************************************************************************/ +extern vm_httpsrv_error_enum vm_inet_httpd_start(VMUINT32 port, VMINT8* root_dir, VMINT8* cgi_pattern); + +/***************************************************************************** + * FUNCTION + * vm_inet_httpd_stop + * DESCRIPTION + * this is for stop http server + * PARAMETERS + * N/A + * RETURNS + * httpsrv_error_enum:return VM_HTTPSRV_ERR_NO_ERROR, success, othersize, fail + * EXAMPLE + * + * vm_inet_httpd_stop(); + * + *****************************************************************************/ +extern vm_httpsrv_error_enum vm_inet_httpd_stop(void); + +/***************************************************************************** + * FUNCTION + * vm_inet_httpd_restart + * DESCRIPTION + * this is for restart http server + * PARAMETERS + * port: [IN]the port to restart + * root_dir:[IN]the root dir + * cgi_pattern:[IN]the cgi pattern + * RETURNS + * httpsrv_error_enum:return VM_HTTPSRV_ERR_NO_ERROR, success, othersize, fail + * EXAMPLE + * + * vm_inet_httpd_restart(80, "C:\\@httpsrv", "**.vxp"); + * + *****************************************************************************/ +extern vm_httpsrv_error_enum vm_inet_httpd_restart(VMUINT32 port, VMINT8* root_dir, VMINT8* cgi_pattern); + +/***************************************************************************** + * FUNCTION + * vm_inet_httpd_cgi_job_finish + * DESCRIPTION + * call this api to notify http server when cgi app finished the job. + * PARAMETERS + * hc_handle:[IN] when launch LinkIt app, will send VM_MSG_HTTPD,and the parameter with this msg + * is the pointer of vm_cgi_launch_param ; app can get hc_handle from vm_cgi_launch_param ,so app should + * save the handle,a lot of api will use hc_handle as parameter + * RETURNS + * N/A + * EXAMPLE + * + * void httpd_cgi_app_demo(VMUINT32 hc_handle, VMCHAR* command_line) + * { + * VMCHAR* request_method; + * VMCHAR* query_string; + * VMCHAR* content_length; + * VMINT32 con_len; + * VMCHAR* content_data; + * VMCHAR output_buffer[256]; + * if (command_line && command_line[0] != '\0') + * { + * ///TODO: parse command line, and do some thing you need, config setting according to command_line + * } + * + * request_method = vm_inet_httpd_getenv(hc_handle,"REQUEST_METHOD"); + * + * if (request_method && strcmp(request_method, "GET") == 0) + * { + * query_string = vm_inet_httpd_getenv(hc_handle,"QUERY_STRING"); + * ///TODO: parse query_string, and do some thing you need. for example, config setting according to query_string + * } + * else if (request_method && strcmp(request_method, "POST") == 0) + * { + * content_length = vm_inet_httpd_getenv(hc_handle,"CONTENT_LENGTH"); + * if (content_length && sscanf(content_length,"%ld",&con_len) == 1) + * { + * content_data = vm_malloc(con_len + 1); + * if (content_data) + * { + * vm_inet_httpd_read(hc_handle, content_data, con_len); + * ///TODO: parse content_data, and do some thing you need. for example, config setting according to content_data + * vm_free(content_data); + * } + * } + * } + * + * //output the config result to client, let end user knows the config result. + * + * //write message header + * sprintf(output_buffer, "Content-Type:text/html\n\n"); + * vm_inet_httpd_write(hc_handle, output_buffer, strlen(output_buffer)); + * sprintf(output_buffer, "\n"); + * vm_inet_httpd_write(hc_handle, output_buffer, strlen(output_buffer)); + * sprintf(output_buffer, "\nResponse\n\n"); + * vm_inet_httpd_write(hc_handle, write_buffer, strlen(output_buffer)); + * + * //write body. + * sprintf(output_buffer, "\n"); + * vm_inet_httpd_write(hc_handle, output_buffer, strlen(output_buffer)); + * sprintf(output_buffer, "

Dear, your configration be saved suceed.\n"); + * vm_inet_httpd_write(hc_handle, output_buffer, strlen(output_buffer)); + * sprintf(output_buffer, "\n\n"); + * vm_inet_httpd_write(my_app_param.hc_handle, output_buffer, strlen(output_buffer)); + * + * //please remember to give a notification to httpd when job is finished. + * vm_inet_httpd_cgi_job_finish(hc_handle); + * + *****************************************************************************/ +extern void vm_inet_httpd_cgi_job_finish(VMUINT32 hc_handle); + +/***************************************************************************** + * FUNCTION + * vm_inet_httpd_read + * DESCRIPTION + * this api is used to read the data which is comes from client, it is used to instead of stand I/O stream. + * PARAMETERS + * hc_handle: [IN] hc_handle,comes from the parameter with VM_MSG_HTTPD + * buf:[IN/OUT]the buf to hold the read data + * buf_size:[IN]the buf size + * RETURNS + * the actually read size + * EXAMPLE + * + * void httpd_cgi_app_demo(VMUINT32 hc_handle, VMCHAR* command_line) + * { + * VMCHAR* content_length; + * VMINT32 con_len; + * content_length = vm_inet_httpd_getenv(hc_handle,"CONTENT_LENGTH"); + * if (content_length && sscanf(content_length,"%ld",&con_len) == 1) + * { + * content_data = vm_malloc(con_len + 1); + * if (content_data) + * { + * vm_inet_httpd_read(hc_handle, content_data, con_len); + * ///TODO: parse content_data, and do some thing you need. for example, config setting according to content_data + * vm_free(content_data); + * } + * } + * } + * + *****************************************************************************/ +extern VMINT32 vm_inet_httpd_read(VMUINT32 hc_handle, VMINT8* buf, VMINT32 buf_size); + +/***************************************************************************** + * FUNCTION + * vm_inet_httpd_write + * DESCRIPTION + * this api is used to write the data to client, it is used to instead of stand I/O stream. + * PARAMETERS + * hc_handle: [IN] hc_handle,comes from the parameter with VM_MSG_HTTPD + * buf:[IN] the data write to httpd + * content_size:[IN]the data size + * RETURNS + * the actually write size + * EXAMPLE + * + * VMCHAR output_buffer[256]; + * sprintf(output_buffer, "Content-Type:text/html\n\n"); + * vm_inet_httpd_write(hc_handle, output_buffer, strlen(output_buffer)); + * + *****************************************************************************/ +extern VMINT32 vm_inet_httpd_write(VMUINT32 hc_handle, VMINT8* buf, VMINT32 content_size); + +/***************************************************************************** + * FUNCTION + * vm_inet_httpd_getenv + * DESCRIPTION + * this api is get enviroment varible, it's same as other plateform in CGI. + * PARAMETERS + * hc_handle:[IN]hc_handle,comes from the parameter with VM_MSG_HTTPD + * name:[IN]the env name + * RETURNS + * the env string + * EXAMPLE + * + * void httpd_cgi_app_demo(VMUINT32 hc_handle, VMCHAR* command_line) + * { + * VMCHAR* content_length; + * VMINT32 con_len; + * content_length = vm_inet_httpd_getenv(hc_handle,"CONTENT_LENGTH"); + * if (content_length && sscanf(content_length,"%ld",&con_len) == 1) + * { + * content_data = vm_malloc(con_len + 1); + * if (content_data) + * { + * vm_inet_httpd_read(hc_handle, content_data, con_len); + * ///TODO: parse content_data, and do some thing you need. for example, config setting according to content_data + * vm_free(content_data); + * } + * } + * } + * + *****************************************************************************/ +extern VMINT8* vm_inet_httpd_getenv(VMUINT32 hc_handle, VMINT8* name); + +/***************************************************************************** + * FUNCTION + * vm_inet_httpd_enable_ssl + * DESCRIPTION + * this api can enable httpd for SSL. Then it can support https. + * Important + * 1. Must start http server after enable ssl. Https server must run with http server. + * 2. Push your https html into http server source path. Emxaple "E:/httpd". + * If some html files can't be get by http server, you can push them into "E:/httpd/https". We will protect the files of "(httpd sourcepath)/https". + * Example: + * input : http://127.0.0.1/user/index.html output: index.html + * input : https://127.0.0.1/user/index.html output: index.html + * input : http://127.0.0.1/https/index.html output: 403 forbidden + * input : https://127.0.0.1/user/index.html output: index.html + * 3. Support base64 and binary certificate file provide by openssl.exe or certificate authority. + * Don't support cermake.exe certificate file. This is xyssl open source limitation. + * PARAMETERS + * port : [IN] https port + * cer_dir : [IN] The directory for https server certificate files. You must be include "httpd_ca.cer" / "httpd_server.cer" / "httpd_server.key". Total three files and can't change names. + * peer_CN: [IN] The name of client certificate which one https server need verify. Example "HTTPD_CLIENT". + * server_key_passwd : [IN] Pass word of "httpd_server.key" file. Your private key file need a password for protection. + * RETURNS + * void + * EXAMPLE + * + * vm_inet_httpd_enable_ssl(443, E:/https, HTTPD_CLIENT, 1234); + * vm_inet_httpd_start(80, E:/httpd, **.vxp); + * + *****************************************************************************/ +extern void vm_inet_httpd_enable_ssl(VMUINT32 port, VMINT8* cer_dir, VMINT8* peer_cn, VMINT8* server_key_passwd); + +/***************************************************************************** + * FUNCTION + * vm_inet_httpd_disable_ssl + * DESCRIPTION + * this api can disable httpd for SSL. Then it can't support https. + * PARAMETERS + * N/A + * RETURNS + * void + * EXAMPLE + * + * vm_inet_httpd_stop(); + * vm_inet_httpd_disable_ssl(); + * + *****************************************************************************/ +extern void vm_inet_httpd_disable_ssl(); + +#ifdef __cplusplus +} +#endif/*__cplusplus*/ + +#endif/*VM_HTTPD_SDK_H*/ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmhttps.h b/hardware/arduino/mtk/system/libmtk/include/vmhttps.h new file mode 100644 index 00000000..6818a7b2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmhttps.h @@ -0,0 +1,538 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMHTTPS_SDK_H +#define VMHTTPS_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/************************************************************************* + * WPS SERVICE -- MACRO's And Typedef's structure definition + ************************************************************************/ + +#define MRE_WPS_MAX_CONTENT_TYPE_LEN 256 + +/* Connection type constants */ + +#define MRE_WPS_CONN_TYPE_HTTP 1 +#define MRE_WPS_CONN_TYPE_WSP_CL 2 +#define MRE_WPS_CONN_TYPE_WSP_CO 3 +#define MRE_WPS_CONN_TYPE_TLS 4 + +/* HTTP method constants */ + +#define MRE_WPS_HTTP_METHOD_GET 0x40 +#define MRE_WPS_HTTP_METHOD_HEAD 0x42 +#define MRE_WPS_HTTP_METHOD_POST 0x60 +#define MRE_WPS_HTTP_METHOD_PUT 0x61 +#define MRE_WPS_HTTP_METHOD_DELETE 0x43 + +/* HTTP request options */ + +#define MRE_WPS_HTTP_OPTION_NO_CACHE 0x00000001 +#define MRE_WPS_HTTP_OPTION_DO_NOT_CACHE_REPLY 0x00000002 +#define MRE_WPS_HTTP_OPTION_ALWAYS_CACHE 0x00000004 +#define MRE_WPS_HTTP_OPTION_CACHE_ONLY 0x00000008 +#define MRE_WPS_HTTP_OPTION_STALE_CACHE 0x00000010 +#define MRE_WPS_HTTP_OPTION_DO_NOT_HANDLE_SERVER_AUTH 0x00008000 +#define MRE_WPS_HTTP_OPTION_DO_NOT_HANDLE_PROXY_AUTH 0x00010000 +#define MRE_WPS_HTTP_OPTION_DO_NOT_REDIRECT 0x00020000 +#define MRE_WPS_HTTP_OPTION_USE_LARGE_PIPE 0x40000000 +#define MRE_WPS_HTTP_OPTION_FS_COMMIT 0x80000000 +#define MRE_WPS_HTTP_OPTION_NO_NOT_ADD_COOKIE 0x00400000 + +/* HTTP authentication constants */ + +#define MRE_WPS_HTTP_AUTH_SERVER 1 +#define MRE_WPS_HTTP_AUTH_PROXY 2 + +#define MRE_WPS_HTTP_AUTH_TYPE_BASIC 1 +#define MRE_WPS_HTTP_AUTH_TYPE_DIGEST 2 + + +/* Protocol constants */ + +#define MRE_WPS_PROTOCOL_WSP_CL 1 +#define MRE_WPS_PROTOCOL_WSP_CL_WTLS 2 +#define MRE_WPS_PROTOCOL_WSP_CO 3 +#define MRE_WPS_PROTOCOL_WSP_CO_WTLS 4 +#define MRE_WPS_PROTOCOL_HTTP 5 +#define MRE_WPS_PROTOCOL_HTTP_TLS 6 +#define MRE_WPS_PROTOCOL_HTTP_SSL 7 +#define MRE_WPS_PROTOCOL_CACHE 8 +#define MRE_WPS_PROTOCOL_FILE 9 +#define MRE_WPS_PROTOCOL_OTHER 10 + + +#define MRE_WPS_READY_STATUS_NULL 0 /* MMI WPS is not ready to service */ +#define MRE_WPS_READY_STATUS_OK 1 /* MMI WPS is ready to service */ + + +/* used to indicate the result and error code of a request. */ + +#define MRE_WPS_OK 0 /* Success */ +#define MRE_WPS_ERROR_UNKNOWN 1 /* Unknonw error */ +#define MRE_WPS_ERROR_SEND 2 /* Fail to write content */ +#define MRE_WPS_ERROR_INVALID_PARAM 3 /* Invalid parameters */ +#define MRE_WPS_ERROR_INVALID_HEADER 4 /* Invalid headers */ +#define MRE_WPS_ERROR_INVALID_CHANNEL_ID 5 /* Invalid channel ID */ +#define MRE_WPS_ERROR_INVALID_REQUEST_ID 6 /* Invalid request ID */ +#define MRE_WPS_ERROR_INVALID_SEQUENCE_NUM 7 /* Incorrect sequence number in MSG_ID_WPS_READ_CONTENT_REQ and MSG_ID_WPS_POST_CONTENT_RES */ +#define MRE_WPS_ERROR_INVALID_DEFAULT_PROFILE 8 /* Invalid default profile */ +#define MRE_WPS_ERROR_INACTIVE_CHANNEL 9 /* Inactive channel */ +#define MRE_WPS_ERROR_INVALID_CONN_TYPE 10 /* Invalid connection type */ +#define MRE_WPS_ERROR_NO_RESOURCE 11 /* Resource limitation */ +#define MRE_WPS_ERROR_ACCESS_DENY 12 /* Access deny */ +#define MRE_WPS_ERROR_PENDING_REQ_EXIST 13 /* Pending request exists */ +#define MRE_WPS_ERROR_FILE_ACCESS 14 /* File system operation error */ +#define MRE_WPS_ERROR_REQ_ABORT 15 /* Request aborted */ +#define MRE_WPS_ERROR_NOT_FOUND 16 /* Not found */ +#define MRE_WPS_ERROR_REQ_MSG_TOO_LARGE 17 /* Message header is too large */ +#define MRE_WPS_ERROR_REQ_NOT_SUPPORT 18 /* Request is not supported */ +#define MRE_WPS_ERROR_DNS_RESOLVE 19 /* DNS error */ +#define MRE_WPS_ERROR_USE_PROXY 20 /* Proxy error */ +#define MRE_WPS_ERROR_NOT_READY 21 /* WPS is not ready yet */ +#define MRE_WPS_ERROR_NO_CNTXT_AVAILABLE 22 /* WPS free context not available, try after some time*/ +#define MRE_WPS_ERROR_CNTXT_NOT_REGISTERED 23 /* when availing WPS service without register context*/ + +/* This enum is used to specify the reply data format in a WSP/HTTP request. */ +typedef enum +{ + /* Use peer buffer to convey replied content. */ + MRE_WPS_DATA_TYPE_BUFFER, + /* Store replied content in specified file path directly with downloading + progress indication while this is specified as reply_type of + MSG_ID_WPS_HTTP_REQ. */ + MRE_WPS_DATA_TYPE_FILE, + /* Store replied content in specified file path directly without downloading + progress indication while this is specified as reply_type of + MSG_ID_WPS_HTTP_REQ. */ + MRE_WPS_DATA_TYPE_FILE_NO_PROG_IND, + /* Resume a download previously. WPS will append the content in the file + specified in the request. */ + MRE_WPS_DATA_TYPE_FILE_RESUME, + /* multipart/form-data, pass to post_type when do posting for multipart/form-data */ + MRE_WPS_DATA_TYPE_MULTIPART, +} mre_wps_data_type_enum; + +/* vm_wps_content_t is the unit of multipart */ +typedef struct { + VMUINT32 contentTypelen; /* The content type length */ + /* These two fields correspond to the following header: * Content-Type: contentType; charset="charset" * In case of multipart/form-data, each part has such a header. */ + VMUINT8 * contentType; + + VMUINT32 namelen; /* The name length */ + /* These two fields are used in case of multipart/form-data, * and are then included with each part as follows: * Content-Disposition: form-data; name="name"; filename="fileName" */ + VMUINT8 * name; + VMUINT32 fileNamelen; /* The fileName name length */ + VMUINT8 * fileName;/* Its an attribute of Content-Disposition. But not the multipart file name */ + + VMUINT32 charset; + VMUINT32 dataType; /* One of MRE_WPS_DATA_TYPE_BUFFER or MRE_WPS_DATA_TYPE_FILE. */ + VMUINT32 dataLen; + VMUINT32 filepathNamelen; /* The fileName name length */ + VMWCHAR * filepathName;/* Absolute multipart filepath along with its name. */ +} vm_wps_content_t; + +/* the structure used for vm_https_send_req_ext. */ +typedef struct +{ + VMUINT32 request_url_len; /* The request URL length */ + VMUINT8 * request_url; /* The request URL */ + VMUINT32 request_header_len; /* The request header length */ + VMUINT8 * request_header; /* The request header */ + + /* The post segment buffer length when post_type is specified as + MRE_WPS_DATA_TYPE_BUFFER. It is mandatory is method is POST/PUT and post_type + is MRE_WPS_DATA_TYPE_BUFFER. */ + VMUINT32 post_segment_len; + + /* The post data segment. It is mandatory is method is POST/PUT and + post_type is MRE_WPS_DATA_TYPE_BUFFER. */ + VMUINT8 * post_segment; + /*To support Posting of multipart data */ + VMUINT32 num_entries; /*no. of multipart entries*/ + vm_wps_content_t * content; /*application should allocate memory for each vm_wps_content_t and fill the info */ +} vm_wps_http_req_var_struct; + + +/************************************************************************* + * WPS SERVICE -- Callback function prototype + ************************************************************************/ + + /* + * Response to the channel configuration request, and if the result is + * successful, then the channel ID will be used n the HTTP/WSP request. + */ +typedef void (*wps_send_set_channel_rsp_cb)( VMUINT32 req_id, + VMUINT8 channel_id, + VMUINT8 result); + +/* + * Response to channel remove request. If the channel ID in request is + * invalid or some pending request of this channel exists, then an error is + * replied. + */ +typedef void (*wps_unset_channel_rsp_cb)( VMUINT8 channel_id, + VMUINT8 result); + + +/* + * Response to release all request. + */ +typedef void (*wps_send_release_all_req_rsp_cb)( VMUINT8 result); + + +/* + * Notifying applcation about WPS agent termination. + * app should clear all information at its end, and can start again + */ +typedef void (*wps_send_wps_termination_ind_cb)(void); + +/* + * Response to the HTTP/WSP request. new_url is used to hold the new URL + * that was used to retrieve this reply If the original request was + * redirected. If the reply_type in MSG_ID_WPS_HTTP_REQ is + * WPS_DATA_TYPE_BUFFER, then the more flag is used to indicate if + * application needs to use MSG_ID_WPS_READ_CONTENT_REQ to retrieve + * remaining content. + * + * The new_url if available, reply_header if available, and reply_segment + */ +typedef void (*wps_send_http_rsp_cb)( VMUINT16 request_id, /* request ID */ + VMUINT8 result, /* Result (wps_result_error_enum) */ + VMUINT16 status, /* HTTP response codes */ + VMINT32 cause, /* Error cause if result is not ok */ + VMUINT8 protocol, /* Network protocol used to retrieve content. Please refer to the Protocol Constants */ + VMUINT8 content_type_len, + VMUINT8 *content_type, /* The type of replied content.. max 256 characters including NULL */ + VMUINT32 content_length, /* The length of replied content. Incase the content length is unknown, use the more field to know whether there is more data*/ + VMINT32 more, /* Indicate if more data is needed to be retrieved. */ + VMUINT32 new_url_len, /* The length of new redirected URL */ + VMUINT8 *new_url, /* The new redirected URL */ + VMUINT32 reply_header_len, /* The length of replied header */ + VMUINT8 *reply_header, /* The replied header */ + VMUINT32 reply_segment_len, /* The reply segment buffer length when reply_type is specified as WPS_DATA_TYPE_BUFFER. It is mandatory when reply_type is WPS_DATA_TYPE_BUFFER. */ + VMUINT8 *reply_segment ); + +/* + * Response to the MSG_ID_WPS_READ_CONTENT_REQ. The seq_num must be the same + * as the one in the corresponding MSG_ID_WPS_READ_CONTENT_REQ. The more + * flag is used to indicate if application needs to use + * MSG_ID_WPS_READ_CONTENT_REQ to retrieve remaining content. + */ +typedef void (*wps_send_read_content_rsp_cb)( VMUINT16 request_id, /* Request ID */ + VMUINT8 seq_num, /* Sequence number (for debug purpose) */ + VMUINT8 result, /* Result (wps_result_error_enum) */ + VMINT32 more, /* Indicate if more data is needed to be retrieved. */ + VMUINT32 reply_segment_len, /* The reply segment buffer length */ + VMUINT8 *reply_segment /* The reply segment buffer */); + + + +/* + * Response to the cancel request. + */ +typedef void (*wps_send_cancel_rsp_cb)( VMUINT16 request_id, + VMUINT8 result); + + +/* + * Response to status query reqeust. If the status is WPS_READY_STATUS_NULL, + * then WPS will send MSG_ID_WPS_READY_IND to the module who submit + * MSG_ID_WPS_STATUS_QUERY_REQ + */ +typedef void (*wps_send_status_query_rsp_cb)( VMUINT8 status); + +/* + * post data indication + */ +typedef void (*wps_post_ind_cb)(VMUINT16 request_id, VMUINT8 seq_num, VMUINT8 result); + +/************************************************************************* + * WPS SERVICE -- INTERFACE FUNCTION PROTOTYPE + ************************************************************************/ + +/***************************************************************************** + * FUNCTION + * vm_https_is_supported + * DESCRIPTION + * query whether the https is supported by platform + * RETURNS + * 0 means successfully, non-zero is NOT SUPPORT. + *****************************************************************************/ +VMINT vm_https_is_supported(void); + +/***************************************************************************** + * FUNCTION + * vm_https_register_wps_cntxt_and_callback + * DESCRIPTION + * This function is to register callback function + * PARAMETERS + * apn :[IN] APN enum, VM_TCP_APN_CMNET/VM_TCP_APN_CMWAP/VM_TCP_APN_WIFI + * set_channel_rsp_cb :[IN] set channel callback + * unset_channel_cb :[IN] unset channel callback + * release_all_req_cb :[IN] release all request callback + * terminal_ind_cb :[IN] terminal req callback + * http_rsp_cb :[IN] http request callback + * read_content_rsp_cb :[IN] read content callback + * cancel_rsp_cb :[IN] cancel req callback + * status_query_rsp_cb :[IN] status query callback + * RETURNS + * 0 success + *****************************************************************************/ +VMUINT8 vm_https_register_wps_cntxt_and_callback( + VMINT apn, + wps_send_set_channel_rsp_cb set_channel_rsp_cb, + wps_unset_channel_rsp_cb unset_channel_cb, + wps_send_release_all_req_rsp_cb release_all_req_cb, + wps_send_wps_termination_ind_cb terminal_ind_cb, + wps_send_http_rsp_cb http_rsp_cb, + wps_send_read_content_rsp_cb read_content_rsp_cb, + wps_send_cancel_rsp_cb cancel_rsp_cb, + wps_send_status_query_rsp_cb status_query_rsp_cb); + + +/***************************************************************************** + * FUNCTION + * vm_https_send_set_channel_req + * DESCRIPTION + * Configure a dedicated channel for HTTP/WSP requests. An channel can be + * configured to use proxy while use_proxy is true. When use_proxy is true, + * prx_ip, prx_port, username, and password will be used to communicate with + * proxy server, thus prx_ip must not be 0.0.0.0 and if prx_port value 0 + * means use default proxy port 8080. When the conn_type is + * WPS_CONN_TYPE_WSP_CO or WPS_CONN_TYPE_WSP_CL, then use_proxy is true + * default. However, if application simply wants to use current activated + * setting used in WAP, then just set use_default as true and ignore all + * other parameters. + * Static_header (if necessary) must be filled in + * WAP_PROF_CONN_TYPE_WSP_CO and the first WSP request of some dedicated + * channel with connection type WSP_CONN_TYPE_WSP_CL. If application doesn't + * specify static_header, then WPS will use the value currently used by WAP. + * + * PARAMETERS + * req_id : [IN] Request ID + * use_proxy : [IN] Use proxy or not + * prx_ip : [IN] Proxy IP address + * prx_port : [IN] Proxy port number. 0 means default proxy 8080. + * username : [IN] Username for the proxy. Only ASCII is allowed and NULL terminated + * username_len : [IN] length should not exceed 40 character excluding NULL character + * password : [IN] Password for the proxy. Only ASCII is allowed and NULL terminated. + * password_len : [IN] length should not exceed 40 character excluding NULL character + * server_auth_username : [IN] Username for the origin server. Only ASCII is allowed and NULL terminated. + * server_auth_username_len : [IN] length should not exceed 128 character excluding NULL character + * server_auth_password : [IN] length should not exceed 128 character excluding NULL character + * server_auth_password_len : [IN] length should not exceed 40 character excluding NULL character + * static_header_len : [IN] The length of static header + * static_header : [IN] static header + * RETURNS + * void + *****************************************************************************/ +VMUINT8 vm_https_send_set_channel_req( + VMUINT16 req_id, /* Request ID */ + VMUINT8 use_proxy, /* Use proxy or not */ + VMUINT8 prx_ip[4], /* Proxy IP address */ + VMUINT16 prx_port, /* Proxy port number. 0 means default proxy 8080. */ + VMUINT8 *username, /* Username for the proxy. Only ASCII is allowed and NULL terminated. */ + VMUINT8 username_len, /*length should not exceed 40 character excluding NULL character*/ + VMUINT8 *password, /* Password for the proxy. Only ASCII is allowed and NULL terminated. */ + VMUINT8 password_len, /*length should not exceed 40 character excluding NULL character*/ + VMUINT8 *server_auth_username, /* Username for the origin server. Only ASCII is allowed and NULL terminated. */ + VMUINT8 server_auth_username_len, /*length should not exceed 128 character excluding NULL character*/ + VMUINT8 *server_auth_password, /* Password for the origin server. Only ASCII is allowed and NULL terminated. */ + VMUINT8 server_auth_password_len, /*length should not exceed 40 character excluding NULL character*/ + VMUINT32 static_header_len, /* The length of static header */ + VMUINT8 *static_header /* static header */ ); + + +/***************************************************************************** + * FUNCTION + * vm_https_send_unset_channel_req + * DESCRIPTION + * this function is to send unset channel request information to WPS + * PARAMETERS + * channel_id : [IN] channel ID + * RETURNS + * void + *****************************************************************************/ + VMUINT8 vm_https_send_unset_channel_req(VMUINT8 channel_id ); + + +/***************************************************************************** + * FUNCTION + * vm_https_send_req + * DESCRIPTION + * this function is to send a HTTP/WSP request. + * PARAMETERS + request_id, : [IN] Request ID + method, : [IN] HTTP Method Constant + option, : [IN] HTTP request options + reply_type, : [IN] Reply type (wps_data_type_enum) + The file path used to store replied content when reply_type is specified + as WPS_DATA_TYPE_FILE, WPS_DATA_TYPE_FILE_NO_PROG_IND or + WPS_DATA_TYPE_FILE_RESUME. + Max. buffer size that reading side suggests when reply_type is specified + as WPS_DATA_TYPE_BUFFER. + reply_segment_len, : [IN] + request_url_len, : [IN] The request URL length + *request_url, : [IN] The request URL + request_header_len : [IN] The request header length + *request_header, : [IN] The request header + The post segment buffer length when post_type is specified as + WPS_DATA_TYPE_BUFFER. It is mandatory is method is POST/PUT and post_type + is WPS_DATA_TYPE_BUFFER. + post_segment_len, : [IN] + *post_segment : [IN] + * RETURNS + * void + *****************************************************************************/ +VMUINT8 vm_https_send_req( VMUINT16 request_id, /* Request ID */ + VMUINT8 method, /* HTTP Method Constant */ + VMUINT32 option, /* HTTP request options */ + VMUINT8 reply_type, /* Reply type (wps_data_type_enum) */ + VMUINT32 reply_segment_len, + VMUINT32 request_url_len, /* The request URL length */ + VMUINT8 *request_url, /* The request URL */ + VMUINT32 request_header_len, /* The request header length */ + VMUINT8 *request_header, /* The request header */ + VMUINT32 post_segment_len, + VMUINT8 *post_segment ); + + +/***************************************************************************** + * FUNCTION + * vm_https_send_read_content_req + * DESCRIPTION + * this function is to send request to continue to read HTTP/WSP reply content. + * PARAMETERS + * request_id : [IN] Request ID + * seq_num : [IN] Sequence number (for debug purpose) + * read_segnemtn_len : [IN] Segnemtn Length + * RETURNS + * void + *****************************************************************************/ +VMUINT8 vm_https_send_read_content_req( VMUINT16 request_id,/* Request ID */ + VMUINT8 seq_num, /* Sequence number (for debug purpose) */ + VMUINT32 read_segnemtn_len); + + +/***************************************************************************** + * FUNCTION + * vm_https_send_cancel_req + * DESCRIPTION + * this function is to send a request to cancel an incomplete WSP/HTTP request. + * PARAMETERS + * request_id : [IN] Request ID + * RETURNS + * void + *****************************************************************************/ +VMUINT8 vm_https_send_cancel_req( VMUINT16 request_id ); + + +/***************************************************************************** + * FUNCTION + * vm_https_send_req_ext + * DESCRIPTION + * this function is to send a HTTP/WSP request. + * CALLS + * + * PARAMETERS + * request_id : [IN] Request ID + * method : [IN] HTTP Method Constant + * option : [IN] HTTP request options + * reply_type : [IN] reply type (mre_wps_data_type_enum) + * reply_segment_len : [IN] length of repy segment + * more_post : [IN] if are still some data need to be posted next time, please set 1 + * post_type : [IN] refer to mre_wps_data_type_enum + * req : [IN] request data, refer to vm_wps_http_req_var_struct + * cb : [IN] callback of post status + * RETURNS + * VMINT + *****************************************************************************/ + VMINT vm_https_send_req_ext(VMUINT16 request_id, + VMUINT8 method, + VMUINT32 option, + VMUINT8 reply_type, + VMUINT32 reply_segment_len, + VMBYTE more_post, + VMUINT8 post_type, + const vm_wps_http_req_var_struct * req, + wps_post_ind_cb cb); + +/***************************************************************************** +* FUNCTION +* vm_https_send_post_content_res +* DESCRIPTION +* this function is to to handle continuous content post of a HTTP request. +* PARAMETERS +* request_id : [IN] Request ID +* seq_num : [IN] sequence id +* more : [IN] need more send or not +* post_segment_len : [IN] +* post_segment : [IN] +* RETURNS +* VMINT +*****************************************************************************/ +VMINT vm_https_send_post_content_res(VMUINT16 request_id, + VMUINT8 seq_num, + VMBYTE more, + VMUINT32 post_segment_len, + VMUINT8* post_segment); + + + +/* DOM-NOT_FOR_SDK-BEGIN */ +/************************************************************************* + * Backup, please do not use them, only For old version's APP. + ************************************************************************/ +/* Please do not use mre_https_init any more, no need to use it.*/ +//#define mre_https_register_wps_cntxt_and_callback( a,b,c,d,e,f,g,h) vm_https_register_wps_cntxt_and_callback( 1,a,b,c,d,e,f,g,h) +//#define mre_https_send_set_channel_req(a,b,c,d,e,f,g,h,i,j,k,l,m,n) vm_https_send_set_channel_req(a,b,c,d,e,f,g,h,i,j,k,l,m,n) +//#define mre_https_send_unset_channel_req(a) vm_https_send_unset_channel_req(a) +//#define mre_https_send_req(a,b,c,d,e,f,g,h,i,j,k,l) vm_https_send_req(b,c,d,e,f,g,h,i,j,k,l) +//#define mre_https_send_read_content_req(a,b,c,d) vm_https_send_read_content_req(b,c,d) +//#define mre_https_send_cancel_req(a,b) vm_https_send_cancel_req(b) +/* DOM-NOT_FOR_SDK-END */ + +#ifdef __cplusplus +} +#endif + +#endif /* VMHTTPS_SDK_H */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vminput.h b/hardware/arduino/mtk/system/libmtk/include/vminput.h new file mode 100644 index 00000000..aeb05432 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vminput.h @@ -0,0 +1,654 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMINPUT_SDK_H +#define VMINPUT_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +typedef enum +{ +VM_INPUT_MODE_NONE = 0, +VM_INPUT_MODE_123, +VM_INPUT_MODE_123_SYMBOLS, +/* English */ +VM_INPUT_MODE_MULTITAP_UPPERCASE_ABC, +VM_INPUT_MODE_MULTITAP_LOWERCASE_ABC, +VM_INPUT_MODE_MULTITAP_UPPERCASE_ABC_NO_NUMERIC, +VM_INPUT_MODE_MULTITAP_LOWERCASE_ABC_NO_NUMERIC, +/* The above 6 input modes are used by Q03C WCSS editor, and the + * editor requires the input modes values are smaller than 0x1F, + * so we should make sure the input modes used in UI_check_WCSS_normal_character() + * of gui_inputs.c are smaller than 0x1F + */ +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_ABC, +VM_INPUT_MODE_SMART_LOWERCASE_ABC, +VM_INPUT_MODE_SMART_UPPERCASE_ABC, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_ABC, + +VM_INPUT_MODE_ARABIC_NUMERIC, +VM_INPUT_MODE_FLOAT_123, +VM_INPUT_MODE_HK_STROKE, +VM_INPUT_MODE_KEYPAD_NUMERIC, +VM_INPUT_MODE_MAGIC_NUMBER, +VM_INPUT_MODE_PHONE_NUMBER, +VM_INPUT_MODE_PHONE_NUMBER_WILDCHAR, +VM_INPUT_MODE_SIGNED_123, +VM_INPUT_MODE_SIGNED_FLOAT_123, +VM_INPUT_MODE_SIM_NUMERIC, + +/*Afrikaans*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_AFRIKAANS, +VM_INPUT_MODE_MULTITAP_LOWERCASE_AFRIKAANS, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_AFRIKAANS, +VM_INPUT_MODE_SMART_LOWERCASE_AFRIKAANS, +VM_INPUT_MODE_SMART_UPPERCASE_AFRIKAANS, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_AFRIKAANS, +/*Albanian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_ALBANIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_ALBANIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_ALBANIAN, +VM_INPUT_MODE_SMART_LOWERCASE_ALBANIAN, +VM_INPUT_MODE_SMART_UPPERCASE_ALBANIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_ALBANIAN, +/*Armenian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_ARMENIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_ARMENIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_ARMENIAN, +VM_INPUT_MODE_SMART_LOWERCASE_ARMENIAN, +VM_INPUT_MODE_SMART_UPPERCASE_ARMENIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_ARMENIAN, +/*Arabic*/ +VM_INPUT_MODE_MULTITAP_ARABIC, +VM_INPUT_MODE_SMART_ARABIC, +/*Assamese*/ +VM_INPUT_MODE_MULTITAP_ASSAMESE, +VM_INPUT_MODE_SMART_ASSAMESE, +/*Azerbaijani*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_AZERBAIJANI, +VM_INPUT_MODE_MULTITAP_LOWERCASE_AZERBAIJANI, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_AZERBAIJANI, +VM_INPUT_MODE_SMART_LOWERCASE_AZERBAIJANI, +VM_INPUT_MODE_SMART_UPPERCASE_AZERBAIJANI, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_AZERBAIJANI, +/*Basque*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_BASQUE, +VM_INPUT_MODE_MULTITAP_LOWERCASE_BASQUE, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_BASQUE, +VM_INPUT_MODE_SMART_LOWERCASE_BASQUE, +VM_INPUT_MODE_SMART_UPPERCASE_BASQUE, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_BASQUE, +/*Bengali*/ +VM_INPUT_MODE_MULTITAP_BENGALI, +VM_INPUT_MODE_SMART_BENGALI, +/*Bulgarian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_BULGARIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_BULGARIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_BULGARIAN, +VM_INPUT_MODE_SMART_LOWERCASE_BULGARIAN, +VM_INPUT_MODE_SMART_UPPERCASE_BULGARIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_BULGARIAN, +/*Catalan*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_CATALAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_CATALAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_CATALAN, +VM_INPUT_MODE_SMART_LOWERCASE_CATALAN, +VM_INPUT_MODE_SMART_UPPERCASE_CATALAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_CATALAN, +/*Croatian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_CROATIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_CROATIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_CROATIAN, +VM_INPUT_MODE_SMART_LOWERCASE_CROATIAN, +VM_INPUT_MODE_SMART_UPPERCASE_CROATIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_CROATIAN, +/*Czech*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_CZECH, +VM_INPUT_MODE_MULTITAP_LOWERCASE_CZECH, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_CZECH, +VM_INPUT_MODE_SMART_LOWERCASE_CZECH, +VM_INPUT_MODE_SMART_UPPERCASE_CZECH, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_CZECH, +/*Danish*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_DANISH, +VM_INPUT_MODE_MULTITAP_LOWERCASE_DANISH, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_DANISH, +VM_INPUT_MODE_SMART_LOWERCASE_DANISH, +VM_INPUT_MODE_SMART_UPPERCASE_DANISH, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_DANISH, +/*Dutch*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_DUTCH, +VM_INPUT_MODE_MULTITAP_LOWERCASE_DUTCH, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_DUTCH, +VM_INPUT_MODE_SMART_LOWERCASE_DUTCH, +VM_INPUT_MODE_SMART_UPPERCASE_DUTCH, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_DUTCH, +/*Estonian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_ESTONIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_ESTONIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_ESTONIAN, +VM_INPUT_MODE_SMART_LOWERCASE_ESTONIAN, +VM_INPUT_MODE_SMART_UPPERCASE_ESTONIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_ESTONIAN, +/*Filipino*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_FILIPINO, +VM_INPUT_MODE_MULTITAP_LOWERCASE_FILIPINO, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_FILIPINO, +VM_INPUT_MODE_SMART_LOWERCASE_FILIPINO, +VM_INPUT_MODE_SMART_UPPERCASE_FILIPINO, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_FILIPINO, +/*Finnish*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_FINNISH, +VM_INPUT_MODE_MULTITAP_LOWERCASE_FINNISH, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_FINNISH, +VM_INPUT_MODE_SMART_LOWERCASE_FINNISH, +VM_INPUT_MODE_SMART_UPPERCASE_FINNISH, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_FINNISH, +/*French*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_FRENCH, +VM_INPUT_MODE_MULTITAP_LOWERCASE_FRENCH, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_FRENCH, +VM_INPUT_MODE_SMART_LOWERCASE_FRENCH, +VM_INPUT_MODE_SMART_UPPERCASE_FRENCH, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_FRENCH, +/*Galician*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_GALICIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_GALICIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_GALICIAN, +VM_INPUT_MODE_SMART_LOWERCASE_GALICIAN, +VM_INPUT_MODE_SMART_UPPERCASE_GALICIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_GALICIAN, +/*Georgian*/ +VM_INPUT_MODE_MULTITAP_GEORGIAN, +VM_INPUT_MODE_SMART_GEORGIAN, +/*German*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_GERMAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_GERMAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_GERMAN, +VM_INPUT_MODE_SMART_LOWERCASE_GERMAN, +VM_INPUT_MODE_SMART_UPPERCASE_GERMAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_GERMAN, +/*Greek*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_GREEK, +VM_INPUT_MODE_MULTITAP_LOWERCASE_GREEK, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_GREEK, +VM_INPUT_MODE_SMART_LOWERCASE_GREEK, +VM_INPUT_MODE_SMART_UPPERCASE_GREEK, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_GREEK, +/*Gujarati*/ +VM_INPUT_MODE_MULTITAP_GUJARATI, +VM_INPUT_MODE_SMART_GUJARATI, +/*Hausa*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_HAUSA, +VM_INPUT_MODE_MULTITAP_LOWERCASE_HAUSA, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_HAUSA, +VM_INPUT_MODE_SMART_LOWERCASE_HAUSA, +VM_INPUT_MODE_SMART_UPPERCASE_HAUSA, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_HAUSA, +/*Hebrew*/ +VM_INPUT_MODE_MULTITAP_HEBREW, +VM_INPUT_MODE_SMART_HEBREW, +/*Hindi*/ +VM_INPUT_MODE_MULTITAP_HINDI, +VM_INPUT_MODE_SMART_HINDI, +/*Hungarian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_HUNGARIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_HUNGARIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_HUNGARIAN, +VM_INPUT_MODE_SMART_LOWERCASE_HUNGARIAN, +VM_INPUT_MODE_SMART_UPPERCASE_HUNGARIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_HUNGARIAN, +/*Icelandic*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_ICELANDIC, +VM_INPUT_MODE_MULTITAP_LOWERCASE_ICELANDIC, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_ICELANDIC, +VM_INPUT_MODE_SMART_LOWERCASE_ICELANDIC, +VM_INPUT_MODE_SMART_UPPERCASE_ICELANDIC, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_ICELANDIC, +/*Igbo*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_IGBO, +VM_INPUT_MODE_MULTITAP_LOWERCASE_IGBO, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_IGBO, +VM_INPUT_MODE_SMART_LOWERCASE_IGBO, +VM_INPUT_MODE_SMART_UPPERCASE_IGBO, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_IGBO, +/*Indonesian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_INDONESIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_INDONESIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_INDONESIAN, +VM_INPUT_MODE_SMART_LOWERCASE_INDONESIAN, +VM_INPUT_MODE_SMART_UPPERCASE_INDONESIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_INDONESIAN, +/*Irish*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_IRISH, +VM_INPUT_MODE_MULTITAP_LOWERCASE_IRISH, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_IRISH, +VM_INPUT_MODE_SMART_LOWERCASE_IRISH, +VM_INPUT_MODE_SMART_UPPERCASE_IRISH, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_IRISH, +/*Italian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_ITALIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_ITALIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_ITALIAN, +VM_INPUT_MODE_SMART_LOWERCASE_ITALIAN, +VM_INPUT_MODE_SMART_UPPERCASE_ITALIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_ITALIAN, +/*Kannada*/ +VM_INPUT_MODE_MULTITAP_KANNADA, +VM_INPUT_MODE_SMART_KANNADA, +/*Kazakh*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_KAZAKH, +VM_INPUT_MODE_MULTITAP_LOWERCASE_KAZAKH, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_KAZAKH, +VM_INPUT_MODE_SMART_LOWERCASE_KAZAKH, +VM_INPUT_MODE_SMART_UPPERCASE_KAZAKH, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_KAZAKH, +VM_INPUT_MODE_MULTITAP_KOREAN, +/*Latvian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_LATVIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_LATVIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_LATVIAN, +VM_INPUT_MODE_SMART_LOWERCASE_LATVIAN, +VM_INPUT_MODE_SMART_UPPERCASE_LATVIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_LATVIAN, +/*Lithuanian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_LITHUANIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_LITHUANIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_LITHUANIAN, +VM_INPUT_MODE_SMART_LOWERCASE_LITHUANIAN, +VM_INPUT_MODE_SMART_UPPERCASE_LITHUANIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_LITHUANIAN, +/*Macedonian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_MACEDONIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_MACEDONIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_MACEDONIAN, +VM_INPUT_MODE_SMART_LOWERCASE_MACEDONIAN, +VM_INPUT_MODE_SMART_UPPERCASE_MACEDONIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_MACEDONIAN, +/*Malay*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_MALAY, +VM_INPUT_MODE_MULTITAP_LOWERCASE_MALAY, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_MALAY, +VM_INPUT_MODE_SMART_LOWERCASE_MALAY, +VM_INPUT_MODE_SMART_UPPERCASE_MALAY, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_MALAY, +/*Malayalam*/ +VM_INPUT_MODE_MULTITAP_MALAYALAM, +VM_INPUT_MODE_MULTITAP_LAO, +VM_INPUT_MODE_MULTITAP_KHMER, +VM_INPUT_MODE_SMART_KHMER, +VM_INPUT_MODE_MULTITAP_MYANMAR, +VM_INPUT_MODE_SMART_MALAYALAM, +/*Marathi*/ +VM_INPUT_MODE_MULTITAP_MARATHI, +VM_INPUT_MODE_SMART_MARATHI, +/*Moldovan*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_MOLDOVAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_MOLDOVAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_MOLDOVAN, +VM_INPUT_MODE_SMART_LOWERCASE_MOLDOVAN, +VM_INPUT_MODE_SMART_UPPERCASE_MOLDOVAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_MOLDOVAN, +/*Norwegian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_NORWEGIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_NORWEGIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_NORWEGIAN, +VM_INPUT_MODE_SMART_LOWERCASE_NORWEGIAN, +VM_INPUT_MODE_SMART_UPPERCASE_NORWEGIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_NORWEGIAN, +/*Oriya*/ +VM_INPUT_MODE_MULTITAP_ORIYA, +VM_INPUT_MODE_SMART_ORIYA, +/*Persian*/ +VM_INPUT_MODE_MULTITAP_PERSIAN, +VM_INPUT_MODE_SMART_PERSIAN, +/*Polish*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_POLISH, +VM_INPUT_MODE_MULTITAP_LOWERCASE_POLISH, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_POLISH, +VM_INPUT_MODE_SMART_LOWERCASE_POLISH, +VM_INPUT_MODE_SMART_UPPERCASE_POLISH, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_POLISH, +/*Portuguese*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_PORTUGUESE, +VM_INPUT_MODE_MULTITAP_LOWERCASE_PORTUGUESE, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_PORTUGUESE, +VM_INPUT_MODE_SMART_LOWERCASE_PORTUGUESE, +VM_INPUT_MODE_SMART_UPPERCASE_PORTUGUESE, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_PORTUGUESE, +/*Punjabi*/ +VM_INPUT_MODE_MULTITAP_PUNJABI, +VM_INPUT_MODE_SMART_PUNJABI, +/*Romanian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_ROMANIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_ROMANIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_ROMANIAN, +VM_INPUT_MODE_SMART_LOWERCASE_ROMANIAN, +VM_INPUT_MODE_SMART_UPPERCASE_ROMANIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_ROMANIAN, +/*Russian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_RUSSIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_RUSSIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_RUSSIAN, +VM_INPUT_MODE_SMART_LOWERCASE_RUSSIAN, +VM_INPUT_MODE_SMART_UPPERCASE_RUSSIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_RUSSIAN, +/*Serbian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_SERBIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_SERBIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_SERBIAN, +VM_INPUT_MODE_SMART_LOWERCASE_SERBIAN, +VM_INPUT_MODE_SMART_UPPERCASE_SERBIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_SERBIAN, +/*Sesotho*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_SESOTHO, +VM_INPUT_MODE_MULTITAP_LOWERCASE_SESOTHO, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_SESOTHO, +VM_INPUT_MODE_SMART_LOWERCASE_SESOTHO, +VM_INPUT_MODE_SMART_UPPERCASE_SESOTHO, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_SESOTHO, +/*Slovak*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_SLOVAK, +VM_INPUT_MODE_MULTITAP_LOWERCASE_SLOVAK, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_SLOVAK, +VM_INPUT_MODE_SMART_LOWERCASE_SLOVAK, +VM_INPUT_MODE_SMART_UPPERCASE_SLOVAK, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_SLOVAK, +/*Slovenian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_SLOVENIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_SLOVENIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_SLOVENIAN, +VM_INPUT_MODE_SMART_LOWERCASE_SLOVENIAN, +VM_INPUT_MODE_SMART_UPPERCASE_SLOVENIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_SLOVENIAN, +/*Spanish*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_SPANISH, +VM_INPUT_MODE_MULTITAP_LOWERCASE_SPANISH, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_SPANISH, +VM_INPUT_MODE_SMART_LOWERCASE_SPANISH, +VM_INPUT_MODE_SMART_UPPERCASE_SPANISH, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_SPANISH, +/*Swahili*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_SWAHILI, +VM_INPUT_MODE_MULTITAP_LOWERCASE_SWAHILI, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_SWAHILI, +VM_INPUT_MODE_SMART_LOWERCASE_SWAHILI, +VM_INPUT_MODE_SMART_UPPERCASE_SWAHILI, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_SWAHILI, +/*Swedish*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_SWEDISH, +VM_INPUT_MODE_MULTITAP_LOWERCASE_SWEDISH, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_SWEDISH, +VM_INPUT_MODE_SMART_LOWERCASE_SWEDISH, +VM_INPUT_MODE_SMART_UPPERCASE_SWEDISH, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_SWEDISH, +/*Tagalog*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_TAGALOG, +VM_INPUT_MODE_MULTITAP_LOWERCASE_TAGALOG, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_TAGALOG, +VM_INPUT_MODE_SMART_LOWERCASE_TAGALOG, +VM_INPUT_MODE_SMART_UPPERCASE_TAGALOG, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_TAGALOG, +/*Tamil*/ +VM_INPUT_MODE_MULTITAP_TAMIL, +VM_INPUT_MODE_SMART_TAMIL, +/*Telugu*/ +VM_INPUT_MODE_MULTITAP_TELUGU, +VM_INPUT_MODE_SMART_TELUGU, +/*Thai*/ +VM_INPUT_MODE_MULTITAP_THAI, +VM_INPUT_MODE_SMART_THAI, +/*Turkish*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_TURKISH, +VM_INPUT_MODE_MULTITAP_LOWERCASE_TURKISH, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_TURKISH, +VM_INPUT_MODE_SMART_LOWERCASE_TURKISH, +VM_INPUT_MODE_SMART_UPPERCASE_TURKISH, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_TURKISH, +/*Ukrainian*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_UKRAINIAN, +VM_INPUT_MODE_MULTITAP_LOWERCASE_UKRAINIAN, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_UKRAINIAN, +VM_INPUT_MODE_SMART_LOWERCASE_UKRAINIAN, +VM_INPUT_MODE_SMART_UPPERCASE_UKRAINIAN, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_UKRAINIAN, +/*Urdu*/ +VM_INPUT_MODE_MULTITAP_URDU, +VM_INPUT_MODE_SMART_URDU, +/*Vietnamese*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_VIETNAMESE, +VM_INPUT_MODE_MULTITAP_LOWERCASE_VIETNAMESE, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_VIETNAMESE, +VM_INPUT_MODE_SMART_LOWERCASE_VIETNAMESE, +VM_INPUT_MODE_SMART_UPPERCASE_VIETNAMESE, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_VIETNAMESE, +/*Xhosa*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_XHOSA, +VM_INPUT_MODE_MULTITAP_LOWERCASE_XHOSA, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_XHOSA, +VM_INPUT_MODE_SMART_LOWERCASE_XHOSA, +VM_INPUT_MODE_SMART_UPPERCASE_XHOSA, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_XHOSA, +/*Yoruba*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_YORUBA, +VM_INPUT_MODE_MULTITAP_LOWERCASE_YORUBA, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_YORUBA, +VM_INPUT_MODE_SMART_LOWERCASE_YORUBA, +VM_INPUT_MODE_SMART_UPPERCASE_YORUBA, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_YORUBA, +/*Zulu*/ +VM_INPUT_MODE_MULTITAP_UPPERCASE_ZULU, +VM_INPUT_MODE_MULTITAP_LOWERCASE_ZULU, +VM_INPUT_MODE_MULTITAP_FIRST_UPPERCASE_ZULU, +VM_INPUT_MODE_SMART_LOWERCASE_ZULU, +VM_INPUT_MODE_SMART_UPPERCASE_ZULU, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_ZULU, + +/* Dialects */ +VM_INPUT_MODE_SMART_UPPERCASE_UK_ABC, +VM_INPUT_MODE_SMART_LOWERCASE_UK_ABC, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_UK_ABC, +VM_INPUT_MODE_SMART_UPPERCASE_CA_FRENCH, +VM_INPUT_MODE_SMART_LOWERCASE_CA_FRENCH, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_CA_FRENCH, +VM_INPUT_MODE_SMART_UPPERCASE_HINGLISH, +VM_INPUT_MODE_SMART_LOWERCASE_HINGLISH, +VM_INPUT_MODE_SMART_UPPERCASE_SA_SPANISH, +VM_INPUT_MODE_SMART_LOWERCASE_SA_SPANISH, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_SA_SPANISH, +VM_INPUT_MODE_SMART_UPPERCASE_SA_PORTUGUESE, +VM_INPUT_MODE_SMART_LOWERCASE_SA_PORTUGUESE, +VM_INPUT_MODE_SMART_FIRST_UPPERCASE_SA_PORTUGUESE, + +/* Chinese*/ +VM_INPUT_MODE_TR_BOPOMO, +VM_INPUT_MODE_TR_MULTITAP_BOPOMO, +VM_INPUT_MODE_TR_STROKE, +VM_INPUT_MODE_QUICK_SEARCH_BOPOMO, +VM_INPUT_MODE_QUICK_SEARCH_HK_STROKE, +VM_INPUT_MODE_QUICK_SEARCH_PINYIN, +VM_INPUT_MODE_QUICK_SEARCH_SM_STROKE, +VM_INPUT_MODE_QUICK_SEARCH_TR_STROKE, +VM_INPUT_MODE_SM_MULTITAP_PINYIN, +VM_INPUT_MODE_SM_PINYIN, +VM_INPUT_MODE_SM_STROKE, + +VM_INPUT_MODE_MAX_NUM +} vm_input_mode_enum; + +/* If selects OK or Cancel in editor screen, the state will pass to application via callback's parameter. */ + +#define VM_INPUT_OK (1) /* If selects OK */ +#define VM_INPUT_CANCEL (0) /* If selects Cancel */ +#define VM_INPUT_NOTIFY (2) /* If another screen makes editor exit, this message will be sent */ +#define VM_INPUT_CLOSE (3) /* If application close the input screen self, application will receive this message */ + /***************************************************************************** + * FUNCTION + * vm_input_text + * DESCRIPTION + * Display a editor screen. The default input method is VM_INPUT_METHOD_TEXT. + * The max length of input string is 250. + * PARAMETERS + * f : [IN] This callback will be invoked when the editor screen closed. If user selects OK, the state will be VM_INPUT_OK. + * If user select Cancel, the state will be VM_INPUT_CANCEL. + * RETURNS + * The error code of the operation. + * RETURN VALUES + * 0 : If open the input screen successfully. + * <0 : If failed. + *****************************************************************************/ +VMINT vm_input_text(void (*f)(VMINT state, VMWSTR text)); + +#define VM_INPUT_METHOD_TEXT 1 /* Input text and the default input method is PINYIN */ +#define VM_INPUT_METHOD_PASSWORD 2 /* Input password and the default input method is multitap abc. + only 0~9, *, # are allowed and the content would be displayed as * in editor. */ +#define VM_INPUT_METHOD_NUMERIC 4 /* Input number and the default input method is phone number */ +#define VM_INPUT_METHOD_ALPHABETIC 8 /* Input English and the default input method is multitap abc */ +#define VM_INPUT_METHOD_URL 16 /* Input URL */ + + /***************************************************************************** + * FUNCTION + * vm_input_text2 + * DESCRIPTION + * Display a editor screen. User can set default string and default input method. + * The max length of input string is 250. + * PARAMETERS + * def_str : [IN] Default string in editor screen. + * def_input_method: [IN] Default input method. + * f : [IN] This callback will be invoked when the editor screen closed. If user selects OK, the state will be VM_INPUT_OK. + * If user select Cancel, the state will be VM_INPUT_CANCEL. + * RETURNS + * The error code of the operation. + * RETURN VALUES + * 0 : If open the input screen successfully. + * <0 : If failed. + *****************************************************************************/ +VMINT vm_input_text2(VMWSTR def_str, VMINT def_input_method, void (*f) (VMINT state, VMWSTR text)); + +/***************************************************************************** + * FUNCTION + * vm_input_text3 + * DESCRIPTION + * Display a editor screen. User can set default string and default input method. + * User can also set the max input length (in short) via parameter input_max_size. + * PARAMETERS + * default_string : [IN] Default string in editor screen. + * input_max_size : [IN] + * default_input_method: [IN] Default input method. + * input_text_cb : [IN] This callback will be invoked when the editor screen closed. If user selects OK, the state will be VM_INPUT_OK. + * If user select Cancel, the state will be VM_INPUT_CANCEL. + * RETURNS + * The error code of the operation. + * RETURN VALUES + * 0 : If open the input screen successfully. + * <0 : If failed. + *****************************************************************************/ +VMINT vm_input_text3(VMWSTR default_string, VMINT input_max_size, + VMINT default_input_method, void (*input_text_cb)(VMINT state, VMWSTR text)); + + /***************************************************************************** + * FUNCTION + * vm_set_app_desired_input_mode + * DESCRIPTION + * To set editor desired input mode. Used when App call vm_input_text/vm_input_text2/vm_input_text3 to enter editor screen. + * PARAMETERS + * desired_input_mode : [IN] input mode. + * RETURN VALUES + * void + *****************************************************************************/ +void vm_set_app_desired_input_mode(vm_input_mode_enum desired_input_mode); + +/***************************************************************************** + * FUNCTION + * vm_input_close_screen + * DESCRIPTION + * Close input screen by application self. And it will send VM_INPUT_CLOSE to application. + * PARAMETERS + * void + * RETURN VALUES + * void + *****************************************************************************/ +void vm_input_close_screen(void); + +/***************************************************************************** + * FUNCTION + * vm_input_move_cursor_to_start + * DESCRIPTION + * Move the cursor to the start position and edit from the beginning. + * You need to call this API after vm_input_text/vm_input_text2/vm_input_text3. + * PARAMETERS + * void + * RETURN VALUES + * void + *****************************************************************************/ +void vm_input_move_cursor_to_start(void); + +/***************************************************************************** + * FUNCTION + * vm_input_set_vk_default_enlarge + * DESCRIPTION + * Set VK default enlarge. + * PARAMETERS + * void + * RETURN VALUES + * void + *****************************************************************************/ +void vm_input_set_vk_default_enlarge(void); + +/****************************************************************************** + * FUNCTION + * vm_input_set_editor_title + * DESCRIPTION + * set the input editor title. This function should be called just before + * vm_input_text, vm_input_text2 or vm_input_text3, and the title's length must + * be less than 60. + * PARAMETERS + * title : [IN] editor title provided by user + * RETURN VALUES + * TRUE : if set the editor title successfully. + * FALSE : if fail to set the editor title. + *****************************************************************************/ +VMINT vm_input_set_editor_title(VMWSTR title); + +#ifdef __cplusplus +} +#endif + +#endif /* VMINPUT_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmio.h b/hardware/arduino/mtk/system/libmtk/include/vmio.h new file mode 100644 index 00000000..6a419bcf --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmio.h @@ -0,0 +1,1325 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMIO_SDK_H_ +#define VMIO_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" +#include "vmsim.h" +#include "vmtel.h" +#include "vmtouch.h" +#include "vmkeypad.h" +#include "vminput.h" + +#ifndef MAX_APP_NAME_LEN +#define MAX_APP_NAME_LEN (260) +#endif + +typedef enum +{ + VM_FILE_COMMIT_ERROR = -1, + VM_FILE_OPEN_ERROR = -2, + VM_FILE_NAME_ERROR = -1, + VM_FILE_OK = 0 +} vm_file_error_t; + +typedef enum +{ + VM_STORE_PATH_TYPE_PHOTO, + VM_STORE_PATH_TYPE_VIDEO, + VM_STORE_PATH_TYPE_MUSIC, + VM_STORE_PATH_TYPE_RINGTONE, + VM_STORE_PATH_TYPE_DOCUMENT, + VM_STORE_PATH_TYPE_OTHERS + +} VM_STORE_PATH_TYPE; + +/* + * file attribution + */ +#define VM_FS_ATTR_READ_ONLY 0x01 +#define VM_FS_ATTR_HIDDEN 0x02 +#define VM_FS_ATTR_SYSTEM 0x04 +#define VM_FS_ATTR_VOLUME 0x08 +#define VM_FS_ATTR_DIR 0x10 +#define VM_FS_ATTR_ARCHIVE 0x20 +#define VM_FS_LONGNAME_ATTR 0x0F + +/* file info */ +struct vm_fileinfo_t +{ + VMWCHAR filename[MAX_APP_NAME_LEN]; /* full path of file */ + VMINT size; /* file size */ +}; + +/* file info */ +typedef struct vm_fileinfo_ext +{ + /* file name without path */ + VMWCHAR filefullname[MAX_APP_NAME_LEN]; + /* file name character array by 8.3 format encoding with UCS2, and the last character may be not '\0' */ + VMCHAR filename[8]; + /* file extention name character array by 8.3 format encoding with UCS2, and the last character may be not '\0' */ + VMCHAR extension[3];/* file attributes */ + VMBYTE attributes; + vm_time_t create_datetime; /* create time */ + vm_time_t modify_datetime; /* modify time */ + VMUINT filesize; /* file size */ + VMUINT drive; /* drive */ + VMUINT stamp; /* stamp */ +} vm_fileinfo_ext; + +/* Disk information */ +typedef struct +{ + /* A zero-terminated Short File Name with the volume's label. */ + VMCHAR Label[24]; + + /* The drive letter in UPPER case. */ + VMCHAR DriveLetter; + + /* Indicate the disk is in write protection or not. 1 for protect, 0 for not protect. */ + VMUINT8 WriteProtect; + + /* Reserved fields */ + VMCHAR Reserved[2]; + + /* The volume's serial number. */ + VMUINT32 SerialNumber; + + /* The LBA address of the logical drive's boot record. For diskettes, this value will be 0. */ + VMUINT32 FirstPhysicalSector; + + /* 2, 16, or 32 for FAT-12, FAT-16, or FAT-32 */ + VMUINT32 FATType; + + /* The number of FATs on the volume. */ + VMUINT32 FATCount; + + /* The number of FATs on the volume. */ + VMUINT32 MaxDirEntries; + + /* The sector size. This value will usually be 512. */ + VMUINT32 BytesPerSector; + + /* Specifies the size of the smallest unit of storage that can be allocated to a file in sectors. */ + VMUINT32 SectorsPerCluster; + + /* Number of clusters for file storage on the volume. */ + VMUINT32 TotalClusters; + + /* The number of clusters, which are marked bad and are unavailable for file storage. */ + VMUINT32 BadClusters; + + /* The number of clusters currently available. */ + VMUINT32 FreeClusters; + + /* The number of files on the volume including directories, but not counting the root directory and files with an allocated file size of 0. */ + VMUINT32 Files; + + /* The number of contiguous cluster chains. On a completely unfragmented volume, this value would be identical to Files. */ + VMUINT32 FileChains; + + /* The number of contiguous cluster chains of free clusters. On a completely unfragmented volume, this value would be 1. */ + VMUINT32 FreeChains; + + /* The maximum allocated file size for a newly allocated contiguous file in clusters. On a completely unfragmented volume, this value would be identical to FreeClusters. */ + VMUINT32 LargestFreeChain; +} vm_fs_disk_info; + +/* vm_get_disk_info Parameter */ +typedef enum +{ + /* + * Returns all fields in structure vm_get_disk_info except FreeClusters, BadClusters, Files, FileChains, FreeChains, LargestFreeChain. + * This flag never requires a FAT scan. + */ + VM_FS_DI_BASIC_INFO = 0x00000001L, + + /* + * Returns field FreeClusters. This flags may require FS to scan the complete FAT if the amount of free space is not known. + * In this case, FS_DI_FAT_STATISTICS is returned in addition to FS_DI_FREE_SPACE. + */ + VM_FS_DI_FREE_SPACE = 0x00000002L, + + /* + * Returns fields BadClusters, Files, FileChains, FreeChains, LargestFreeChain. + * This flag will always cause FS to scan the complete FAT. + */ + VM_FS_DI_FAT_STATISTICS = 0x00000004L, + + /* + * Get volume label of the target drive. The maximum length is 11 wide characters. + * This option must be used with FS_DI_BASIC_INFO. + */ + VM_FS_DI_VOLUME_LABEL = 0x00000008L, + + VM_FS_DI_INVALID +}vm_fs_di_enum; + + +/** + * open file with file Read-Only mode. + */ +#define MODE_READ 1 + +/** + * open file with Read-Write mode. + */ +#define MODE_WRITE 2 + +/** + * open file with Read-Write mode, create if the file not exist. + */ +#define MODE_CREATE_ALWAYS_WRITE 4 + +/** + * open file with Append mode. + */ +#define MODE_APPEND 8 + +/***************************************************************************** +* FUNCTION + * vm_file_open + * DESCRIPTION + * open file + * PARAMETERS + * filename : [IN] file full path encoding with UCS2 + * mode : [IN] file open mode: + * MODE_READ: Read-Only + * MODE_WRITE : Read-Write + * MODE_CREATE_ALWAYS_WRITE : Read-Write mode, create if the file not exist. + * binary : [IN] TRUE means open with binary format, FALSE means open with ASCII format. + * RETURNS + * non-negative file handle if successfully, and error code if failed to open. + * +*****************************************************************************/ +VMFILE vm_file_open(const VMWSTR filename, VMUINT mode, VMUINT binary); + +/***************************************************************************** +* FUNCTION + * vm_file_close + * DESCRIPTION + * close file + * PARAMETERS + * handle : [IN] file handle to be closed. + * +*****************************************************************************/ +void vm_file_close(VMFILE handle); + +/***************************************************************************** +* FUNCTION + * vm_file_read + * DESCRIPTION + * read file from current pointer of file + * PARAMETERS + * handle : [IN] file handle to be read. + * data : [OUT] output data address + * length : [IN] bytes to be read + * nread : [IN] bytes read actually + * RETURNS + * bytes of read data if > 0, 0 means error happened or reach end of file. + * +*****************************************************************************/ +VMINT vm_file_read(VMFILE handle, void * data, VMUINT length, VMUINT *nread); + +/***************************************************************************** +* FUNCTION + * vm_file_write + * DESCRIPTION + * write data to current pointer of the file + * PARAMETERS + * handle : [IN] file handle to write. + * data : [IN] the address of data to be written + * length : [IN] bytes to be written + * written : [IN] bytes written actually + * RETURNS + * bytes of written data if > 0, 0 means error happened. + * +*****************************************************************************/ +VMINT vm_file_write(VMFILE handle, void * data, VMUINT length, VMUINT * written); + +/***************************************************************************** +* FUNCTION + * vm_file_commit + * DESCRIPTION + * commit the I/O cache data to file. + * PARAMETERS + * handle : [IN] file handle to commit. + * RETURNS + * 0 means successfully, non-zero is error code. + * +*****************************************************************************/ +VMINT vm_file_commit(VMFILE handle); + +#define BASE_BEGIN 1 +#define BASE_CURR 2 +#define BASE_END 3 + +/***************************************************************************** +* FUNCTION + * vm_file_seek + * DESCRIPTION + * move the file pointer to specified position. If exceed file size, this operation will return error. + * PARAMETERS + * handle : [IN] file handle to seek. + * offset : [IN] bytes to move. + * base: [IN] base position to move. + * BASE_BEGIN means from begin of file; + * BASE_CURR means from current position; + * BASE_END means from end of file. + * RETURNS + * 0 means successfully, non-zero is error code. + * +*****************************************************************************/ +VMINT vm_file_seek(VMFILE handle, VMINT offset, VMINT base); + +/***************************************************************************** +* FUNCTION + * vm_file_tell + * DESCRIPTION + * get the position of current pointer of file. + * PARAMETERS + * handle : [IN] file handle. + * RETURNS + * current pointer position, or negative number error code if failed. + * +*****************************************************************************/ +VMINT vm_file_tell(VMFILE handle); + +/***************************************************************************** +* FUNCTION + * vm_file_is_eof + * DESCRIPTION + * check if the current pointer is end of file or not. + * PARAMETERS + * handle : [IN] file handle. + * RETURNS + * current pointer is end of file or not. + * RETURN VALUES + * TRUE : current pointer is end of file. + * FALSE : current pointer is not end of file. + * +*****************************************************************************/ +VMINT vm_file_is_eof(VMFILE handle); + +/***************************************************************************** +* FUNCTION + * vm_file_getfilesize + * DESCRIPTION + * get file size by byte. + * PARAMETERS + * handle : [IN] file handle. + * file_size : [OUT] output the file size by byte + * RETURNS + * get file size successfully or failed + * RETURN VALUES + * 0 : get file size successfully. + * non-zero : failed to get file size + * +*****************************************************************************/ +VMINT vm_file_getfilesize(VMFILE handle, VMUINT *file_size); + +/***************************************************************************** +* FUNCTION + * vm_file_delete + * DESCRIPTION + * delete specified file. + * PARAMETERS + * filename : [IN] file name full path encoding with UCS2 format. + * RETURNS + * delete file successfully or failed + * RETURN VALUES + * 0 : delete file successfully. + * non-zero : failed to delete file. + * +*****************************************************************************/ +VMINT vm_file_delete(const VMWSTR filename); + +/***************************************************************************** +* FUNCTION + * vm_file_rename + * DESCRIPTION + * delete specified file. + * PARAMETERS + * filename : [IN] old file name full path encoding with UCS2 format. + * newname : [IN] new file name full path encoding with UCS2 format. + * RETURNS + * rename file successfully or failed + * RETURN VALUES + * 0 : rename file successfully. + * non-zero : failed to rename file. + * +*****************************************************************************/ +VMINT vm_file_rename(const VMWSTR filename, const VMWSTR newname); + +/***************************************************************************** +* FUNCTION + * vm_file_mkdir + * DESCRIPTION + * create new directory with specified path name. + * PARAMETERS + * dirname : [IN] path name encoding with UCS2 format. + * RETURNS + * create directory successfully or failed + * RETURN VALUES + * 0 : create directory successfully. + * non-zero : failed to create directory. + * +*****************************************************************************/ +VMINT vm_file_mkdir(const VMWSTR dirname); + +/***************************************************************************** +* FUNCTION + * vm_file_rmdir + * DESCRIPTION + * remove directory with specified path name. + * PARAMETERS + * dirname : [IN] path name encoding with UCS2 format. + * RETURNS + * remove directory successfully or failed + * RETURN VALUES + * 0 : remove directory successfully. + * non-zero : failed to remove directory. + * +*****************************************************************************/ +VMINT vm_file_rmdir(const VMWSTR dirname); + +/***************************************************************************** +* FUNCTION + * vm_file_set_attributes + * DESCRIPTION + * set attributes of specified full path file name encoding with UCS2 format. The attributes + * can not include VM_FS_ATTR_VOLUME, VM_FS_ATTR_DIR, or VM_FS_LONGNAME_ATTR. + * The value of attributes is the result of OR operator. + * PARAMETERS + * filename : [IN] file name encoding with UCS2 format. + * attributes : [IN] file attributes. + * RETURNS + * set attributes successfully or failed + * RETURN VALUES + * 0 : set attributes successfully. + * non-zero : failed to set attributes. + * +*****************************************************************************/ +VMINT vm_file_set_attributes(const VMWSTR filename, VMBYTE attributes); + +/***************************************************************************** +* FUNCTION + * vm_file_get_attributes + * DESCRIPTION + * set attributes of specified full path file name encoding with UCS2 format. + * The value of attributes is the result of OR operator. + * PARAMETERS + * filename : [IN] file name encoding with UCS2 format. + * RETURNS + * get attributes successfully or failed + * RETURN VALUES + * -1 : failed to get attributes. + * else : get the attributes value. + * +*****************************************************************************/ +VMINT vm_file_get_attributes(const VMWSTR filename); + +/***************************************************************************** +* FUNCTION + * vm_find_first + * DESCRIPTION + * find files from specified path, support wild character finding. + * PARAMETERS + * pathname : [IN] path name encoding with UCS2 format. + * info : [OUT] result of finding + * RETURNS + * find handle or error code + * RETURN VALUES + * non-negative number : find handle. + * negative number : error code. + * +*****************************************************************************/ +VMINT vm_find_first(VMWSTR pathname, struct vm_fileinfo_t* info); + +/***************************************************************************** +* FUNCTION + * vm_find_next + * DESCRIPTION + * continue to find next file. + * PARAMETERS + * handle : [IN] find handle. + * info : [OUT] result of finding + * RETURNS + * find handle or error code + * RETURN VALUES + * 0 : find next file successfully. + * negative number : end of finding. + * +*****************************************************************************/ +VMINT vm_find_next(VMINT handle, struct vm_fileinfo_t* info); + +/***************************************************************************** +* FUNCTION + * vm_find_close + * DESCRIPTION + * close finding process. + * PARAMETERS + * handle : [IN] find handle. + * +*****************************************************************************/ +void vm_find_close(VMINT handle); + +#define vm_get_removable_driver vm_get_removeable_driver +/***************************************************************************** +* FUNCTION + * vm_get_removable_driver + * DESCRIPTION + * get drive letter of removable disk, which normally is memory card. + * RETURNS + * drive letter of removable disk. negative number means no removable drive. + * +*****************************************************************************/ +VMINT vm_get_removable_driver(void); + +/***************************************************************************** +* FUNCTION + * vm_get_system_driver + * DESCRIPTION + * get drive letter of phone disk, which normally is public drive. + * RETURNS + * drive letter of phone disk. negative number means no public drive. + * +*****************************************************************************/ +VMINT vm_get_system_driver(void); + +/***************************************************************************** +* FUNCTION + * vm_get_disk_free_space + * DESCRIPTION + * get free space by byte of specified drive. + * PARAMETERS + * drv_name : [IN] drive letter string terminated with '\0' . + * RETURNS + * free space by byte. 0 means specified disk does not exist. + * 0xFFFFFFFF means exceed the max limitation, the free space size lager than this value. + * another choice to use vm_get_disk_info + * +* EXAMPLE [this TAG is optional] + * + * VMINT sys_driver = -1; + * VMUINT sys_driver_size = 0; + * if ((sys_driver = vm_get_system_driver()) >= 0) + * { + * VMCHAR driver_str[2] = {0}; + * + * sprintf(driver_str, "%c", (VMCHAR)sys_driver); + * sys_driver_size = vm_get_disk_free_space(vm_ucs2_string(driver_str)); + * } + * +*****************************************************************************/ +VMUINT vm_get_disk_free_space(VMWSTR drv_name); + +/***************************************************************************** + * FUNCTION + * vm_get_disk_info + * DESCRIPTION + * Return information about a logical drive + * PARAMETERS + * DriveName : [IN]

Must be a valid file name, e.g., a root directory name. + * Only the drive information (possibly the current default drive) is determined. + * DiskInfo : [OUT]

Refer to vm_fs_disk_info. + * Flags : [IN]

Refer to vm_fs_di_enum. + * RETURNS + * success if >= 0, else failure. + *****************************************************************************/ +VMINT vm_get_disk_info(const VMCHAR * drv_name, vm_fs_disk_info * fs_disk, vm_fs_di_enum e_di); + +/***************************************************************************** +* FUNCTION + * vm_file_get_modify_time + * DESCRIPTION + * get the latest modified time of specified file. + * PARAMETERS + * filename : [IN] file name of full path encoding with UCS2 format. + * modify_time : [OUT] output the latest modified time + * RETURNS + * 0 means get modified time successfully, -1 means failed. + * +*****************************************************************************/ +VMINT vm_file_get_modify_time(const VMWSTR filename, vm_time_t * modify_time); + +/***************************************************************************** +* FUNCTION + * vm_find_first_ext + * DESCRIPTION + * find files from specified path, support wild character finding. + * PARAMETERS + * pathname : [IN] path name encoding with UCS2 format. + * direntry : [OUT] result of finding + * RETURNS + * find handle or error code + * RETURN VALUES + * non-negative number : find handle. + * negative number : error code. + * +*****************************************************************************/ +VMINT vm_find_first_ext(VMWSTR pathname, vm_fileinfo_ext * direntry); + +/***************************************************************************** +* FUNCTION + * vm_find_next_ext + * DESCRIPTION + * continue to find next file. + * PARAMETERS + * handle : [IN] find handle. + * direntry : [OUT] result of finding + * RETURNS + * find handle or error code + * RETURN VALUES + * 0 : find next file successfully. + * negative number : end of finding. + * +*****************************************************************************/ +VMINT vm_find_next_ext(VMINT handle, vm_fileinfo_ext * direntry); + +/***************************************************************************** +* FUNCTION + * vm_find_close_ext + * DESCRIPTION + * close finding process. + * PARAMETERS + * handle : [IN] find handle. + * +*****************************************************************************/ +void vm_find_close_ext(VMINT handle); + +typedef struct +{ + VMUINT8 home_city; + VMUINT8 foreign_city; + VMUINT8 date_seperator; + VMUINT8 date_format; + VMUINT8 time_format; + VMINT current_dst; + + VMUINT8 current_city; + float current_timezone; + + VMUINT8 foreign_index; + VMUINT8 wc_dst; + VMUINT8 setting_dt_dst; + VMUINT16 timezone; + VMUINT16 frn_timezone; + + VMUINT8 wc_entry_screen; /* wc_entry_screen, 0:worldclock, 1:homecity, 2:foreigncity */ + VMUINT8 tz_city_match; /* tz_city_match, 0:Not Match, 1:Match */ +} vm_phoneset_info_struct; + + +/* DOM-NOT_FOR_SDK-BEGIN */ + + +/* error code of storage */ +typedef enum +{ + VM_STORAGE_ERR_RES = -10, /* resource is not enough */ + VM_STORAGE_ERR_PARAM = -9, /* input param error */ + VM_STORAGE_ERR_FILE_CREATE = -8, /* sto create failure */ + VM_STORAGE_ERR_FILE_OPEN = -7, /* sto open failure */ + VM_STORAGE_ERR_FILE_SEEK = -6, /* sto seek failure */ + VM_STORAGE_ERR_FILE_WRITE = -5, /* sto wirte failure */ + VM_STORAGE_ERR_FILE_READ = -4, /* sto read failure */ + VM_STORAGE_ERR_AUTHORIZATION = -3, /* no authorization */ + VM_STORAGE_ERR_NONE = 0 /* no error */ +}vm_storage_error_type; + +/***************************************************************************** + * FUNCTION + * vm_storage_open + * DESCRIPTION + * open storage. + * PARAMETERS + * void + * RETURNS + * storage handle or error code + * RETURN VALUES + * vm_storage_error_type +*****************************************************************************/ +VMINT vm_storage_open(void); + +/***************************************************************************** + * FUNCTION + * vm_storage_close + * DESCRIPTION + * close storage. + * PARAMETERS + * h : [IN] handle of storage +*****************************************************************************/ +void vm_storage_close(VMINT h); + +/***************************************************************************** + * FUNCTION + * vm_storage_read + * DESCRIPTION + * read data from storage. + * PARAMETERS + * h : [IN] handle of storage + * data : [OUT] buffer will be filled + * offset : [IN] offset from head of storage + * size : [IN] buffer size + * read : [OUT] read size + * RETURNS + * 0 or error code + * RETURN VALUES + * vm_storage_error_type +*****************************************************************************/ +VMINT vm_storage_read(VMINT h, void * data, VMUINT offset, VMUINT size, VMUINT * read); + +/***************************************************************************** + * FUNCTION + * vm_storage_write + * DESCRIPTION + * write data to storage + * PARAMETERS + * h : [IN] handle of storage + * data : [IN] buffer will be written to storage + * offset : [IN] offset from head of storage + * size : [IN] buffer size + * written : [OUT] written size + * RETURNS + * 0 or error code + * RETURN VALUES + * vm_storage_error_type +*****************************************************************************/ +VMINT vm_storage_write(VMINT h, const void * data, VMUINT offset, VMUINT size, VMUINT * written); +/* DOM-NOT_FOR_SDK-END */ + +/* error code of storage */ +typedef enum +{ + VM_SYS_FILE_ERR_DISK_FULL = -12, + VM_SYS_FILE_ERR_RES , /* resource is not enough */ + VM_SYS_FILE_ERR_PARAM, /* input param error */ + VM_SYS_FILE_ERR_FILE_CREATE, /* create failure */ + VM_SYS_FILE_ERR_FILE_OPEN, /* open failure */ + VM_SYS_FILE_ERR_FILE_DELETE, + VM_SYS_FILE_ERR_FILE_SEEK, /* seek failure */ + VM_SYS_FILE_ERR_FILE_WRITE, /* wirte failure */ + VM_SYS_FILE_ERR_FILE_WRITE_PARTLY, + VM_SYS_FILE_ERR_FILE_READ, /* read failure */ + VM_SYS_FILE_ERR_AUTHORIZATION, /* no authorization */ + VM_SYS_FILE_ERR_NONE = 0 /* no error */ +}vm_sys_file_error_type; + + +/***************************************************************************** +* FUNCTION + * vm_sys_file_open + * DESCRIPTION + * open file in system drive disk + * PARAMETERS + * mode : [IN] file open mode: + * MODE_READ: Read-Only + * MODE_WRITE : Read-Write + * MODE_CREATE_ALWAYS_WRITE : Read-Write mode, create if the file not exist. + * binary : [IN] TRUE means open with binary format, FALSE means open with ASCII format. + * RETURNS + * non-negative file handle if successfully, and error code if failed to open. + * +*****************************************************************************/ +VMFILE vm_sys_file_open(VMUINT mode, VMUINT binary); + +/***************************************************************************** +* FUNCTION + * vm_sys_file_seek + * DESCRIPTION + * move the sys file pointer to specified position. If exceed file size, this operation will return error. + * PARAMETERS + * handle : [IN] sys file handle to seek. + * offset : [IN] bytes to move. + * base: [IN] base position to move. + * BASE_BEGIN means from begin of file; + * BASE_CURR means from current position; + * BASE_END means from end of file. + * RETURNS + * 0 means successfully, non-zero is error code. + * +*****************************************************************************/ +VMINT vm_sys_file_seek(VMFILE handle, VMINT offset, VMINT base); + + +/***************************************************************************** +* FUNCTION + * vm_sys_file_read + * DESCRIPTION + * read file from current pointer of sys file + * PARAMETERS + * handle : [IN] file handle to be read. + * data : [OUT] output data address + * length : [IN] bytes to be read + * nread : [IN] bytes read actually + * RETURNS + * bytes of read data if > 0, 0 means error happened or reach end of file. + * +*****************************************************************************/ +VMINT vm_sys_file_read(VMFILE handle, void * data, VMUINT length, VMUINT *nread); + +/***************************************************************************** +* FUNCTION + * vm_sys_file_write + * DESCRIPTION + * write data to current pointer of the sys file + * PARAMETERS + * handle : [IN] file handle to write. + * data : [IN] the address of data to be written + * length : [IN] bytes to be written + * written : [IN] bytes written actually + * RETURNS + * bytes of written data if > 0, 0 means error happened. + * +*****************************************************************************/ +VMINT vm_sys_file_write(VMFILE handle, void * data, VMUINT length, VMUINT * written); + + +/***************************************************************************** +* FUNCTION + * vm_sys_file_close + * DESCRIPTION + * close sys file + * PARAMETERS + * handle : [IN] sys file handle to be closed. + * +*****************************************************************************/ +void vm_sys_file_close(VMFILE h); + +/***************************************************************************** +* FUNCTION + * vm_sys_file_delete + * DESCRIPTION + * delete sys file. + * RETURNS + * delete sys file successfully or failed + * RETURN VALUES + * 0 : delete file successfully. + * non-zero : failed to delete sys file. + * +*****************************************************************************/ +VMINT vm_sys_file_delete(void); + +/***************************************************************************** +* FUNCTION + * vm_sys_file_get_space + * DESCRIPTION + * get the current free size of sys file + * PARAMETERS + * RETURNS + * rest space size. + * +*****************************************************************************/ +VMINT vm_sys_file_get_space(void); + + +/***************************************************************************** +* FUNCTION + * vm_get_default_store_path_by_type + * DESCRIPTION + * get default store path of different types + * PARAMETERS + * RETURNS + * path string. + * +*****************************************************************************/ + +VMUWSTR vm_get_default_store_path_by_type(VMINT disk_letter, VM_STORE_PATH_TYPE type); + + +/***************************************************************************** + * FUNCTION + * vm_startup_email + * DESCRIPTION + * startup email + * PARAMETERS + * to_addr : [IN] email address of receiver (UCS2) + * RETURN VALUES + * 0 : success + * non-zero : failure + * -2 : platform not support + * -3 : no email account + *****************************************************************************/ +VMINT vm_startup_email(const VMWSTR to_addr); + +/* vm_fmgr_default_folder_enum */ +typedef enum +{ + VM_FMGR_DEFAULT_FOLDER_EBOOKS, /* path of defualt ebooks */ + VM_FMGR_DEFAULT_FOLDER_IMAGES, /* path of defualt images */ + VM_FMGR_DEFAULT_FOLDER_AUDIO, /* path of defualt audio */ + VM_FMGR_DEFAULT_FOLDER_VIDEO, /* path of defualt video */ + VM_FMGR_DEFAULT_FOLDER_SWFLASH, /* path of defualt swflash */ + VM_FMGR_DEFAULT_FOLDER_LANGLN, /* path of defualt langln */ + VM_FMGR_DEFAULT_FOLDER_TEMP, /* path of defualt temp */ + VM_FMGR_DEFAULT_FOLDER_THEMES, /* path of defualt themes */ + VM_FMGR_DEFAULT_FOLDER_BARCODE, /* path of defualt barcode */ + VM_FMGR_DEFAULT_FOLDER_MMSBOX, /* path of defualt mmsbox */ + VM_FMGR_DEFAULT_FOLDER_ROOT, /* path of defualt root */ + VM_FMGR_DEFAULT_FOLDER_TOTAL +}vm_fmgr_default_folder_enum; + +/***************************************************************************** + * FUNCTION + * vm_get_default_folder_path + * DESCRIPTION + * get the default path of folder type + * PARAMETERS + * mode : [IN] see vm_fmgr_default_folder_enum + * RETURNS + * const VMWCHAR * (UCS2) + * RETURN VALUES + * non-NULL : success + * NULL : failure + *****************************************************************************/ +const VMWCHAR * vm_get_default_folder_path(vm_fmgr_default_folder_enum type); + + +/* vm_file_copy Callback Return Value */ +typedef enum +{ + /* if something wrong, will call once + * Fail to do the copy action. Total and Completed will be zero. + */ + VM_FS_MOVE_PGS_FAIL = -1, + + /* + * Always call once + * Prepare to do the copy action. Parameter checking and remove target will be done at this stage. + * Total and Completed will be zero. + */ + VM_FS_MOVE_PGS_PREPARE, + + /* + * If pass parameter checking, always call once. + * Start to do the copy action. Total and Completed will be zero. + */ + VM_FS_MOVE_PGS_START, + + /* + * Not always call even if nothing wrong. + * If you move/copy a folder recursively, Total will be the number of files/folders to be moved/copied. + * Completed will be the files/folders that had been copied. + * If you just copy a file, Total will be the size of this file and Completed will be the bytes that had been copied. + * Note that if move/copy only one file, this callback will be triggered when interval is longer than 100ms around. + */ + VM_FS_MOVE_PGS_ING, + + /* + * + * Move/copy action is done. Total and Completed will be zero. + */ + VM_FS_MOVE_PGS_DONE +} vm_fs_move_pgs_enum; + + +/***************************************************************************** + * + * FUNCTION + * vm_file_copy_cb + * DESCRIPTION + * Callback function type for file copy. + * PARAMETERS + * act : [IN] see vm_fs_move_pgs_enum. + * total : [IN] the size of source file. + * completed : [IN] copied size. + * hdl : [IN] handle of file copy. + * RETURNS + * VMINT + *****************************************************************************/ +typedef VMINT (*vm_file_copy_cb)(VMINT act, VMUINT32 total, VMUINT32 completed, VMINT hdl); + +/***************************************************************************** + * FUNCTION + * vm_file_copy + * DESCRIPTION + * copy file + * PARAMETERS + * dst : [IN] the file path of destination UCS2 + * src : [IN] the file path of source UCS2 + * cb : [IN] callback of file copy + * RETURNS + * VMINT + * RETURN VALUES + * successful if 0, else failure + * (-2): bad parameter. + * (-3): Either source full path or destination full path is wrong + * (-19): Cannot find source full path specified. + * (-36): destination full path exists. + * (-44): Cannot get memory to do the operation + * (-46): busy. + * (-47): This action has been aborted in the user's callback function. + *****************************************************************************/ +VMINT vm_file_copy(const VMWSTR dst, const VMWSTR src, vm_file_copy_cb cb); + +/***************************************************************************** + * FUNCTION + * vm_file_copy_abort + * DESCRIPTION + * abort file copy + * PARAMETERS + * hdl : [IN] handle of file copy + * RETURNS + * VMINT + * RETURN VALUES + * success if 0, else failure + *****************************************************************************/ +VMINT vm_file_copy_abort(VMINT hdl); + + +/* flag for async fs */ +#define VM_FS_READ_WRITE 0x00000000L +#define VM_FS_READ_ONLY 0x00000100L +#define VM_FS_OPEN_SHARED 0x00000200L +#define VM_FS_OPEN_NO_DIR 0x00000400L +#define VM_FS_OPEN_DIR 0x00000800L +#define VM_FS_CREATE 0x00010000L +#define VM_FS_CREATE_ALWAYS 0x00020000L +#define VM_FS_COMMITTED 0x01000000L +#define VM_FS_CACHE_DATA 0x02000000L +#define VM_FS_LAZY_DATA 0x04000000L +#define VM_FS_NONBLOCK_MODE 0x10000000L +#define VM_FS_PROTECTION_MODE 0x20000000L +#define VM_FS_NOBUSY_CHECK_MODE 0x40000000L + + + +typedef VMINT vm_fs_api_enum; +typedef VMINT vm_fs_job_state_enum; +typedef VMINT vm_fs_job_id; +typedef VMINT vm_module_type; +typedef VMINT VM_FS_HANDLE; +typedef VMINT (*vm_fs_async_callback)(vm_fs_job_id jid, VMINT64 * result, void *data); + + +typedef enum +{ + VM_FS_PRIORITY_DEFAULT = 0, // Default: This job will use lower priority to run. Suitable to non-critical jobs. + VM_FS_PRIORITY_INHERITED, // Inherited: This job will inherites the priority of user. Suitable to critical jobs. + VM_FS_PRIORITY_INVALID = 0xFF +}vm_fs_prioity_enum; + +typedef struct +{ + vm_fs_api_enum api; // The API enumeration of this job + vm_fs_job_state_enum reserved1; // Reserved + VMUINT8 reserved2; // Reserved + vm_fs_job_id jid; // Job ID. It also appears in the 1st parameter of callback function. + vm_module_type reserved3; // Reserved + VMINT64 result; // Execution result of FS API. It also appears in the 2nd parameter of callback function. + vm_fs_async_callback callback; // Callback function pointer + void *param; // Parameter of callback function. It is defined in by user whenever FS async I/F is used. + void *reserved4; // Reserved +}vm_fs_async_callback_data_struct; + + +typedef struct +{ + vm_fs_async_callback_data_struct head; + VMINT job_id; + VMINT aborted; +}vm_fs_job_abort_struct; + +typedef struct +{ + vm_fs_async_callback_data_struct head; + VMWCHAR * filename; + VMUINT flag; +}vm_fs_job_open_struct; + +typedef struct +{ + vm_fs_async_callback_data_struct head; + VMINT fs_hdl; + void * data; + VMUINT length; + VMUINT * read; +}vm_fs_job_read_struct; + +typedef struct +{ + vm_fs_async_callback_data_struct head; + VMINT fs_hdl; + void * data; + VMUINT length; + VMUINT * written; +}vm_fs_job_write_struct; + +typedef struct +{ + vm_fs_async_callback_data_struct head; + const VMWCHAR * filename; +}vm_fs_job_delete_struct; + +typedef struct +{ + vm_fs_async_callback_data_struct head; + VMINT fs_hdl; + VMINT64 offset; + VMINT whence; +}vm_fs_job_seek_struct; + + +typedef struct +{ + vm_fs_prioity_enum priority; // priority configuration of this job + vm_fs_async_callback callback; // callback function pointer + void *param; // parameter of callback function +}vm_fs_overlapped_struct; + +/***************************************************************************** + * FUNCTION + * fs_aysnc_open + * + * DESCRIPTION + * Open a file + * + * PARAMETERS + * filename :[IN] Must point to the name of the file to open/create. + * File names are not case sensitive; they will be converted to + * upper case when file system searches this file, and they should + * be two-byte aligned and UCS2 encoded. The file name can have one + * of the following formats: + * flag :[IN] Can be a combination of the following flags: + * VM_FS_READ_WRITE VM_FS_READ_ONLY VM_FS_OPEN_SHARED VM_FS_OPEN_NO_DIR + * VM_FS_OPEN_DIR VM_FS_CREATE VM_FS_CREATE_ALWAYS VM_FS_COMMITTED + * VM_FS_CACHE_DATA VM_FS_LAZY_DATA VM_FS_ATTR_HIDDEN VM_FS_ATTR_SYSTEM + * VM_FS_ATTR_ARCHIVE VM_FS_NONBLOCK_MODE VM_FS_PROTECTION_MODE + * overlapped :[IN] Overlapped structure has 3 members, + * 1. callback :[IN] (Optional) Call back function. This function will be executed just after response message is received by user. + * 2. param :[IN] (Optional) Parameters for call back function + * 3. priority :[IN] (*Required) Priority of this job, it can be any one of following options, + * 1. VM_FS_PRIORITY_DEFAULT : User has no priority concern for this job) + * 2. VM_FS_PRIORITY_INHERITED: FS task will be raised to a higher priorty to execute this job) + * RETURNS + * Successful : A positive integer. It is Job ID. + * Failed : A negative integer. -1 means no authorization. + *****************************************************************************/ +VMINT vm_fs_async_open(const VMWSTR file_name, VMINT flag, vm_fs_overlapped_struct *overlapped); + +/***************************************************************************** + * FUNCTION + * vm_fs_async_write + * + * DESCRIPTION + * Write data to a file + * + * PARAMETERS + * fs_hdl :[IN] file handle, get it from *result in VMINT (*vm_fs_async_callback)(vm_fs_job_id jid, VMINT64 * result, void *data); + * data :[IN] Specifies the address of the data to be written. + * length :[IN] Specifies the number of bytes to write. + * written :[OUT] Pointer to an unsigned integer to receive the number of + * bytes actually been written. Usually, *Written will contain + * Length after the call. However, in case of an error, the + * returned value may be less. Written may be set to NULL if + * this information is not required by an application. + * overlapped :[IN] Overlapped structure has 3 members, + * 1. callback :[IN] (Optional) Call back function. This function will be executed just after response message is received by user. + * 2. param :[IN] (Optional) Parameters for call back function + * 3. priority :[IN] (*Required) Priority of this job, it can be any one of following options, + * 1. VM_FS_PRIORITY_DEFAULT : User has no priority concern for this job) + * 2. VM_FS_PRIORITY_INHERITED: FS task will be raised to a higher priorty to execute this job) + * RETURNS + * Successful : A positive integer. It is Job ID. + * Failed : A negative integer. -1 means no authorization. + *****************************************************************************/ +VMINT vm_fs_async_write(VM_FS_HANDLE fs_hdl, void *data, VMUINT length, VMUINT *written, vm_fs_overlapped_struct *overlapped); + +/***************************************************************************** + * FUNCTION + * vm_fs_async_write + * + * DESCRIPTION + * Read data to a file + * + * PARAMETERS + * fs_hdl :[IN] file handle, get it from *result in VMINT (*vm_fs_async_callback)(vm_fs_job_id jid, VMINT64 * result, void *data); + * data :[IN] Specifies the address of the data to be read. + * length :[IN] Specifies the number of bytes to write. + * read :[OUT] Pointer to an unsigned integer to receive the number of + * bytes actually been read. Usually, *Written will contain + * Length after the call. However, in case of an error, the + * returned value may be less. Written may be set to NULL if + * this information is not required by an application. + * overlapped :[IN] Overlapped structure has 3 members, + * 1. callback :[IN] (Optional) Call back function. This function will be executed just after response message is received by user. + * 2. param :[IN] (Optional) Parameters for call back function + * 3. priority :[IN] (*Required) Priority of this job, it can be any one of following options, + * 1. VM_FS_PRIORITY_DEFAULT : User has no priority concern for this job) + * 2. VM_FS_PRIORITY_INHERITED: FS task will be raised to a higher priorty to execute this job) + * RETURNS + * Successful : A positive integer. It is Job ID. + * Failed : A negative integer. -1 means no authorization. + *****************************************************************************/ +VMINT vm_fs_async_read(VM_FS_HANDLE fs_hdl, void *data, VMUINT length, VMUINT *read, vm_fs_overlapped_struct *overlapped); + +/***************************************************************************** + * FUNCTION + * vm_fs_async_seek + * + * DESCRIPTION + * Seek to a specific position of a file + * + * PARAMETERS + * fs_hdl :[IN] file handle, get it from *result in VMINT (*vm_fs_async_callback)(vm_fs_job_id jid, VMINT64 * result, void *data); + * offset :[IN] Specifies the offset (bytes) of the file to be seeked. + * whence :[IN] Specifies the method (start address) of the seek. + * overlapped :[IN] Overlapped structure has 3 members, + * 1. callback :[IN] (Optional) Call back function. This function will be executed just after response message is received by user. + * 2. param :[IN] (Optional) Parameters for call back function + * 3. priority :[IN] (*Required) Priority of this job, it can be any one of following options, + * 1. VM_FS_PRIORITY_DEFAULT : User has no priority concern for this job) + * 2. VM_FS_PRIORITY_INHERITED: FS task will be raised to a higher priorty to execute this job) + * RETURNS + * Successful : A positive integer. It is Job ID. + * Failed : A negative integer. -1 means no authorization. + *****************************************************************************/ +VMINT vm_fs_async_seek(VM_FS_HANDLE fs_hdl, VMINT64 * offset, VMINT whence, vm_fs_overlapped_struct *overlapped); + + +/***************************************************************************** + * FUNCTION + * vm_fs_async_delete + * + * DESCRIPTION + * Delete a file + * + * PARAMETERS + * filename :[IN] References the open file to seek to. + * overlapped :[IN] Overlapped structure has 3 members, + * 1. callback :[IN] (Optional) Call back function. This function will be executed just after response message is received by user. + * 2. param :[IN] (Optional) Parameters for call back function + * 3. priority :[IN] (*Required) Priority of this job, it can be any one of following options, + * 1. VM_FS_PRIORITY_DEFAULT : User has no priority concern for this job) + * 2. VM_FS_PRIORITY_INHERITED: FS task will be raised to a higher priorty to execute this job) + * RETURNS + * Successful : A positive integer. It is Job ID. + * Failed : A negative integer. -1 means no authorization. + *****************************************************************************/ +VMINT vm_fs_async_delete(const VMWSTR filename, vm_fs_overlapped_struct *overlapped); + +/***************************************************************************** + * FUNCTION + * vm_fs_async_abort + * + * DESCRIPTION + * This function provides the facility to abort a specific job by Job ID + * + * PARAMETERS + * jid :[IN] Job ID + * + * RETURNS + * Successful : A non-negative integer + * Failed : A negative integer. -1 means no authorization. + *****************************************************************************/ +VMINT vm_fs_async_abort(vm_fs_job_id jid); + + +/***************************************************************************** + * FUNCTION + * vm_fs_async_commit + * + * PARAMETERS + * fs_hdl :[IN] file handle, get it from *result in VMINT (*vm_fs_async_callback)(vm_fs_job_id jid, VMINT64 * result, void *data); + * + * DESCRIPTION + * Immediately flushes all buffers associated with a file to disk. + * + * PARAMETERS + * jid :[IN] Job ID + * + * RETURNS + * Successful : A non-negative integer + * Failed : A negative integer. -1 means no authorization. + *****************************************************************************/ +VMINT vm_fs_async_commit(VM_FS_HANDLE fs_hdl); + +/***************************************************************************** + * FUNCTION + * vm_fs_async_close + * + * PARAMETERS + * fs_hdl :[IN] file handle, get it from *result in VMINT (*vm_fs_async_callback)(vm_fs_job_id jid, VMINT64 * result, void *data); + * + * DESCRIPTION + * Immediately flushes all buffers associated with a file to disk. + * + * RETURNS + * Successful : A non-negative integer + * Failed : A negative integer. -1 means no authorization. + *****************************************************************************/ +VMINT vm_fs_async_close(VM_FS_HANDLE fs_hdl); + +VMINT vm_fs_async_get_working_buf_size(void); + +/***************************************************************************** + * FUNCTION + * vm_kbd_is_key_supported + * DESCRIPTION + * query if specified key code is supported + * PARAMETERS + * keycode [IN] key code + * RETURNS + * non-zero : supported. + * zero : unsupported + *****************************************************************************/ +VMINT vm_kbd_is_key_supported(VMINT keycode); + + + +typedef struct +{ + VMBYTE * dst; + VMUINT dst_size; + VMBYTE * src; + VMUINT src_size; +}vm_zip_t; + +VMINT vm_uncompress(const vm_zip_t * info, void * (*app_malloc)(VMUINT items, VMUINT size), void (*app_free)(void * address)); + + +#ifdef __cplusplus +} +#endif + +#endif /* VMIO_SDK_H_ */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmjava.h b/hardware/arduino/mtk/system/libmtk/include/vmjava.h new file mode 100644 index 00000000..c7f0eb6c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmjava.h @@ -0,0 +1,81 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef VMJAVA_SDK_H_ +#define VMJAVA_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" +#include "vmpromng.h" + +#define MMI_MRE_MAX_ID_LEN 32 +#define MMI_MRE_MAX_URL_LEN 128 + +typedef enum +{ + VM_RESULT_OK, + VM_RESULT_FAILED +} vm_process_result_enum; + +typedef enum +{ + VM_CMD_JAVA_INSTALL, + VM_CMD_JAVA_REMOVE, + VM_CMD_JAVA_START, + VM_CMD_END +} vm_cmd_enum; + +typedef void (*vm_java_report_status_t)( vm_process_result_enum error_code, VMSTR mids_storage_id); + +typedef struct +{ + VMCHAR mids_storage_id[MMI_MRE_MAX_ID_LEN]; /* App software ID */ + VMINT16 pkg_install_path[MMI_MRE_MAX_URL_LEN]; /* Install file path */ + VMCHAR pkg_network_url[MMI_MRE_MAX_URL_LEN]; /* network package url */ + VM_P_HANDLE process_handle; + vm_java_report_status_t vm_java_report_status; +} vm_cmd_info_struct; + +void vm_process_java_app( vm_cmd_enum cmd, vm_cmd_info_struct *info); + +VMINT vm_java_is_removed(VMSTR mids_storage_id); + +#ifdef __cplusplus +} +#endif + +#endif /* VMJAVA_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmkeypad.h b/hardware/arduino/mtk/system/libmtk/include/vmkeypad.h new file mode 100644 index 00000000..5eea1fe8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmkeypad.h @@ -0,0 +1,281 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMKEYPAD_SDK_H +#define VMKEYPAD_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/* Key events supported by MRE. */ + +#define VM_KEY_EVENT_UP (1) /* Key up event */ +#define VM_KEY_EVENT_DOWN (2) /* Key down event */ +#define VM_KEY_EVENT_LONG_PRESS (3) /* Key long press event */ +#define VM_KEY_EVENT_REPEAT (4) /* Key repeat event */ + +/* Key codes supported by MRE. */ + +#define VM_KEY_UP (-1) /* Arrow key up */ +#define VM_KEY_DOWN (-2) /* Arrow key down */ +#define VM_KEY_LEFT (-3) /* Arrow key left */ +#define VM_KEY_RIGHT (-4) /* Arrow key right */ +#define VM_KEY_LEFT_SOFTKEY (-6) /* Left soft key */ +#define VM_KEY_RIGHT_SOFTKEY (-7) /* Right soft key */ +#define VM_KEY_OK (-5) /* OK key */ +#define VM_KEY_CLEAR (-8) /* Clear key */ +#define VM_KEY_BACK (-9) /* Back key */ +#define VM_KEY_HOME (-10) /* Key home */ +#define VM_KEY_END (-11) /* key end */ +#define VM_KEY_NUM0 (48) /* Number key 0 */ +#define VM_KEY_NUM1 (49) /* Number key 1 */ +#define VM_KEY_NUM2 (50) /* Number key 2 */ +#define VM_KEY_NUM3 (51) /* Number key 3 */ +#define VM_KEY_NUM4 (52) /* Number key 4 */ +#define VM_KEY_NUM5 (53) /* Number key 5 */ +#define VM_KEY_NUM6 (54) /* Number key 6 */ +#define VM_KEY_NUM7 (55) /* Number key 7 */ +#define VM_KEY_NUM8 (56) /* Number key 8 */ +#define VM_KEY_NUM9 (57) /* Number key 9 */ +#define VM_KEY_VOL_UP (58) /* Volume key up */ +#define VM_KEY_VOL_DOWN (59) /* Volume key down */ +#define VM_KEY_POUND (35) /* Key # */ +#define VM_KEY_STAR (42) /* Key * */ + +/* Key codes from A to Z on a qwerty keypad, each code represents the Unicode value of the corresponding capital letter. */ +#define VM_KEY_A 65 /* A */ +#define VM_KEY_B 66 /* B */ +#define VM_KEY_C 67 /* C */ +#define VM_KEY_D 68 /* D */ +#define VM_KEY_E 69 /* E */ +#define VM_KEY_F 70 /* F */ +#define VM_KEY_G 71 /* G */ +#define VM_KEY_H 72 /* H */ +#define VM_KEY_I 73 /* I */ +#define VM_KEY_J 74 /* J */ +#define VM_KEY_K 75 /* K */ +#define VM_KEY_L 76 /* L */ +#define VM_KEY_M 77 /* M */ +#define VM_KEY_N 78 /* N */ +#define VM_KEY_O 79 /* O */ +#define VM_KEY_P 80 /* P */ +#define VM_KEY_Q 81 /* Q */ +#define VM_KEY_R 82 /* R */ +#define VM_KEY_S 83 /* S */ +#define VM_KEY_T 84 /* T */ +#define VM_KEY_U 85 /* U */ +#define VM_KEY_V 86 /* V */ +#define VM_KEY_W 87 /* W */ +#define VM_KEY_X 88 /* X */ +#define VM_KEY_Y 89 /* Y */ +#define VM_KEY_Z 90 /* Z */ +#define VM_KEY_SPACE 91 /* Space */ +#define VM_KEY_TAB 92 /* Tab */ +#define VM_KEY_DEL 93 /* Delete */ +#define VM_KEY_ALT 94 /* Alt */ +#define VM_KEY_CTRL 95 /* Ctrl */ +#define VM_KEY_WIN 96 /* Winodows key */ +#define VM_KEY_SHIFT 97 /* Shift */ +#define VM_KEY_QUESTION 98 /* Question */ +#define VM_KEY_PERIOD 99 /* Period */ +#define VM_KEY_COMMA 100 /* Comma (,) */ +#define VM_KEY_EXCLAMATION 101 /* Exclamation (!) */ +#define VM_KEY_APOSTROPHE 102 /* Apostrophe (') */ +#define VM_KEY_AT 103 /* @ */ +#define VM_KEY_BACKSPACE 104 /* Backspace */ +#define VM_KEY_QWERTY_ENTER 105 /* Qwerty enter */ +#define VM_KEY_FN 106 /* Function */ +#define VM_KEY_SYMBOL 107 /* Symbol */ +#define VM_KEY_NUM_LOCK 108 /* Number lock */ +#define VM_KEY_QWERTY_MENU 109 /* Qwerty menu */ + +/***************************************************************************** + * FUNCTION + * vm_kbd_is_key_supported + * DESCRIPTION + * query if specified key code is supported + * PARAMETERS + * keycode [IN] key code + * RETURNS + * non-zero : supported. + * zero : unsupported + *****************************************************************************/ +VMINT vm_kbd_is_key_supported(VMINT keycode); + + +typedef enum +{ + VM_DEVCONFIG_KEYPAD_TYPE_NORMAL, /* normal keypad type */ + VM_DEVCONFIG_KEYPAD_TYPE_REDUCED, /* reduced keypad type */ + VM_DEVCONFIG_KEYPAD_TYPE_QWERTY, /* qwerty keypad type */ + VM_DEVCONFIG_KEYPAD_TYPE_TOTAL +} vm_devconfig_keypad_type_enum; + + +/***************************************************************************** +* FUNCTION +* vm_get_keypad_type +* DESCRIPTION +* check the current type of keypad +* PARAMETERS +* void +* RETURN VALUES +* less than zero : failure +* VM_DEVCONFIG_KEYPAD_TYPE_NORMAL : normal keypad type. +* VM_DEVCONFIG_KEYPAD_TYPE_REDUCED : reduced keypad type. +* VM_DEVCONFIG_KEYPAD_TYPE_QWERTY : qwerty keypad type. +*****************************************************************************/ +VMINT vm_get_keypad_type(void); + +typedef enum +{ + /* KEY1 Number */ + VM_KEYPAD_1KEY_NUMBER = 0, + /* KEY2 Number */ + VM_KEYPAD_2KEY_NUMBER, + /* reserved */ + VM_KEYPAD_3KEY_NUMBER, + /* KEY1 Qwerty */ + VM_KEYPAD_1KEY_QWERTY, + /* KEY2 Qwerty */ + VM_KEYPAD_2KEY_QWERTY, + /* reserved */ + VM_KEYPAD_3KEY_QWERTY, + /* reserved */ + VM_KEYPAD_MODE_END +} vm_keypad_mode_enum; + +typedef enum +{ + VM_KBD_MODE_ERR_PARAM = -2, /* input invalid parameter */ + VM_KBD_MODE_ERR_NOT_AUTHORIZED, /* no authrization */ + VM_KBD_MODE_ERR_SUCCESS = 0 /* success */ +}vm_kbd_mode_error_t; + +/***************************************************************************** + * FUNCTION + * vm_kbd_set_mode + * DESCRIPTION + * set the concurrent key mode + * PARAMETERS + * mode : [IN] see vm_keypad_mode_enum + * RETURNS + * vm_kbd_mode_error_t + * RETURN VALUES + * 0 : success + * non-zero : failure + *****************************************************************************/ +VMINT vm_kbd_set_mode(VMUINT8 mode); + +/***************************************************************************** + * FUNCTION + * vm_is_support_keyborad + * DESCRIPTION + * Check whether the phone support keypad or not. + * PARAMETERS + * void + * RETURN VALUES + * TRUE : Supports keypad. + * FALSE : Not support. + *****************************************************************************/ +VMINT vm_is_support_keyborad(void); + + + +/***************************************************************************** + * + * + * FUNCTION + * vm_key_handler_t + * DESCRIPTION + * Callback function type for key event handler. + * PARAMETERS + * event : [IN] Key event. + * keycode : [IN] Key code. + * RETURNS + * void + *****************************************************************************/ +typedef void (*vm_key_handler_t)(VMINT event, VMINT keycode); + +/***************************************************************************** + * + * + * FUNCTION + * vm_key_handler_ex_t + * DESCRIPTION + * Callback function type for key event handler. + * PARAMETERS + * event : [IN] Key event. + * keycode : [IN] Key code. + * RETURNS + * void + *****************************************************************************/ +typedef VMINT (*vm_key_handler_ex_t)(VMINT event, VMINT keycode); + +/***************************************************************************** + * FUNCTION + * vm_reg_keyboard_callback + * DESCRIPTION + * Registers key handler. + * PARAMETERS + * vm_key_handler_t : [IN] Key event handler. + * RETURNS + * void + *****************************************************************************/ +void vm_reg_keyboard_callback(vm_key_handler_t handler); + +/***************************************************************************** + * FUNCTION + * vm_reg_keyboard_callback + * DESCRIPTION + * Registers key extension handler. app will take the key event + * and not give it back to platform if return value from callback is non-zero, + * else not. + * PARAMETERS + * vm_key_handler_ex_t : [IN] Key extension event handler. + * RETURNS + * void + *****************************************************************************/ +VMINT vm_reg_keyboard_callback_ex(vm_key_handler_ex_t handler); + +#ifdef __cplusplus +} +#endif + +#endif /* VMKEYPAD_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmlog.h b/hardware/arduino/mtk/system/libmtk/include/vmlog.h new file mode 100644 index 00000000..0a0620b0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmlog.h @@ -0,0 +1,147 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef LOG_SDK_H_ +#define LOG_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define VM_DEBUG_LEVEL 5 +#define VM_INFO_LEVEL 4 +#define VM_WARN_LEVEL 3 +#define VM_ERROR_LEVEL 2 +#define VM_FATAL_LEVEL 1 + + +void vm_log_init(char* filename, int log_level); +void vm_log_close(void); + +#if defined(__LINKIT_ONE__) + +void _vm_log_debug(const char* fmt, ...); +void _vm_log_info(const char* fmt, ...); +void _vm_log_warn(const char* fmt, ...); +void _vm_log_error(const char* fmt, ...); +void _vm_log_fatal(const char* fmt, ...); + +#else + +void _vm_log_debug(char* fmt, ...); +void _vm_log_info(char* fmt, ...); +void _vm_log_warn(char* fmt, ...); +void _vm_log_error(char* fmt, ...); +void _vm_log_fatal(char* fmt, ...); + +#endif + +int _vm_log_module(const char* __file__, const int __line__); + +#ifdef WIN32 +#define vm_log_fatal if(_vm_log_module(__FILE__, __LINE__)) _vm_log_fatal +#define vm_log_error if(_vm_log_module(__FILE__, __LINE__)) _vm_log_error +#define vm_log_warn if(_vm_log_module(__FILE__, __LINE__)) _vm_log_warn +#define vm_log_info if(_vm_log_module(__FILE__, __LINE__)) _vm_log_info +#define vm_log_debug if(_vm_log_module(__FILE__, __LINE__)) _vm_log_debug + +#elif defined(__LINKIT_ONE_RELEASE__) + +#define vm_log_fatal +#define vm_log_error +#define vm_log_warn +#define vm_log_info +#define vm_log_debug + +#else +/***************************************************************************** + * FUNCTION + * vm_log_fatal + * DESCRIPTION + * write fatal level log. + * PARAMETERS + * fmt : [IN] format string. +*****************************************************************************/ +#define vm_log_fatal(...) if(_vm_log_module(__FILE__, __LINE__)) _vm_log_fatal(__VA_ARGS__) + +/***************************************************************************** + * FUNCTION + * vm_log_error + * DESCRIPTION + * write error level log. + * PARAMETERS + * fmt : [IN] format string. +*****************************************************************************/ +#define vm_log_error(...) if(_vm_log_module(__FILE__, __LINE__)) _vm_log_error(__VA_ARGS__) + +/***************************************************************************** + * FUNCTION + * vm_log_warn + * DESCRIPTION + * write warn level log. + * PARAMETERS + * fmt : [IN] format string. +*****************************************************************************/ +#define vm_log_warn(...) if(_vm_log_module(__FILE__, __LINE__)) _vm_log_warn(__VA_ARGS__) + +/***************************************************************************** + * FUNCTION + * vm_log_info + * DESCRIPTION + * write info level log. + * PARAMETERS + * fmt : [IN] format string. +*****************************************************************************/ +#define vm_log_info(...) if(_vm_log_module(__FILE__, __LINE__)) _vm_log_info( __VA_ARGS__) + +/***************************************************************************** + * FUNCTION + * vm_log_debug + * DESCRIPTION + * write debug level log. + * PARAMETERS + * fmt : [IN] format string. +*****************************************************************************/ +#define vm_log_debug(...) if(_vm_log_module(__FILE__, __LINE__)) _vm_log_debug(__VA_ARGS__) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* LOG_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmmagic.h b/hardware/arduino/mtk/system/libmtk/include/vmmagic.h new file mode 100644 index 00000000..9f633b23 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmmagic.h @@ -0,0 +1,78 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMMAGIC_SDK_H +#define VMMAGIC_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" +#include "vmpromng.h" + +/* Max num of magic api using resource */ +#define VM_RES_TYPE_MAGIC_NUM (10) + +/* struct of storing in resource */ +typedef struct vm_magic_t { + /* the pointer to customer struct */ + void* pointer; + /* saving current mre app handle */ + VM_P_HANDLE m_pHandle; + /* the handle of native function which register cb */ + VMINT native_handle; +} vm_magic_t; + +/***************************************************************************** +* FUNCTION + * vm_magic_wrapper_for_customer + * DESCRIPTION + * magic wrapper api for customer, customer can use this api to realize apis which is not released in SDK + * PARAMETERS + * index: [IN] the index which implies different apis + * param: [IN] the data transfered into wrapper api, which maybe callback function + * RETURNS + * if 0, success; others, fail. +*****************************************************************************/ +VMINT vm_magic_wrapper_for_customer(VMINT index, void* param, void* reserve); + + +#ifdef __cplusplus +} +#endif + +#endif /* VMMAGIC_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmmm.h b/hardware/arduino/mtk/system/libmtk/include/vmmm.h new file mode 100644 index 00000000..fe7d6e98 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmmm.h @@ -0,0 +1,963 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMMM_SDK_H_ +#define VMMM_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/* driver name length */ +#define DRV_NAME_LEN (4) + +/* record file name length */ +#define REC_NAME_LEN (50) + +/* directory length */ +#define DIR_NAME_LEN (200) + +/* file name length */ +#define MAX_NAME_LEN (260) + +/* wide char file name length */ +#define MAX_WNAME_LEN (260 * sizeof(VMWCHAR)) + +/* default volume */ +#define DEFAULT_VOLUME 3 + +/* path to play */ +#define VM_DEVICE_SPEAKER 0 +#define VM_DEVICE_MICROPHONE 1 +#define VM_DEVICE_SPEAKER2 4 +#define VM_DEVICE_LOUDSPEAKER 5 +#define VM_DEVICE_SPEAKER_BOTH 6 +#define VM_DEVICE_BT_HEADSET 8 + +/* media type */ +typedef enum +{ + VM_FORMAT_NONE = -1, + VM_FORMAT_AMR = 3, + VM_FORMAT_MP3 = 5, + VM_FORMAT_AAC = 6, + VM_FORMAT_WAV = 13, + VM_FORMAT_MIDI = 17, + VM_FORMAT_IMELODY = 18, + VM_FORMAT_OTHER = 100, + VM_FORMAT_MAX +}vm_format_enum; + +/* ======================= record ====================== */ + + +/* record success */ +#define VM_RECORD_SUCCEED (1) + +/* record failed */ +#define VM_RECORD_FAILED (0) + +/* callback function pointer */ +typedef void(*vm_recorder_callback)(VMINT result); + +typedef void (*vm_audio_result_callback)(VMINT handle, VMINT result); + +/***************************************************************************** + * FUNCTION + * vm_record_start + * DESCRIPTION + * start record. + * PARAMETERS + * drv_name : [IN] driver name. + * dir_name : [IN] directory name. + * rec_name : [IN] record file name. + * format : [IN] record file format, VM_FORMAT_AMR and VM_FORMAT_WAV. + * full_rec_file_wname : [OUT] the real file name, maybe different with rec_name. + * vm_record_cb : [IN] callback function. + * RETURNS + * start record success or not. + * RETURN VALUES + * VM_RECORD_FAILED : start record failed. + * VM_RECORD_SUCCEED : start record success. +*****************************************************************************/ +VMINT vm_record_start(VMSTR drv_name, VMSTR dir_name, VMSTR rec_name, VMUINT8 format, VMWSTR full_rec_file_wname, vm_recorder_callback vm_record_cb); + +/***************************************************************************** + * FUNCTION + * vm_record_pause + * DESCRIPTION + * record pause. + * RETURNS + * record pause success or not. + * RETURN VALUES + * VM_RECORD_FAILED : record pause failed. + * VM_RECORD_SUCCEED : record pause success. +*****************************************************************************/ +VMINT vm_record_pause(void); + +/***************************************************************************** + * FUNCTION + * vm_record_resume + * DESCRIPTION + * record resume. + * RETURNS + * record resume success or not. + * RETURN VALUES + * VM_RECORD_FAILED : record resume failed. + * VM_RECORD_SUCCEED : record resume success. +*****************************************************************************/ +VMINT vm_record_resume(void); + +/***************************************************************************** + * FUNCTION + * vm_record_stop + * DESCRIPTION + * stop record. + * RETURNS + * stop record success or not. + * RETURN VALUES + * VM_RECORD_FAILED : stop record failed. + * VM_RECORD_SUCCEED : stop record success. +*****************************************************************************/ +VMINT vm_record_stop(void); + + +/* ===================== audio ========================== */ + + +/* audio operation success */ +#define VM_AUDIO_SUCCEED (0) + +/* audio operation failed */ +#define VM_AUDIO_FAILED (-1) + +/* stop play audio */ +#define VM_AUDIO_RESULT_STOP 1 + +/* pause audio */ +#define VM_AUDIO_RESULT_PAUSE 2 + +/* resume audio */ +#define VM_AUDIO_RESULT_RESUME 3 + +/* play end */ +#define VM_AUDIO_RESULT_END_OF_FILE 5 + +/* demo end time */ +#define VM_AUDIO_RESULT_DEMO_END 6 + +/* interruptted by others */ +#define VM_AUDIO_RESULT_INTERRUPT 7 + +/* resume from interruptting */ +#define VM_AUDIO_RESULT_INTERRUPT_RESUME 8 + + +/***************************************************************************** + * FUNCTION + * vm_audio_play_file + * DESCRIPTION + * play file use default volume(3) and path(VM_DEVICE_SPEAKER2). + * PARAMETERS + * filename : [IN] file name to play. + * f : [IN] callback function. + * RETURNS + * play a file success or not. + * RETURN VALUES + * VM_AUDIO_FAILED : play a file failed. + * VM_AUDIO_SUCCEED : play a file success. +*****************************************************************************/ +VMINT vm_audio_play_file(VMWSTR filename, void (*f)(VMINT result)); + +/***************************************************************************** + * FUNCTION + * vm_audio_play_file_ex + * DESCRIPTION + * play file use default volume(3) but set start time and path. + * PARAMETERS + * filename : [IN] file name to play. + * start_time : [IN] start time to play. + * path : [IN] play path. + * VM_DEVICE_SPEAKER Tone, Keypad sound to play on audio device. + * VM_DEVICE_MICROPHONE Microphone sound to send on audio device. + * VM_DEVICE_SPEAKER2 Earphone, carkit + * VM_DEVICE_LOUDSPEAKER Loudspeaker for free sound + * VM_DEVICE_SPEAKER_BOTH Output from earphone and loud speaker + * VM_DEVICE_BT_HEADSET Used to be OR bitwise with above audio output devices + * f : [IN] callback function. + * RETURNS + * play a file success or not. + * RETURN VALUES + * VM_AUDIO_FAILED : play a file failed. + * VM_AUDIO_SUCCEED : play a file success. +*****************************************************************************/ +VMINT vm_audio_play_file_ex(VMWSTR filename, VMUINT start_time, VMUINT path, void (*f)(VMINT result)); + +/***************************************************************************** + * FUNCTION + * vm_audio_play_bytes + * DESCRIPTION + * play buffer use default volume(3) but set start time and path. + * PARAMETERS + * audio_data : [IN] audio buffer to play. + * len : [IN] buffer length. + * format : [IN] buffer format, only support mp3 and aac. + * start_time : [IN] start time to play. + * path : [IN] play path. + * VM_DEVICE_SPEAKER Tone, Keypad sound to play on audio device. + * VM_DEVICE_MICROPHONE Microphone sound to send on audio device. + * VM_DEVICE_SPEAKER2 Earphone, carkit + * VM_DEVICE_LOUDSPEAKER Loudspeaker for free sound + * VM_DEVICE_SPEAKER_BOTH Output from earphone and loud speaker + * VM_DEVICE_BT_HEADSET Used to be OR bitwise with above audio output devices + * f : [IN] callback function. + * RETURNS + * play buffer success or not. + * RETURN VALUES + * VM_AUDIO_FAILED : play buffer failed. + * VM_AUDIO_SUCCEED : play buffer success. +*****************************************************************************/ +VMINT vm_audio_play_bytes(void *audio_data, VMUINT len, VMUINT8 format, VMUINT start_time, VMUINT path, void (*f)(VMINT result)); + + +/***************************************************************************** + * FUNCTION + * vm_audio_play_bytes_no_block + * DESCRIPTION + * play buffer use default volume(3) but set path, this is no block function. + * PARAMETERS + * audio_data : [IN] audio buffer to play. + * len : [IN] buffer length. + * format : [IN] buffer format, only support mp3 and aac. + * path : [IN] play path. + * VM_DEVICE_SPEAKER Tone, Keypad sound to play on audio device. + * VM_DEVICE_MICROPHONE Microphone sound to send on audio device. + * VM_DEVICE_SPEAKER2 Earphone, carkit + * VM_DEVICE_LOUDSPEAKER Loudspeaker for free sound + * VM_DEVICE_SPEAKER_BOTH Output from earphone and loud speaker + * VM_DEVICE_BT_HEADSET Used to be OR bitwise with above audio output devices + * f : [IN] callback function. + * RETURNS + * play buffer success or not. + * RETURN VALUES + * VM_AUDIO_FAILED : play buffer failed. + * VM_AUDIO_SUCCEED : play buffer success. +*****************************************************************************/ +VMINT vm_audio_play_bytes_no_block(void *audio_data, VMUINT len, VMUINT8 format, VMUINT path, void (*f)(VMINT result)); + + +/***************************************************************************** + * FUNCTION + * vm_audio_pause + * DESCRIPTION + * pause audio. + * PARAMETERS + * f : [IN] callback function. + * RETURNS + * pause success or not. + * RETURN VALUES + * VM_AUDIO_FAILED : pause failed. + * VM_AUDIO_SUCCEED : pause success. +*****************************************************************************/ +VMINT vm_audio_pause(void (*f)(VMINT result)); + +/***************************************************************************** + * FUNCTION + * vm_audio_resume + * DESCRIPTION + * resume audio. + * PARAMETERS + * f : [IN] callback function. + * RETURNS + * resume success or not. + * RETURN VALUES + * VM_AUDIO_FAILED : resume failed. + * VM_AUDIO_SUCCEED : resume success. +*****************************************************************************/ +VMINT vm_audio_resume(void (*f)(VMINT result)); + +/***************************************************************************** + * FUNCTION + * vm_audio_stop + * DESCRIPTION + * stop audio. + * PARAMETERS + * f : [IN] callback function. + * RETURNS + * stop success or not. + * RETURN VALUES + * VM_AUDIO_FAILED : stop failed. + * VM_AUDIO_SUCCEED : stop success. +*****************************************************************************/ +VMINT vm_audio_stop(void (*f)(VMINT result)); + +/***************************************************************************** + * FUNCTION + * vm_audio_stop_all + * DESCRIPTION + * stop all audios. + * PARAMETERS + * + * RETURNS + * stop success or not. + * RETURN VALUES + * VM_AUDIO_FAILED : stop failed. + * VM_AUDIO_SUCCEED : stop success. +*****************************************************************************/ +VMINT vm_audio_stop_all(void); + +/***************************************************************************** + * FUNCTION + * vm_audio_duration + * DESCRIPTION + * get file time. + * PARAMETERS + * filename : [IN] file name to get time. + * RETURNS + * time timer or failed. + * RETURN VALUES + * VM_AUDIO_FAILED : get time failed. + * Other : audio time. +*****************************************************************************/ +VMINT vm_audio_duration(VMWSTR filename); + +/***************************************************************************** + * FUNCTION + * vm_audio_bytes_duration + * DESCRIPTION + * get buffer time. + * PARAMETERS + * audio_data : [IN] audio buffer to play. + * len : [IN] buffer length. + * format : [IN] buffer format, support mp3,aac,midi,amr. + * RETURNS + * buffer timer or failed. + * RETURN VALUES + * VM_AUDIO_FAILED : play buffer failed. + * Other : buffer time. +*****************************************************************************/ +VMINT vm_audio_bytes_duration(void *audio_data, VMUINT len, VMUINT8 format); + + +/***************************************************************************** + * FUNCTION + * vm_audio_get_time + * DESCRIPTION + * get current play time. + * RETURN VALUES + * VM_AUDIO_FAILED : play buffer failed. + * Other : current play time. +*****************************************************************************/ +VMINT vm_audio_get_time(void); + +/***************************************************************************** + * FUNCTION + * vm_set_volume + * DESCRIPTION + * set play volume. + * PARAMETERS + * volume : [IN] volume to set, range is 0-6. +*****************************************************************************/ +void vm_set_volume(VMINT volume); + + +/* ========================== midi ============================ */ + +/* midi operation success */ +#define VM_MIDI_SUCCEED (0) + +/* midi operation failed */ +#define VM_MIDI_FAILED (-1) + +/* play count once time */ +#define VM_MIDI_PLAY_MAX 9 + +/* midi paly start */ +#define VM_STATE_MIDI_START 1 + +/* midi paly end */ +#define VM_STATE_MIDI_STOP 2 + + +/***************************************************************************** + * FUNCTION + * vm_midi_set_type + * DESCRIPTION + * set midi play format. + * PARAMETERS + * type : [IN] resource id. + * RETURNS + * set midi type + * RETURN VALUES +*****************************************************************************/ +void vm_midi_set_type(VMINT type); + +/***************************************************************************** + * FUNCTION + * vm_midi_play + * DESCRIPTION + * play midi. + * PARAMETERS + * resid : [IN] resource id. + * repeat : [IN] repeat count. + * f : [IN] callback function. + * RETURNS + * if play success return midi handle, else return VM_MIDI_FAILED. + * RETURN VALUES + * VM_MIDI_FAILED : play midi failed. + * Other : midi handle. +*****************************************************************************/ +VMINT vm_midi_play(VMINT resid, VMINT repeat, void (*f)(VMINT handle, VMINT event)); + +/***************************************************************************** + * FUNCTION + * vm_midi_play_ex + * DESCRIPTION + * play midi. + * PARAMETERS + * resid : [IN] resource id. + * start_time : [IN] time to play. + * repeat : [IN] repeat count. + * path : [IN] play path. + * VM_DEVICE_SPEAKER Tone, Keypad sound to play on audio device. + * VM_DEVICE_MICROPHONE Microphone sound to send on audio device. + * VM_DEVICE_SPEAKER2 Earphone, carkit + * VM_DEVICE_LOUDSPEAKER Loudspeaker for free sound + * VM_DEVICE_SPEAKER_BOTH Output from earphone and loud speaker + * VM_DEVICE_BT_HEADSET Used to be OR bitwise with above audio output devices + * f : [IN] callback function. + * RETURNS + * if play success return midi handle, else return VM_MIDI_FAILED. + * RETURN VALUES + * VM_MIDI_FAILED : play midi failed. + * Other : midi handle. +*****************************************************************************/ +VMINT vm_midi_play_ex(VMINT resid, VMUINT start_time, VMINT repeat, VMUINT path, void (*f)(VMINT handle, VMINT event)); + +/***************************************************************************** + * FUNCTION + * vm_midi_play_by_bytes + * DESCRIPTION + * play buffer. + * PARAMETERS + * midibuf : [IN] buffer data. + * len : [IN] buffer length. + * repeat : [IN] repeat count. + * f : [IN] callback function. + * RETURNS + * if play success return midi handle, else return VM_MIDI_FAILED. + * RETURN VALUES + * VM_MIDI_FAILED : play midi failed. + * Other : midi handle. +*****************************************************************************/ +VMINT vm_midi_play_by_bytes( VMUINT8 * midibuf, VMINT len, VMINT repeat, void (*f)(VMINT handle, VMINT event) ); + +/***************************************************************************** + * FUNCTION + * vm_midi_play_ex + * DESCRIPTION + * play midi. + * PARAMETERS + * midibuf : [IN] buffer data. + * len : [IN] buffer length. + * start_time : [IN] time to play. + * repeat : [IN] repeat count. + * path : [IN] play path. + * VM_DEVICE_SPEAKER Tone, Keypad sound to play on audio device. + * VM_DEVICE_MICROPHONE Microphone sound to send on audio device. + * VM_DEVICE_SPEAKER2 Earphone, carkit + * VM_DEVICE_LOUDSPEAKER Loudspeaker for free sound + * VM_DEVICE_SPEAKER_BOTH Output from earphone and loud speaker + * VM_DEVICE_BT_HEADSET Used to be OR bitwise with above audio output devices + * f : [IN] callback function. + * RETURNS + * if play success return midi handle, else return VM_MIDI_FAILED. + * RETURN VALUES + * VM_MIDI_FAILED : play midi failed. + * Other : midi handle. +*****************************************************************************/ +VMINT vm_midi_play_by_bytes_ex( VMUINT8 * midibuf, VMINT len, VMUINT start_time, VMINT repeat, VMUINT path, void (*f)(VMINT handle, VMINT event) ); + +/***************************************************************************** + * FUNCTION + * vm_midi_pause + * DESCRIPTION + * pause audio. + * PARAMETERS + * handle : [IN] play handle. + * RETURNS + * pause success or not. + * RETURN VALUES + * 0 : resume success. + * others : resume failed. +*****************************************************************************/ +VMINT vm_midi_pause(VMINT handle); + +/***************************************************************************** + * FUNCTION + * vm_midi_resume + * DESCRIPTION + * resume audio. + * PARAMETERS + * handle : [IN] play handle. + * RETURNS + * resume success or not. + * RETURN VALUES + * 0 : resume success. + * others : resume failed. +*****************************************************************************/ +VMINT vm_midi_resume(VMINT handle); + +/***************************************************************************** + * FUNCTION + * vm_midi_get_time + * DESCRIPTION + * get play time. + * PARAMETERS + * handle : [IN] play handle. + * current_time : [OUT] play time. + * RETURNS + * get play time success or not. + * RETURN VALUES + * 0 : resume success. + * others : resume failed. +*****************************************************************************/ +VMINT vm_midi_get_time(VMINT handle, VMUINT *current_time); + +/***************************************************************************** + * FUNCTION + * vm_midi_stop + * DESCRIPTION + * stop midi. + * PARAMETERS + * handle : [IN] play handle. + * RETURNS + * stop success or not. + * RETURN VALUES + * VM_MIDI_SUCCEED : stop success. + * VM_MIDI_FAILED : stop failed. +*****************************************************************************/ +void vm_midi_stop(VMINT handle); + +/***************************************************************************** + * FUNCTION + * vm_midi_stop_all + * DESCRIPTION + * stop all opened midi. + * EXAMPLE +*****************************************************************************/ +void vm_midi_stop_all(void); + +/***************************************************************************** + * FUNCTION + * vm_set_key_tone_on + * DESCRIPTION + * set key tone on. +*****************************************************************************/ +void vm_set_key_tone_on(void); + +/***************************************************************************** + * FUNCTION + * vm_set_key_tone_off + * DESCRIPTION + * set key tone off. +*****************************************************************************/ +void vm_set_key_tone_off(void); + +/* key tone type */ +typedef enum +{ + VM_KEY_TONE_ENABLED = 0, /* Not Disable all key tone */ + VM_KEY_VOL_TONE_DISABLED, /* Disable VOL_UP VOL_DOWN key tone */ + VM_KEY_VOL_UP_DOWN_TONE_DISABLED, /* Disable VOL_UP, VOL_DOWN, UP_ARROW, DOWN_ARROW key tone */ + VM_KEY_RIGHT_LEFT_ARROW_TONE_DISABLED, /* Disable LEFT ARROW, RIGHT ARROW */ + VM_KEY_TONE_DISABLED, /* Disable all key tone */ + VM_KEY_TONE_INVALID +} vm_kbd_tone_state_enum; + +/***************************************************************************** + * FUNCTION + * vm_get_key_tone_state + * DESCRIPTION + * get current key tone states. + * RETURNS + * key tone states, please refer the struct of vm_kbd_tone_state_enum. +*****************************************************************************/ +vm_kbd_tone_state_enum vm_get_key_tone_state(void); + +/***************************************************************************** + * FUNCTION + * vm_set_key_tone_state + * DESCRIPTION + * set key tone states. + * PARAMETERS + * key_tone_state : [IN] key tone states to set. + * RETURNS + * set key tone states success or not. + * RETURN VALUES + * FALSE : set key tone states failed. + * TRUE : set key tone states success. +*****************************************************************************/ +VMINT vm_set_key_tone_state(vm_kbd_tone_state_enum key_tone_state); + + +/***************************************************************************** + * FUNCTION + * vm_set_ringtone + * DESCRIPTION + * set file as ringtone. + * PARAMETERS + * filepath : [IN] the path for setting ringtone. + * RETURNS + * set ringtone success or not. + * RETURN VALUES + * >0 : the slot of set ringtone + * VM_KURO_FAILED : set ringtone error +*****************************************************************************/ +VMINT vm_set_ringtone(VMWSTR filepath); + +/***************************************************************************** +* FUNCTION +* vm_audio_resume_bg_play +* DESCRIPTION +* resume background audio +*****************************************************************************/ +void vm_audio_resume_bg_play(void); + +/***************************************************************************** +* FUNCTION +* vm_audio_suspend_bg_play +* DESCRIPTION +* suspend background audio +*****************************************************************************/ +void vm_audio_suspend_bg_play(void); + + +typedef void (*vm_audio_mixed_callback_p) (VMINT handle, VMINT result, void* user_data); + +typedef struct +{ + void* data; /* String data. */ + VMINT32 data_len; /* The length of string data. Don't care if using file name */ + vm_format_enum format; /* Audio format, please refer vm_format_enum */ + VMINT8 repeats; /* Repate times */ + VMINT8 output_path; /* Output path. Use VM_DEVICE_SPEAKER2 for default setting */ + VMBOOL async_mode; /* Async mode, if this is TRUE, play and stop will be asynchronous */ + vm_audio_mixed_callback_p callback; /* Callback function */ + void* user_data; /* User data */ +} vm_auido_mixed_open_struct; + + +/***************************************************************************** + * FUNCTION + * vm_audio_mixed_set_speedup_mode + * DESCRIPTION + * Speed mode, if this is TRUE, play and stop will speed up, but this will use on mixed channel, + * Example : if the paltformat support 5 channels to mixed, if you set this is TRUE , application + * only can use 4 channels to play + * PARAMETERS + * mode : [IN] TRUE + * RETURNS + * RETURN VALUES +*****************************************************************************/ +void vm_audio_mixed_set_speedup_mode(VMBOOL mode); + +/***************************************************************************** + * FUNCTION + * vm_audio_mixed_open + * DESCRIPTION + * this function support mixed audio's play, support format is VM_FORMAT_WAV,VM_FORMAT_MIDI,VM_FORMAT_IMELODY, + * other audio format only can play, but could not mixed. + * PARAMETERS + * mixed_play : [IN] open parameters, please refer vm_auido_mixed_open_struct. + * RETURNS + * if open success , it will return handle, else return VM_AUDIO_FAILED. + * RETURN VALUES + * VM_AUDIO_FAILED : mixed play open failed. + * Other : play handle. +*****************************************************************************/ +VMINT vm_audio_mixed_open(vm_auido_mixed_open_struct* mixed_open); + + +/***************************************************************************** + * FUNCTION + * vm_audio_mixed_play + * DESCRIPTION + * play the audio + * PARAMETERS + * handle : [IN] play parameters, please refer vm_auido_mixed_play_struct. + * RETURNS + * play success or not. + * RETURN VALUES + * VM_AUDIO_SUCCEED : mixed play success. + * Other : play failed. +*****************************************************************************/ +VMINT vm_audio_mixed_play(VMINT handle); + + +/***************************************************************************** + * FUNCTION + * vm_audio_mixed_pause + * DESCRIPTION + * pause audio. + * PARAMETERS + * handle : [IN] audio handle, get from vm_audio_mixed_open + * RETURNS + * pause success or not. + * RETURN VALUES + * VM_AUDIO_SUCCEED : resume success. + * others : resume failed. +*****************************************************************************/ +VMINT vm_audio_mixed_pause(VMINT handle); + +/***************************************************************************** + * FUNCTION + * vm_audio_mixed_resume + * DESCRIPTION + * resume audio. + * PARAMETERS + * handle : [IN] audio handle, get from vm_audio_mixed_open + * RETURNS + * resume success or not. + * RETURN VALUES + * VM_AUDIO_SUCCEED : resume success. + * others : resume failed. +*****************************************************************************/ +VMINT vm_audio_mixed_resume(VMINT handle); + + +/***************************************************************************** + * FUNCTION + * vm_audio_mixed_set_start_time + * DESCRIPTION + * set start time to play. + * PARAMETERS + * handle : [IN] audio handle, get from vm_audio_mixed_open + * current_time : [IN] start time. + * RETURNS + * set start time success or not. + * RETURN VALUES + * VM_AUDIO_SUCCEED : set time success. + * others : set time failed. +*****************************************************************************/ +VMINT vm_audio_mixed_set_start_time(VMINT handle, VMUINT start_time); + + +/***************************************************************************** + * FUNCTION + * vm_audio_mixed_get_time + * DESCRIPTION + * get current play time. + * PARAMETERS + * handle : [IN] audio handle, get from vm_audio_mixed_open + * current_time : [OUT] play time. + * RETURNS + * get play time success or not. + * RETURN VALUES + * VM_AUDIO_SUCCEED : get time success. + * others : get time failed. +*****************************************************************************/ +VMINT vm_audio_mixed_get_time(VMINT handle, VMUINT *current_time); + +/***************************************************************************** + * FUNCTION + * vm_audio_mixed_stop + * DESCRIPTION + * stop the opened audio. + * PARAMETERS + * handle : [IN] audio handle, get from vm_audio_mixed_open + * RETURNS +*****************************************************************************/ +void vm_audio_mixed_stop(VMINT handle); + +/***************************************************************************** + * FUNCTION + * vm_audio_mixed_close + * DESCRIPTION + * close the opened audio. + * PARAMETERS + * handle : [IN] audio handle, get from vm_audio_mixed_open + * RETURNS +*****************************************************************************/ +void vm_audio_mixed_close(VMINT handle); + + +/***************************************************************************** + * FUNCTION + * vm_audio_mixed_close_all + * DESCRIPTION + * close all opened mixed audio. + * EXAMPLE +*****************************************************************************/ +void vm_audio_mixed_close_all(void); + + +/***************************************************************************** + * FUNCTION + * vm_audio_register_interrupt_callback + * DESCRIPTION + * register interrupt callback, when audio was interrupted it will invoke this callback + * PARAMETERS + * callback : [IN] callback function pointer + * RETURNS + * handle of the app + * RETURN VALUES + * 0 : error + * other : handle of the app +*****************************************************************************/ +VMINT vm_audio_register_interrupt_callback(vm_audio_result_callback callback); + + +/***************************************************************************** + * FUNCTION + * vm_audio_clear_interrupt_callback + * DESCRIPTION + * clear interrupt callback + * PARAMETERS + * handle : [IN] get from vm_audio_register_interrupt_callback + * RETURNS + * +*****************************************************************************/ +void vm_audio_clear_interrupt_callback(VMINT handle); + +/***************************************************************************** + * FUNCTION + * vm_audio_play_beep + * DESCRIPTION + * when other app use audio play, application can use this to play notification tone + * PARAMETERS + * + * RETURNS + * +*****************************************************************************/ +void vm_audio_play_beep(void); + + +/***************************************************************************** + * FUNCTION + * vm_audio_is_app_playing + * DESCRIPTION + * this is to check if there is other applications are palying + * PARAMETERS + * + * RETURNS + * TRUE: other application is playing + * FLASE: no there is palying +*****************************************************************************/ +VMBOOL vm_audio_is_app_playing(void); + + +/***************************************************************************** + * FUNCTION + * vm_audio_terminate_background_play + * DESCRIPTION + * terminate background play , if the LINKIT appliction is audio player, please use it. + * PARAMETERS +*****************************************************************************/ +void vm_audio_terminate_background_play(void); + + +/***************************************************************************** + * FUNCTION + * vm_get_volume + * DESCRIPTION + * get current volume + * PARAMETERS + * + * RETURNS + * volume value + * +*****************************************************************************/ +VMINT vm_get_volume(void); + + +/***************************************************************************** + * FUNCTION + * vm_audio_is_calling + * DESCRIPTION + * quer is calling now + * PARAMETERS + * + * RETURNS + * TRUE or FALSE + * +*****************************************************************************/ +VMINT vm_audio_is_calling(void); + + +/***************************************************************************** + * FUNCTION + * vm_audio_set_volume_type + * DESCRIPTION + * set volume type, media or ring, media only cosmos project support + * PARAMETERS + * type 0-ring 1-media + * RETURNS + * TRUE or FALSE + * +*****************************************************************************/ +VMINT vm_audio_set_volume_type(VMINT type); + +/***************************************************************************** + * FUNCTION + * vm_audio_set_sph_volume + * DESCRIPTION + * set speech volume + * PARAMETERS + * volume + * RETURNS + * +*****************************************************************************/ +void vm_audio_set_sph_volume(VMINT volume); + +/***************************************************************************** + * FUNCTION + * vm_audio_get_sph_mode_volume + * DESCRIPTION + * get speech volume + * PARAMETERS + * void + * RETURNS + * volume value +*****************************************************************************/ +VMINT vm_audio_get_sph_mode_volume(void); + +#ifdef __cplusplus +} +#endif + +#endif /* VMMM_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmmms.h b/hardware/arduino/mtk/system/libmtk/include/vmmms.h new file mode 100644 index 00000000..c94b385f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmmms.h @@ -0,0 +1,1183 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMMMS_SDK_H +#define VMMMS_SDK_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/** + *maxium length of xml file path, including '\0' + */ +#define MAX_MMS_APP_NAME_LEN 100 + +/*Max length of address MMS adaptor supports*/ +#define VM_MMS_MAX_ADDR_LEN 128 +/*Max length of subbject MMS adaptor supports*/ +#define VM_MMS_MAX_SUBJECT_LEN 41 + +#define VM_MMS_MSG_ID_LIST_LEN 100 +typedef enum +{ + VM_MMS_CANCEL = -3, /*user cancelled sending*/ + VM_MMS_FAIL = -2, /*operation request error*/ + VM_MMS_MEMORY_NOT_ENOUGH = -1, /*not enough memory*/ + VM_MMS_SUCCESS /*operation successfully*/ + }vm_mms_result_enum; + +typedef enum +{ + VM_MMS_TYPE_SMIL_MMS = 0, /*SMIL type of XML */ + VM_MMS_TYPE_MIXED_MMS /*MIXED type of XML */ +}vm_mms_type_enum; + +typedef enum +{ + VM_MMS_SIM_ID_SIM1 = 0x01, /*sim1 card */ + VM_MMS_SIM_ID_SIM2 = 0x02, /*sim2 card */ + VM_MMS_SIM_ID_SIM3 = 0x04, /*sim3 card */ + VM_MMS_SIM_ID_SIM4 = 0x08, /*sim4 card */ +}vm_mms_sim_id_enum; + +typedef struct +{ + VMUWCHAR xml_filepath[MAX_MMS_APP_NAME_LEN];/*XML file path*/ + VMUINT xml_size; /*XML file size*/ + VMUINT8 mms_type; /*refer to vm_mms_type_enum*/ + VMUINT8 sim_id; /*refer to vm_mms_sim_id_enum*/ +}vm_send_mms_req_t; + +typedef enum +{ + VM_MMS_ADDR_PHONE_NUM = 0, + VM_MMS_ADDR_EMAIL, + VM_MMS_ADDR_IP +}vm_mms_addr_type_enum; + + + +typedef enum +{ + VM_EVT_ID_MMS_NEW_MSG, + VM_EVT_ID_MMS_MAX_ENUM +}vm_mms_event_enum; + + +/* This enum is used to specify MMS contains only one media type objects. */ +typedef enum +{ + VM_MMS_MEDIA_MSG_NONE = 0, /* Not specified */ + VM_MMS_MEDIA_MSG_TEXT, /* Text MMS: One MMS only contains text object */ + VM_MMS_MEDIA_MSG_AUDIO, /* Audio MMS: One MMS only contains audio object */ + VM_MMS_MEDIA_MSG_PHOTO, /* Photo MMS: One MMS only contains image object */ + VM_MMS_MEDIA_MSG_VIDEO /* Video MMS: One MMS only contains video object */ +} vm_mms_media_msg_enum; + + +/* This enum is used to specify message type. */ +typedef enum +{ + VM_MMS_MSG_TYPE_NOTIFICATION, /* MMS notification */ + VM_MMS_MSG_TYPE_DELIVERY_REPORT, /* MMS delivery report */ + VM_MMS_MSG_TYPE_READ_REPORT, /* MMS read report v1.1 */ + VM_MMS_MSG_TYPE_MMS, /* normal MMS message */ + VM_MMS_MSG_TYPE_JAVA, /* Java MMS */ + VM_MMS_MSG_TYPE_TEMPLATE, /* MMS template */ + VM_MMS_MSG_TYPE_POSTCARD, /* MMS postcard */ + VM_MMS_MSG_TYPE_UNSUPPORTED +}vm_mms_msg_type_enum; + +typedef enum +{ + VM_MMS_MSG_STORAGE_NONE = 0X00, + VM_MMS_MSG_STORAGE_PHONE = 0X01, + VM_MMS_MSG_STORAGE_CARD1 = 0X02, + VM_MMS_MSG_STORAGE_TOTAL = 0X03 +} vm_mms_msg_storage_type_enum; + +/* This enum is used to specify MMS folder. */ +typedef enum +{ + VM_MMS_FOLDER_NONE = 0x0, + VM_MMS_FOLDER_INBOX = 0x1, + VM_MMS_FOLDER_OUTBOX = 0x2, + VM_MMS_FOLDER_SENT = 0x4, + VM_MMS_FOLDER_DRAFT = 0x8, + VM_MMS_FOLDER_TEMPLATE = 0x10, /* This folder is for predefined MMS template */ + VM_MMS_FOLDER_USRDEF_TEMPLATE = 0x20, /* This folder is for user to save MMS as template */ + VM_MMS_FOLDER_ARCHIVE = 0x40, + VM_MMS_FOLDER_HIDDEN = 0x80, + VM_MMS_FOLDER_REPORT_BOX = 0x100, +}vm_mms_folder_enum; +typedef enum +{ + VM_MMS_RESULT_OK, /* 0 */ + VM_RESULT_DELAYED, /* 1 */ + VM_RESULT_CONTINUE, /* 2 */ + VM_RESULT_FAIL, /* 3 */ + VM_RESULT_FAIL_IN_CALL, /* 4 */ + VM_RESULT_FAIL_NOT_READY, /* 5 */ + VM_RESULT_FAIL_BUSY, /* 6 */ + VM_RESULT_FAIL_INSUFFICIENT_MEMORY, /* 7 */ + VM_RESULT_FAIL_INSUFFICIENT_STORAGE, /* 8 */ + VM_RESULT_FAIL_MAX_MSG_NUM_REACHED, /* 9 */ + VM_RESULT_FAIL_MAX_MSG_SIZE_REACHED, /* 10 */ + VM_RESULT_FAIL_MAX_SLIDE_NUM_REACHED, /* 11 */ + VM_RESULT_FAIL_MAX_ATTACHMENT_NUM_REACHED, /* 12 */ + VM_RESULT_FAIL_FILE_EMPTY, /* 13 */ + VM_RESULT_FAIL_FILE_NOT_FOUND, /* 14 */ + VM_RESULT_FAIL_FILE_CORRUPTED, /* 15 */ + VM_RESULT_FAIL_FILE_IN_USE, /* 16 */ + VM_RESULT_FAIL_FILE_IO, /* 17 */ + VM_RESULT_FAIL_FOLDER_NOT_FOUND, /* 18 */ + VM_RESULT_FAIL_UNSUPPORT_CONTENT, /* 19 */ + VM_RESULT_FAIL_COMM_UNSUPPORT_CONTENT, /* 20 */ + VM_RESULT_FAIL_COMM_CONFIG_ERROR, /* 21 */ + VM_RESULT_FAIL_COMM_CONNECT_ERROR, /* 22 */ + VM_RESULT_FAIL_COMM_SERVER_ERROR, /* 23 */ + VM_RESULT_FAIL_COMM_SERVER_TIMEOUT, /* 24 */ + VM_RESULT_FAIL_COMM_SERVICE_DENIED, /* 25 */ + VM_RESULT_FAIL_COMM_UNKNOWN_APN, /* 26 */ + VM_RESULT_FAIL_COMM_UNAUTHORIZED, /* 27 */ + VM_RESULT_FAIL_USER_CANCEL, /* 28 */ + VM_RESULT_FAIL_INVALID_PARAMETER, /* 29 */ + VM_RESULT_FAIL_INVALID_MSGID, /* 30 */ + VM_RESULT_FAIL_INVALID_FOLDER, /* 31 */ + VM_RESULT_FAIL_QUEUE_FULL, /* 32 */ + VM_RESULT_FAIL_PARSE, /* 33 */ + VM_RESULT_FAIL_MSGID_IS_USING, /* 34 */ + VM_RESULT_FAIL_CREATION_MODE_MAX_MSG_SIZE_REACHED, /* 35 */ + VM_RESULT_FAIL_UPDATE_CHECKSUM_INVALID_PARAM, /* 36 */ + VM_RESULT_FAIL_IN_USB_MODE, /* 37 */ + VM_RESULT_FAIL_FILE_ACCESS_IN_USB_MODE, /* 38 */ + VM_RESULT_FAIL_TERMINATING, /* 39 */ + VM_RESULT_FAIL_USERDEF_TEMPLATE_FULL, /* 40 */ + VM_RESULT_FAIL_WAP_CONN_MAX_MSG_SIZE_REACHED, /* 41 */ + VM_RESULT_OK_WITH_WARNING_CONTENT, /* 42 */ + VM_RESULT_ABORTED, /* 43 */ + VM_RESULT_FAIL_SUSPENDED_MODE, /* 44 */ + VM_RESULT_FAIL_MSG_EXPIRED, /* 45 */ + VM_RESULT_FAIL_IN_VIDEO_CALL, /* 46 */ + VM_RESULT_FAIL_IMAGE_TOO_LARGE, /* 47 */ + VM_RESULT_FAIL_MEM_CARD_NOT_PRESENT, /* 48 */ + VM_RESULT_FAIL_MEM_CARD_NOT_PRESENT_USE_PHONE, /* 49 */ + VM_RESULT_FAIL_MEM_CARD_NOT_PRESENT_INSERT_CARD, /* 50 */ + VM_RESULT_FAIL_MAX_MSG_REACHED_ON_PHONE_MEMORY, /* 51 */ + VM_RESULT_FAIL_MAX_MSG_REACHED_ON_MEM_CARD, /* 52 */ + VM_RESULT_FAIL_MEM_CARD_PLUG_OUT, /* 53 */ + VM_RESULT_FAIL_UNSUPPORT_MMS_TYPE, + VM_RESULT_FAIL_ROOT_DIR_FULL, + /*NEW ADDED AS REMOVAL OF SLS*/ + VM_SMIL_RESULT_SMIL_NOT_CREATED, + VM_SMIL_RESULT_MISSING_MEDIA_OBJECTS, + VM_SMIL_RESULT_MISSING_MEDIA_OBJECT_SRC, + VM_RESULT_END +}vm_result_enum; + +/* This enum is used to specify MMS folder. */ +typedef enum +{ + VM_FOLDER_NONE = 0x0, + VM_FOLDER_INBOX = 0x1, + VM_FOLDER_OUTBOX = 0x2, + VM_FOLDER_SENT = 0x4, + VM_FOLDER_DRAFT = 0x8, + VM_FOLDER_TEMPLATE = 0x10, /* This folder is for predefined MMS template */ + VM_FOLDER_USRDEF_TEMPLATE = 0x20, /* This folder is for user to save MMS as template */ + VM_FOLDER_ARCHIVE = 0x40, + VM_FOLDER_HIDDEN = 0x80, + VM_FOLDER_REPORT_BOX = 0x100, + VM_FOLDER_ALL = 0xFFFF +}vm_folder_enum; + +/* This enum is used to specify MMS creation mode. */ +typedef enum +{ + VM_CREATION_MODE_FREE, /* Creation mode: Free*/ + VM_CREATION_MODE_RESTRICTED, /* Creation mode: Restricted */ + VM_CREATION_MODE_WARNING /* Creation mode: Warning*/ +}vm_creation_mode_enum; + +/* This enum is used to specify the MMS priority. */ +typedef enum +{ + VM_PRIORITY_NOT_SET, /*Prority is not defined */ + VM_PRIORITY_LOW, /*Prority is low */ + VM_PRIORITY_MEDIUM, /*Prority is medium */ + VM_PRIORITY_HIGH /*Prority is high */ +}vm_priority_enum; + +/* This enum is used to specify MMS expiry time. Count by seconds*/ +typedef enum +{ + VM_EXPIRY_NOT_SET = 0, /* epxiry time is not defined */ + VM_EXPIRY_1_HOUR = 3600, /* epxiry time is 1 hour */ + VM_EXPIRY_6_HOURS = 21600, /* epxiry time is 6 hours */ + VM_EXPIRY_12_HOURS = 43200, /* epxiry time is 12 hours */ + VM_EXPIRY_1_DAY = 86400, /* epxiry time is 1 day */ + VM_EXPIRY_1_WEEK = 604800, /* epxiry time is 1 week */ + VM_EXPIRY_MAX = 0 /* epxiry time is not defined */ +}vm_expiry_time_enum; + +/* This enum is used to specify MMS delivery time. */ +typedef enum +{ + VM_DELIVERY_NOT_SET = 0, /* delivery time is not defined */ + VM_DELIVERY_IMMEDIATE = 0, /* delivery time is 0 hour */ + VM_DELIVERY_1_HOUR = 3600, /* delivery time is 1 hours */ + VM_DELIVERY_2_HOUR = 7200, /* delivery time is 2 hours */ + VM_DELIVERY_12_HOURS = 43200, /* delivery time is 12 hours */ + VM_DELIVERY_24_HOURS = 86400 /* delivery time is 1 day */ +}vm_delivery_time_enum; + +/* This enum is used to specify the MMS header field type. */ +typedef enum +{ + VM_HEADER_UNKNOWN, /* Unknowm */ + VM_HEADER_ADDRESS, /* Address */ + VM_HEADER_SUBJECT /* Subject */ +}vm_header_attr_enum; + +/* This enum is used to specify the media type which the object will be inserted as. */ +typedef enum +{ + VM_INSERT_UNKNOWN, /* Unknown */ + VM_INSERT_TEXT, /* Text */ + VM_INSERT_IMAGE, /* image */ + VM_INSERT_AUDIO, /* audio */ + VM_INSERT_VIDEO, /* video */ + VM_INSERT_REF, /* object embeded in tag */ + VM_INSERT_ATTACHMENT /* attachment */ +}vm_insert_type_enum; + +/*This enum is used to specify the DRM type.*/ +typedef enum +{ + VM_DRM_NONE, /*Not DRM object*/ + VM_DRM_FL_CD, /* forward-lock or combined delivery */ + VM_DRM_SD, /* seperate-delivery */ + VM_DRM_SD_NO_RIGHT, /* Separate-delivery object without right */ + VM_DRM_PDCF_V2, /* DRM v2.0 PDCF or V2 object */ + VM_DRM_PDCF_V2_NO_RIGHT, /* DRM v2.0 PDCF or V2 object without right */ + VM_DRM_TYPE_TOTAL +}vm_drm_type_enum; + +/*This enum is used to specify slide layout.*/ +typedef enum +{ + VM_LAYOUT_NONE, /* No relative layout specification */ + VM_LAYOUT_IMAGE_ON_TOP, /* Image on top; text on bottom */ + VM_LAYOUT_TEXT_ON_TOP, /* Text on top; image on bottom */ + VM_LAYOUT_IMAGE_AT_LEFT, /* Image at left; text at right */ + VM_LAYOUT_TEXT_AT_LEFT /* Text at left; image at right */ +}vm_slide_layout_enum; + +/* This enum is used to specify connection type. */ +typedef enum +{ + VM_CONN_TYPE_HTTP_PROXY, /* HTTP connection with proxy */ + VM_CONN_TYPE_HTTP_DIRECT, /* HTTP connection without proxy */ + VM_CONN_TYPE_WSP_CL, /* WSP connectionless */ + VM_CONN_TYPE_WSP_CO, /* WSP connection oriented */ + VM_CONN_TYPE_WSP_SEC_CL, /* WSP connectionless with security */ + VM_CONN_TYPE_WSP_SEC_CO /* WSP connection oriented with security */ +}vm_connection_type_enum; + +/* This enum is used to specify 'text style' like bold and italic. Also, these two are mutually exclusive. */ +typedef enum +{ + VM_TEXT_STYLE_BOLD = 0x01, /* Bold text */ + VM_TEXT_STYLE_ITALIC = 0x02 /* Italic text */ +}vm_text_style_enum; + +/* This enum is used to specify 'text size */ +typedef enum +{ + VM_TEXT_SIZE_SMALL = 1, /* Small text */ + VM_TEXT_SIZE_MEDIUM, /* Medium text */ + VM_TEXT_SIZE_LARGE /* Large text */ +}vm_text_size_enum; + +/* This enum is used to specify address group type. */ +typedef enum +{ + VM_ADDRESS_GROUP_TYPE_TO, + VM_ADDRESS_GROUP_TYPE_CC, + VM_ADDRESS_GROUP_TYPE_BCC, + VM_ADDRESS_GROUP_TYPE_FROM, + VM_ADDRESS_GROUP_TYPE_TOTAL_NUM +} vm_address_group_type_enum; + +/* This enum is used to specify address type. */ +typedef enum +{ + VM_ADDR_TYPE_NONE, /* Unknown */ + VM_ADDR_TYPE_PHONE_NUMBER, /* Phone number */ + VM_ADDR_TYPE_EMAIL, /* Email */ + VM_ADDR_TYPE_IPV4 /* IPv4 */ +}vm_addr_type_enum; + +/* This enum is used to specify message class. */ +typedef enum +{ + VM_MSG_CLASS_NOT_SET, + VM_MSG_CLASS_PERSONAL, /* MMS message is created by person */ + VM_MSG_CLASS_ADVERTISEMENT, /* MMS message is for advertisement */ + VM_MSG_CLASS_INFORMATIONAL, /* MMS message is for informational */ + VM_MSG_CLASS_AUTO /* MMS message is created automatically */ +}vm_msg_class_enum; + +/* This enum is used to specify message type. */ +typedef enum +{ + VM_MSG_TYPE_NOTIFICATION, /* MMS notification */ + VM_MSG_TYPE_DELIVERY_REPORT, /* MMS delivery report */ + VM_MSG_TYPE_READ_REPORT, /* MMS read report v1.1 */ + VM_MSG_TYPE_MMS, /* normal MMS message */ + VM_MSG_TYPE_JAVA, /* Java MMS */ + VM_MSG_TYPE_TEMPLATE, /* MMS template */ + VM_MSG_TYPE_POSTCARD, /* MMS postcard */ + VM_MSG_TYPE_UNSUPPORTED +}vm_msg_type_enum; + +/* This enum is used to specify message status.*/ +typedef enum +{ + VM_MSG_STATUS_WAITING_SENDING, /* The status is for msg in outbox */ + VM_MSG_STATUS_SENDING, /* The status is for msg in outbox */ + VM_MSG_STATUS_WAITING_DOWNLOADING, /* The status is for msg in inbox folder */ + VM_MSG_STATUS_DOWNLOADING, /* The status is for msg in inbox folder */ + VM_MSG_STATUS_NORMAL, /* It is for template, draft, received MMS, delivery report and read report. */ + VM_MSG_STATUS_FAILED /* The status is for msg in sent or inbox folder. In case of inbox folder, the msg shall be mms notification. */ +}vm_msg_status_enum; + +/* This enum is used to specify retrieval mode. */ +typedef enum +{ + VM_RETRIEVAL_MODE_IMMED, /* Immediate retrieval */ + VM_RETRIEVAL_MODE_DEFERRED, /* delayed retrieval */ + VM_RETRIEVAL_MODE_REJECT, /* Reject to retrieve MMS message */ + VM_RETRIEVAL_MODE_AS_HOME /* Same as setting in home network */ +}vm_retrieval_mode_enum; + +/* This enum is used to specify delivery report status (value refer to X-Mms-Status header field). */ +typedef enum +{ + VM_DR_STATUS_PENDING = 0, + VM_DR_STATUS_EXPIRED = 0x80, /* MMS is expired */ + VM_DR_STATUS_RETRIEVED = 0x81, /* MMS is retrieved */ + VM_DR_STATUS_REJECTED = 0x82, /* MMS is rejected */ + VM_DR_STATUS_DEFERRED = 0x83, /* MMS is defered */ + VM_DR_STATUS_UNRECOGNISED = 0x84, /* MMS is unrecognized */ + VM_DR_STATUS_INDETERMINATE = 0x85, /* MMS is indeterminate */ + VM_DR_STATUS_FORWARDED = 0x86, /* MMS is forwarded */ + VM_DR_STATUS_UNREACHABLE = 0x87 /* MMS is unreachable */ +}vm_dr_status_enum; + +/*This enum is used to specify read report status (value refer to X-Mms-Read-Status header field).*/ +typedef enum +{ + VM_RR_STATUS_PENDING = 0, + VM_RR_STATUS_READ = 0x80, /* MMS is read */ + VM_RR_STATUS_DELETED_NO_READ = 0x81 /* MMS is deleted without reading */ +}vm_rr_status_enum; + +/* This enum is used to specify MMS version (value refer to X-Mms-MMS-Version). */ +typedef enum +{ + VM_VERSION_10 = 0x10, /* MMS V1.0 */ + VM_VERSION_11 = 0x11, /* MMS V1.1 */ + VM_VERSION_12 = 0x12 /* MMS V1.2 */ +}vm_version_enum; + +/* This enum is used to specify region fit parameter. */ +typedef enum +{ + VM_REGION_FIT_NONE, /* Not specified */ + VM_REGION_FIT_MEET, /* Scale the object so that its aspect ratio is kept, and it is stays fully visible */ + VM_REGION_FIT_SCROLL, /* Scale the object so that its aspect ratio is kept, and some parts are cropped */ + VM_REGION_FIT_HIDDEN, /* Do not resize the media object, but fill the box with the background color, or crop the object */ + VM_REGION_FIT_FILL, /* Resize the media object so that it fills the width and height defined in the SMIL document */ + VM_REGION_FIT_SLICE /* Add a scrolling mechanism if the object exceeds the box */ +}vm_region_fit_enum; + +/* This enum is used to specify text encoding charset (value refer to IANA MIBEnum).*/ +typedef enum +{ + VM_CHARSET_UNKNOWN = 0, /* Not specified */ + VM_CHARSET_ASCII = 3, /* ASCII */ + VM_CHARSET_ISO_8859_1 = 4, /* ISO 8859-1 */ + VM_CHARSET_UTF8 = 106, /* UFT8 */ + VM_CHARSET_UCS2 = 1000, /* UCS2 */ + VM_CHARSET_UTF16BE = 1013, /* UTF16BE */ + VM_CHARSET_UTF16LE = 1014, /* UTF16LE */ + VM_CHARSET_UTF16 = 1015, /* UTF16 */ + VM_CHARSET_GB2312 = 2025, /* GB2312 */ + VM_CHARSET_BIG5 = 2026 /* BIG5 */ +}vm_charset_enum; + +/* This enum is used to specify UC filter mode. */ +typedef enum +{ + VM_UC_FILTER_MODE_AUDIO_OPEN_MODE, /*audio type when creation mode is free*/ + VM_UC_FILTER_MODE_IMAGE_OPEN_MODE, /*image type when creation mode is free*/ + VM_UC_FILTER_MODE_TEXT_OPEN_MODE, /*text type when creation mode is free*/ + VM_UC_FILTER_MODE_VIDEO_OPEN_MODE, /*video type when creation mode is free*/ + VM_UC_FILTER_MODE_ATTACHMENT_OPEN_MODE, /*image type when creation mode is free*/ + VM_UC_FILTER_MODE_AUDIO_RESTRICTED_MODE, /*audio type when creation mode is restricted*/ + VM_UC_FILTER_MODE_IMAGE_RESTRICTED_MODE, /*image type when creation mode is restricted*/ + VM_UC_FILTER_MODE_TEXT_RESTRICTED_MODE, /*text type when creation mode is restricted*/ + VM_UC_FILTER_MODE_VIDEO_RESTRICTED_MODE, /*video type when creation mode is restricted*/ + VM_UC_FILTER_MODE_ATTACHMENT_RESTRICTED_MODE /*image type when creation mode is restricted*/ +}vm_uc_filter_mode_enum; + +/* This enum is used to specify UC filter mode. */ +typedef enum +{ + VM_EVENT_NEW_MSG, /* For new message */ + VM_EVENT_DELETE_MSG, /* When one message is deleted. Send after delete. */ + VM_EVENT_SAVE_MSG, /* When one message is saved to another folder. Send after saved. */ + VM_EVENT_DELETE_FOLDER, /* Send before delete a folder */ + VM_EVENT_UM_DELETE_FOLDER_DONE, /* Send after MMA finish deleting folder */ + VM_EVENT_TOTAL +}vm_event_enum; + +/* This enum is used to specify MMS contains only one media type objects. */ +typedef enum +{ + VM_MEDIA_MSG_NONE = 0, /* Not specified */ + VM_MEDIA_MSG_TEXT, /* Text MMS: One MMS only contains text object */ + VM_MEDIA_MSG_AUDIO, /* Audio MMS: One MMS only contains audio object */ + VM_MEDIA_MSG_PHOTO, /* Photo MMS: One MMS only contains image object */ + VM_MEDIA_MSG_VIDEO /* Video MMS: One MMS only contains video object */ +} vm_media_msg_enum; + + +/* This enum is used to specify MMS sending size limit */ +typedef enum +{ + VM_SETTING_SIZE_LIMIT_100 = 102400, /* 100KB */ + VM_SETTING_SIZE_LIMIT_300 = 307200, /* 300KB */ + VM_SETTING_SIZE_LIMIT_600 = 614400, /* 600KB */ + VM_SETTING_SIZE_LIMIT_MAX +}vm_setting_size_limit_enum; + +typedef enum +{ + VM_TRUNCATED_ATTACHMENT = 0X01, + VM_TRUNCATED_SLIDE = 0X02, + VM_TRUNCATE_TEXT = 0X04, + VM_TRUNCATED_TOTAL = 0XFF +}vm_content_truncated_enum; + + +typedef enum +{ + VM_MSG_STORAGE_NONE = 0X00, + VM_MSG_STORAGE_PHONE = 0X01, + VM_MSG_STORAGE_CARD1 = 0X02, + VM_MSG_STORAGE_TOTAL = 0X03 +} vm_msg_storage_type_enum; + +typedef enum +{ + VM_MMS_STORAGE_ACTION_COPY_MMS, + VM_MMS_STORAGE_ACTION_MOVE_MMS, + VM_MMS_STORAGE_ACTION_TOTAL +}vm_mms_storage_action_type_enum; + +/* This enum is used to specify delivery report status (value refer to X-Mms-Status header field). */ +typedef enum +{ + VM_MSG_ICON_STATUS_NONE = 0, + VM_MSG_ICON_STATUS_WAITING_FOR_SEND, /* MMS status is waiting sending */ + VM_MSG_ICON_STATUS_SENDING, /* MMS status is sending */ + VM_MSG_ICON_STATUS_SEND_FAIL, /* MMS status is send failed */ + VM_MSG_ICON_STATUS_POSTPONE_FOR_SEND, /* MMS status is defered to send*/ + VM_MSG_ICON_STATUS_CORRUPTED_MMS, /* MMS status is corrupted mms*/ + VM_MSG_ICON_STATUS_JAVA_MMS, /* MMS status is JAVA mms */ + VM_MSG_ICON_STATUS_PRIO_HIGH_MMS, /* MMS status is high priority MMS */ + VM_MSG_ICON_STATUS_PRIO_LOW_MMS, /* MMS status is low priority MMS */ + VM_MSG_ICON_STATUS_PRIO_MED_MMS, /* MMS status is Medium/default priority MMS */ + VM_MSG_ICON_STATUS_DR_MMS, /* MMS status is Delivery Report */ + VM_MSG_ICON_STATUS_RR_MMS, /* MMS status is Read Report */ + VM_MSG_ICON_STATUS_DRAFT_MMS, /* MMS status is draft/Normal MMS */ + VM_MSG_ICON_STATUS_NOTIFICATION_MMS, /* MMS status is Notification */ + VM_MSG_ICON_TOTAL_MAX_STATUS /* Total MAX MMS status */ +}vm_msg_icon_status_enum; + + +typedef enum +{ + VM_MMS_FROM_ADDRESS_PRESENT = 128, /*!< The address is added by the client */ + VM_MMS_FROM_INSERT_ADDRESS = 129 /*!< The address is added by the server */ +} vm_mms_from_type_enum; + + +typedef enum +{ + VM_MMS_TIME_ABSOLUTE = 128, + VM_MMS_TIME_RELATIVE = 129 +} vm_mms_time_type_enum; + + +typedef enum +{ + VM_MMS_READ_REPLY_NOT_SET = 0, + VM_MMS_READ_REPLY_YES = 128, /*!< Read reply is requested. */ + VM_MMS_READ_REPLY_NO = 129 /*!< Read reply is not requested. */ +} vm_mms_read_reply_enum; + + +typedef enum +{ + VM_MMS_DELIVERY_REPORT_NOT_SET = 0, + VM_MMS_DELIVERY_REPORT_YES = 128, /*!< Delivery report is requested. */ + VM_MMS_DELIVERY_REPORT_NO = 129 /*!< Delivery report is not requested. */ +} vm_mms_delivery_report_enum; + + +typedef enum +{ + VM_MMS_SENDER_VISIBILITY_NOT_SET = 0, /*!< Show unless sender has secret address*/ + VM_MMS_SENDER_HIDE = 128, /*!< Don't show the address. */ + VM_MMS_SENDER_SHOW = 129 /*!< Show even secret address. */ +} vm_mms_sender_visibility_enum; + + +typedef enum +{ + VM_MMS_OBJECT_TYPE_IMAGE, + VM_MMS_OBJECT_TYPE_AUDIO, + VM_MMS_OBJECT_TYPE_VIDEO, + VM_MMS_OBJECT_TYPE_TEXT, + VM_MMS_OBJECT_TYPE_ATTACHMENT, + VM_MMS_OBJECT_TYPE_REF, /*needed by UC*/ + VM_MMS_OBJECT_TYPE_UNKNOWN, + VM_MMS_OBJECT_TYPE_MAX +} vm_mms_viewer_object_type_enum; + +/* This enum is used to define UC current state of operation. It will be need to set when launch UC. As each state have different type of flow. */ +typedef enum +{ + VM_MMS_STATE_WRITE_NEW_MSG, /* Writing new msg state. */ + VM_MMS_STATE_EDIT_EXISTED_MSG, /* Edit existing msg state. */ + VM_MMS_STATE_FORWARD, /* Forward existing msg state. Only for inbox and sent box msgs. */ + VM_MMS_STATE_SEND, /* Send existing msg state. Only for outbox and draft box msgs. */ + VM_MMS_STATE_REPLY, /* Reply existing msg state. */ + VM_MMS_STATE_REPLY_ALL, /* Reply all existing msg state. */ + VM_MMS_STATE_TOTAL_NUM /* Max number of msg states in UC. */ +} vm_mms_state_enum; + +/* This enum is used to specify the group types of addresses. */ +typedef enum +{ + VM_MMS_ADDRESS_GROUP_TYPE_TO, /* To group. */ + VM_MMS_ADDRESS_GROUP_TYPE_CC, /* Cc group. */ + VM_MMS_ADDRESS_GROUP_TYPE_BCC, /* Bcc group. */ + VM_MMS_ADDRESS_GROUP_TYPE_FROM, /* From group. */ + VM_MMS_ADDRESS_GROUP_TYPE_TOTAL_NUM /* Max number of address group. */ +} vm_mms_address_group_type_enum; + + +typedef struct +{ + VMUINT msg_id; /* Message id */ + VMUINT msg_size; /* The size of message. Counted by byte */ + VMUINT user_elements_size; /* The size of MMS bodies and subject*/ + VMUINT date; /* The date field is in mms header of mms message. It should be given in seconds since 1.Jan. 1970 GMT. */ + VMUINT expiry_date; /* Expiration date. The format is in relative seconds value. */ + VMUINT received_date; /* Received date. This value is only valid for the received MMS message. */ + VMINT16 from_address[VM_MMS_MAX_ADDR_LEN]; /* SRV_MMS_MAX_ADDR_LEN From address of the MMS. Encoded by USC2 */ + VMINT16 subject[VM_MMS_MAX_SUBJECT_LEN]; /* SRV_MMS_MAX_SUBJECT_LEN Subject of the MMS. Encoded by USC2 */ + VMBOOL need_read_report; /* Specify if the MMS message require to send read report to sender. */ + VMBOOL isRead; /* Specify if the MMS message is already read. */ + VMBOOL isForwardLock; /* When MMS contain any DRM forward-lock or combine-delivery object, the value is KAL_TRUE. Because separate-delivery DRM object can be forwarded. */ + VMBOOL isDRM; /* When MMS contain any DRM object, the value is KAL_TRUE */ + VMBOOL isFollowPhoneMMSContentClass; /* Specify if the MMS follow handset content class */ + VMBOOL hasAttachment; /* Specify if the MMS message contain any attachment. */ + VMUINT8 result; /* 0 means success, other fail */ + VMUINT8 msg_media_type; /* vm_mms_media_msg_enum, media type , for no media=0,text=1,audio=2,photo=3,video=4 */ + VMUINT8 from_address_type; /* vm_mms_addr_type_enum, from address type,unknown=0,phone=1,email=2,IPV4=3 */ + VMUINT8 msg_type; /* vm_mms_msg_type_enum, message type Notification=0,DR=1,RR=2,MMS=3,JAVA=4,Template=5,postcard=6 */ + VMUINT8 storage_type; /* vm_mms_msg_storage_type_enum, storage type,phone=1,card=2*/ + VMUINT8 sim_id; /* vm_mms_sim_id_enum, sim ID SIM1=1 SIM2=2 SIM3=4 ,SIM4=8 */ +}vm_mms_msg_info; + +typedef struct +{ + VMINT sim; // sim card :1,2,3,4 + vm_mms_addr_type_enum addr_type; + VMWCHAR* addr; // address UCS2 + VMWCHAR* subject; //subject UCS2 + VMWCHAR* content; //content UCS2 + VMWCHAR* att_path; //attach_file +}vm_mms_launch_data; + +typedef struct +{ + VMINT result; //0 means success + VMINT msg_num; + VMINT msg_id_list[VM_MMS_MSG_ID_LIST_LEN]; +}vm_mms_get_msg_id_list_rsp; + +typedef struct vm_mms_addr_list_struct_t +{ + VMCHAR *address; + VMUINT8 addr_type; /*unused*/ + VMUINT8 group; /*unused*/ + + /*! Address for current element */ + // vm_mms_address_struct current; + struct vm_mms_addr_list_struct_t *prev; + /*! Next address list element or NULL if last element */ + struct vm_mms_addr_list_struct_t *next; + +} vm_mms_addr_list_struct; + +typedef struct +{ + VMUINT8 charset; /*unused */ + VMCHAR *text; /*!< Text buffer, must be NULL terminated */ +} vm_mms_encoded_text_struct; + +typedef struct +{ + VMUINT8 class_identifier; /*unused */ + VMCHAR *text_string; /*!< Textual representation of a message class */ +}vm_mms_msg_class_struct; + +typedef struct +{ + + VMUINT8 version;/*reserved*/ + + /*! [M] The address of the message sender. */ + vm_mms_addr_list_struct *from; + + /*! [O] The addressee of the message. The address field can contain one or + * several addresses. The parameter is a reference to a list + * containing the recipient addresses. One element in the list carries + * the address (PLMN or e-mail) and the text string representing the + * recipient real name (e.g. Joe User) to be used in multimedia + * messages. Please note that PLMN addresses cannot make use of real + * names. A message needs always at least one specified address in one + * of the to, cc or bcc field. + */ + VMUINT8 from_type; /*vm_mms_from_type_enum*/ + + + vm_mms_addr_list_struct *to; + + /*! [O] See To field. */ + vm_mms_addr_list_struct *cc; + + /*! [O] See To field. */ + vm_mms_addr_list_struct *bcc; + + /*! [O] The text string containing the subject of the message. See also + * configuration setting for the maximum length of this field in + * mms_cfg.h. + */ + vm_mms_encoded_text_struct subject; + + /*! [O] Arrival time (in seconds since 1970-01-01) of the message at the + * MMS Proxy-Relay. The MMS Proxy-Relay will generate this field if + * not supplied. + */ + VMUINT32 date; + + /*! [O] The message class field labels the message type as Auto, + * Informational or Advertisement. When the message class is not set + * the class will be interpreted as Personal at the recipient. It is + * recommended not to set this field in normal MMS Applications. + */ + vm_mms_msg_class_struct msg_class; + + + /*! [O] The type of expiry time, absolute or relative. Absolute means that + * an absolute time (in seconds since 1970-01-01) is given. Relative + * means that the server will add the given number of seconds to + * current time. + */ + VMUINT8 expiry_time_type;/*vm_mms_time_type_enum*/ + + /*! [O] Defines the time when the message will be removed from the + * recipient's MMS Proxy-Relay. If not set the maximum time will be + * used. The maximum value is dependent on the MMS Proxy-Relay. + */ + VMUINT32 expiry_time; + +//#ifdef MTK_TMP_PATCH /* TR 29894 */ + /*! [O] The type of delivery time, absolute or relative. Absolute means that + * an absolute time (in seconds since 1970-01-01) is given. Relative + * means that the server will add the given number of seconds to + * current time. + */ + VMUINT8 delivery_time_type;/*vm_mms_time_type_enum*/ +//#endif + + /*! [O] This time value indicates for the MMS Proxy-Relay when the message + * should be delivered to the recipient(s) at a later time. When this + * field is not set the message is delivered immediately. + */ + VMUINT32 delivery_time; + + /*! [O] This value defines the message priority. */ + VMUINT8 priority;/*vm_mms_priority_enum*/ + + /*! [O] This value is used to control if the "From" address is displayed + * in the message at the recipient's MMS Application. + */ + VMUINT8 visibility; /*vm_mms_sender_visibility_enum*/ + + /*! [O] This field is requesting the retrieving MMS Applications to send a + * read reply message when the message was read. Note; a retrieving + * MMS Application may cancel the request. A read reply message sent + * is seen as an ordinary message and the MMS Application controls + * the contents. + */ + VMUINT8 read_reply; /*vm_mms_read_reply_enum*/ + + /*! [O] The setting of this flag will cause the MMS Proxy-Relay to send + * back a notification message when the recipient retrieves the + * message. A retrieving MMS Application may prevent a Delivery + * Report from being sent. + */ + VMUINT8 delivery_report; /*vm_mms_delivery_report_enum*/ + + /*! [M] Id of the message. + * This field is only used when retrieving a message, NOT used when + * sending. + */ + VMUINT8 to_num; + + VMUINT8 cc_num; + + VMUINT8 bcc_num; + + VMUINT8 status; + + VMWCHAR reported_subject[VM_MMS_MAX_SUBJECT_LEN]; + VMCHAR *presentation; + VMCHAR *app_id; + VMCHAR *reply_app_id; + /*notif*/ + VMUINT32 download_size; + VMCHAR *content_location; + /*report*/ + VMUINT8 dr_status; + VMUINT8 rr_status; +} vm_mms_header_struct; + +typedef struct +{ + vm_mms_header_struct *header; /* used when parsing */ +} vm_mms_description_header_struct; + +typedef struct vm_mms_object_struct_t +{ + VMUINT32 size; + VMUINT32 offset; + VMUINT32 id; + VMUINT32 encoding; + VMUINT16 reference_count; + VMUINT32 charset; /*vm_charset_enum*/ + VMCHAR *file_path; + VMCHAR *file_name; + VMWCHAR *file_path_ucs; + VMWCHAR *file_name_ucs; + VMWCHAR *mime_type_ext; + VMUINT8 type; /*vm_mms_viewer_object_type_enum*/ + VMBOOL is_attachment; + VMBOOL is_virtual_file; + VMBOOL rights_expired; + VMBOOL is_restricted; + VMBOOL is_mixed_obj; + VMUINT8 drm_type; /*vm_drm_type_enum*/ + VMUINT8 drm_process_type; + VMCHAR *mime_str; + + VMUINT32 drm_ext[5];//SRV_FMGR_PATH_MAX_FILE_EXT_LEN defined in filemgrgprot.h + VMCHAR *drm_mime_type; + VMUINT32 consume_id; + VMUINT32 drm_offset; + VMUINT32 drm_size; + VMBOOL consume_only_timed; + VMBOOL is_drm_processed; + VMUINT8 mime_type;/*applib_mime_type_enum*/ + VMCHAR *content_id; // Used By JSR + VMCHAR *content_location; //USED by JSR + /*requested by ashok to process JSR message */ + VMCHAR *content_type; + VMUINT32 content_type_value; + VMUINT8 encoding_scheme; + VMBOOL auto_delete_file; + VMBOOL is_invallid; + struct vm_mms_object_struct_t *next; + struct vm_mms_object_struct_t *prev; +// #ifdef __DRM_SUPPORT__ +// drm_cid_struct *cid; +// #endif /* __DRM_SUPPORT__ */ +} vm_mms_object_struct; + +typedef struct +{ + VMUINT32 value; + VMUINT8 type;/*vm_mms_time_type_enum*/ +}vm_mms_type_value_struct; + +typedef struct +{ + vm_mms_type_value_struct x; + vm_mms_type_value_struct y; + vm_mms_type_value_struct w; + vm_mms_type_value_struct h; +} vm_mms_object_area_struct; + +typedef struct vm_mms_slide_object_struct_t +{ + vm_mms_object_struct *object; + VMUINT32 begin; + VMUINT32 end; + vm_mms_object_area_struct *region_area; + VMCHAR *alt; + VMUINT16 id; + struct vm_mms_slide_object_struct_t *next; +} vm_mms_slide_object_struct; + +typedef struct vm_mms_slide_text_object_struct_t +{ + vm_mms_object_struct *object; + VMUINT32 bg_color; + VMUINT32 fg_color; + VMUINT8 text_style;/*vm_text_style_enum*/ + VMUINT16 char_count; + VMUINT16 utf8_msg_len; + VMUINT16 extension_char_count; + VMUINT16 UCS2_count; + VMUINT8 text_size;/*vm_text_size_enum*/ + VMUINT32 begin; + VMUINT32 end; + VMCHAR *alt; + VMUINT16 id; + VMUINT16 str_id; + + vm_mms_object_area_struct *region_area; + + +}vm_mms_slide_text_object_struct; + +typedef struct vm_mms_slide_ref_object_struct_t +{ + vm_mms_object_struct *object; + VMUINT32 bg_color; + VMUINT32 fg_color; + VMUINT8 text_style;/*vm_text_style_enum*/ + VMUINT8 text_size;/*vm_text_size_enum*/ + VMUINT32 begin; + VMUINT32 end; + VMCHAR *alt; + VMUINT16 id; + vm_mms_object_area_struct *region_area; + struct vm_mms_slide_ref_object_struct_t *next; + struct vm_mms_slide_ref_object_struct_t *prev; +} vm_mms_slide_ref_object_struct; + +typedef struct vm_mms_slide_struct_t +{ + + struct vm_mms_slide_struct_t *prev; + vm_mms_slide_object_struct img; + vm_mms_slide_object_struct vid; + vm_mms_slide_object_struct aud; + vm_mms_slide_text_object_struct txt; + vm_mms_slide_ref_object_struct *ref_items; + VMUINT32 duration; + VMUINT16 slide_num; + struct vm_mms_slide_struct_t *next; +} vm_mms_slide_struct; + +typedef struct vm_mms_attachment_info_struct_t +{ + vm_mms_object_struct *object; + struct vm_mms_attachment_info_struct_t *next; + struct vm_mms_attachment_info_struct_t *prev; +} vm_mms_attachment_info_struct; + +typedef struct{ + vm_mms_slide_struct *slides; + vm_mms_object_struct *objects; + vm_mms_slide_struct *curr_slide; + vm_mms_object_struct *curr_object; + vm_mms_attachment_info_struct *attachment; + VMUINT32 slide_no; + VMUINT32 bgColor; + VMUINT32 fgColor; + VMUINT32 obj_no; + VMUINT32 total_attach_no; + VMUINT32 total_ref_no; + VMUINT16 total_address; + VMUINT8 layout;/*vm_slide_layout_enum*/ + VMUINT8 text_fit; /*vm_region_fit_enum*//* this one also insertion of regions in the main context */ + VMUINT8 image_fit; /*vm_region_fit_enum*//* this one also insertion of regions in the main context */ +}vm_mms_description_body_struct; + +typedef struct +{ + vm_mms_description_header_struct *header; /*new one to be used*/ + vm_mms_description_body_struct *body; +}vm_mms_description_struct; + +typedef struct +{ + VMUINT msg_id; /* Message id */ + VMUINT req_id; /* request id for get content rsp*/ + VMUINT mms_header_size; /* Size of MMS headers */ + VMUINT mms_body_size; /* Size of MMS bodies */ + VMBOOL isFollowPhoneMMSContentClass; /* Specify if the MMS follow handset content class */ + VMUINT8 app_id; /* unused*/ + VMUINT8 result; /* result OK=0 */ + VMUINT8 unused; /* Unused */ + vm_mms_description_struct *content_info; +}vm_mms_get_content_rsp_struct; + +typedef void (*vm_mms_get_content_callback_type)(vm_mms_get_content_rsp_struct *rsp_data, void *user_data); + +typedef struct +{ + VMUINT msg_id; /* Message id */ + void * user_data; /* Service will save this data and will return in callback*/ + vm_mms_get_content_callback_type callback;/* srv_mms_funcptr_type, Callback API which service will use to response back to caller Application*/ + VMUINT reserved; /*reserved*/ + VMUINT8 mode; /* vm_app_mode_enum, Content request mode edit=0 send=1 reply=2 replyall=3 forwward=4 upload=5 header=6 view=7 raw=8 abort=10 postcard=11 mixed=12 template=13 */ + VMUINT8 creation_mode; /* vm_creation_mode_enum, Creation mode to filter content.Free=0,restricted=1,Warning=2*/ +}vm_mms_get_content_req_struct; + +/***************************************************************************** + * + * FUNCTION + * vm_mms_interrupt_callback + * DESCRIPTION + * MMS interrupt callback function + * RETURN VALUES + * result : [IN] TRUE means deleted the MMS, othewise return FALSE +*****************************************************************************/ +typedef VMBOOL (*vm_mms_interrupt_callback)(vm_mms_msg_info* param, void* user_data); + + +/***************************************************************************** + * + * FUNCTION + * vm_mms_delete_callback + * DESCRIPTION + * MMS delete callback function + * RETURN VALUES + * +*****************************************************************************/ +typedef VMINT (*vm_mms_delete_callback)( + VMINT result, VMUINT* msg_id_list,VMINT* result_list,VMUINT num,void* user_data); + +/***************************************************************************** + * + * FUNCTION + * vm_mms_callback_type + * DESCRIPTION + * MMS callback function + * PARAMETERS + * result : [IN] refer to vm_mms_result_enum. +*****************************************************************************/ +typedef void (*vm_mms_callback_type)(VMINT result); + + +typedef void (*vm_mms_get_msg_id_list_callback_type)(vm_mms_get_msg_id_list_rsp *rsp_data, void *user_data); + + +/***************************************************************************** +* FUNCTION + * vm_mms_send_mms + * DESCRIPTION + * Send MMS. The result will be returned in callback. + * PARAMETERS + * req_ptr : [IN] MMS information to send, refer to vm_send_mms_req_t + * callback : [IN] callback function pointer. + * RETURNS + * send request successfully or failed. + * RETURN VALUES + * FALSE : failed to send request. + * TRUE : send request successfully. + * +*****************************************************************************/ +VMINT vm_mms_send_mms(vm_send_mms_req_t * req_ptr, vm_mms_callback_type callback); + +/***************************************************************************** +* FUNCTION + * vm_mms_cancel_send_mms + * DESCRIPTION + * Cancel the procedure of sending MMS. If the MMS has sent already and callback + * has been invoked or there is no sending function invoked before, this cancelling + * will be ignored. + * +*****************************************************************************/ +void vm_mms_cancel_send_mms(void); + +/***************************************************************************** +* FUNCTION + * vm_mms_launch + * DESCRIPTION + * launch native editor to edit mms + * PARAMETERS + * data : [IN] MMS info + * data_size : [IN] sizeof data + * RETURN VALUES + * 0 means success + * +*****************************************************************************/ +VMINT vm_mms_launch(vm_mms_launch_data* data, VMINT data_size); + +/***************************************************************************** +* FUNCTION + * vm_mms_set_interrupt_event_handler + * DESCRIPTION + * set handler to interrupt MMS + * PARAMETERS + * event : [IN] MMS event type + * callback : [IN] sizeof data + * user_data : [IN] user_data + * RETURN VALUES + * 0 means success + * +*****************************************************************************/ +VMINT vm_mms_set_interrupt_event_handler(vm_mms_event_enum event, vm_mms_interrupt_callback callback, void* user_data); + +/***************************************************************************** +* FUNCTION + * vm_mms_clear_interrupt_event_handler + * DESCRIPTION + * clear handler + * PARAMETERS + * event : [IN] MMS event type + * RETURN VALUES + * 0 means success + * +*****************************************************************************/ +VMINT vm_mms_clear_interrupt_event_handler(vm_mms_event_enum event); + +/***************************************************************************** +* FUNCTION + * vm_mms_download + * DESCRIPTION + * download mms + * PARAMETERS + * msg_id : [IN] message id + * sim : [IN] sim card id + * storage_type : [IN] storage type + * RETURN VALUES + * 0 means success + * +*****************************************************************************/ +VMINT vm_mms_download(VMUINT msg_id, vm_mms_sim_id_enum sim, vm_mms_msg_storage_type_enum storage_type); + +/***************************************************************************** +* FUNCTION + * vm_mms_cancel_download + * DESCRIPTION + * cancel downloading mms + * PARAMETERS + * msg_id : [IN] message id + * RETURN VALUES + * +*****************************************************************************/ +void vm_mms_cancel_download(VMINT msg_id); + +/***************************************************************************** +* FUNCTION + * vm_mms_delete + * DESCRIPTION + * delete mms + * PARAMETERS + * msg_id_list : [IN] message id + * msg_num : [IN] sim card id + * folder : [IN] storage type + * vm_mms_delete_callback : [IN] sim card id + * user_data : [IN] storage type + * RETURN VALUES + * 0 means success + * +*****************************************************************************/ +VMINT vm_mms_delete(VMUINT* msg_id_list, VMUINT msg_num, vm_mms_folder_enum folder, vm_mms_delete_callback callback,void* user_data); + +/***************************************************************************** +* FUNCTION + * vm_mms_get_msg_id_list + * DESCRIPTION + * get mms message id list + * PARAMETERS + * folder : [IN] where to get message + * callback : [IN] callback + * user_data: [IN] user data + * RETURN VALUES + * 0 means success + * +*****************************************************************************/ +VMINT vm_mms_get_msg_id_list(vm_mms_folder_enum folder, vm_mms_get_msg_id_list_callback_type callback, void* user_data); + +/***************************************************************************** +* FUNCTION + * vm_mms_get_content + * DESCRIPTION + * get mms content + * PARAMETERS + * req_data : [IN] request struct + * RETURN VALUES + * 0 means success + * +*****************************************************************************/ +VMINT vm_mms_get_content(vm_mms_get_content_req_struct *req_data); + +#ifdef __cplusplus +} +#endif + +#endif /* VMMMS_SDK_H */ + + + + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmmullang.h b/hardware/arduino/mtk/system/libmtk/include/vmmullang.h new file mode 100644 index 00000000..69f34f63 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmmullang.h @@ -0,0 +1,176 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef _VM_MUL_LANG_SDK_ +#define _VM_MUL_LANG_SDK_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/*multi-language segment name*/ +#define MUL_LANG_RES_NAME "lang.bin" + +/*language type list*/ +enum{ + VM_LANG_NULL = 0, /*no language*/ + VM_LANG_ENG,/*English*/ + VM_LANG_CHS,/*Chinese Simple*/ + VM_LANG_CHT /*Chinese Tradition*/ +}; + +/*language list begin*/ +#define VM_LANG_ID_START VM_LANG_ENG + +/*language list end*/ +#define VM_LANG_ID_END VM_LANG_CHT + +/*default language*/ +#define VM_LANG_ID_DEFAULT VM_LANG_ENG + + + +/***************************************************************************** + * FUNCTION + * vm_mul_lang_init + * DESCRIPTION + * init multi-language model. multi-lang resource is in the segment "vm_res" in the vxp file, its name is lang.bin. so it has + * malloc memory operation. + * PARAMETERS + * void + * RETURNS + * if succeed, return the handle of multi-lang resource(the resource pointer), otherwise, return NULL + *****************************************************************************/ +VMCHAR * vm_mul_lang_init( void ); + + +/***************************************************************************** + * FUNCTION + * vm_mul_lang_deinit + * DESCRIPTION + * release multi-lang resource + * PARAMETERS + * mul_lang_handle : [IN] the handle of multi-lang resource, in fact, it is pointer address. + * RETURNS + * void + *****************************************************************************/ +void vm_mul_lang_deinit( VMCHAR * mul_lang_handle ); + + + +/***************************************************************************** + * FUNCTION + * vm_mul_lang_get_string + * DESCRIPTION + * get the appointed string from multi-lang resource + * PARAMETERS + * lang_buf : [IN] multi-lang resource pointer address. + * res_id : [IN] string resource id + * lang_id : [IN] language id + * str_buf : [OUT] string pointer + * RETURNS + * the length of string. if length is 0, the operation is failed. + *****************************************************************************/ +VMINT vm_mul_lang_get_string( VMCHAR * lang_buf, VMINT res_id, VMINT lang_id, VMCHAR ** str_buf ); + + + + +/***************************************************************************** + * FUNCTION + * vm_mul_lang_set_lang + * DESCRIPTION + * set current language + * PARAMETERS + * lang_id : [IN] language id + * RETURNS + * if succeed, return 1, otherwise, return 0 + *****************************************************************************/ +VMINT vm_mul_lang_set_lang( VMINT lang_id ); + + + +/***************************************************************************** + * FUNCTION + * vm_mul_lang_set_lang + * DESCRIPTION + * get current language + * PARAMETERS + * void + * RETURNS + * language id, default value is VM_LANG_ENG + *****************************************************************************/ +VMINT vm_mul_lang_get_lang( void ); + + + +/***************************************************************************** + * FUNCTION + * vm_graphic_textout_by_id + * DESCRIPTION + * show string to the destination buffer + * PARAMETERS + * disp_buf : [IN] display buffer + * x : [IN] x offset of display buffer + * y : [IN] y offset of display buffer + * lang_buf : [IN] multi-lang resource pointer address. + * res_id : [IN] resource id + * color : [IN] string color + * RETURNS + * void + *****************************************************************************/ +void vm_graphic_textout_by_id( VMUINT8* disp_buf, VMINT x, VMINT y, VMCHAR * lang_buf, VMINT res_id, VMUINT16 color); + + +/***************************************************************************** + * FUNCTION + * vm_graphic_get_string_width_by_id + * DESCRIPTION + * get string width by resource id + * PARAMETERS + * lang_buf : [IN] multi-lang resource pointer address. + * res_id : [IN] string resource id + * RETURNS + * if succeed, return string width, otherwise, return error code + *****************************************************************************/ +VMINT vm_graphic_get_string_width_by_id( VMCHAR * lang_buf, VMINT res_id ); + +#ifdef __cplusplus +} +#endif + +#endif /* _VM_MUL_LANG_SDK_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmnat.h b/hardware/arduino/mtk/system/libmtk/include/vmnat.h new file mode 100644 index 00000000..28ef52c0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmnat.h @@ -0,0 +1,233 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* +* Filename: +* --------- +* +* +* Project: +* -------- +* MAUI +* +* Description: +* ------------ +* +* +* Author: +* ------- +* +* +*============================================================================== +* HISTORY +* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! +*------------------------------------------------------------------------------ +* $Log$ +* +* 06 20 2014 shuaihui.ren +* [MAUI_03493338] MRE NAT check in +* . +* +* 06 18 2014 shuaihui.ren +* [MAUI_03505838] "apk occure some error please check" happened when try to view video. +* . +* +* 05 20 2014 shuaihui.ren +* [MAUI_03493338] MRE NAT check in +* . +* +* 03 11 2014 feng.lin +* [MAUI_03479763] [IOT]Merge IOT code to 11C +* . +* +* 01 27 2014 xiufeng.zhang +* [MAUI_03484297] [IOT] UPnP check in +* . +* +* 01 27 2014 xiufeng.zhang +* [MAUI_03484297] [IOT] UPnP check in +* . +* +* . +*------------------------------------------------------------------------------ +* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! +*============================================================================== +*******************************************************************************/ +#ifndef VM_NAT_SDK_H +#define VM_NAT_SDK_H + +#define VM_TYPE_MAX_LEN 4 +#define VM_UPNP_SUCCESS 0 +#define VM_UPNP_FAIL_CREATE_SOCKET -1 +#define VM_UPNP_FAIL_NO_ROUTER -2 +#define VM_UPNP_FAIL_ROUTER_NOT_SUPPORT_UPNP -3 +#define VM_UPNP_FAIL_CREATE_THREAD -4 +#define VM_UPNP_FAIL_NO_MEMORY -5 +#define VM_UPNP_FAIL_MAPPING -6 +#define VM_UPNP_FAIL_OTHER -7 +#define VM_UPNP_PROTOCAL_UDP 0 +#define VM_UPNP_PROTOCAL_TCP 1 + +/* use for mmi_frm_mapping_ports() parameter*/ +typedef struct _vm_upnp_request_info +{ + VMUINT8 mapping_protocal; /* UPNP_PROTOCAL_UDP or UPNP_PROTOCAL_TCP */ + VMUINT16 local_port; /* local port of mapping request. */ + VMUINT16 ext_port; /* external port of mapping result. If not 0, upnp will try to mapping the ext_port, or it will mapping a random port.*/ +} vm_upnp_request_info; + +/* use for response port mapping */ +typedef struct _vm_upnp_map_info +{ + VMUINT32 count; + vm_upnp_request_info* requset_data; +} vm_upnp_map_info; + +typedef void(* vm_upnp_result_cb)(VMUINT8 request_id, VMINT ret, void* res_data, void* user_data); + +/**/ +typedef struct +{ + VMUINT32 protocol_type; + VMUINT16 port; + VMUINT32 userNum; + VMUINT32 seqId; + VMUINT8 addr[4]; + VMINT8 request_id[64]; +}vm_nat_invite_req_struct; + +typedef void(* vm_got_tunneling_addr_cb)(vm_nat_invite_req_struct *out_info, void *user_data); + +typedef struct +{ + VMUINT16 port; /* local port */ + VMUINT16 nat_port; /* port for NAT */ + VMUINT8 ip_addr[4]; /* local IP address */ + VMUINT8 nat_ip_addr[4]; /* address for NAT */ +}vm_nat_addr_struct; + +typedef void (*vm_nat_got_mapped_addr_cb)(vm_nat_addr_struct *addr, void *user_data); + +/***************************************************************************** +* FUNCTION +* vm_upnp_mapping_ports +* DESCRIPTION +* Async function, use for add mapping ports on router, the mapping result is notifyed by cb function. +* only can be used in mmi task, +* PARAMETERS +* request_id: [in] user define, use for identify the request. +* cb [in] the call back function. +* request_data: [in] the request ports mapping info. +* user_data: [in] user data. +* RETURNS +* None +* Example +* +* kal_int8 mapping_handler (kal_uint8 request_id, kal_int32 ret, void* res_data, void* user_data); +* kal_int32 fun() +* { +* upnp_request_info req_data[2]; +* upnp_map_res_info req; +* kal_uint8 request_id = 1234; +* req_data[0].mapping_protocal = UPNP_PROTOCAL_UDP; +* req_data[0].local_port = 2002; +* req_data[0].ext_port = 0; +* req_data[1].mapping_protocal = UPNP_PROTOCAL_TCP; +* req_data[1].local_port = 4221; +* req_data[1].ext_port = 0; +* req.requset_data = req_data; +* vm_upnp_mapping_ports(request_id, mapping_handler, req, NULL); +* return 0; +* } +* +* +* kal_int8 mapping_handler (kal_uint8 request_id, kal_int32 ret, void* res_data, void* user_data); +* { +* upnp_map_info* res_data; +* if(ret == UPNP_SUCCESS) +* { +* MMI_FRM_MAPPING_RES_INFO* res; +* res_data = (vm_upnp_request_info*) res_data; +* // do_sth(); +* } +* return 0; +* } +* +*****************************************************************************/ +VMINT vm_upnp_mapping_ports(VMUINT8 request_id, vm_upnp_result_cb cb, vm_upnp_map_info* request_data, void* user_data); + +/***************************************************************************** +* FUNCTION +* vm_upnp_get_ext_ip +* DESCRIPTION +* Async function, use for geting external ip of router, the mapping result is notifyed by cb function. +* only can be used in mmi task, +* PARAMETERS +* request_id: [in] user define, use for identify the request. +* cb [in] the call back function. +* user_data: [in] user data. +* RETURNS +* None +* +* Example +* +* kal_int8 ip_handler (kal_uint8 request_id, kal_int32 ret, void* res_data); +* kal_int32 fun() +* { +* kal_uint8 request_id = 231; +* vm_upnp_get_ext_ip(request_id, ip_handler); +* return 0; +* } +* +* kal_int8 ip_handler(kal_uint8 request_id, kal_int32 ret, void* res_data) +* { +* kal_char* ip; +* if(ret == UPNP_SUCCESS) +* { +* ip = (kal_char*) res_data; +* // do_sth(); +* } +* return 0; +* } +* +*****************************************************************************/ +VMINT vm_upnp_get_ext_ip(VMUINT8 request_id, vm_upnp_result_cb cb, void *user_data); + +VMINT vm_nat_invite_req(vm_nat_invite_req_struct *req, vm_got_tunneling_addr_cb cb, void* user_data); +VMINT vm_nat_set_life_time(VMUINT32 life_time); +VMINT vm_nat_set_stun_server(VMCHAR *server, VMUINT16 port); +VMINT vm_nat_get_mapped_addr_async(vm_nat_got_mapped_addr_cb callback, void *user_data); +VMINT vm_nat_set_type(VMUINT32 type); +#endif /* VM_NAT_SDK_H */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmnvram.h b/hardware/arduino/mtk/system/libmtk/include/vmnvram.h new file mode 100644 index 00000000..4409c4c1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmnvram.h @@ -0,0 +1,115 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMNVRAM_SDK_H_ +#define VMNVRAM_SDK_H_ +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/* NVRAM ID for Sensor */ +typedef enum{ + VM_NVRAM_EF_SENSOR_START_LID = 513, /* begin */ + VM_NVRAM_EF_SENSOR1_LID = VM_NVRAM_EF_SENSOR_START_LID, /* used for sensor1 */ + VM_NVRAM_EF_ACCELERATOR_SENSOR_LID = VM_NVRAM_EF_SENSOR1_LID, /* ACCELERATOR has used thi one, others cannot use it */ + VM_NVRAM_EF_SENSOR2_LID, /* reserved */ + VM_NVRAM_EF_SENSOR3_LID, /* reserved */ + VM_NVRAM_EF_SENSOR4_LID, /* reserved */ + VM_NVRAM_EF_SENSOR5_LID, /* reserved */ + VM_NVRAM_EF_SENSOR6_LID, /* reserved */ + VM_NVRAM_EF_SENSOR7_LID, /* reserved */ + VM_NVRAM_EF_SENSOR8_LID, /* reserved */ + VM_NVRAM_EF_SENSOR9_LID, /* reserved */ + VM_NVRAM_EF_SENSOR10_LID, /* reserved */ + VM_NVRAM_EF_SENSOR11_LID, /* reserved */ + VM_NVRAM_EF_SENSOR12_LID, /* reserved */ + VM_NVRAM_EF_SENSOR13_LID, /* reserved */ + VM_NVRAM_EF_SENSOR14_LID, /* reserved */ + VM_NVRAM_EF_SENSOR15_LID, /* reserved */ + VM_NVRAM_EF_SENSOR16_LID, /* reserved */ + VM_NVRAM_EF_SENSOR17_LID, /* reserved */ + VM_NVRAM_EF_SENSOR18_LID, /* reserved */ + VM_NVRAM_EF_SENSOR19_LID, /* reserved */ + VM_NVRAM_EF_SENSOR20_LID /* reserved */ +}vm_nvram_sensor_lid; + +/* Max size of NVRAM data */ +#define VM_NVRAM_EF_SENSOR_SIZE 512 + + +/***************************************************************************** + * FUNCTION + * vm_nvram_get_data + * DESCRIPTION + * get nvram data from special ID. + * PARAMETERS + * id : [IN] NVRAM ID to get data. + * buff : [OUT] data buffer. + * size : [IN] size to get + * RETURNS + * get data success or not. + * RETURN VALUES + * <0 : error, other is success +*****************************************************************************/ +VMINT vm_nvram_get_data(vm_nvram_sensor_lid id, void* buff, VMUINT size); + +/***************************************************************************** + * FUNCTION + * vm_nvram_set_data + * DESCRIPTION + * set nvram data for special ID. + * PARAMETERS + * id : [IN] NVRAM ID to set data. + * buff : [IN] data buffer. + * size : [IN] size to set + * RETURNS + * set data success or not. + * RETURN VALUES + * <0 : error, other is success +*****************************************************************************/ +VMINT vm_nvram_set_data(vm_nvram_sensor_lid id, void* buff, VMUINT size); + + +#ifdef __cplusplus +} +#endif + + +#endif + + + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmnwsetting.h b/hardware/arduino/mtk/system/libmtk/include/vmnwsetting.h new file mode 100644 index 00000000..3870588d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmnwsetting.h @@ -0,0 +1,1639 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VM_NWSETTING_SDK_H +#define VM_NWSETTING_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + + + +/* Maximum length of WLAN SSID attribute in WLAN profile */ +#define VM_WLAN_PROF_MAX_SSID_LEN (32) + +/* Maximum length of WLAN SSID attribute in WLAN profile */ +#define VM_WLAN_PROF_MAX_SSID_LEN (32) +/* Maximum length of profile IP address length in WLAN profile */ +#define VM_WLAN_PROF_MAX_IP_ADDR_LEN (4) + +#define VM_WLAN_PROF_MAX_PROXY_ADDR_LEN (63) +/* Maximum length of proxy auth ID attribute in WLAN profile */ +#define VM_WLAN_PROF_MAX_PX_AUTH_ID_LEN (40) +/* Maximum length of proxy auth password attribute in WLAN profile */ +#define VM_WLAN_PROF_MAX_PX_AUTH_PW_LEN (40) +/* Maximum length of homepage attribute in WLAN profile */ +#define VM_WLAN_PROF_MAX_HOMEPAGE_LEN (256) +/* Maximum length of WLAN profile name attribute in WLAN profile */ +#define VM_WLAN_PROF_MAX_WLAN_PROF_NAME_LEN (VM_WLAN_PROF_MAX_SSID_LEN) +//#ifdef __WAPI_SUPPORT__ +#define VM_WLAN_WAPI_PSK_STR_LEN (32+1) /* WAPI PSK string length */ +//#endif /* __WAPI_SUPPORT__ */ +/* Maximum length of password attribute in WLAN profile */ +#define VM_WLAN_PROF_MAX_PW_LEN (31) +/* Maximum length of username attribute in WLAN profile */ +#define VM_WLAN_PROF_MAX_USER_LEN (31) +/* Maximum length of WLAN profile passphrase attribute in WLAN profile */ +#define VM_WLAN_PROF_MAX_PASSPHRASE_LEN (64) +/* Maximum length of WLAN profile psk attribute in WLAN profile */ +#define VM_WLAN_PROF_MAX_PSK_LEN (34) +/* Maximum length of WLAN profile wep key attribute in WLAN profile */ +#define VM_WLAN_PROF_MAX_WEP_KEY_LEN (26) +/* MAX WLAN profile number */ +#define VM_MAX_WLAN_ACCOUNT_NUM (30) + +/* --- MAC Address Length -------------------------------------------------- */ +/* WNDRV_MAC_ADDRESS_LEN */ +#define VM_WLAN_WNDRV_MAC_ADDRESS_LEN (6) +/* --- SSID Length --------------------------------------------------------- */ +/* WNDRV_SSID_MAX_LEN */ +#define VM_WLAN_WNDRV_SSID_MAX_LEN (32) + +#define VM_WLAN_MAX_AP_LIST_NUM (30) + +/* Maximum length of password attribute of all kinds in WLAN profile */ +#define VM_WLAN_PROF_PSWD_MAX_LEN (64) + +/* Profile fields */ + +/* Set SSID field in wlan account profile */ +#define VM_WLAN_PROF_FIELD_SSID (0x00000002) + +/* Set auth type field in wlan account profile */ +#define VM_WLAN_PROF_FIELD_AUTH_TYPE (0x00000400) + +/* Set username field in wlan account profile */ +#define VM_WLAN_PROF_FIELD_USER (0x00080000) + +/* Set password field in wlan account profile */ +#define VM_WLAN_PROF_FIELD_PW (0x00100000) + +/* Set All fields */ +#define VM_WLAN_PROF_FIELD_ALL (0xFFFFFFFF) + +#define VM_WLAN_MAX_SPEC_SSID_LIST_NUM (7) + +/* wlan network type enum */ +typedef enum +{ + VM_WLAN_NETWORK_TYPE_INFRA, /* infrasturcture mode */ + VM_WLAN_NETWORK_TYPE_ADHOC, /* ad-hoc mode */ + VM_WLAN_NETWORK_TYPE_TOTAL +} vm_wlan_network_type_enum; + + +/* wlan auth.mode enum */ +typedef enum +{ + VM_WLAN_AUTH_MODE_OPEN, /* Open Network */ + VM_WLAN_AUTH_MODE_WEP, /* WEP */ + VM_WLAN_AUTH_MODE_IEEE8021X, /* IEEE802.1x */ + VM_WLAN_AUTH_MODE_WPA_ONLY, /* WPA Enterprise */ + VM_WLAN_AUTH_MODE_WPA_ONLY_PSK, /* WPA Only PSK */ + VM_WLAN_AUTH_MODE_WAPICERT, /* WAPICERT */ + VM_WLAN_AUTH_MODE_WAPIPSK, /* WAPIPSK */ + + VM_WLAN_AUTH_MODE_WPA2_ONLY, /* WPA2 Enterprise */ + VM_WLAN_AUTH_MODE_WPA_WPA2_MIX, /* WPA WPA2 Mix Enterprise */ + VM_WLAN_AUTH_MODE_WPA2_ONLY_PSK, /* WPA2 Only PSK */ + VM_WLAN_AUTH_MODE_WPA_WPA2_MIX_PSK, /* WPA WPA2 Mix PSK */ + VM_WLAN_AUTH_MODE_TOTAL +} vm_wlan_auth_mode_enum; + +/* wlan encrypt mode */ +typedef enum +{ + VM_WLAN_ENCRYPT_MODE_NONE, /* unencrypt mode */ + VM_WLAN_ENCRYPT_MODE_WEP, /* WEP mode */ + VM_WLAN_ENCRYPT_MODE_TKIP, /* TKIP mode */ + VM_WLAN_ENCRYPT_MODE_AES, /* AES mode */ + VM_WLAN_ENCRYPT_MODE_WPI, /* WPI mode */ + VM_WLAN_ENCRYPT_MODE_TKIP_AES, /*TKIP_CCMP */ + VM_WLAN_ENCRYPT_MODE_TOTAL +} vm_wlan_encrypt_mode_enum; + +typedef enum +{ + VM_WLAN_WEP_KEY_FORMAT_HEX, /* HEX encoded */ + VM_WLAN_WEP_KEY_FORMAT_ASCII,/* ASCII encoded */ + VM_WLAN_WEP_KEY_FORMAT_TOTAL +} vm_wlan_wep_key_format_enum; + +typedef enum +{ + VM_WLAN_AP_USER_DEFINE, + VM_WLAN_AP_DEFAULT, + VM_WLAN_AP_UNKNOW, + VM_WLAN_AP_BLACK_LIST, + VM_WLAN_AP_END +}vm_wlan_ap_type_enum; + +/* Connect error type */ +typedef enum +{ + VM_WLAN_TIMEOUT, + VM_WLAN_LOST_COVERAGE, + VM_WLAN_NORMAL_REJ, + VM_WLAN_CONNECT_FAIL, + VM_WLAN_AUTH_FAIL, + VM_WLAN_CAUSE_COUNT, + VM_WLAN_UNSUPPORTED_EAP_TYPE, //add for WiFi UE enhancement + VM_WLAN_WRONG_USER_INFO, //add for WiFi UE enhancement + VM_WLAN_LOW_RSSI, // when RSSI < -85dBm . indicate this cause + VM_WLAN_INVALID_CAUSE +} vm_wlan_cause_enum; /* same as supc_abm_cause_enum */ + +/* Connection type */ +typedef enum +{ + VM_WLAN_ALL_PROFILE_ENABLE, + VM_WLAN_ONE_PROFILE_SELECT, + VM_WLAN_START_WPS_PIN, + VM_WLAN_START_WPS_PBC +} vm_wlan_connection_type_enum; /* supc_connection_type_enum */ + +/* WLAN request result enum */ +typedef enum +{ + VM_WLAN_REQ_RES_DONE = 0, /* request completed successfully */ + VM_WLAN_REQ_RES_TERMINATED, /* request is terminated by newer request */ + VM_WLAN_REQ_RES_DUPLICATED, /* request is removed by newer same request */ + VM_WLAN_REQ_RES_FAILED, /* request is ignored due to state error */ + VM_WLAN_REQ_RES_ADD_BY_SRV, + VM_WLAN_REQ_RES_UNKNOWN_ERROR, + VM_WLAN_REQ_RES_CANCELLED, + VM_WLAN_REQ_RES_BUSY, + + VM_WLAN_REQ_RES_TOTAL +} vm_wlan_req_res_enum; + +/* WLAN scan result enum */ +typedef enum +{ + VM_WLAN_SCAN_RESULT_SUCCESS = 0, /* WLAN scan success */ + VM_WLAN_SCAN_RESULT_FAILED, /* WLAN scan failed */ + VM_WLAN_SCAN_RESULT_ABORTED, /* WLAN scan service is aborted */ + VM_WLAN_SCAN_RESULT_DELETE, /* WLAN scan delete in CONNECT_WAIT */ + VM_WLAN_SCAN_RESULT_TOTAL +} vm_wlan_scan_result_enum; + +/* WLAN services result enum */ +typedef enum +{ + VM_WLAN_RESULT_SUCCESS = 0, /* success */ + VM_WLAN_RESULT_FAILED, /* general failed case */ + VM_WLAN_RESULT_PROCESSING, /* processing state implies Event notify */ + VM_WLAN_RESULT_STATE_ERROR, /* service status error */ + VM_WLAN_RESULT_INVALID_INPUT, /* the input parameter is invalid */ + VM_WLAN_RESULT_ABORTED, /* the process is aborted */ + VM_WLAN_RESULT_TERMINATED, /* the process is terminated */ + VM_WLAN_RESULT_ONE_STORE_EXISTS, /* currently only support one store */ + VM_WLAN_RESULT_STORE_NOT_COMMIT, /* store doesn't be config commited before */ + VM_WLAN_RESULT_INVALID_STORE, /* store invalid */ + VM_WLAN_RESULT_STORE_FULL, /* reach maximum profile storage */ + VM_WLAN_RESULT_READ_ONLY, /* can't delete or update read_only profile */ + VM_WLAN_RESULT_FIRST_BOOTUP, /* first bootup rerurn code for store open */ + VM_WLAN_RESULT_RESET_FACTORY, /* the data base sim profiles folder is deleted */ + VM_WLAN_RESULT_FS_ERROR, /* the database file system error */ + VM_WLAN_RESULT_IGNORE, + VM_WLAN_RESULT_TOTAL +} vm_wlan_result_enum; + +/* WLAN set mode enum */ +typedef enum +{ + VM_WLAN_SET_MODE_NONE, + VM_WLAN_SET_MODE_OFF, /* OFF */ + VM_WLAN_SET_MODE_AP, /* AP only*/ + VM_WLAN_SET_MODE_STA, /* STA only */ + VM_WLAN_SET_MODE_AP_STA, /* AP+STA */ + + VM_WLAN_SET_MODE_TOTAL +}vm_wlan_set_mode_enum; + + + +/* WLAN mode status enum */ +typedef enum +{ + VM_WLAN_MODE_STATUS_OFF, /* OFF */ + VM_WLAN_MODE_STATUS_OFF_SWITCHING, + VM_WLAN_MODE_STATUS_AP, /* AP only*/ + VM_WLAN_MODE_STATUS_AP_SWITCHING, + VM_WLAN_MODE_STATUS_STA, /* STA only */ + VM_WLAN_MODE_STATUS_STA_SWITCHING, + VM_WLAN_MODE_STATUS_AP_STA, /* AP+STA */ + VM_WLAN_MODE_STATUS_AP_STA_SWITCHING, + VM_WLAN_MODE_STATUS_ERROR, + + VM_WLAN_MODE_STATUS_TOTAL +}vm_wlan_mode_status_enum; + + +/* WLAN mode status enum */ +typedef enum +{ + VM_WLAN_STA_STATUS_INACTIVE = 0x01, /* inactive state */ + VM_WLAN_STA_STATUS_ACTIVE = 0x02, /* active state */ + VM_WLAN_STA_STATUS_CONNECTED = 0x04, /* connected state */ + VM_WLAN_STA_STATUS_INVALID_MAC = 0x08, /* current MAC address isn't valid, OR'd with ACTIVE and CONNECTED status */ + VM_WLAN_STA_STATUS_SNIFFER = 0x10, /* sniffer status */ + VM_WLAN_STA_STATUS_BUSY = 0x20, /* status changing */ + + VM_WLAN_STA_STATUS_TOTAL = 0xFF +} vm_wlan_sta_status_enum; + + + +/* Sniffer ON Callback type */ +typedef enum +{ + VM_WLAN_SNIFFER_ON_RES, + VM_WLAN_SNIFFER_ON_AP_INFO, + + VM_WLAN_SNIFFER_ON_END +}vm_wlan_sniffer_on_cb_type_enum; + + +/* Sniffer ON/OFF callback result Enum */ +typedef enum +{ + VM_WLAN_SNIFFER_SUCCESS = 0, + VM_WLAN_SNIFFER_FAIL_INVALID_CHANNEL, + VM_WLAN_SNIFFER_FAIL_INVALID_SNIFFERFILTEROPTIONS, + VM_WLAN_SNIFFER_FAIL_INVALID_ONOFFSWITCH, + VM_WLAN_SNIFFER_FAIL_NETWORK_IS_CONNECTED, + VM_WLAN_SNIFFER_FAIL_UNKNOWN, + VM_WLAN_SNIFFER_FAIL_STATE_ERROR, + VM_WLAN_SNIFFER_FAIL_HW_ERROR +}vm_wlan_sniffer_res_enum; + + +/* Notification type */ +typedef enum +{ + VM_WLAN_NOTI_NONE, + VM_WLAN_NOTI_IP_AVAILABLE, //IP available + VM_WLAN_NOTI_PASSIVE_DISCONN, //Passive disconnect + + VM_WLAN_NOTI_END = 0xFFFF +}vm_wlan_noti_type_enum; + + +/* Connected ap info type */ +typedef enum +{ + VM_WLAN_AP_INFO_BSSID, //Get BSSID + VM_WLAN_AP_INFO_PROF_ID, //Get Profile ID + VM_WLAN_AP_INFO_RSSI, //Get RSSI + VM_WLAN_AP_INFO_ALL, //Get All infomation + + VM_WLAN_AP_INFO_END = 0xFFFF +}vm_wlan_ap_info_type_enum; + + +/* scan param type */ +typedef enum +{ + VM_WLAN_SCAN_PARAM_DWELL_TIME, /* Get/Set dwell time */ + VM_WLAN_SCAN_PARAM_SPEC_SSID_LIST, /* Get/Set ssid list */ + + VM_WLAN_SCAN_PARAM_END = 0xFFFF +}vm_wlan_scan_param_type_enum; + +/* Custom config apmode para enum */ +typedef enum +{ + VM_WLAN_CFG_AP_PARA_AUTH_MODE = 0x00000001, /* AP mode */ + VM_WLAN_CFG_AP_PARA_SSID = 0x00000002, /* AP mode */ + VM_WLAN_CFG_AP_PARA_PWD = 0x00000004, /* AP mode */ + + VM_WLAN_CFG_AP_PARA_ALL = VM_WLAN_CFG_AP_PARA_AUTH_MODE | + VM_WLAN_CFG_AP_PARA_SSID | + VM_WLAN_CFG_AP_PARA_PWD, /*All parameter */ + + VM_WLAN_CFG_AP_PARA_END +} vm_wlan_cfg_ap_para_enum; + +typedef struct +{ + VMUINT8 ssid[VM_WLAN_PROF_MAX_SSID_LEN+1]; /* SSID ASCII string (MAX: VM_WLAN_PROF_MAX_SSID_LEN) */ + vm_wlan_auth_mode_enum auth_mode; /* profile auth.mode */ + VMUINT8 username[VM_WLAN_PROF_MAX_USER_LEN+1]; /* user name string (ASCII, MAX: VM_WLAN_PROF_MAX_USER_LEN) */ + VMUINT8 password[VM_WLAN_PROF_PSWD_MAX_LEN+1]; /* password string (ASCII, MAX: VM_WLAN_PROF_PSWD_MAX_LEN) */ + VMUINT32 profile_id; /* Profile ID */ +} vm_wlan_prof_struct; + + + +/* Sniffer ON structure , used in callback function*/ +typedef struct +{ + vm_wlan_sniffer_on_cb_type_enum cb_type; // callback type, reference vm_wlan_sniffer_on_cb_type_enum + vm_wlan_sniffer_res_enum result; // Result ENUM, reference vm_wlan_sniffer_res_enum + vm_wlan_prof_struct profile; // Get by sniffer +}vm_wlan_sniffer_on_res_struct; + + +/* Sniffer ON Config structure, used in paramter */ +typedef struct +{ + VMUINT32 sniffer_filter_op; + VMUINT8 channel_num; + VMINT32 min_rssi; + VMINT32 max_rssi; + VMUINT16 min_pack_len; + VMUINT16 max_pack_len; +}vm_wlan_sniffer_on_cfg_struct; + + +/* WLAN Notification Structure */ +typedef struct +{ + vm_wlan_noti_type_enum type; //Notification type + void * data; //Notification data +}vm_wlan_noti_struct; + + +/* Mac addres query structure */ +typedef struct +{ + VMCHAR *dest; /* destination buffer. */ + VMUINT16 dest_len; /* application's dest buffer length. */ + VMUINT16 req_len; /* if this attribute is provided by application (NOT NULL), + WLAN SRV will hint application the required buffer length */ +} vm_wlan_prof_str_info_qry_struct; + + +/* WLAN scan AP info strucutre */ +typedef struct +{ + VMUINT8 bssid[ VM_WLAN_WNDRV_MAC_ADDRESS_LEN ]; /* MAC address */ + VMUINT8 ssid [ VM_WLAN_WNDRV_SSID_MAX_LEN ]; /* SSID */ + VMUINT16 ssid_len; /* SSID Length */ + VMINT32 rssi; /* receive signal, in dBm */ + VMUINT32 channel_number; /* AP Channel number */ + VMUINT8 max_rate; /* AP Max rate */ + VMUINT8 privacy; /* WEP encryption requirement */ + vm_wlan_network_type_enum network_type; /* profile network type */ + vm_wlan_auth_mode_enum auth_mode; /* profile auth.mode */ + vm_wlan_encrypt_mode_enum encrypt_mode; /* profile encrypt mode */ +} vm_wlan_scan_ap_info_struct; + +/* this struct is designed for WLAN SRV to send the scan result to APP */ +typedef struct +{ + vm_wlan_scan_result_enum result; /* scan result enum */ + VMUINT8 ap_list_num; /* total num of searched ap list */ + vm_wlan_scan_ap_info_struct ap_list[VM_WLAN_MAX_AP_LIST_NUM]; /* bss info array */ + VMINT32 scan_job_id; /* scan_job_id, 0xFFFFFF means scan result broadcasting */ +} vm_wlan_scan_result_struct; + +/* This struct is designed for user to pass the specialized ssid for scaning. */ +typedef struct +{ + VMUINT8 ssid_len; //SSID length + VMUINT8 ssid[VM_WLAN_WNDRV_SSID_MAX_LEN]; //SSID +}vm_wlan_ssid_struct; + + +/* this struct is designed for WLAN SRV to send the connect result to APP */ +typedef struct +{ + vm_wlan_result_enum result; /* SUCCESS: connected, FAILD: connect failed, + * ABORTED: preemptived by new connect req + * TERMINATED: terminated by new disconnect req + * STATE_ERROR: can't perform connect req + */ + vm_wlan_cause_enum cause; /* Error cause, uses only if result = FAILD */ + VMUINT8 bssid[VM_WLAN_WNDRV_MAC_ADDRESS_LEN]; /* MAC Address */ + VMUINT8 ssid[VM_WLAN_WNDRV_SSID_MAX_LEN]; /* SSID */ + VMBYTE init_by_soc; /* connection activated by socket flag */ + VMUINT16 ssid_len; /* SSID length in array */ + VMUINT32 channel_number; /* channel info from chip */ + VMUINT32 profile_id; /* connected profile id */ + VMUINT32 auth_type; + VMUINT32 eap_peap_auth_type; + VMUINT32 eap_ttls_auth_type; + vm_wlan_connection_type_enum conn_type; + VMUINT16 encry_mode; /*defaultly, it is WPS_ENCR_TYPES, + and now we don't to parse encry_mode in M2 */ + VMUINT8 passphase[32]; + VMUINT8 passphase_len; + VMBYTE need_login; + VMBYTE cancel_by_discon; + VMINT rssi; +} vm_wlan_conn_res_struct; + +/* this struct is designed for WLAN store query operation */ +typedef struct +{ + VMUINT32 ids[VM_MAX_WLAN_ACCOUNT_NUM]; /* profile id list query result */ + VMUINT8 num_ids; /* the number of queried id list */ +} vm_wlan_prof_list_struct; + +/* event structure for setting roaming parameter*/ +typedef struct { + VMBYTE is_roaming; // param of roaming, 1 is roming, 0 is non-roaming +} vm_wlan_roaming_para_struct; + + +/* This struct is designed for wlan srv to tell the ip inforamtion. */ +typedef struct +{ + VMUINT8 ip_addr[VM_WLAN_PROF_MAX_IP_ADDR_LEN]; /* IP address (ASCII, MAX: VM_WLAN_PROF_MAX_IP_ADDR_LEN) */ + VMUINT8 netmask[VM_WLAN_PROF_MAX_IP_ADDR_LEN]; /* Netmask (ASCII, MAX: VM_WLAN_PROF_MAX_IP_ADDR_LEN) */ + VMUINT8 gateway[VM_WLAN_PROF_MAX_IP_ADDR_LEN]; /* Gateway (ASCII, MAX: VM_WLAN_PROF_MAX_IP_ADDR_LEN) */ + VMUINT8 dns1[VM_WLAN_PROF_MAX_IP_ADDR_LEN]; /* Primary DNS (ASCII, MAX: VM_WLAN_PROF_MAX_IP_ADDR_LEN) */ + VMUINT8 dns2[VM_WLAN_PROF_MAX_IP_ADDR_LEN]; /* Secondary DNS (ASCII, MAX: VM_WLAN_PROF_MAX_IP_ADDR_LEN) */ +}vm_wlan_ip_info_struct; + + +/* AP information */ +typedef struct +{ + VMUINT8 ssid[VM_WLAN_PROF_MAX_SSID_LEN+1]; //SSID of AP + vm_wlan_auth_mode_enum auth_mode; //Auth mode, reference vm_wlan_auth_mode_enum + VMUINT8 password[VM_WLAN_PROF_PSWD_MAX_LEN+1]; //Password of AP +}vm_wlan_ap_info_struct; + +/* Connected ap information */ +typedef struct +{ + VMUINT8 bssid[VM_WLAN_WNDRV_MAC_ADDRESS_LEN + 1]; + VMUINT32 prof_id; + VMINT32 rssi_out; +}vm_wlan_conned_ap_info_struct; + + +/* part of scan param -- spec ssid list */ +typedef struct +{ + VMUINT8 ssid_list_num; + vm_wlan_ssid_struct ssid_list[VM_WLAN_MAX_SPEC_SSID_LIST_NUM]; +}vm_wlan_spec_ssid_list_struct; + +typedef struct +{ + /* AP mode info */ + vm_wlan_auth_mode_enum auth_mode; + VMINT8 ssid[VM_WLAN_WNDRV_SSID_MAX_LEN + 1]; + VMINT8 psk[VM_WLAN_PROF_PSWD_MAX_LEN]; + + /* add */ +}vm_wlan_cfg_ap_struct; +/***************************************************************************** + * FUNCTION + * vm_wlan_conn_res_cb_func_ptr + * DESCRIPTION + * Prototype of wLAN scan result callback function + * PARAMETERS + * user_data : [IN] APP's piggyback user_data + * conn_res : [IN] connect results from DA SRV + * RETURNS + * void + *****************************************************************************/ +typedef void (*vm_wlan_conn_res_cb_func_ptr) ( + void *user_data, + vm_wlan_conn_res_struct *conn_res); + +/***************************************************************************** + * FUNCTION + * vm_wlan_cb_func_ptr + * DESCRIPTION + * Prototype of wLAN general callback function for no feedback arguments except application piggyback data + * PARAMETERS + * user_data : [IN] APP's piggyback user_data + * res : [IN] request result + * RETURNS + * void + *****************************************************************************/ +typedef void (*vm_wlan_cb_func_ptr) (void *user_data, vm_wlan_req_res_enum res); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_sniffer_off_cb_func_ptr + * DESCRIPTION + * Prototype of wlan sniffer on callback function. Tell user the result of sniffer on. If successfully, + * function will be called again with AP info. + * PARAMETERS + * user_data : [IN] APP's piggyback user_data + * res : [IN] Sniffer on results from WLAN srv + * RETURNS + * void + *****************************************************************************/ +typedef void (*vm_wlan_sniffer_on_cb_func_ptr) ( + void *user_data, + vm_wlan_sniffer_on_res_struct *res); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_sniffer_off_cb_func_ptr + * DESCRIPTION + * Prototype of wlan sniffer off callback function. Tell user the result of sniffer off. + * PARAMETERS + * user_data : [IN] APP's piggyback user_data + * res : [IN] Sniffer off results from WLAN srv + * RETURNS + * void + *****************************************************************************/ +typedef void (*vm_wlan_sniffer_off_cb_func_ptr) ( + void *user_data, + vm_wlan_sniffer_res_enum res); + +/***************************************************************************** + * FUNCTION + * vm_wlan_noti_func_ptr + * DESCRIPTION + * Prototype of notification register function. When notification comes, corresponding register + * function will be called if it's registered before. + * PARAMETERS + * user_data : [IN] APP's piggyback user_data + * noti : [IN] Noti type + * RETURNS + * void + *****************************************************************************/ +typedef void (*vm_wlan_noti_func_ptr) (void *user_data, vm_wlan_noti_struct *noti); + + + +/***************************************************************************** + * FUNCTION + * vm_wlan_scan_res_cb_func_ptr + * DESCRIPTION + * WLAN scan result callback function + * APPs need to copy the bss info byself. + * PARAMETERS + * job_id : [IN] APP's job ID from return value by calling WLAN scan operation + * user_data : [IN] APP's piggyback user_data + * scan_res : [IN] Scan results from WLAN srv + * RETURNS + * success if 0, else failure. + *****************************************************************************/ +typedef void (*vm_wlan_scan_res_cb_func_ptr) ( + VMUINT32 job_id, + void *user_data, + vm_wlan_scan_result_struct *scan_res); + + + +/***************************************************************************** + * FUNCTION + * vm_wlan_connect + * DESCRIPTION + * The function is used to connect the AP specified by the info in ap_info. + * 1. DA WLAN servive can only support one connection at the same time due to chip constraint. + * 2. If the new connect request is arrived, current connecting process will be aborted. + * 3. If there is one connection already, the connection will be disconnected + * then connect a new one. + * PARAMETERS + * prof_id : [IN] prof_id for wlan profile + * callback : [IN] connect result callback notify function for APP + * user_data : [IN] application associated piggyback data + * RETURN VALUES + * VM_WLAN_RESULT_INVALID_INPUT : profile_num <= 0 or profile pointer invalid + * VM_WLAN_RESULT_STATE_ERROR : the wlan status can't perform the scan process + * VM_WLAN_RESULT_PROCESSING : accept the connect quest, wait for event notify. + * SEE ALSO + * vm_wlan_prof_connect + * EXAMPLE + * + * // STA status is ACTIVED before calling vm_wlan_connect(). + * vm_wlan_ap_info_struct ap_info = {0}; + * strcpy(ap_info.ssid, "ssidexample"); + * ap_info.auth_mode = VM_WLAN_AUTH_MODE_WPA_ONLY_PSK; + * strcpy(ap_info.password, "ssidpwd"); + * vm_wlan_connect(&ap_info, conn_cb, NULL); + * void conn_cb(void *user_data, vm_wlan_req_res_enum res) + * { + * if (VM_WLAN_REQ_RES_DONE == res) + * { + * // Connection succeeds. + * } + * } + * + *****************************************************************************/ +VMINT vm_wlan_connect( + vm_wlan_ap_info_struct *ap_info, + vm_wlan_conn_res_cb_func_ptr callback, + void *user_data); + +/***************************************************************************** + * FUNCTION + * vm_wlan_disconnect + * DESCRIPTION + * 1. The function is used to disconnect current WLAN connection. + * 2. After WLAN init process is done, SRV will callback APP with user_data. + * PARAMETERS + * callback : [IN] callback function to notify applications the disconnect operation is done + * user_data : [IN] application piggyback data + * RETURN VALUES + * refer to vm_wlan_result_enum + * VM_WLAN_RESULT_STATE_ERROR : the wlan status can't perform the disconnect process + * VM_WLAN_RESULT_SUCCESS : the WLAN status is active. + * VM_WLAN_RESULT_PROCESSING : accept the disconnect quest, wait for event notify. + * EXAMPLE + * + * // STA status is CONNECTED before calling vm_wlan_disconnect(). + * vm_wlan_disconnect(disconn_cb, NULL); + * void disconn_cb(void *user_data, vm_wlan_req_res_enum res) + * { + * if (VM_WLAN_REQ_RES_DONE == res) + * { + * // Disconnection succeeds. + * } + * } + * + *****************************************************************************/ +VMINT vm_wlan_disconnect(vm_wlan_cb_func_ptr callback, void *user_data); + + + +/***************************************************************************** + * FUNCTION + * vm_wlan_mode_set + * DESCRIPTION + * The function is used to switch the mode. + * VM_WLAN_SET_MODE_OFF turns off both AP mode and STA mode. + * VM_WLAN_SET_MODE_AP turns only AP mode on. + * VM_WLAN_SET_MODE_STA turns only STA mode on. + * VM_WLAN_SET_MODE_AP_STA turns both AP mode and STA mode on. + * PARAMETERS + * mode : [IN] The mode wanted to switch on. + * RETURN VALUES + * + * EXAMPLE + * + * vm_wlan_mode_set(VM_WLAN_SET_MODE_AP, switch_mode_cb, NULL); + * void switch_mode_cb(void *user_data, vm_wlan_req_res_enum res) + * { + * if (VM_WLAN_REQ_RES_DONE == res) + * { + * // Switch mode successfully. + * } + * } + * + *****************************************************************************/ +VMINT vm_wlan_mode_set(vm_wlan_set_mode_enum mode, vm_wlan_cb_func_ptr callback, void *user_data); + + + +/***************************************************************************** + * FUNCTION + * vm_wlan_mode_get + * DESCRIPTION + * The function is query the status of WLAN services. + * PARAMETERS + * void + * RETURNS + * refer to vm_wlan_mode_status_enum + * EXAMPLE + * + * vm_wlan_mode_status_enum mode; + * mode = srv_wlan_status(); + * + *****************************************************************************/ +VMINT vm_wlan_mode_get(void); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_status + * DESCRIPTION + * The function is used to query current status in WLAN STA mode. + * PARAMETERS + * VMINT + * RETURNS + * vm_wlan_sta_status_enum + * VM_WLAN_STA_STATUS_BUSY means that WIFI status is changing, + * User need to wait changing finish and poll the result in interval timer + * EXAMPLE + * + * srv_wlan_sta_status_enum sta_status; + * sta_status = srv_wlan_sta_status(); + * + *****************************************************************************/ +VMINT vm_wlan_status(void); + + + +/***************************************************************************** + * FUNCTION + * vm_wlan_get_ip_info + * DESCRIPTION + * The function is used to get ip addr, netmask, gateway ip, dns, when they are available. + * These ip info will be available only when wlan srv is in CONNECTED status. And there're + * two situation due to the way of how to get ip. + * If using static ip when connecting, the ip will be availabe once connection succeeds. + * If using DHCP when connecting, ip will be availabe only when ABM notify the ip by MSG. + * That'll take a little time after connection succeeds. + * PARAMETERS + * ip_info : [OUT] Ip info + * RETURN VALUES + * VM_WLAN_RESULT_SUCCESS: Successfuly. + * VM_WLAN_RESULT_STATE_ERROR: Wrong time to get ip for ip is not available. + * VM_WLAN_RESULT_FAILED: Failed. + * EXAMPLE + * + * vm_wlan_ip_info_struct ip_info = {0}; + * vm_wlan_get_ip_info(&ip_info); + * + *****************************************************************************/ +VMINT vm_wlan_get_ip_info(vm_wlan_ip_info_struct* ip_info); + + + +/***************************************************************************** + * FUNCTION + * vm_wlan_get_mac_address + * DESCRIPTION + * The function is used to get MAC address. + * 1. dest buffer length must be >= VM_WLAN_WNDRV_MAC_ADDRESS_LEN, i.e. dest_len must + * be >= VM_WLAN_WNDRV_MAC_ADDRESS_LEN, otherwise WLAN SRV will be failure + * and reqired length (VM_WLAN_WNDRV_MAC_ADDRESS_LEN) will be set back to application. + * 2. Also, if dest = NULL, and req_len exist, it will get failure + * with required length in req_len for application. + * PARAMETERS + * mac_address_out : [OUT] MAC address output location + * RETURN VALUES + * success if 0, else failure. + * EXAMPLE + * + * CHAR dest[VM_WLAN_WNDRV_MAC_ADDRESS_LEN] = {0}; + * vm_wlan_prof_str_info_qry_struct mac_addr; + * mac_addr.dest = dest; + * mac_addr.dest_len = VM_WLAN_WNDRV_MAC_ADDRESS_LEN; + * vm_wlan_get_mac_address(&mac_addr); + * + *****************************************************************************/ +VMINT vm_wlan_get_mac_address(vm_wlan_prof_str_info_qry_struct *mac_address_out); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_get_connected_ap_info + * DESCRIPTION + * The function is used to get information of the connected AP, such as bssid, rssi, + * and profile id. + * + * Input parameter, info_type, indicates what kind of information is wanted. User should provide + * enough memory to store the information as following: + * + * info_type info + * VM_WLAN_AP_INFO_BSSID U8 array with length at least VM_WLAN_WNDRV_MAC_ADDRESS_LEN + 1 + * VM_WLAN_AP_INFO_PROF_ID U32* points to a U32 variable + * VM_WLAN_AP_INFO_RSSI S32* points to an S32 variable + * VM_WLAN_AP_INFO_ALL vm_wlan_conned_ap_info_struct* to an vm_wlan_conned_ap_info_struct variable + * + * PARAMETERS + * info [OUT]: parameter used to store ap info. Please refer to the description. + * info_type [IN]: vm_wlan_ap_info_type_enum + * RETURN VALUES + * success if 0, else failure. + * EXAMPLE + * + * // To get bssid + * U8 bssid[VM_WLAN_WNDRV_MAC_ADDRESS_LEN + 1] = {0}; + * vm_wlan_get_connected_ap_info((void*)bssid, VM_WLAN_AP_INFO_BSSID); + * // To get prof id + * U32 prof_id; + * vm_wlan_get_connected_ap_info((void*)&prof, VM_WLAN_AP_INFO_PROF_ID); + * // To get rssi + * S32 rssi; + * vm_wlan_get_connected_ap_info((void*)&rssi, VM_WLAN_AP_INFO_RSSI); + * // To get all inforamtion + * vm_wlan_conned_ap_info_struct ap_info = {0}; + * vm_wlan_get_connected_ap_info((void*)&ap_info, VM_WLAN_AP_INFO_ALL); + * + *****************************************************************************/ +VMINT vm_wlan_get_connected_ap_info(void *info, VMINT info_type); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_scan + * DESCRIPTION + * The function is used to scan the AP list for applications. + * PARAMETERS + * callback : [IN] scan result callback notify function for APP + * user_data : [IN] application piggyback data + * RETURN VALUES + * Job ID > 0 : New scan job created successfully. + * Job ID <= 0 : Can't create a new scan job. + * EXAMPLE + * + * U32 job_id; + * job_id = vm_wlan_scan(scan_cb, NULL); + * void scan_cb( + * U32 job_id, + * void *user_data, + * vm_wlan_scan_result_struct *scan_res) + * { + * if (VM_WLAN_SCAN_RESULT_SUCCESS == scan_res->result) + * { + * // Scan successfully. Information of APs scaned is in scan_res. + * } + * } + * + *****************************************************************************/ +VMINT vm_wlan_scan(vm_wlan_scan_res_cb_func_ptr callback, void *user_data); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_scan_abort + * DESCRIPTION + * The function is used to abort the scanning AP list process for applications. + * PARAMETERS + * job_id : [IN] created job ID from calling vm_wlan_scan + * RETURNS + * success if 0, else failure. + * EXAMPLE + * + * // scan job_id is returned by vm_wlan_scan(). + * vm_wlan_scan_abort(job_id); + * + *****************************************************************************/ +VMINT vm_wlan_scan_abort(VMUINT32 job_id); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_scan_set_param + * DESCRIPTION + * The function is used to set scan parameters, such as dwell time or specific ssid list. + * For scan parameters will be initialized to the default value evertytime wlan is turned on + * from inactive status, setting scan parameters is not useful at INACTIVE status, so it's not + * allowed. + * If scan parameter(s) is(are) not set, default value(s) will be used. + * Default values: dwell time: 60 spec_ssid_list: NULL + * + * Input parameter param_type indicates the kind of scan param that is wanted to be set. User + * should provide proper param to each kind of scan param as following: + * + * param_type param + * VM_WLAN_SCAN_PARAM_DWELL_TIME U16* points to a U16 variable + * VM_WLAN_SCAN_PARAM_SPEC_SSID_LIST vm_wlan_spec_ssid_list_struct* points to an + * vm_wlan_spec_ssid_list_struct variable + * PARAMETERS + * param [IN] scan parameters + * param_type [IN] vm_wlan_scan_param_type_enum + * RETURN VALUES + * VM_WLAN_RESULT_SUCCESS: Successfuly. + * VM_WLAN_RESULT_FAILED: Failed. + * VM_WLAN_RESULT_INVALID_INPUT: Invalid input parameter(s). + * VM_WLAN_RESULT_STATE_ERROR: Set scan parameter(s) in INACTIVE status + * EXAMPLE + * + * // Set dwell time + * U16 dwell_time = 70; + * vm_wlan_scan_set_param((void*)&dwell_time, VM_WLAN_SCAN_PARAM_DWELL_TIME, set_dwell_time_cb, NULL); + * + * void set_dwell_time_cb(void *user_data, vm_wlan_req_res_enum res) + * { + * if (VM_WLAN_REQ_RES_DONE == res) + * { + * // Set dwell time successfully. + * } + * } + * // Set specialized ssid list + * vm_wlan_spec_ssid_list_struct ssid_list = {0}; + * ssid_list.ssid_list[0] = {5, "ssid1"}; + * ssid_list.ssid_list[1] = {5, "ssid2"}; + * ssid_list.ssid_list[2] = {5, "ssid3"}; + * ssid_list.ssid_list[3] = {5, "ssid4"}; + * ssid_list.ssid_list_num = 4; + * vm_wlan_scan_set_param((void*)&ssid_list, VM_WLAN_SCAN_PARAM_SPEC_SSID_LIST, set_spec_ssid_list_cb, NULL); + * void set_spec_ssid_list_cb(void *user_data, vm_wlan_req_res_enum res) + * { + * if (VM_WLAN_REQ_RES_DONE == res) + * { + * // Set specialized ssid list successfully. + * } + * } + * + *****************************************************************************/ +VMINT vm_wlan_scan_set_param( + void *param, + VMINT32 param_type, + vm_wlan_cb_func_ptr callback, + void *user_data); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_scan_get_param + * DESCRIPTION + * The function is used to get scan parameters, such as dwell time or specific ssid list. + * + * Input parameter param_type indicates the kind of scan param that is wanted. User + * should provide proper param to each kind of scan param as following: + * + * param_type param + * VM_WLAN_SCAN_PARAM_DWELL_TIME U16* points to a U16 variable + * VM_WLAN_SCAN_PARAM_SPEC_SSID_LIST vm_wlan_spec_ssid_list_struct* points to an + * vm_wlan_spec_ssid_list_struct variable + * PARAMETERS + * param [OUT] scan parameters + * param_type [IN] vm_wlan_scan_param_type_enum + * RETURN VALUES + * VM_WLAN_RESULT_SUCCESS: Successfuly. + * VM_WLAN_RESULT_FAILED: Failed. + * VM_WLAN_RESULT_INVALID_INPUT: Invalid input parameter(s). + * EXAMPLE + * + * // Get dwell time + * U16 dwell_time; + * vm_wlan_scan_get_param((void*)&dwell_time, VM_WLAN_SCAN_PARAM_DWELL_TIME); + * // Get specialized ssid list + * vm_wlan_spec_ssid_list_struct ssid_list; + * vm_wlan_scan_get_param((void*)&ssid_list, VM_WLAN_SCAN_PARAM_SPEC_SSID_LIST); + * + *****************************************************************************/ +VMINT vm_wlan_scan_get_param(void *param, VMINT32 param_type); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_reg_noti + * DESCRIPTION + * The function is used to register the handler of notifications, such as ip available notification, or + * WIFI passive disconnect notification. When relative things happens, notification will be actived and + * callback function will be invoked if it's registered before. + * + * vm_wlan_reg_noti() should be paired with vm_wlan_dereg_noti(). + * PARAMETERS + * noti_type : [IN] Notification type. Please refer to vm_wlan_noti_type_enum + * callback : [IN] callback function to notify that notification is coming + * user_data : [IN] application piggyback data + * RETURN VALUES + * success if 0, else failure. + * EXAMPLE + * + * vm_wlan_reg_noti(VM_WLAN_NOTI_IP_AVAILABLE, ip_available_hdl, NULL); + * // When IP is available, ip_available_hdl will be called. + * void ip_available_hdl(void *user_data, vm_wlan_noti_struct *noti) + * { + * if (noti->type == VM_WLAN_NOTI_IP_AVAILABLE) + * { + * //... + * } + * } + * + *****************************************************************************/ +VMINT vm_wlan_reg_noti(VMINT noti_type, vm_wlan_noti_func_ptr callback, void *user_data); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_dereg_noti + * DESCRIPTION + * The function is used to deregister the handler of notifications which is registered before. + * the type of notification, callback and user_data should be the same as the one that registed + * by using vm_wlan_reg_noti(). + * + * vm_wlan_dereg_noti() should be paired with vm_wlan_reg_noti() + * PARAMETERS + * noti_type : [IN] Notification type. Please refer to vm_wlan_noti_type_enum + * callback : [IN] callback function to notify that notification is coming + * user_data : [IN] application piggyback data + * RETURN VALUES + * success if 0, else failure. + * EXAMPLE + * + * vm_wlan_reg_noti(VM_WLAN_NOTI_IP_AVAILABLE, ip_available_hdl, NULL); + * // Deregister with the same callback and user_data. Then when IP is avaliable, ip_available_hdl + * // will not be called. + * vm_wlan_dereg_noti(VM_WLAN_NOTI_IP_AVAILABLE, ip_available_hdl, NULL); + * + *****************************************************************************/ +VMINT vm_wlan_dereg_noti(VMINT noti_type, vm_wlan_noti_func_ptr callback, void *user_data); + + + +/***************************************************************************** + * FUNCTION + * vm_wlan_sniffer_on + * DESCRIPTION + * The function is used to open sniffer in WLAN STA mode. + * PARAMETERS + * sniffer_on_config : [IN] the configuration parameter of sniffer status + * callback : [IN] callback function to notify applications the operation is done + * user_data : [IN] application piggyback data + * RETURN VALUES + * VM_WLAN_RESULT_SUCCESS : Successfuly. + * VM_WLAN_RESULT_FAILED : Failed. + * VM_WLAN_RESULT_INVALID_INPUT : Invalid input parameter(s). + * VM_WLAN_RESULT_PROCESSING : Waiting for result. + * EXAMPLE + * + * vm_wlan_sniffer_on(NULL, sniffer_on_cb, NULL); + * void sniffer_on_cb(void *user_data, vm_wlan_sniffer_on_res_struct *res) + * { + * switch (res->cb_type) + * { + * case VM_WLAN_SNIFFER_ON_RES: + * { + * if (res->result == VM_WLAN_SNIFFER_SUCCESS) + * { + * // Open sniffer successfully. + * } + * break; + * } + * case VM_WLAN_SNIFFER_ON_AP_INFO: + * { + * if (res->result == VM_WLAN_SNIFFER_SUCCESS) + * { + * // Get AP information successfully. And Ap information is stored + * // in res->profile. + * } + * break; + * } + * default: + * break; + * } + * } + * + *****************************************************************************/ +VMINT vm_wlan_sniffer_on(vm_wlan_sniffer_on_cfg_struct *sniffer_on_config, vm_wlan_sniffer_on_cb_func_ptr callback, void *user_data); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_sniffer_off + * DESCRIPTION + * The function is used to close sniffer in WLAN STA mode. + * PARAMETERS + * callback : [IN] callback function to notify applications the operation is done + * user_data : [IN] application piggyback data + * RETURN VALUES + * VM_WLAN_RESULT_SUCCESS : Successfuly. + * VM_WLAN_RESULT_FAILED : Failed. + * VM_WLAN_RESULT_INVALID_INPUT : Invalid input parameter(s). + * VM_WLAN_RESULT_PROCESSING : Waiting for result. + * EXAMPLE + * + * vm_wlan_sniffer_off(sniffer_off_cb, NULL); + * void sniffer_off_cb(void *user_data, vm_wlan_sniffer_res_enum res) + * { + * if (VM_WLAN_SNIFFER_SUCCESS == res) + * { + * // Exist sniffer successfully. + * } + * } + * + *****************************************************************************/ +VMINT vm_wlan_sniffer_off(vm_wlan_sniffer_off_cb_func_ptr callback, void *user_data); + + + +/***************************************************************************** + * FUNCTION + * vm_wlan_prof_init + * DESCRIPTION + * The function is used to init the wlan profile structure. In other words, fill in default + * values for the structure data members. + * PARAMETERS + * profile : [OUT] specified profile to be set + * RETURN VALUES + * refer to vm_wlan_result_enum + * EXAMPLE + * + * vm_wlan_prof_struct wlan_prof; + * vm_wlan_prof_init(&wlan_prof); + * + *****************************************************************************/ +VMINT vm_wlan_prof_init(vm_wlan_prof_struct *profile); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_prof_add + * DESCRIPTION + * The function is to add a new wlan profile by specified profile data. + * PARAMETERS + * prof : [IN] profile data buffer to be added + * prof_id : [OUT] return prof_id for wlan profile + * RETURN VALUES + * refer to vm_wlan_result_enum + * VM_WLAN_RESULT_SUCCESS : add profile successfully. + * VM_WLAN_RESULT_FAILED : add profile failed. + * VM_WLAN_RESULT_ONE_STORE_EXISTS : the profile has already been added. + * VM_WLAN_RESULT_INVALID_STORE : store handle invalid. + * VM_WLAN_RESULT_INVALID_INPUT : the input parameter is invalid. + * VM_WLAN_RESULT_STORE_FULL : storage full + * EXAMPLE + * + * vm_wlan_prof_struct wlan_prof; + * U32 prof_id = 0; + * vm_wlan_result_enum ret; + * vm_wlan_prof_init(&wlan_prof); + * strcpy(wlan_prof.ssid, "ssidexample"); + * // If auth mode is VM_WLAN_AUTH_MODE_OPEN, password is no need. + * wlan_prof.auth_mode = VM_WLAN_AUTH_MODE_WPA2_ONLY_PSK; + * strcpy(wlan_prof.password, "ssidpwd"); + * ret = vm_wlan_prof_add(&wlan_prof, &prof_id); + * if (ret == VM_WLAN_RESULT_SUCCESS) + * { + * // Add profile successfully. + * } + * + *****************************************************************************/ +VMINT vm_wlan_prof_add(const vm_wlan_prof_struct *prof, VMUINT32 *prof_id); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_prof_update + * DESCRIPTION + * The function is to update WLAN profile content by specified profile id. Structure + * data members can be updated seperately, or updated all at one time. + * PARAMETERS + * prof_id : [IN] update wlan profile id + * wlan_prof : [IN] profile info from application + * prof_fields : [IN] VM_WLAN_PROF_FIELD_X, such as VM_WLAN_PROF_FIELD_ALL + * RETURN VALUES + * refer to vm_wlan_result_enum + * VM_WLAN_RESULT_SUCCESS : update profile successfully. + * VM_WLAN_RESULT_INVALID_STORE : store handle invalid. + * VM_WLAN_RESULT_INVALID_INPUT : the input parameter is invalid. + * VM_WLAN_RESULT_READ_ONLY : this profile can't be deleted or update + * EXAMPLE + * + * // Fill in the new value for the data members you want to update. + * vm_wlan_prof_struct wlan_prof = {0}; + * strcpy(wlan_prof.password, "newpwd"); + * // There's an avaialbe profile id(For how to get an available profile id, please + * // refer to vm_wlan_prof_add()). + * vm_wlan_prof_update(prof_id, &wlan_prof, VM_WLAN_PROF_FIELD_PW); + * + *****************************************************************************/ +VMINT vm_wlan_prof_update(VMUINT32 prof_id, vm_wlan_prof_struct *prof, VMUINT32 prof_fields); + + + +/***************************************************************************** + * FUNCTION + * vm_wlan_prof_delete + * DESCRIPTION + * The function is to delete a WLAN profile by specified profile id. + * PARAMETERS + * prof_id : [IN] query wlan profile id + * RETURN VALUES + * refer to vm_wlan_result_enum + * VM_WLAN_RESULT_SUCCESS : delete profile successfully. + * VM_WLAN_RESULT_INVALID_STORE : store handle invalid. + * VM_WLAN_RESULT_INVALID_INPUT : the input parameter is invalid. + * VM_WLAN_RESULT_READ_ONLY : this profile can't be deleted or update + * EXAMPLE + * + * // There's an avaialbe profile id(For how to get an available profile id, please + * // refer to vm_wlan_prof_add()). + * vm_wlan_prof_delete(prof_id); + * + *****************************************************************************/ +VMINT vm_wlan_prof_delete(VMUINT32 prof_id); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_prof_connect + * DESCRIPTION + * The function is used to connect the applications specified AP for applications. + * 1. DA WLAN servive can only support one connection at the same time due to chip constraint. + * 2. If the new connect request is arrived, current connecting process will be aborted. + * 3. If there is one connection already, the connection will be disconnected + * then connect a new one. + * PARAMETERS + * prof_id : [IN] prof_id for wlan profile + * callback : [IN] connect result callback notify function for APP + * user_data : [IN] application associated piggyback data + * RETURN VALUES + * refer to vm_wlan_result_enum + * VM_WLAN_RESULT_INVALID_INPUT : profile_num <= 0 or profile pointer invalid + * VM_WLAN_RESULT_STATE_ERROR : the wlan status can't perform the scan process + * VM_WLAN_RESULT_PROCESSING : accept the connect quest, wait for event notify. + * EXAMPLE + * + * // STA status is ACTIVED before calling vm_wlan_prof_connect(). And there's an available + * // profile id(For how to get an available profile id, please refer to vm_wlan_prof_add()). + * vm_wlan_prof_connect(prof_id, conn_cb, NULL); + * void conn_cb(void *user_data, vm_wlan_req_res_enum res) + * { + * if (VM_WLAN_REQ_RES_DONE == res) + * { + * // Connection succeeds. + * } + * } + * + *****************************************************************************/ +VMINT vm_wlan_prof_connect(VMUINT32 prof_id, vm_wlan_conn_res_cb_func_ptr callback, void *user_data); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_prof_query + * DESCRIPTION + * The function is to query WLAN profile content by specified profile id. + * PARAMETERS + * prof_id : [IN] query wlan profile id + * prof : [OUT] profile info from application + * RETURN VALUES + * refer to vm_wlan_result_enum + * VM_WLAN_RESULT_SUCCESS : query profile successfully. + * VM_WLAN_RESULT_INVALID_STORE : store handle invalid. + * VM_WLAN_RESULT_INVALID_INPUT : the input parameter is invalid. + * EXAMPLE + * + * // There's an avaialbe profile id(For how to get an available profile id, please + * // refer to vm_wlan_prof_add()). + * vm_wlan_prof_struct wlan_prof = {0}; + * VM_WLAN_RESULT_SUCCESS ret; + * ret = vm_wlan_prof_query(prof_id, &wlan_prof); + * if (VM_WLAN_RESULT_SUCCESS == ret) + * { + * // Query profile successfully. wlan_prof returns with detail of the profile. + * } + * + *****************************************************************************/ +VMINT vm_wlan_prof_query(VMUINT32 prof_id, vm_wlan_prof_struct *prof); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_prof_query_list + * DESCRIPTION + * The function is to query the number and ids of the WLAN profiles added. + * PARAMETERS + * prof_list : [IN] query wlan profile list + * RETURN VALUES + * refer to vm_wlan_result_enum + * VM_WLAN_RESULT_SUCCESS : query profile successfully. + * VM_WLAN_RESULT_INVALID_STORE : store handle invalid. + * VM_WLAN_RESULT_INVALID_INPUT : the input parameter is invalid. + * EXAMPLE + * + * vm_wlan_prof_list_struct prof_list; + * vm_wlan_prof_query_list(&prof_list); + * + *****************************************************************************/ +VMINT vm_wlan_prof_query_list(vm_wlan_prof_list_struct *prof_list); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_set_reconn_prof_id + * DESCRIPTION + * The function is used to set reconnect profile id. It will be stored and may be used + * in reconfig flow. Every time connection succeeds, the reconn prof id will be set to + * be the conn prof id automatically. + * PARAMETERS + * prof_id : [IN] WLAN profile id which has been stored in WLAN service + * RETURN VALUES + * success if 0, else failure. + * EXAMPLE + * + * // There's an avaialbe profile id(For how to get an available profile id, please + * // refer to vm_wlan_prof_add()). + * vm_wlan_prof_set_reconn_id(prof_id); + * + *****************************************************************************/ +VMINT vm_wlan_prof_set_reconn_id(VMUINT32 prof_id); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_get_reconn_prof_id + * DESCRIPTION + * The function is used to get reconnect profile id. It will be stored and may be used + * in bootup flow. Everytime connection succeeds, the reconn prof id will be set to be + * the conn prof id automatically. + * PARAMETERS + * prof_id : [OUT] WLAN profile id which has been stored in WLAN service + * RETURN VALUES + * success if 0, else failure. + * EXAMPLE + * + * U32 prof_id; + * vm_wlan_prof_get_reconn_id(&prof_id); + * + *****************************************************************************/ +VMINT vm_wlan_prof_get_reconn_id(VMUINT32 *prof_id); + + +/***************************************************************************** + * FUNCTION + * vm_wlan_roaming_set + * DESCRIPTION + * The function is used to set roaming parameter. + * PARAMETERS + * enable_roaming : [IN] WLAN roaming parameter + * RETURN VALUES + * VM_WLAN_RESULT_SUCCESS : Successfuly. + * VM_WLAN_RESULT_FAILED : Failed. + * VM_WLAN_RESULT_PROCESSING : Waiting for result. + * EXAMPLE + * + * MMI_BOOL enable_roaming = MMI_TRUE; + * vm_wlan_roaming_set(enable_roaming, set_roaming_cb, NULL); + * void set_roaming_cb(void *user_data, vm_wlan_req_res_enum res) + * { + * if (VM_WLAN_REQ_RES_DONE == res) + * { + * // Set roaming successfully. + * } + * } + * + *****************************************************************************/ +VMINT vm_wlan_roaming_set(VMINT enable_roaming, vm_wlan_cb_func_ptr callback, void *user_data); + +/***************************************************************************** + * FUNCTION + * vm_wlan_roaming_get + * DESCRIPTION + * The function is used to get roaming parameter. + * PARAMETERS + * is_roaming : [OUT] WLAN roaming parameter + * RETURN VALUES + * VM_WLAN_RESULT_SUCCESS: Successfuly. + * VM_WLAN_RESULT_FAILED: Failed. + * EXAMPLE + * + * MMI_BOOL is_roaming = MMI_TRUE; + * vm_wlan_roaming_get(&is_roaming); + * + *****************************************************************************/ +VMINT vm_wlan_roaming_get(VMINT *is_roaming); + + +/***************************************************************************** + * FUNCTION + * vm_srv_wlan_set_para + * DESCRIPTION + * Set parameters under different modes. User should prepare variables with proper types for + * "para" and "flag" input parameters. + * + * Currently, only MODE_AP and MODE_AP_STA are supported to set AP's SSID, Auth mode, and + * Password. For Auth mode, only OPEN and WPA2_ONLY_PSK are supported. To make the parameter(s) + * work, do set parameter(s) before AP is turned on. + * + * Default values will be used if parameters are not set or setting operation failed. + * Default SSID: MTK_XXXXXX(The value of XXXXXX depends on the last three bytes of mac addr) + * Default AUTH MODE: WPA2_ONLY_PSK + * Default Password: 12345678 + * + * PARAMETERS + * para : [IN] vm_wlan_cfg_ap_struct(in AP mode) + * flag : [IN] Indicate which parameter to config. + * vm_wlan_cfg_ap_para_enum(in AP mode) + * RETURNS + * VM_WLAN_RESULT_SUCCESS: set parameter success + * VM_WLAN_RESULT_FAILED: set parameter fail + * VM_WLAN_RESULT_STATE_ERROR: set at inappropriate state, such as set AP para when AP is on. + * VM_WLAN_RESULT_INVALID_INPUT: invalid input parameters. + * EXAMPLE + * + * // Set AP parameter before turning on AP mode. + * srv_wlan_cfg_ap_struct ap_param = {0}; + * ap_param.auth_mode = VM_WLAN_AUTH_MODE_WPA2_ONLY_PSK; + * strcpy(ap_param.ssid, "SSIDEXAMPLE"); + * strcpy(ap_param.pwd, "PWDEXAMPLE") + * vm_wlan_set_para(VM_WLAN_SET_MODE_AP, (void*)&ap_param, VM_WLAN_CFG_AP_PARA_ALL); + * + *****************************************************************************/ +VMINT vm_wlan_set_para( + vm_wlan_set_mode_enum mode, + void *para, + VMINT32 flag); + + +/***************************************************************************** + * FUNCTION + * vm_srv_wlan_get_para + * DESCRIPTION + * Get parameter under different modes. Currently, only MODE_AP or MODE_AP_STA are + * supported to get AP's SSID, Auth mode, and Password. + + * User should prepare varible with proper type for "para" input parameter. + * PARAMETERS + * para : [OUT] return parameters to App. + * srv_wlan_cfg_ap_struct(under MODE_AP or MODE_AP_STA) + * RETURNS + * VM_WLAN_RESULT_SUCCESS: get parameter success + * VM_WLAN_RESULT_FAILED: get parameter fail + * VM_WLAN_RESULT_INVALID_INPUT: invalid input parameters. + * EXAMPLE + * + * vm_wlan_cfg_ap_struct ap_param = {0}; + * vm_wlan_get_para(SRV_WLAN_SET_MODE_AP, (void*)&ap_param); + * + *****************************************************************************/ +VMINT vm_wlan_get_para( + vm_wlan_set_mode_enum mode, + void *para); + + + + +#define VM_SCANONLY_MAX_SCAN_AP_NUM 15 +#define VM_SCANONLY_MAC_ADDRESS_LEN 6 +#define VM_SCANONLY_SSID_MAX_LEN 32 + +typedef enum +{ + VM_WNDRV_RESULT_SUCCESS, + VM_WNDRV_RESULT_WOULDBLOCK, + VM_WNDRV_RESULT_TOTAL +} vm_wndrv_result_enum; + +typedef enum + +{ + VM_SCANONLY_SUCCESS = 0, + + VM_SCANONLY_INIT_BUSY_IS_INITING= 1, + VM_SCANONLY_INIT_FAIL__ALREAD_INITED, + VM_SCANONLY_INIT_FAIL__DRIVER_REASON, + VM_SCANONLY_INIT_FAIL__UNKOWN, + + VM_SCANONLY_DEINIT_BUSY__IS_DEINITING = 10, + VM_SCANONLY_DEINIT_FAIL__ALREAD_DEINITED, + VM_SCANONLY_DEINIT_FAIL__DRIVER_REASON, + VM_SCANONLY_DEINIT_FAIL__UNKOWN, + + VM_SCANONLY_SCAN_BUSY__IS_SCANNING = 20, + VM_SCANONLY_SCAN_FAIL__NOT_INITED, + VM_SCANONLY_SCAN_FAIL__DRIVER_REASON, + VM_SCANONLY_SCAN_FAIL__UNKOWN, + + VM_SCANONLY_STATUS_END +}VM_SCANONLY_STATUS_ENUM; + +typedef struct +{ + // Reserved struct + void *para; +} vm_wlan_init_req_struct; + +typedef struct +{ + VM_SCANONLY_STATUS_ENUM state; +} vm_wlan_init_cnf_struct; + +typedef struct +{ + // Reserved struct + void *para; +} vm_wlan_deinit_req_struct; + +typedef struct +{ + VM_SCANONLY_STATUS_ENUM state; +} vm_wlan_deinit_cnf_struct; + +typedef struct +{ + // Reserved struct + void *para; +} vm_wlan_scan_req_struct; + + +typedef struct +{ + VMUINT8 bssid[ VM_SCANONLY_MAC_ADDRESS_LEN ]; + VMUINT8 ssid_len; + VMUINT8 ssid [ VM_SCANONLY_SSID_MAX_LEN ]; + signed char rssi; + VMUINT8 channel_number; +} vm_scanonly_scan_ap_info_struct; + +typedef struct +{ + VM_SCANONLY_STATUS_ENUM status; + VMUINT8 scan_ap_num; + vm_scanonly_scan_ap_info_struct scan_ap[ VM_SCANONLY_MAX_SCAN_AP_NUM ]; +} vm_wlan_scan_cnf_struct; + +/* Callback */ +typedef void (*vm_wlan_init_cb) (void *user_data, vm_wlan_init_cnf_struct *cnf); +typedef void (*vm_wlan_deinit_cb) (void *user_data, vm_wlan_deinit_cnf_struct *cnf); +typedef void (*vm_wlan_scan_cb) (void *user_data, vm_wlan_scan_cnf_struct *cnf); + +/***************************************************************************** + * FUNCTION + * vm_wndrv_init + * DESCRIPTION + * The function is used to switch WIFI on in station mode. + * PARAMETERS + * req : [IN] reserved parameter + * callback : [IN] init result callback notify function for APP + * user_data : [IN] application piggyback data + * RETURNS + * VM_WNDRV_RESULT_WOULDBLOCK : Wouldblock. callback will be invoked later to notify the result. + * EXAMPLE + * + * vm_wndrv_init(NULL, init_cb, NULL); + * void init_cb(void *user_data, vm_wlan_init_cnf_struct *cnf) + * { + * if (VM_SCANONLY_SUCCESS == cnf->state) + * { + * // successfully. + * } + * } + * + *****************************************************************************/ +VMINT vm_wndrv_init(vm_wlan_init_req_struct *req, vm_wlan_init_cb callback, void *user_data); + +/***************************************************************************** + * FUNCTION + * vm_wndrv_deinit + * DESCRIPTION + * The function is used to switch WIFI off. + * PARAMETERS + * req : [IN] reserved parameter + * callback : [IN] deinit result callback notify function for APP + * user_data : [IN] application piggyback data + * RETURNS + * VM_WNDRV_RESULT_WOULDBLOCK : Wouldblock. callback will be invoked later to notify the result. + * EXAMPLE + * + * vm_wndrv_deinit(NULL, deinit_cb, NULL); + * void deinit_cb(void *user_data, vm_wlan_deinit_cnf_struct *cnf) + * { + * if (VM_SCANONLY_SUCCESS == cnf->state) + * { + * // successfully. + * } + * } + * + *****************************************************************************/ +VMINT vm_wndrv_deinit(vm_wlan_deinit_req_struct *req, vm_wlan_deinit_cb callback, void *user_data); + +/***************************************************************************** + * FUNCTION + * vm_wndrv_scan + * DESCRIPTION + * The function is used to scan the AP list for applications. + * PARAMETERS + * req : [IN] reserved parameter + * callback : [IN] scan result callback notify function for APP + * user_data : [IN] application piggyback data + * RETURNS + * VM_WNDRV_RESULT_WOULDBLOCK : Wouldblock. callback will be invoked later to notify the result. + * EXAMPLE + * + * vm_wndrv_scan(NULL, scan_cb, NULL); + * void scan_cb(void *user_data, vm_wlan_scan_cnf_struct *cnf) + * { + * if (VM_SCANONLY_SUCCESS == cnf->status) + * { + * // Scan successfully. Information of APs scaned is in cnf. + * } + * } + * + *****************************************************************************/ +VMINT vm_wndrv_scan(vm_wlan_scan_req_struct *req, vm_wlan_scan_cb callback, void *user_data); + + +#ifdef __cplusplus +} +#endif + +#endif /* VM_NWSETTING_SDK_H */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmota.h b/hardware/arduino/mtk/system/libmtk/include/vmota.h new file mode 100644 index 00000000..0131715f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmota.h @@ -0,0 +1,140 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmota_sdk.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * ota + * + * Author: + * ------- + * + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ +* *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== +*******************************************************************************/ +#ifndef VM_OTA_SDK_H +#define VM_OTA_SDK_H +#ifdef __cplusplus +extern "C"{ +#endif/*__cplusplus*/ +#include "vmsys.h" + +#define VM_UPDATE_OK_ALREADY_DOWNLOADED 1 +#define VM_UPDATE_OK 0 +#define VM_UPDATE_ERROR -2 +#define VM_UPDATE_ERROR_GET_VERSION_FAIL -3 +#define VM_UPDATE_ERROR_GET_APP_ID_FAIL -4 +#define VM_UPDATE_ERROR_GET_SC_FAIL -5 +#define VM_UPDATE_ERROR_PATH_NOT_EXIST -6 +#define VM_UPDATE_ERROR_NO_MEMORY -7 +#define VM_UPDATE_ERROR_NO_UPDATE_FILE -8 +#define VM_UPDATE_ERROR_INTER -9 + +typedef void (*vm_update_app_callback)(VMINT hdl, void * para); + + + +/***************************************************************************** + * FUNCTION + * vm_update_check_version + * DESCRIPTION + * check new version is avaliable or not through service. + * PARAMETERS + * + * RETURNS + * error code, VM_UPDATE_OK means success, can get result from callback + * VM_UPDATE_OK_ALREADY_DOWNLOADED means new version already downloaded + *****************************************************************************/ +VMINT vm_update_check_version(VMSTR URL, VMINT port, VMINT apn, vm_update_app_callback callback, void* user_data); + +/***************************************************************************** + * FUNCTION + * vm_update_download + * DESCRIPTION + * after check version, can use this to download new version app + * PARAMETERS + * + * RETURNS + * error code, VM_UPDATE_OK means success, can get result from callback + *****************************************************************************/ +VMINT vm_update_download(VMINT handle, VMINT bOnCard, vm_update_app_callback callback, void* user_data); + + +/***************************************************************************** + * FUNCTION + * vm_update_update_file + * DESCRIPTION + * if downloaded, can use this to update to new version app. This will exit the running app. + * PARAMETERS + * + * RETURNS + *****************************************************************************/ +VMINT vm_update_update_file(void); + +/***************************************************************************** + * FUNCTION + * vm_update_cancel + * DESCRIPTION + * cancel the downloading process + * PARAMETERS + * + * RETURNS + *****************************************************************************/ +VMINT vm_update_cancel(VMINT handle); + +VMINT vm_update_check_launch(VMWSTR path, VMWSTR new_path); + + +#define vm_update_mre_app_callback vm_update_app_callback + +#ifdef __cplusplus +} +#endif/*__cplusplus*/ + +#endif/*VM_OTA_SDK_H*/ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmpayment.h b/hardware/arduino/mtk/system/libmtk/include/vmpayment.h new file mode 100644 index 00000000..e2942187 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmpayment.h @@ -0,0 +1,103 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VM_PURCHASE_SDK_H +#define VM_PURCHASE_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +typedef enum +{ + VM_BUYER_ALIPAY +}vm_payment_type_enum; + +typedef enum +{ + VM_PURCHASE_RET_ERR_PARAM, + VM_PURCHASE_RET_ERR_FAILURE, + VM_PURCHASE_RET_ERR_SIM, + VM_PURCHASE_RET_ERR_SUCCESS = 0, +}vm_purchase_ret_enum; + +typedef VMINT VM_H_BUYER; +typedef void (*purchase_cb)(void*); + + +/***************************************************************************** + * FUNCTION + * vm_create_buyer + * DESCRIPTION + * get the payment handle. + * PARAMETERS + * payment_type : [IN] + * RETURNS + * the handle of the buyer, non-negtive is successful +*****************************************************************************/ +VM_H_BUYER vm_create_buyer(vm_payment_type_enum payment_type); + +/***************************************************************************** +* FUNCTION + * vm_purchase_item + * DESCRIPTION + * the operation of item-purchase. + * PARAMETERS + * h : [IN] buyer handle. + * data : [IN] user data. + * cb : [IN] feedback of purchase + * RETURNS + * the number of process that have created already. +*****************************************************************************/ +VMINT vm_purchase_item(VM_H_BUYER h, void * data, purchase_cb cb); + + +/***************************************************************************** + * FUNCTION + * vm_release_buyer + * DESCRIPTION + * release the handle of buyer. + * PARAMETERS + * h : [IN] buyer handle. +*****************************************************************************/ +void vm_release_buyer(VM_H_BUYER h); + +#ifdef __cplusplus +} +#endif + +#endif /* VM_PURCHASE_SDK_H */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmpn.h b/hardware/arduino/mtk/system/libmtk/include/vmpn.h new file mode 100644 index 00000000..be4441aa --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmpn.h @@ -0,0 +1,316 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmpn.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * MRE push + * + * Author: + * ------- + * Feng Lin(mtk80996) + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ + * $Log$ + * + * 06 14 2012 feng.lin + * [MAUI_03129054] MRE PUSH Receiver check in CR + * . + * + * 05 15 2012 jianying.li + * [MAUI_03185909] [MREPUSH2.0] push 2.0 check-in + * . + * + * 05 10 2012 feng.lin + * [MAUI_02997195] [MRE_SOC] + * query key supported & pn supported. + * + * 04 23 2012 zhibo.tong + * [MAUI_03129054] MRE PUSH Receiver check in CR + * . + * + * 04 10 2012 zhibo.tong + * [MAUI_03129054] MRE PUSH Receiver check in CR + * . + * + * 04 10 2012 zhibo.tong + * [MAUI_03129054] MRE PUSH Receiver check in CR + * . + * + * 04 09 2012 zhibo.tong + * [MAUI_03129054] MRE PUSH Receiver check in CR + * . + * + * 04 05 2012 feng.lin + * [MAUI_03129054] MRE PUSH Receiver check in CR + * . + * + * 04 01 2012 feng.lin + * [MAUI_03129054] MRE PUSH Receiver check in CR + * . + * + * 04 01 2012 zhibo.tong + * [MAUI_03129054] MRE PUSH Receiver check in CR + * . + * + * 03 27 2012 feng.lin + * [MAUI_02997195] [MRE_SOC] + * push. + * + * 03 26 2012 zhibo.tong + * [MAUI_03129054] MRE PUSH Receiver check in CR + * . + * + * 03 22 2012 feng.lin + * [MAUI_02997195] [MRE_SOC] + * vmpn. + * + * *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== + *******************************************************************************/ +#ifndef VM_PN_SDK_H +#define VM_PN_SDK_H + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "vmsys.h" + +#define VM_SRV_PNS_ALERT_TEXT_MAX_LEN 150 /* include '\0' */ +#define VM_SRV_PNS_MAX_MSGBODY_SIZE 257 /* include '\0' */ +#define VM_SRV_PNS_REGID_LEN 26 /* include '\0' */ +#define VM_SRV_PNS_ACTION_TEXT_MAX_LEN 51 +#define VM_SRV_PNS_MAX_MPS_ARGS_NUM 3 +#define VM_SRV_PNS_MAX_MPS_ARG_LEN 21 /* include '\0' */ + +#define VM_PN_EVT_PARAM_HEADER \ +VMUINT16 evt_id; \ +VMUINT16 size; \ +void * user_data + + +typedef enum +{ + VM_SRV_PNS_NO_ERROR = 0, + VM_SRV_PNS_SERVICE_NOT_AVAILABLE = -1, + VM_SRV_PNS_INVALID_DATA_CONNECTION = -2, + VM_SRV_PNS_TOO_MANY_REGISTRATIONS = -3, + VM_SRV_PNS_INVALID_SENDER = -4, + VM_SRV_PNS_INVALID_APPID = -5, + VM_SRV_PNS_LAST_MSG_ON_PROCESSING = -6, + VM_SRV_PNS_SYSTEM_ERROR = -7, + + VM_SRV_PNS_ALREADY_IN_QUEUE = -8, + VM_SRV_PNS_JSON_PARSING_ERR = -9, + VM_SRV_PNS_JSON_PAYLOAD_FORMAT_ERR = -10, + VM_SRV_PNS_JSON_PAYLOAD_NOT_FOUND = -11, + + VM_SRV_PNS_PARAM_ERR = -12, + VM_SRV_PNS_QUERY_FAIL = -13, + + VM_SRV_PNS_ERR_TOTAL = -100 +} vm_srv_pns_result; + +typedef enum +{ + // list/File + SRV_MRE_PUSH_TYPE_LIST_NULL = -100, + SRV_MRE_PUSH_TYPE_LIST_NOT_FIND, + SRV_MRE_PUSH_TYPE_FILE_SAVE_FAIL, + + // dereg / reg + SRV_MRE_PUSH_TYPE_REG_ID_ALREADY_REG = -70, + SRV_MRE_PUSH_TYPE_DEREG_BADPARA, + + // Setting + SRV_MRE_PUSH_TYPE_SETTING_OFF = -50, + + // normal + SRV_MRE_PUHS_TYPE_BADPARA = -30, + SRV_MRE_PUHS_TYPE_INTERNAL_ERROR, + SRV_MRE_PUHS_TYPE_SUCCESS = 0, + SRV_MRE_PUHS_TYPE_FILE_EXIT, + SRV_MRE_PUHS_TYPE_FILE_NOT_EXIT, + SRV_MRE_PUHS_TYPE_END, +}srv_mre_push_type_enum; + + +typedef enum +{ + VM_SRV_MRE_MPR_QUERY_APP_ID = 0, + VM_SRV_MRE_MPR_QUERY_SENDER_ID, + VM_SRV_MRE_MPR_QUERY_REGISTER_ID, + VM_SRV_MRE_MPR_QUERY_SETTING_STATUS, + VM_SRV_MRE_MPR_QUERY_BADGE, + VM_SRV_MRE_MPR_QUERY_PAYLOAD, + VM_SRV_MRE_MPR_QUERY_PAYLOAD_COUNT, + VM_SRV_MRE_MPR_QUERY_PAYLOAD_BY_INDEX, + VM_SRV_MRE_MPR_QUERY_MULTIPLE_PAYLOAD, + VM_SRV_MRE_MPR_QUERY_END, +} vm_srv_pns_query_event; + + +/* + * please notify that:high-Weight is means ON/OFF. + * so if you add style don't change this for new type + * so never use 0x10000000 express a kind of style, +*/ +typedef enum +{ + VM_SRV_MRE_MPR_NOTIFY_STYLE_TEXT_PREVIEW = 0x00000001, + VM_SRV_MRE_MPR_NOTIFY_STYLE_POPUP = 0x00000010, + VM_SRV_MRE_MPR_NOTIFY_STYLE_END, +} vm_srv_pns_notify_style; + +typedef enum +{ + VM_SRV_MRE_MPR_NOTIFY_OFF = 0x00000000, + VM_SRV_MRE_MPR_NOTIFY_ON = 0x10000000, + VM_SRV_MRE_MPR_NOTIFY_END, +} vm_srv_pns_notify_switch; + +typedef struct +{ + VMUINT32 index; + VMCHAR * app_payload; /*the length of this should be VM_SRV_PNS_MAX_MSGBODY_SIZE or larger*/ +}vm_query_one_payload_by_index; /*when user query one payload,should transfer this struct to query function*/ + +typedef VMCHAR vm_one_payload_struct[VM_SRV_PNS_MAX_MSGBODY_SIZE]; +typedef struct +{ + VMUINT32 * payload_count; /*this is an input and also an output*/ + vm_one_payload_struct * app_payload; +}vm_query_multiple_payload_by_count;/*when user query multiple payload,should transfer this struct to query function*/ + +typedef struct +{ + VM_PN_EVT_PARAM_HEADER; +}vm_srv_pns_event_struct; + +typedef struct +{ + VM_PN_EVT_PARAM_HEADER; + VMINT appId; + VMCHAR reg_id[VM_SRV_PNS_REGID_LEN]; + vm_srv_pns_result result; +}vm_srv_pns_identity_event_struct; + + +typedef struct +{ + /* alert begin */ + VMINT32 mainLen; + VMCHAR main[VM_SRV_PNS_ALERT_TEXT_MAX_LEN]; + VMINT32 hintLen; + VMCHAR hint[VM_SRV_PNS_ALERT_TEXT_MAX_LEN]; + VMINT32 mainResId; + VMINT32 hintResId; + /* alert end */ + + VMINT32 actionLen; + VMCHAR action[VM_SRV_PNS_ACTION_TEXT_MAX_LEN]; + + VMINT32 badge; + VMINT32 icon; + VMINT32 sound; +}vm_srv_pns_msg_mps_struct; + +typedef struct +{ + /* alert begin */ + VMINT32 mainLen; + VMCHAR main[VM_SRV_PNS_ALERT_TEXT_MAX_LEN]; + VMINT32 hintLen; + VMCHAR hint[VM_SRV_PNS_ALERT_TEXT_MAX_LEN]; + VMINT32 mainResId; + VMCHAR main_args[VM_SRV_PNS_MAX_MPS_ARGS_NUM][VM_SRV_PNS_MAX_MPS_ARG_LEN]; + VMINT32 main_args_num; + + VMINT32 hintResId; + VMCHAR hint_args[VM_SRV_PNS_MAX_MPS_ARGS_NUM][VM_SRV_PNS_MAX_MPS_ARG_LEN]; + VMINT32 hint_args_num; + /* alert end */ + + VMINT32 actionLen; + VMCHAR action[VM_SRV_PNS_ACTION_TEXT_MAX_LEN]; + VMINT32 actionResId; + + VMINT32 badge; + VMINT32 icon; + VMINT32 sound; +}vm_srv_pns_msg_mps_struct_ex; +typedef struct +{ + VMBYTE dictionary; + VMCHAR msgBody[VM_SRV_PNS_MAX_MSGBODY_SIZE]; +}vm_srv_pns_msg_value_struct; + + +typedef VMINT (*vm_pn_cb)(vm_srv_pns_event_struct * evt, void * user_data); + + +VMINT vm_pn_is_support(void); + +VMINT vm_pn_get_global_setting(void); // 0 off; 1 on. + +VMINT vm_pn_reg(vm_pn_cb cb, void* user_data); +VMINT vm_pn_dereg(); +VMINT vm_pn_query(vm_srv_pns_query_event query_id, void * user_data); +VMINT vm_pn_get_mps_info(const VMCHAR * msgBody, vm_srv_pns_msg_mps_struct * mpsPtr); +VMINT vm_pn_get_object(const VMCHAR * msgBody, const VMCHAR * key, vm_srv_pns_msg_value_struct * value); +VMINT vm_pn_set_notify_style(vm_srv_pns_notify_switch OnOff, vm_srv_pns_notify_style style); +VMINT vm_pn_set_badge(VMINT32 badge_number); +VMINT vm_pn_get_mps_info_ex(const VMCHAR * msgBody, vm_srv_pns_msg_mps_struct_ex * mpsPtr); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* VM_PN_H */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmpromng.h b/hardware/arduino/mtk/system/libmtk/include/vmpromng.h new file mode 100644 index 00000000..876ec385 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmpromng.h @@ -0,0 +1,719 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef _VM_PRO_MNG_SDK_ +#define _VM_PRO_MNG_SDK_ + +#include "vmsys.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +typedef VMINT VM_P_HANDLE;/*VMINT*/ + +//process procedure related interfaces + +#define VM_PMNG_OP_OK (0) +#define VM_PMNG_PROCESS_NO_EXISTS (-1) +#define VM_PMNG_NO_OP_IN_STATUS (-2) +#define VM_PMNG_ERROR_PARAM (-3) +#define VM_PMNG_NO_MEM (-4) +#define VM_PMNG_ERROR_IO (-5) +#define VM_PMNG_NO_SCHEDULE (-6) +#define VM_PMNG_EXIT (-7) +#define VM_PMNG_CERT_FAIL (-8) +#define VM_PMNG_ERROR_FUNLST (-9) + +#define VM_PMNG_SEC_TAG_PLATFORM_PARAM_DISMATCH (-10) +#define VM_PMNG_SEC_APP_TIMESTAMP_ERROR (-11) +#define VM_PMNG_SEC_IMSI_DISMATCH (-12) +#define VM_PMNG_SEC_BAN_LIST_APP (-13) +#define VM_PMNG_SEC_INVALIDATE_APP (-14) +#define VM_PMNG_SEC_CERT_OMREDUE (-15) +#define VM_PMNG_SEC_CERT_SMALL_SYS_MEM (-16) + +#define VM_PMNG_WAIT_ASM (-17) +#define VM_PMNG_NOT_SUPPORT_VP (-18) +#define VM_PMNG_ONLY_ONE_FOREGROUND (-19) +#define VM_PMNG_MAX_APP_NUM_REACHED (-20) + +#define VM_PMNG_CUR_HANDLE (0x0f) + +#define VM_PMNG_KERNEL_HANDLE (0) + +#define VM_MAX_PATH 261 /*VM_MAX_PATH*/ +/*VM_PROCESS_STATUS*/ +typedef enum +{ + VM_PMNG_UNLOAD = 0, /* state that loaded to memory but not started */ + VM_PMNG_FOREGROUND, /* state of foreground running */ + VM_PMNG_BACKGROUND, /*state of background running */ + VM_PMNG_STARTING, /*state of starting */ + VM_PMNG_CLOSING, /*state of closing */ + VM_PMNG_INACTIVE, /*state of inactive */ + VM_PMNG_MAX_NUM /*max status */ +}VM_PROCESS_STATUS; + +typedef enum +{ + VM_QUIT_NORMAL, + VM_QUIT_MASS_STORAGE, + VM_QUIT_CARD_PLUG_OUT +}VM_QUIT_TYPE; +/*vm_process_property*/ +typedef struct +{ + VM_P_HANDLE pHandle;/*process's handle*/ + VMINT appID;/*appid*/ + VM_PROCESS_STATUS status;/*VM_PROCESS_STATUS*/ + VM_P_HANDLE pParentHandle;/*parent's handle*/ + VMINT type;/*not used*/ + VMINT reserved[5];/*not used*/ + VMWCHAR filePath[VM_MAX_PATH];/*path*/ +}vm_process_property; + +typedef struct { + VMINT (*sys_event_filter)(VMINT message, VMINT param); + VMINT (*pen_event_filter)(VMINT pen_event, VMINT x, VMINT y); + VMINT (*key_event_filter)(VMINT key_event, VMINT key_code); +} _event_filter_t; + +/* LinkIt module structure */ +typedef struct +{ + VMUINT mod_core_base : 1;//base + VMUINT mod_core_sandbox : 1;//sandbox + VMUINT mod_core_resmgr : 1;//resource manager + VMUINT mod_core_safety : 1;//safety + VMUINT mod_core_commu : 1;//communication + VMUINT mod_core_sm : 1;//share module,use for ADS,RVCT + VMUINT mod_core_so : 1;//share object,for RVCT,GCC + VMUINT mod_lib_appres : 1;//app resource + VMUINT mod_lib_c : 1;//c library + VMUINT mod_lib_chset : 1;//char set + VMUINT mod_lib_defgame : 1; + VMUINT mod_lib_ddraw : 1;//direct draw + VMUINT mod_lib_gfxold : 1; + VMUINT mod_lib_image : 1;//graphic + VMUINT mod_lib_http : 1;//http + VMUINT mod_lib_ime : 1;//ime + VMUINT mod_lib_ini : 1; + VMUINT mod_lib_log : 1;//log + VMUINT mod_lib_mullang : 1;//multi-language + VMUINT mod_lib_network : 1;//network + VMUINT mod_lib_vip : 1; + VMUINT mod_lib_vip_vg : 1; + VMUINT mod_lib_xml : 1;//xml + VMUINT mod_sal_audio : 1;//audio + VMUINT mod_sal_bitstream : 1;//bit stream + VMUINT mod_sal_camera : 1;//camera + VMUINT mod_sal_cell : 1;//cell + VMUINT mod_sal_che_des : 1;//CHE DES + VMUINT mod_sal_che_md5 : 1;//CHE MD5 + VMUINT mod_sal_che_sha1 : 1;//CHE SHA1 + VMUINT mod_sal_gps : 1;//gps + VMUINT mod_sal_mms : 1;//mms + VMUINT mod_sal_phonebook : 1;//phonebook + VMUINT mod_sal_sensor : 1;//sensor + VMUINT mod_sal_sim : 1;//sim + VMUINT mod_sal_sms : 1;//sms + VMUINT mod_sal_socket : 1;//socket + VMUINT mod_sal_status : 1;//status bar + VMUINT mod_sal_tele : 1;//telephone + VMUINT mod_sal_timer : 1;//timer + VMUINT mod_sal_video : 1;//video + VMUINT mod_sal_wallpaper : 1; + VMUINT mod_sal_wps : 1;//https + VMUINT mod_app_launch : 1;//launch app + VMUINT mod_sal_payment : 1;//payment +}vm_module_struct; +/***************************************************************************** +* FUNCTION +* vm_main +* DESCRIPTION +* This is entry function of application and application must implement it. +*****************************************************************************/ +void vm_main(void); + +/** + * the message of asking for application to repaint screen. + */ +#define VM_MSG_PAINT 1 + +/** + * the message of application state from inactive to active. + */ +#define VM_MSG_ACTIVE 2 + +/** + * the message of application state from active to inactive. + */ +#define VM_MSG_INACTIVE 3 + +/** + * the message of creation of application + */ +#define VM_MSG_CREATE 4 + +/** + * the message of quit of application + */ +#define VM_MSG_QUIT 5 + +/** + * the message of application state from foreground running to background running. + */ +#define VM_MSG_HIDE 6 + +/** + * the message to notify application memory card has been plug out. + */ +#define VM_MSG_CARD_PLUG_OUT 7 + +/** + * the message when screen rotate. + */ +#define VM_MSG_SCREEN_ROTATE 8 + +/** + * the message of application when foreground running and receive PUSH Message. + */ +#define VM_MSG_PUSH 9 + +/*when cgi start LinkIt app with cmd,will send VM_MSG_HTTP*/ +#define VM_MSG_HTTPD 10 + +/** + * when AP mode application launch success, it will receive this message, in this message app need load tiny system driver + */ +#define VM_MSG_LOAD_TINY 12 + +/** + * when system switch form suspend mode to AP mode, app will receive this message, and app need deal with the share data + */ +#define VM_MSG_SUSPEND_TO_AP_MODE 13 + +/** + * when system switch form hibernation mode to AP mode, app will receive this message, and app need get tiny system driver handle, and deal with the share data + */ +#define VM_MSG_HIBERNATION_TO_AP_MODE 14 + +#define VM_MSG_CELL_INFO_CHANGE 15 + +/** + * when the battery is low + */ +#define VM_MSG_LOW_BATTERY 16 + +/** + * when the power off + */ +#define VM_MSG_SHUTDOWN 17 + +/** + * atci message + */ +#define VM_MSG_ATCI_IND 1030 + +/** + * atci message response + */ +#define VM_MSG_ATCI_RSP 1031 + + +#define VM_MSG_RESTART_PARENT 100 + + +/*LinkIt user ID, corresponding to the value : a string with max length 20(unit:VMCHAR) e.g. 100973*/ +#define MRE_SYS_SUBSCRIBER_ID (1) + +/*LinkIt system user agent, corresponding to the value : a string with max length 20(unit:VMCHAR) e.g. Gionee-A10*/ +#define MRE_SYS_EQUIPMENT_ID (2) + +/*LinkIt version,corresponding to the value : a string with max length 12(unit:VMCHAR) + *naming rule :"main version number.sub-version number.release number",e.g. 1.2.6 */ +#define MRE_SYS_VERSION (3) + +/*platform version,corresponding to the value :a string with max length 30(unit:VMCHAR). e.g. MT6225_08A_VERSION*/ +#define MRE_SYS_HOST_VERSION (4) + +/*Max memory that LinkIt can get,corresponding to the value :a string with max length 6(unit:VMCHAR), it can be change to +*number by atoi function(unit:KB), the memory is the sum of LinkIt system memory and app memory. e.g. 800*/ +#define MRE_SYS_HOST_MAX_MEM (5) + +/*LinkIt system home path,corresponding to the value :a string with max length 30(unit:VMCHAR),e.g. C:\LinkIt*/ +#define MRE_SYS_HOME_DIR (6) + +/*platform build date and time :a string with max length 30(unit:VMCHAR). e.g. 2012/02/09 11:47*/ +#define MRE_SYS_BUILD_DATE_TIME (7) + +/*platform release branch and info. e.g. 11B NEUTRON52_12864*/ +#define MRE_SYS_RELEASE_BRANCH (8) + +#define VM_PROF_NORMAL_MODE 0 /* normal mode */ +#define VM_PROF_MEETING_MODE 1 /* Meeting mode */ +#define VM_PROF_SILENT_MODE 2 /* Silnet mode */ +#define VM_PROF_HEADSET_MODE 3 /* Headset mode */ +#define VM_PROF_BLUETOOTH_MODE 4 /* Bluetooth profile */ + +/* builtin sm struct */ +typedef struct _vm_sm_builtin_struct +{ + VMINT8 file_name[32]; /* sm file name */ + VMUINT address; /* sm memory address */ +} vm_sm_builtin_struct; + +/* DOM-NOT_FOR_SDK-BEGIN */ + +#define VM_MSG_CONFIRM_EXIT 1001 +#define VM_MSG_FORCE_FREE 1002 + + +/** + * The reason of HIDE or PAINT Event + */ +enum { + SCREEN_POPUP = 0, /* HIDE or PAINT cause of POPUP£Ĵlike incoming call, sms, input method, etc. */ + USER_END_KEY /* HIDE cause of END key */ +}; + +/** + * System event structure + */ +typedef struct _vm_sysevt_param_t +{ + VMINT evt_cause; /* Reason of the event */ + void * evt_detail; /* reserved */ +} vm_sysevt_param_t; + +/* DOM-NOT_FOR_SDK-END */ + +/***************************************************************************** +* FUNCTION + * vm_reg_sysevt_callback + * DESCRIPTION + * register system message callback function.must be called in vm_main() + * PARAMETERS + * f : [IN] callback function. +*****************************************************************************/ +void vm_reg_sysevt_callback(void (*f)(VMINT message, VMINT param)); + +/***************************************************************************** +* FUNCTION +* vm_exit_app +* DESCRIPTION +* LinkIt application call this function to quit. +*****************************************************************************/ +void vm_exit_app(void); + +/* DOM-NOT_FOR_SDK-BEGIN */ +// do not support this function +/***************************************************************************** +* FUNCTION +* vm_exit_and_update_app +* DESCRIPTION +* LinkIt application call this function to quit and update application itself. +*****************************************************************************/ +void vm_exit_and_update_app(void); +/* DOM-NOT_FOR_SDK-END */ + + +/* DOM-NOT_FOR_SDK-BEGIN */ + +/****************************************************************************** + * FUNCTION + * vm_get_customer_name + * DESCRIPTION + * get customer name + * PARAMETERS + * value : [OUT] string to store customer name. + * len : [IN] length of value. + * RETURNS + * length of customer name. + ******************************************************************************/ +VMUINT vm_get_customer_name(VMCHAR *value, VMUINT len); + +/****************************************************************************** + * FUNCTION + * vm_get_origin_release_verno + * DESCRIPTION + * get origin release verno. + * PARAMETERS + * value : [OUT] string to store origin release verno. + * len : [IN] length of value. + * RETURNS + * length of origin release verno. + ******************************************************************************/ +VMUINT vm_get_origin_release_verno(VMCHAR *value, VMUINT len); + +/* DOM-NOT_FOR_SDK-END */ + +/***************************************************************************** +* FUNCTION + * vm_get_exec_filename + * DESCRIPTION + * get current application file name + * PARAMETERS + * filename: [OUT] output file name string encoding with UCS2 format. + * RETURNS + * if 0, file name will output to the parameter filename, else means there is no application running. +*****************************************************************************/ +VMINT vm_get_exec_filename(VMWSTR filename); + +/***************************************************************************** + * FUNCTION + * vm_get_sys_property + * DESCRIPTION + * get LinkIt system property. Property is defined as group of key and value. The property is maintained by LinkIt internal and APP can not + * modify it or delete it. + * PARAMETERS + * key : [IN] the key to get the system property + * value : [OUT] point to continuous memory,store the gotten system property. if value ==NULL, it shows that no data writing operation. + * len : [IN] the max length that value storing data. unit: VMCHAR + * e.g. if len =12 and actual written length is 10, value[10] = 0x00 + * if len =12 and actual written length is 12, value string will not include 0x00 + * if len =12 and actual need to be written length is 15, only the first 12 character will be written to value region + * RETURNS + * the actual written length, not including 0x00 + * EXAMPLE + * VMCHAR value[20] = {0}; + * VMUINT valueNum = vm_get_sys_property(MRE_SYS_SUBSCRIBER_ID, value, 20); + *****************************************************************************/ +VMUINT vm_get_sys_property(const VMINT key, VMCHAR* value, VMUINT len); + +/***************************************************************************** + * FUNCTION + * vm_get_modules + * DESCRIPTION + * get modules information + * PARAMETERS + * modules : module structure + * size : module structure's size + * RETURNS + * if succeed ,return 0, otherwise,return error code + *****************************************************************************/ +VMINT vm_get_modules(vm_module_struct *modules, VMUINT size); + +/***************************************************************************** + * FUNCTION + * vm_get_version + * DESCRIPTION + * get version + * PARAMETERS + * + * RETURNS: + * if 1000,will be the version LinkIt1.0.00, if 3000,will be the version LinkIt3.0.00 + * version + *****************************************************************************/ +VMUINT vm_get_version(void); + +/* DOM-NOT_FOR_SDK-BEGIN */ +/***************************************************************************** +* FUNCTION + * vm_reg_func_callback + * DESCRIPTION + * register get function pointer callback. for download UI + * PARAMETERS + * f : [IN] callback function. +*****************************************************************************/ +void vm_reg_func_callback(VMINT (*f)(VMSTR symbol)); +/* DOM-NOT_FOR_SDK-END */ + +/***************************************************************************** +* FUNCTION + * vm_pmng_set_bg + * DESCRIPTION + * set the caller process to background state. This function can be invoked only during foreground + * state, and all the UI resource should be release before call this function. + * RETURNS + * result of setting background state + * RETURN VALUES + * VM_PMNG_OP_OK : set successfully. + * VM_PMNG_NO_OP_IN_STATUS : the caller process is not during foreground state. + * +*****************************************************************************/ +VMINT vm_pmng_set_bg(void); + +/***************************************************************************** +* FUNCTION + * vm_pmng_state + * DESCRIPTION + * get the state of specified process ID. + * PARAMETERS + * p_handle : [IN] process handle to be checked. If want to get current process state, + * it should be VM_PMNG_CUR_HANDLE. + * RETURNS + * the state of specified process. +* RETURN VALUES + * VM_PMNG_FOREGROUND : foreground state + * VM_PMNG_BACKGROUND : background state + * VM_PMNG_PAUSED : inactive state + * VM_PMNG_UNLOAD : unloaded state + * +*****************************************************************************/ +VM_PROCESS_STATUS vm_pmng_state(VM_P_HANDLE p_handle); + +/***************************************************************************** +* FUNCTION + * vm_pmng_get_current_handle + * DESCRIPTION + * get process handle of current process(app or sm/so). + * RETURNS + * the process ID of current running if larger than zero, 0 means no process running + * +*****************************************************************************/ +VM_P_HANDLE vm_pmng_get_current_handle(void); + + +/**************************************************************************** + * for application communication begin + ****************************************************************************/ + +/* LinkIt application messge id base, application should define its own message id started from this. */ +#define VM_MESSAGE_ID_BASE 1000 + +typedef VMINT (*VM_MESSAGE_PROC) (VM_P_HANDLE sender, VMUINT msg_id, VMINT wparam, VMINT lparam); +/***************************************************************************** +* FUNCTION + * vm_pmng_get_handle + * DESCRIPTION + * get process handle of specified file name. + * PARAMETERS + * file_name : [IN] file name to be checked. + * RETURNS + * the process ID of specified file if larger than zero, 0 means there is no specified file running + * +*****************************************************************************/ +VM_P_HANDLE vm_pmng_get_handle(VMWSTR file_name); + +/***************************************************************************** +* FUNCTION + * vm_reg_msg_proc + * DESCRIPTION + * register user defined message callback function. + * use vm_appcomm_send_msg send msg to app, will invoke this callback + * PARAMETERS + * proc : [IN] callback function. + * + *VM_MESSAGE_PROC f; + *VMINT message_proc(VM_P_HANDLE sender, VMUINT msg_id, VMINT wparam, VMINT lparam) + *{ + * ... + *} + *f = message_proc; + *vm_reg_msg_proc(f); + * + * +*****************************************************************************/ +void vm_reg_msg_proc(VM_MESSAGE_PROC proc); + +/***************************************************************************** +* FUNCTION + * vm_send_msg + * DESCRIPTION + * send message to LinkIt app or native app, will invoke message procedure directly. + * PARAMETERS + * phandle : [IN] receiver process handle, if receiver is native application, this value should be zero. + * msg_id : [IN] user defined message ID, should larger than VM_MESSAGE_ID_BASE. + * wparam : [IN] wparam of message. + * lparam : [IN] lparam of message. + * RETURNS + * message procedure return value. +*****************************************************************************/ +VMINT vm_send_msg(VM_P_HANDLE phandle, VMUINT msg_id, VMINT wparam, VMINT lparam); + + +/***************************************************************************** +* FUNCTION + * vm_post_msg + * DESCRIPTION + * post message to LinkIt app or native app, will put this message to the end of LinkIt message queue. + * when this function call finish, MMI task will dispatch LinkIt message and invoke message procedure. + * PARAMETERS + * phandle : [IN] receiver process handle, if receiver is native application, this value should be zero. + * msg_id : [IN] user defined message ID, should larger than VM_MESSAGE_ID_BASE. + * wparam : [IN] wparam of message. + * lparam : [IN] lparam of message. + * RETURNS + * 1 means add message into message queue successfully, 0 means message queue is full. +*****************************************************************************/ +VMINT vm_post_msg(VM_P_HANDLE phandle, VMUINT msg_id, VMINT wparam, VMINT lparam); + +/**************************************************************************** + * for application communication end + ****************************************************************************/ + +/***************************************************************************** +* FUNCTION + * vm_pmng_get_app_handle + * DESCRIPTION + * get process handle of current process(app). + * RETURNS + * the process ID of current running app if larger than zero, 0 means no process running + * +*****************************************************************************/ +VMINT vm_pmng_get_app_handle(void); + +/** + * notification mode of background running application applying to foreground running. + */ +typedef enum +{ + VM_NOTIFY_TYPE_DEFAULT = 0, /* by default mode (follow engine control) */ + VM_NOTIFY_TYPE_SOUND = 1, /* by sound mode */ + VM_NOTIFY_TYPE_VIBRATILITY = 2 /* by vibration mode */ +} VM_FG_NOTIFY_TYPE; + +/***************************************************************************** +* FUNCTION + * vm_start_app + * DESCRIPTION + * Run another APP + * PARAMETERS + * filepath : [IN] The file path need to startup. + * parent_app_handle : [IN] Parent APP handle, usually should be current APP. + * is_parent_exit : [IN] Is need exit Parent APP before enter new one. + * RETURNS + * void + * +*****************************************************************************/ +void vm_start_app(const VMWCHAR* filepath, VMINT parent_app_handle, VMINT is_parent_exit); + +/***************************************************************************** +* FUNCTION + * vm_start_app_with_para + * DESCRIPTION + * Run another APP,the parameter will be send with message VM_MSG_CREATE in param(an address) + * handle_sysevt(VMINT message, VMINT param) + * PARAMETERS + * filepath : [IN] The file path need to startup. + * parent_app_handle : [IN] Parent APP handle, usually should be current APP. + * is_parent_exit : [IN] Is need exit Parent APP before enter new one. + * parameter : [IN] parmeter. + * parameter_size : [IN] parameter size + * RETURNS + * void + * +*****************************************************************************/ +void vm_start_app_with_para(const VMWCHAR* filepath, VMINT parent_app_handle, VMINT is_parent_exit,void* parameter,VMINT parameter_size); + + +/***************************************************************************** +* FUNCTION + * vm_pmng_get_process_list + * DESCRIPTION + * get process list. set handle_list NULL to get process number. + * PARAMETERS + * handle_list : [IN] process handle list + * num : [IN/OUT] process number. + * RETURNS + * >0 means process number, <0 means fail +*****************************************************************************/ +VMINT vm_pmng_get_process_list(VM_P_HANDLE *handle_list, VMUINT *num); + +/***************************************************************************** +* FUNCTION + * vm_pmng_get_process_property + * DESCRIPTION + * get process property + * PARAMETERS + * handle : [IN] process handle + * property : [OUT] process property + * RETURNS + * 0 means success, < 0 means fail +*****************************************************************************/ +VMINT vm_pmng_get_process_property(VM_P_HANDLE handle, vm_process_property *property); + +/***************************************************************************** + * FUNCTION + * vm_pmng_set_fg + * DESCRIPTION + * bring an application from bg to fg + * PARAMETERS + * fileName [IN] Application file name encoding with USC2 format. + * RETURNS + * sucess app handle, <0 means fail + *****************************************************************************/ +VM_P_HANDLE vm_pmng_set_fg(VMWSTR fileName); + +/***************************************************************************** + * FUNCTION + * vm_get_full_path_by_short_name + * DESCRIPTION + * get full path from short name. it is get the vxp or vpp or vsp file in current running app folder. + * e.g.FBv2, maybe get FBv2.vsp in the same folder, or rom which named FBv2 + * PARAMETERS + * short_name [IN] Short name encoding with USC2 format. + * full_path [OUT] full path + * RETURNS + * sucess 0; <0 means fail + *****************************************************************************/ + +VMINT vm_get_full_path_by_short_name(VMWSTR short_name, VMWSTR full_path); + +/***************************************************************************** + * FUNCTION + * vm_pmng_set_pen_move_not_exit + * DESCRIPTION + * when call this api in wearable app, will not exit app when pen move event release. + * this api should call in when receive VM_MSG_ACTIVE,because only when app forground, this setting work. + * PARAMETERS + * none + * RETURNS + * none + *****************************************************************************/ +void vm_pmng_set_pen_move_not_exit(); +/***************************************************************************** + * FUNCTION + * vm_pmng_set_pen_move_exit + * DESCRIPTION + * when call this api in wearable app, will hide or inactive app when pen move event release. + * PARAMETERS + * none + * RETURNS + * none + *****************************************************************************/ +void vm_pmng_set_pen_move_exit(); +/* DOM-NOT_FOR_SDK-BEGIN */ +#define vm_get_mre_modules vm_get_modules +#define vm_get_mre_version vm_get_version +/* DOM-NOT_FOR_SDK-END */ +#ifdef __cplusplus +} +#endif +#endif /* _VM_PRO_MNG_SDK_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmpwr.h b/hardware/arduino/mtk/system/libmtk/include/vmpwr.h new file mode 100644 index 00000000..9e116033 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmpwr.h @@ -0,0 +1,328 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmpwr_sdk.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * pwr + * + * Author: + * ------- + * + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ +* *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== +*******************************************************************************/ +#ifndef VM_PRW_SDK_H +#define VM_PRW_SDK_H +#ifdef __cplusplus +extern "C"{ +#endif/*__cplusplus*/ +#include "vmsys.h" + +typedef enum +{ + VM_MAINLCD_BRIGHTNESS_LEVEL0 =0 , /* TURN OFF*/ + VM_MAINLCD_BRIGHTNESS_LEVEL1 , + VM_MAINLCD_BRIGHTNESS_LEVEL2 , + VM_MAINLCD_BRIGHTNESS_LEVEL3 , + VM_MAINLCD_BRIGHTNESS_LEVEL4 , + VM_MAINLCD_BRIGHTNESS_LEVEL5 , + VM_MAINLCD_BRIGHTNESS_LEVEL6 , + VM_MAINLCD_BRIGHTNESS_LEVEL7 , + VM_MAINLCD_BRIGHTNESS_LEVEL8 , + VM_MAINLCD_BRIGHTNESS_LEVEL9 , + VM_MAINLCD_BRIGHTNESS_LEVEL10 , + VM_MAINLCD_BRIGHTNESS_LEVEL11 , + VM_MAINLCD_BRIGHTNESS_LEVEL12 , + VM_MAINLCD_BRIGHTNESS_LEVEL13 , + VM_MAINLCD_BRIGHTNESS_LEVEL14 , + VM_MAINLCD_BRIGHTNESS_LEVEL15 , + VM_MAINLCD_BRIGHTNESS_LEVEL16 , + VM_MAINLCD_BRIGHTNESS_LEVEL17 , + VM_MAINLCD_BRIGHTNESS_LEVEL18 , + VM_MAINLCD_BRIGHTNESS_LEVEL19 , + VM_MAINLCD_BRIGHTNESS_LEVEL20 , + VM_MAINLCD_BRIGHTNESS_20LEVEL_MAX /* DO NOT USE THIS */ +} vm_mainlcd_brightness_level_enum; + +typedef enum { + turn_on_mode = 0, /*turn on saving mode */ + turn_off_mode /*turn off saving mode*/ +} power_saving_mode_enum; + +/***************************************************************************** + * FUNCTION + * vm_mode_block + * DESCRIPTION + * Disable the system switch to Tiny mode, usually used when you want the device keep in Normal mode. + * PARAMETERS + * void + * RETURNS + * void + *****************************************************************************/ +void vm_mode_block(void); + +/***************************************************************************** + * FUNCTION + * vm_mode_unblock + * DESCRIPTION + * Enable the system switch to Tiny mode + * PARAMETERS + * void + * RETURNS + * void + *****************************************************************************/ +void vm_mode_unblock(void); + +/***************************************************************************** + * FUNCTION + * vm_get_battery_level + * DESCRIPTION + * get handset battery level + * PARAMETERS + * void + * RETURNS + * battery level .depend on the target config, return value maybe one of 0,25,50,75,100 + * or one of 0,33,66,100 + *****************************************************************************/ +VMINT vm_get_battery_level(void) ; + + +/***************************************************************************** + * FUNCTION + * vm_charbat_is_charging + * DESCRIPTION + * is charging or not + * PARAMETERS + * void + * RETURNS + * Return VM_TRUE if battery is charging or return VM_FALSE + *****************************************************************************/ +VMBOOL vm_charbat_is_charging(void); + +/***************************************************************************** + * FUNCTION + * vm_set_mainlcd_brightness + * DESCRIPTION + * set handset main LCD brightness + * PARAMETERS + * vm_mainlcd_brightness_level_enum + * RETURNS + * NO + *****************************************************************************/ +void vm_set_mainlcd_brightness(vm_mainlcd_brightness_level_enum brighness_level); + +/***************************************************************************** + * FUNCTION + * vm_get_mainlcd_brightness + * DESCRIPTION + * get handset main LCD brightness + * PARAMETERS + * NULL + * RETURNS + * an unsigned int value + *****************************************************************************/ +VMINT vm_get_mainlcd_brightness(void); +/***************************************************************************** + * FUNCTION + * vm_switch_power_saving_mode + * DESCRIPTION + * settign saving mode. + * LinkIt default value is turn_on_mode, when app is set to background running or + * exit, or receives INACTIVE message, the mode also should be set as turn_on_mode. + * turn_on_mode: LCD will off when no action occurs in a period time. + * turn_off_mode: LCD will keep on,only when app is on fore-ground running, can + * it set the mode. + * PARAMETERS + * mode : whether open the saving mode + * RETURNS + * if succeed ,return 0, otherwise,return error code + *****************************************************************************/ +VMINT vm_switch_power_saving_mode(power_saving_mode_enum mode); + +/***************************************************************************** + * FUNCTION + * vm_switch_backlight + * DESCRIPTION + * turn on /off backlight + * PARAMETERS + * turn_on + * 1: turn on the backlight + * 0: turn off the backlight + * RETURNS + * + *****************************************************************************/ +void vm_switch_backlight(VMINT turn_on); + +/***************************************************************************** + * FUNCTION + * vm_disable_auto_screen_lock + * DESCRIPTION + * diable auto screen lock function. + * PARAMETERS + * NONE. + * RETURNS + * void + *****************************************************************************/ +void vm_disable_auto_screen_lock(void); + +/***************************************************************************** + * FUNCTION + * vm_enable_auto_screen_lock + * DESCRIPTION + * enable auto screen lock function. + * PARAMETERS + * NONE. + * RETURNS + * void + *****************************************************************************/ +void vm_enable_auto_screen_lock(void); + +/***************************************************************************** + * FUNCTION + * vm_reboot_normal_start + * DESCRIPTION + * Launch normal shutdown flow. + * PARAMETERS + * NONE. + * RETURNS + * void + *****************************************************************************/ +void vm_reboot_normal_start(void); + +/***************************************************************************** + * FUNCTION + * vm_shutdown_normal_start + * DESCRIPTION + * Launch normal shutdown flow. + * It plays shutdown animation and emit deinit events normally. + * PARAMETERS + * trigger_man_app_id : [IN] The ID of the application who triggers shutdown. + * RETURNS + * void + *****************************************************************************/ +void vm_shutdown_normal_start(VMUINT16 trigger_man_app_id); + + +#define VM_FLY_MODE_EVT_PARAM_HEADER \ +VMUINT16 evt_id; \ +VMUINT16 size; \ +void * user_data + +/* fly mode event enum*/ +typedef enum +{ + /* switch finish */ + VM_FLY_MODE_SWITCH_FINISH, + + VM_FLY_MODE_EVENT_END +} vm_fly_mode_event_enum; + +/* fly mode event structure */ +typedef struct +{ + /* Event id */ + VMUINT16 evt_id; + /* Event structure size */ + VMUINT16 size; + /* User data pointer */ + void *user_data; + /* resule */ + VMUINT16 result; +}vm_fly_mode_event_struct; + +/* fly mode switch callback */ +typedef VMINT (*vm_fly_mode_cb)(vm_fly_mode_event_struct * evt, void * user_data); + +/***************************************************************************** + * FUNCTION + * vm_fly_mode_is_switching + * DESCRIPTION + * get fly mode switch is running or not + * PARAMETERS + * void + * RETURNS + * 0 : not switching 1 : switching + *****************************************************************************/ +extern VMBOOL vm_fly_mode_is_switching(void); + +/***************************************************************************** + * FUNCTION + * vm_fly_mode_is_network_service_available + * DESCRIPTION + * check if having available network service including GSM and WLAN. + * PARAMETERS + * void + * RETURNS + * MMI_FALSE in flight mode + * MMI_TRUE not in flight mode + *****************************************************************************/ +extern VMBOOL vm_fly_mode_is_network_service_available(void); + +/***************************************************************************** + * FUNCTION + * vm_fly_mode_switch + * DESCRIPTION + * Switch to flight mode or back to normal mode + * If check_sim is MMI_TRUE, the phone will only turn on RF of inserted SIM + * PARAMETERS + * flight_mode_on [IN] is switch to flight mode + * check_sim [IN] is switch the RF according to SIM insert status + * callback [IN] + * user_data + * RETURNS + * MMI_BOOL + *****************************************************************************/ +extern VMBOOL vm_fly_mode_switch(VMBOOL flight_mode_on, VMBOOL check_sim, vm_fly_mode_cb callback, void *user_data); + +#ifdef __cplusplus +} +#endif/*__cplusplus*/ + +#endif/*VM_PRW_SDK_H*/ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmres.h b/hardware/arduino/mtk/system/libmtk/include/vmres.h new file mode 100644 index 00000000..8ed5547e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmres.h @@ -0,0 +1,335 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMRES_SDK_H +#define VMRES_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/* cache data structure */ +typedef struct _vm_res_read_hint_struct +{ + VMINT res_offset; /* res offset */ + VMINT res_size; /* res size */ +}vm_res_read_hint_struct; + +/***************************************************************************** + * FUNCTION + * vm_load_resource + * DESCRIPTION + * load resource from current file, system will alloc memory and read the + * resource from file to memory,need to call vm_free after use. + * PARAMETERS + * res_name : [IN] Resource name, not include path. + * res_size : [OUT] Resource size, bytes. + * RETURNS + * Resource pointer + * SEE ALSO + * vm_load_resource_from_file + * EXAMPLE + * get resource named "mre-2.0" + * + * VMCHAR* res_buf; + * + * res_buf = vm_load_resource("mre-2.0", (VMINT*)&res_size); + * if(res_buf == NULL) + * { + * // get error + * } + * else + * { + * // get success + * ... + * vm_free(res_buf); // release the resource after use it. + * } + * +*****************************************************************************/ +VMUINT8* vm_load_resource(char* res_name, VMINT* res_size); + + + /***************************************************************************** + * FUNCTION + * vm_load_resource_from_file + * DESCRIPTION + * Load Resource from one filesystem will alloc memory and read the + * res from file to memory,need to call vm_free after use. + * PARAMETERS + * filename : [IN] full path need to read the resource. + * res_name : [IN] Resource name, not include path. + * res_size : [OUT] Resource size, bytes. + * RETURNS + * Resource pointer + * SEE ALSO + * vm_load_resource + * EXAMPLE + * get resource named "mre-2.0" + * + * VMCHAR* res_buf; + * + * res_buf = vm_load_resource_from_file("E:\\sample.vxp", "mre-2.0", (VMINT*)&res_size); + * if(res_buf == NULL) + * { + * // get error + * } + * else + * { + * // get success + * ... + * vm_free(res_buf); // release the resource after use it. + * } + * +*****************************************************************************/ +VMUINT8* vm_load_resource_from_file(VMWSTR filename, char *res_name, VMINT *res_size); + + /***************************************************************************** + * FUNCTION + * vm_load_virtual_resource + * DESCRIPTION + * load resource from current file, system will alloc 16 bytes as virtual image for graphic interface + * this need to call vm_free after use. this will not load the real data of image, only load res offset + * and file handle, graphic interface will load the real data when it to show the image + * PARAMETERS + * res_name : [IN] Resource name, not include path. + * res_size : [OUT] Resource size, bytes. + * RETURNS + * Resource pointer + * EXAMPLE + * get resource named "logo" + * + * VMCHAR* res_buf; + * + * res_buf = vm_load_virtual_resource( "logo", (VMINT*)&res_size); + * if(res_buf == NULL) + * { + * // get error + * } + * else + * { + * // get success + * ... + * vm_free(res_buf); // release the resource after use it. + * } + * + *****************************************************************************/ +VMUINT8 *vm_load_virtual_resource(char *res_name, VMINT *res_size); + +/***************************************************************************** + * FUNCTION + * vm_resource_get_data + * DESCRIPTION + * Function to Get data from current app file, some app have it own resource format, so they can make all their resource + * as on MRE resource, and get the resource offset form vm_get_resource_offset, then they can manage the data by themslef + * PARAMETERS + * data [IN] Buffer of data + * offset [IN] Offset of the file + * size [IN] Size of the data + * RETURNS + * 0 successful + * SEE ALSO + * vm_resource_get_data_from_file + * EXAMPLE + * get data of the resource "mre-2.0", size is 1200 bytes + * + * VMCHAR* res_buf; + * VMUINT offset; + * offset = vm_get_resource_offset("mre-2.0"); + * res_buf = vm_malloc(1200); + * result = vm_resource_get_data( res_buf, offset, 1200); + * if(result == 0) + * { + * // get error + * } + * else + * { + * // get success + * ... + * vm_free(res_buf); // release the resource after use it. + * } + * + *****************************************************************************/ +extern VMINT32 vm_resource_get_data(VMUINT8 *data, VMUINT32 offset, VMUINT32 size); + +/***************************************************************************** + * FUNCTION + * vm_resource_get_data_from_file + * DESCRIPTION + * Function to Get data from file with full path. + * PARAMETERS + * filename[IN] File full path + * data [IN] Buffer of data + * offset [IN] Offset of the file + * size [IN] Size of the data + * RETURNS + * 0 successful + * SEE ALSO + * vm_get_resource_offset_from_file + * EXAMPLE + * get data of the resource "mre-2.0", size is 1200 bytes + * + * VMCHAR* res_buf; + * VMUINT offset; + * offset = vm_get_resource_offset_from_file("E:\\sample.vxp","mre-2.0"); + * res_buf = vm_malloc(1200); + * result = vm_resource_get_data_from_file( "E:\\sample.vxp", res_buf, offset, 1200); + * if(result == 0) + * { + * // get error + * } + * else + * { + * // get success + * ... + * vm_free(res_buf); // release the resource after use it. + * } + * + *****************************************************************************/ +VMINT32 vm_resource_get_data_from_file(VMWSTR filename, VMUINT8 *data, VMUINT32 offset, VMUINT32 size); + +/***************************************************************************** + * FUNCTION + * vm_get_resource_offset + * DESCRIPTION + * get resource's offset from current file + * PARAMETERS + * res_name : [IN] Resource name, not include path. + * RETURNS + * Resource offset + * 0 is error + * SEE ALSO + * vm_get_resource_offset_from_file + * EXAMPLE + * get offset of the resource "mre-2.0" + * + * VMUINT offset; + * offset = vm_get_resource_offset("mre-2.0"); + * +*****************************************************************************/ +VMUINT vm_get_resource_offset(char *res_name); + + /***************************************************************************** + * FUNCTION + * vm_get_resource_offset_from_file + * DESCRIPTION + * get resource offset from one file + * PARAMETERS + * filename : [IN] The file need to read the resource. + * res_name : [IN] Resource name, not include path. + * RETURNS + * Resource offset + * 0 is error + * SEE ALSO + * vm_get_resource_offset + * EXAMPLE + * get offset of the resource "mre-2.0" + * + * VMUINT offset; + * + * offset = vm_get_resource_offset("E:\\sample.vxp", "mre-2.0"); + * +*****************************************************************************/ +VMUINT vm_get_resource_offset_from_file(VMWSTR filename, char *res_name); + + + /***************************************************************************** + * FUNCTION + * vm_get_resource_offset_and_size_from_file + * DESCRIPTION + * get resource offset and size from one file + * PARAMETERS + * filename : [IN] The file need to read the resource. + * res_name : [IN] Resource name, not include path. + * res_size : [OUT] res size. + * RETURNS + * Resource offset + * 0 is error + * SEE ALSO + * vm_get_resource_offset_from_file + * EXAMPLE + * get offset of the resource "mre-2.0" + * + * VMUINT offset; + * VMINT size; + * offset = vm_get_resource_offset("E:\\sample.vxp", "mre-2.0", (VMINT*)&size); + * +*****************************************************************************/ +VMUINT vm_get_resource_offset_and_size_from_file(VMWSTR filename, char *res_name, VMINT* res_size); + + +/***************************************************************************** + * FUNCTION + * vm_load_resource_use_outside_memory + * DESCRIPTION + * get resource use outside memory + * PARAMETERS + * filename : [IN] The file need to read the resource. + * res_name : [IN] Resource name, not include path. + * buffer : [IN] buffer to put resource data. + * buffer_size : [IN] buffer size. + * hint : [OUT] buffer size and offset. this will cache data to speed up resource loading time + * RETURNS + * Resource offset + * 0 is error + * EXAMPLE + * get data of the resource "mre-2.0" + * + * VMCHAR* res_buf; + * vm_res_read_hint_struct hint; + * VMINT buffer_size; + * vm_load_resource_use_outside_memory("E:\\sample.vxp","mre-2.0", NULL, 0, &hint); + * res_buf = vm_malloc(hint.res_size); + * result = vm_load_resource_use_outside_memory("E:\\sample.vxp","mre-2.0", res_buf, hint.res_size, &hint); + * if(result == 0) + * { + * // get error + * } + * else + * { + * // get success + * ... + * vm_free(res_buf); // release the resource after use it. + * } + * +*****************************************************************************/ +VMBOOL vm_load_resource_use_outside_memory(VMWSTR filename, char *res_name, void* buffer, VMINT buffer_size, vm_res_read_hint_struct* hint); + +#ifdef __cplusplus +} +#endif + +#endif /* VMRES_SDK_H */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmrtspd.h b/hardware/arduino/mtk/system/libmtk/include/vmrtspd.h new file mode 100644 index 00000000..45f93e35 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmrtspd.h @@ -0,0 +1,176 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmrtspd_sdk.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * + * + * Author: + * ------- + * + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ +* *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== +*******************************************************************************/ +#ifndef VM_RTSPD_SDK_H +#define VM_RTSPD_SDK_H +#ifdef __cplusplus +extern "C"{ +#endif/*__cplusplus*/ +#include "vmsys.h" +/*vm_rtspd_error_enum*/ +typedef enum +{ + VM_RTSPD_ERR_NO_ERROR = 0, //operator suceed + VM_RTSPD_ERR_STATE_ERROR = -1, //state of http is mess + VM_RTSPD_ERR_GET_MEM_FAIL = -2, //memory is not enough + VM_RTSPD_ERR_CONNECT_NETWORK_FAIL = -3, //net work is not ready + VM_RTSPD_ERR_FD_INIT_FAIL = -4, //file disciptor init fail + VM_RTSPD_ERR_SRV_INIT_FAIL = -5, //server init fail + VM_RTSPD_ERR_SAVE_CB = -65534,//save cb fail + VM_RTSPD_ERR_OTHERS = -65535, // other errors + VM_RTSPD_ERR_CODE = -65536 //end mark. +}vm_rtspd_error_enum; +/*vm_rtspd_status_enum*/ +typedef enum +{ + VM_RTSPD_IND_IDLE = 0, + VM_RTSPD_IND_RECORDING_ONLY,// in local recording and save temp file + VM_RTSPD_IND_FILE_MERGE_ONLY,// create local video file + VM_RTSPD_IND_STREAMING_ONLY,//rtsp send rtp data + VM_RTSPD_IND_STREAMING_RECORDING,//rtsp send rtp & local save temp file + VM_RTSPD_IND_STREAMING_FILE_MERGE//rtsp send rtp & local save file merge +}vm_rtspd_status_enum; + +/***************************************************************************** + * DESCRIPTION + * VM_RTSPD_CB is the prototype of the call back function. + * PARAMETERS + * status: [IN] vm_rtspd_status_enum + * data: [IN] currently have no meaning,use for future extend + * RETURNS + * The return value is void. + *****************************************************************************/ +typedef void (*VM_RTSPD_CB)(vm_rtspd_status_enum status, void* data); +/***************************************************************************** + * FUNCTION + * vm_inet_rtspd_register_cb + * DESCRIPTION + * register rtspd callback function + * PARAMETERS + * callback: VM_RTSPD_CB + * RETURNS + * vm_rtspd_error_enum: 0,success; others: fail. + *****************************************************************************/ +extern vm_rtspd_error_enum vm_inet_rtspd_register_cb(VM_RTSPD_CB callback); +/***************************************************************************** + * FUNCTION + * vm_inet_rtspd_start + * DESCRIPTION + * this is for lauch rtsp server + * PARAMETERS + * port: + * root_dir:[IN] the root dir + * RETURNS + * vm_rtspd_error_enum: + * + *vm_inet_rtspd_start(554, "C:\\@rtsp"); + * + *****************************************************************************/ +extern vm_rtspd_error_enum vm_inet_rtspd_start(VMUINT32 port, VMCHAR* root_dir); +/***************************************************************************** + * FUNCTION + * vm_inet_httpd_stop + * DESCRIPTION + * this is for stop http server + * PARAMETERS + * N/A + * RETURNS + * httpsrv_error_enum:return VM_HTTPSRV_ERR_NO_ERROR, success, othersize, fail + * + *vm_inet_rtspd_stop(); + * + *****************************************************************************/ +extern vm_rtspd_error_enum vm_inet_rtspd_stop(void); +/***************************************************************************** + * FUNCTION + * vm_inet_rtspd_restart + * DESCRIPTION + * this is for restart rtsp server + * PARAMETERS + * port: [IN]the port to restart + * root_dir:[IN]the root dir + * RETURNS + * vm_rtspd_error_enum + * + *vm_inet_rtspd_restart(554, "C:\\@rtsp"); + * + *****************************************************************************/ +extern vm_rtspd_error_enum vm_inet_rtspd_restart(VMUINT32 port, VMCHAR* root_dir); +/***************************************************************************** + * FUNCTION + * vm_inet_rtspd_set_stream_identify + * DESCRIPTION + * this is for set the name of real time stream,rtsp server will check request URL with this string + * PARAMETERS + * stream_name: [IN] + * RETURNS + * none + * + *vm_inet_rtspd_set_stream_identify("xxx.3gp"); + * + *****************************************************************************/ +extern void vm_inet_rtspd_set_stream_identify(VMCHAR* stream_name); + + +#ifdef __cplusplus +} +#endif/*__cplusplus*/ + +#endif/*VM_RTSPD_SDK_H*/ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmsalui.h b/hardware/arduino/mtk/system/libmtk/include/vmsalui.h new file mode 100644 index 00000000..f51353b7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmsalui.h @@ -0,0 +1,149 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMSALUI_SDK_H_ +#define VMSALUI_SDK_H_ + +#include "vmsys.h" + +/* If set thsi flag for behavior_mask, it will show nothing if this ui is not supported */ +#define VM_COMMON_UI_MASK_NO_SHOW_UNSUPPORTED 0x1 + +typedef enum +{ + VM_COMMON_UI_ERROR_INVALID_ID = -7, + VM_COMMON_UI_ERROR_OF_PROCESS, + VM_COMMON_UI_ERROR_OF_RES , + VM_COMMON_UI_ERROR_OF_MEM , + VM_COMMON_UI_ERROR_UNSUPPORTED, + VM_COMMON_UI_ERROR_WRONG_PARAM, + VM_COMMON_UI_ERROR , + VM_COMMON_UI_OK +} vm_common_ui_error_t; + +/* popup type */ +typedef enum +{ + VM_COMMON_UI_POPUP_TYPE_FAILURE, + VM_COMMON_UI_POPUP_TYPE_INFO, + VM_COMMON_UI_POPUP_TYPE_WARNING, + VM_COMMON_UI_POPUP_TYPE_SUCCESS, + VM_COMMON_UI_POPUP_TYPE_PROGRESS, + VM_COMMON_UI_POPUP_TYPE_QUERY, + + VM_COMMON_UI_POPUP_TYPE_MAX +} vm_common_ui_popup_type_enum; + +/* confirm type - one button(confirm) or two button(user defeind and cancel) */ +typedef enum +{ + VM_COMMON_UI_CONFIRM_TYPE_ONE_BUTTON, + VM_COMMON_UI_CONFIRM_TYPE_TWO_BUTTON, + + VM_COMMON_UI_CONFIRM_TYPE_MAX +} vm_common_ui_confirm_type_enum; + +/* common ui type */ +typedef enum +{ + VM_COMMON_UI_TYPE_BALLOON, + VM_COMMON_UI_TYPE_TEXT_PREVIEW, // If app is foreground, text preview just can show when statusbar exist + VM_COMMON_UI_TYPE_POPUP, + VM_COMMON_UI_TYPE_CONFIRM, + VM_COMMON_UI_TYPE_END_OF_ENUM +}vm_common_ui_type; + +/* receive event in confirm popup callback function */ +typedef enum +{ + VM_COMMON_UI_CONFIRM_EVENT_BUTTON_NONE, + VM_COMMON_UI_CONFIRM_EVENT_USER_1, + VM_COMMON_UI_CONFIRM_EVENT_USER_2, + + VM_COMMON_UI_CONFIRM_EVENT_MAX +} vm_common_ui_confirm_evt_enum; + +typedef void (*VM_COMMONUIPROC_T)(vm_common_ui_confirm_evt_enum evt_id, void *user_data); + + +/* Balloon information */ +typedef struct { + const VMWCHAR *display_string; +}vm_common_ui_balloon_struct; + +/* Text preview information */ +typedef struct { + const VMWCHAR *display_string; +}vm_common_ui_text_preview_struct; + +/* Popup information*/ +typedef struct { + vm_common_ui_popup_type_enum popup_type; + const VMWCHAR *display_string; +}vm_common_ui_popup_struct; + +/* Confirm Popup information*/ +typedef struct +{ + vm_common_ui_confirm_type_enum confirm_type; + vm_common_ui_popup_type_enum confirm_popup_type; + const VMWCHAR *popup_string; + const VMWCHAR *popup_button_string1; + const VMWCHAR *popup_button_string2; + VM_COMMONUIPROC_T confirm_popup_proc; + void *user_data; +} vm_common_ui_confirm_popup_struct; + + +typedef struct +{ + vm_common_ui_type ui_type; + VMUINT16 behavior_mask; + + /*balloon parameter*/ + vm_common_ui_balloon_struct balloon_para; + /*text preview parameter*/ + vm_common_ui_text_preview_struct text_preview_para; + /*popup parameter*/ + vm_common_ui_popup_struct popup_para; + /*confirm popup parameter*/ + vm_common_ui_confirm_popup_struct confirm_popup_para; +}vm_common_ui_info_struct; + +VMINT vm_common_ui_show(vm_common_ui_info_struct *ui_info); +VMINT vm_common_ui_cancel(VMINT id); + + +#endif diff --git a/hardware/arduino/mtk/system/libmtk/include/vmsensor.h b/hardware/arduino/mtk/system/libmtk/include/vmsensor.h new file mode 100644 index 00000000..234500f9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmsensor.h @@ -0,0 +1,352 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef __VM_SENSOR_SDK +#define __VM_SENSOR_SDK + +#include "vmsys.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Motion Sensor Angle define */ +typedef enum +{ + VM_SRV_SENSOR_MOTION_ANGLE_GX0, /* angle 0 of x */ + VM_SRV_SENSOR_MOTION_ANGLE_GY0, /* angle 0 of y */ + VM_SRV_SENSOR_MOTION_ANGLE_GZ0, /* angle 0 of z */ + VM_SRV_SENSOR_MOTION_ANGLE_GX180, /* angle 180 of x */ + VM_SRV_SENSOR_MOTION_ANGLE_GY180, /* angle 180 of y */ + VM_SRV_SENSOR_MOTION_ANGLE_GZ180, /* angle 180 of z */ + VM_SRV_SENSOR_MOTION_ANGLE_OTHER /* others */ +} vm_srv_sensor_motion_direct_enum; + +/* Motion Sensor Action define */ +typedef enum +{ + VM_SRV_SENSOR_MOTION_ACTION_NULL, /* None */ + VM_SRV_SENSOR_MOTION_ACTION_ROLL_RIGHT, /* Roll right */ + VM_SRV_SENSOR_MOTION_ACTION_ROLL_LEFT, /* Roll left */ + VM_SRV_SENSOR_MOTION_ACTION_PITCH_BACKWARD, /* Pitch Backward */ + VM_SRV_SENSOR_MOTION_ACTION_PITCH_FORWARD, /* Pitch Forward */ + VM_SRV_SENSOR_MOTION_ACTION_YAW_RIGHT, /* Yaw right */ + VM_SRV_SENSOR_MOTION_ACTION_YAW_LEFT, /* Yaw left */ + VM_SRV_SENSOR_MOTION_ACTION_TOTAL +} vm_srv_sensor_motion_action_enum; + + +/* Motion Sensor Type */ +typedef enum +{ + VM_SRV_SENSOR_MOTION_DIRECT, /* direct */ + VM_SRV_SENSOR_MOTION_SHAKE, /* shake */ + VM_SRV_SENSOR_MOTION_TILT, /* tilt */ + VM_SRV_SENSOR_MOTION_TAP, /* tap */ + VM_SRV_SENSOR_MOTION_DOUBLE_TAP, /* double tap */ + VM_SRV_SENSOR_MOTION_DROP, /* drop */ + VM_SRV_SENSOR_MOTION_STEP, /* step */ + VM_SRV_SENSOR_MOTION_ADVANCED_SHAKE,/* shake */ + VM_SRV_SENSOR_MOTION_TURNOVER, /* turnover */ + VM_SRV_SENSOR_TOTAL, + VM_SRV_SENSOR_DISABLE /* motion sensor have been disabled */ +} vm_srv_sensor_type_enum; + +/* Motion Sensor direct structure */ +typedef struct +{ + VMUINT8 angle_threshold; /* angle */ +} vm_srv_sensor_motion_direct_cfg_struct ; + +/* Motion Sensor tilt angle structure */ +typedef struct +{ + VMINT gx; /* angle of x */ + VMINT gy; /* angle of y */ + VMINT gz; /* angle of z */ +}vm_srv_sensor_motion_tilt_angle_struct; + +/* Motion Sensor tilt acc */ +typedef struct +{ + VMINT16 x; /* acceleration of x */ + VMINT16 y; /* acceleration of y */ + VMINT16 z; /* acceleration of z */ +}vm_srv_sensor_motion_tilt_acc_struct; + +/* sensor_type = VM_SRV_SENSOR_MOTION_TILT */ +typedef struct +{ + vm_srv_sensor_motion_tilt_angle_struct angle; /* tilt angle */ + vm_srv_sensor_motion_tilt_acc_struct acc; /* tilt acceleration */ +}vm_srv_sensor_motion_tilt_struct; + +/* Handle define */ +typedef VMINT VM_SRV_SENSOR_HANDLE; + +/* Result define */ +typedef VMINT VM_SRV_SENSOR_RESULT; + +/* Sensor tap event */ +typedef enum +{ + VM_SRV_SENSOR_MOTION_TAP_DONE /*tap done*/ +}vm_srv_sensor_motion_tap_direct_enum; + +/* Sensor step event */ +typedef enum +{ + VM_SRV_SENSOR_MOTION_ACTION_STEP, /*Step devent happen*/ + VM_SRV_SENSOR_MOTION_STEP_NULL +}vm_srv_sensor_motion_step_enum; + +/* Sensor drop event */ +typedef enum +{ + VM_SRV_SENSOR_MOTION_ACTION_DROP, /*Drop event happen*/ + VM_SRV_SENSOR_MOTION_DROP_NULL +}vm_srv_sensor_motion_drop_enum; + +/* Sensor turnover type */ +typedef enum { + VM_SRV_SENSOR_MOTION_TURNOVER_NONE = 0, /*NONE*/ + VM_SRV_SENSOR_MOTION_TURNOVER_UP = 0x01, /*back to front*/ + VM_SRV_SENSOR_MOTION_TURNOVER_DOWN = 0x02, /*front to back*/ + VM_SRV_SENSOR_MOTION_TURNOVER_LEFT = 0x04, /*turnover left*/ + VM_SRV_SENSOR_MOTION_TURNOVER_RIGHT = 0x08, /*turnover right*/ + VM_SRV_SENSOR_MOTION_TURNOVER_TOTAL = 0xffff +} vm_srv_sensor_motion_turnover_enum; + +/* sensor_type = VM_SRV_SENSOR_MOTION_STEP + step sensitive enum +*/ +typedef enum +{ + VM_SRV_SENSOR_MOTION_STEP_HIGH, /*HIGH */ + VM_SRV_SENSOR_MOTION_STEP_MEDIUM, /*MEDIUM */ + VM_SRV_SENSOR_MOTION_STEP_LOW /*LOW */ +}vm_srv_sensor_motion_step_sensitive_enum; + +/* sensor_type = VM_SRV_SENSOR_MOTION_STEP + struct of sensor_data*/ +typedef struct +{ + vm_srv_sensor_motion_step_sensitive_enum sensitive; /* step sensitive */ +}vm_srv_sensor_motion_step_cfg_struct; + + +/* sensor_type = VM_SRV_SENSOR_MOTION_TILT */ +typedef enum +{ + VM_SRV_SENSOR_MOTION_NORMAL_TILT, /* nomal TILT */ + VM_SRV_SENSOR_MOTION_RAW_TILT /* raw TILT */ +}vm_srv_sensor_motion_tilt_sensitive_enum; + +/* sensor_type = VM_SRV_SENSOR_MOTION_TILT + struct of sensor_data*/ +typedef struct +{ + vm_srv_sensor_motion_tilt_sensitive_enum sensitive; /* tilt sensitive */ +}vm_srv_sensor_motion_tilt_cfg_struct; + +/*sensor_type = VM_SRV_SENSOR_MOTION_TAP + struct of sensor_data*/ +typedef struct +{ + vm_srv_sensor_motion_tap_direct_enum tap_direct; /* tap direction */ +}vm_srv_sensor_motion_tap_struct; + +/*sensor_type = VM_SRV_SENSOR_MOTION_DOUBLE_TAP + struct of sensor_data*/ +typedef struct +{ + vm_srv_sensor_motion_tap_direct_enum double_tap_direct; /* tap direction */ +}vm_srv_sensor_motion_double_tap_struct; + + +/*sensor_type = VM_SRV_SENSOR_MOTION_DROP + struct of sensor_data*/ +typedef struct +{ + vm_srv_sensor_motion_drop_enum action; /* drop action */ +}vm_srv_sensor_motion_drop_struct; + +/*sensor_type = VM_SRV_SENSOR_MOTION_STEP + struct of sensor_data*/ +typedef struct +{ + vm_srv_sensor_motion_step_enum action; /* step action */ +}vm_srv_sensor_motion_step_struct; + +/*sensor_type = VM_SRV_SENSOR_MOTION_ADVANCED_SHAKE + struct of sensor_data*/ +typedef struct { + VMUINT8 direction; /*shake direction */ +}vm_srv_sensor_motion_advanced_shake_struct; + +/*sensor_type = VM_SRV_SENSOR_MOTION_TURNOVER + struct of sensor_data*/ +typedef struct { + vm_srv_sensor_motion_turnover_enum direction; /* Tunover direction */ +} vm_srv_sensor_motion_turnover_struct; + +/*sensor_type = VM_SRV_SENSOR_MOTION_DIRECT + struct of sensor_data*/ +typedef struct +{ + vm_srv_sensor_motion_direct_enum direct; /* Direct */ + vm_srv_sensor_motion_action_enum action; /* Action */ +} vm_srv_sensor_motion_direct_struct ; + +#define VM_SRV_SENSOR_MOTION_ALWAYS_ON_MODE 0x0001 /* Sensor always open */ + + +/*----------------------------------------------------------------------------*/ +/* Extern Function */ +/*----------------------------------------------------------------------------*/ + +/***************************************************************************** + * DESCRIPTION + * sensor event callback handler + * please invole this function to release it. + * PARAMETERS + * sensor_handle : [IN] sensor's handle which is created by vm_create_sensor_instance. + * sensor_type : [IN] sensor type + * sensor_data : [IN] this is a structure of the sensor type, please convert it by type + * VM_SRV_SENSOR_MOTION_DIRECT -> vm_srv_sensor_motion_direct_struct + * VM_SRV_SENSOR_MOTION_SHAKE, -> NONE + * VM_SRV_SENSOR_MOTION_TILT, -> vm_srv_sensor_motion_tilt_struct + * VM_SRV_SENSOR_MOTION_TAP, -> vm_srv_sensor_motion_tap_struct + * VM_SRV_SENSOR_MOTION_DOUBLE_TAP, -> vm_srv_sensor_motion_double_tap_struct + * VM_SRV_SENSOR_MOTION_DROP, -> vm_srv_sensor_motion_drop_struct + * VM_SRV_SENSOR_MOTION_STEP, -> vm_srv_sensor_motion_step_struct + * VM_SRV_SENSOR_MOTION_ADVANCED_SHAKE, -> vm_srv_sensor_motion_advanced_shake_struct + * VM_SRV_SENSOR_MOTION_TURNOVER, -> vm_srv_sensor_motion_turnover_struct + * RETURNS + * void + *****************************************************************************/ +typedef void (*VM_SRV_SENSOR_EVENT_HDLR)(vm_srv_sensor_type_enum sensor_type, void *sensor_data, void *user_data); + +/***************************************************************************** + * FUNCTION + * vm_srv_sensor_start_listen + * DESCRIPTION + * Start the listen + * PARAMETERS + * type : [IN] sensor type, please refer vm_srv_sensor_type_enum + * option : [IN] some type's option, if it have + * event_hdlr : [IN] callback function + * user_data : [IN] user data + * RETURNS + * VM_SRV_SENSOR_HANDLE + * RETURN VALUES + * VM_SRV_SENSOR_MOTION_NO_SLOT : open too much detection, so that no have enough handle . + * Other: the handle of direct detection . + *****************************************************************************/ +extern VM_SRV_SENSOR_HANDLE vm_srv_sensor_start_listen(vm_srv_sensor_type_enum type, void *option, + VM_SRV_SENSOR_EVENT_HDLR event_hdlr, void *user_data); + + +/***************************************************************************** + * FUNCTION + * vm_srv_sensor_stop_listen + * DESCRIPTION + * Stop listen a sensor application + * PARAMETERS + * sensor_handle : [IN] sensor's handle. + * control_name : [IN] sensor's control name. + * value : [IN] set value. + * RETURNS + * VM_SRV_SENSOR_RESULT + * RETURN VALUES + * VM_SRV_SENSOR_SUCCEED: Stop success + * VM_SRV_SENSOR_CB_NOT_FOUND: Pass the wrong handle + *****************************************************************************/ +extern VM_SRV_SENSOR_RESULT vm_srv_sensor_stop_listen(VM_SRV_SENSOR_HANDLE handle); + + +/***************************************************************************** + * FUNCTION + * vm_srv_sensor_enable_mode + * DESCRIPTION + * This function is to enable mode + * PARAMETERS + * sensor_handle : [IN] The return value of start listen + * sensor_mode : [IN] A bitmask of sensor mode(VM_SRV_SENSOR_MOTION_ALWAYS_ON_MODE) + * RETURNS + * VM_SRV_SENSOR_RESULT + * RETURN VALUES + * VM_SRV_SENSOR_SUCCEED: enable success + * VM_SRV_SENSOR_MOTION_NO_SLOT: + *****************************************************************************/ +extern VM_SRV_SENSOR_RESULT vm_srv_sensor_enable_mode(VM_SRV_SENSOR_HANDLE handle , VMUINT16 sensor_mode); + + +/***************************************************************************** + * FUNCTION + * vm_srv_sensor_disable_mode + * DESCRIPTION + * This function is to disable mode + * PARAMETERS + * sensor_handle : [IN] The return value of start listen + * sensor_mode : [IN] A bitmask of sensor mode(VM_SRV_SENSOR_MOTION_ALWAYS_ON_MODE) + * RETURNS + * VM_SRV_SENSOR_RESULT + * RETURN VALUES + * VM_SRV_SENSOR_SUCCEED: disable success + * VM_SRV_SENSOR_MOTION_NO_SLOT: + *****************************************************************************/ +extern VM_SRV_SENSOR_RESULT vm_srv_sensor_disable_mode(VM_SRV_SENSOR_HANDLE handle, VMUINT16 sensor_mode); + + +/***************************************************************************** + * FUNCTION + * vm_srv_sensor_is_available + * DESCRIPTION + * Check whether the sensor(motion ,or future other sensors...) is enable + * stop sensor. + * PARAMETERS + * sensor_handle : [OUT] sensor's handle. + * RETURNS + * stop sensor success or not. + * RETURN VALUES + *****************************************************************************/ +extern VMINT vm_srv_sensor_is_available(vm_srv_sensor_type_enum sensor_type); + +#ifdef __cplusplus +} +#endif + +#endif /* __VM_SENSOR_SDK */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmsettings.h b/hardware/arduino/mtk/system/libmtk/include/vmsettings.h new file mode 100644 index 00000000..c80183ba --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmsettings.h @@ -0,0 +1,616 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMSETTINGS_SDK_H +#define VMSETTINGS_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +#define VM_SETTINGS_RET_OK 0 +#define VM_SETTINGS_RET_FAIL -2 +#define VM_SETTINGS_RET_NOT_SUPPORT -3 +#define VM_SETTINGS_RET_PARAM_ERR -4 +#define VM_SETTINGS_RET_NO_MEM -5 + + +typedef VMINT (*vm_settings_set_wallpaper_callback)(void* user_data); + +typedef enum +{ + VM_SETTINGS_POWER_ON_TONE, + VM_SETTINGS_POWER_OFF_TONE, + VM_SETTINGS_POWER_ON_OFF_TONE, + VM_SETTINGS_COVER_OPEN_TONE, + VM_SETTINGS_COVER_CLOSE_TONE, + VM_SETTINGS_SMS_TONE, + VM_SETTINGS_SMS_CARD2_TONE, + VM_SETTINGS_SMS_CARD3_TONE, + VM_SETTINGS_SMS_CARD4_TONE, + VM_SETTINGS_MMS_TONE, + VM_SETTINGS_MMS_CARD2_TONE, + VM_SETTINGS_MMS_CARD3_TONE, + VM_SETTINGS_MMS_CARD4_TONE, + VM_SETTINGS_EMAIL_TONE, + VM_SETTINGS_EMAIL_CARD2_TONE, + VM_SETTINGS_EMAIL_CARD3_TONE, + VM_SETTINGS_EMAIL_CARD4_TONE, + VM_SETTINGS_VOICE_TONE, + VM_SETTINGS_VOICE_CARD2_TONE, + VM_SETTINGS_VOICE_CARD3_TONE, + VM_SETTINGS_VOICE_CARD4_TONE, + VM_SETTINGS_MT_CALL_TONE, + VM_SETTINGS_MT_CALL_CARD2_TONE, + VM_SETTINGS_MT_CALL_CARD3_TONE, + VM_SETTINGS_MT_CALL_CARD4_TONE, + VM_SETTINGS_VT_CALL_TONE, + VM_SETTINGS_VT_CALL_CARD2_TONE, + VM_SETTINGS_VT_CALL_CARD3_TONE, + VM_SETTINGS_VT_CALL_CARD4_TONE, + VM_SETTINGS_TONE_END +}vm_settings_tone_enum; + +typedef enum +{ + VM_SETTINGS_HOME_PAPER, + VM_SETTINGS_LOCK_PAPER, + VM_SETTINGS_WALLPAPER_END +}vm_setttings_wallpaper_enum; + + +VMINT vm_settings_set_tone(vm_settings_tone_enum type, VMWCHAR* path); + +VMINT vm_settings_set_wallpaper(vm_setttings_wallpaper_enum type, + VMWCHAR* path,vm_settings_set_wallpaper_callback callback, void* user_data); + + + +/* Enum for time format */ +typedef enum +{ + VM_SETTING_TIME_FORMAT_12_HOURS, + VM_SETTING_TIME_FORMAT_24_HOURS, + + VM_SETTING_TIME_FORMAT_END +} vm_setting_time_format_enum; + +/* Enum for date format */ +typedef enum +{ + VM_SETTING_DATE_FORMAT_DD_MM_YYYY, + VM_SETTING_DATE_FORMAT_MM_DD_YYYY, + VM_SETTING_DATE_FORMAT_YYYY_MM_DD, + + VM_SETTING_DATE_FORMAT_END +} vm_setting_date_format_enum; + +/* Enum for date seperator */ +typedef enum +{ + VM_SETTING_DATE_SEPERATOR_DOT, + VM_SETTING_DATE_SEPERATOR_COLON, + VM_SETTING_DATE_SEPERATOR_SLOPE, + VM_SETTING_DATE_SEPERATOR_LINE, + + VM_SETTING_DATE_SEPERATOR_END +} vm_setting_date_seperator_enum; + + +/***************************************************************************** + * FUNCTION + * vm_setting_get_time_format + * DESCRIPTION + * Get system time format + * PARAMETERS + * void + * RETURNS + * vm_setting_time_format_enum + *****************************************************************************/ +VMINT vm_setting_get_time_format(void); + + +/***************************************************************************** + * FUNCTION + * vm_setting_get_date_format + * DESCRIPTION + * Get system date format + * PARAMETERS + * void + * RETURNS + * vm_setting_date_format_enum + *****************************************************************************/ +VMINT vm_setting_get_date_format(void); + + +/***************************************************************************** + * FUNCTION + * vm_setting_get_date_seperator + * DESCRIPTION + * Get system date seperator + * PARAMETERS + * void + * RETURNS + * vm_setting_date_seperator_enum + *****************************************************************************/ +VMINT vm_setting_get_date_seperator(void); + + + + +/*Setting Type Enum*/ +typedef enum +{ + VM_SETTING_ENUM_NULL, //NULL + VM_SETTING_CELLULAR_GPRS_SERVICE, //GPRS on/off + VM_SETTING_CELLULAR_GPRS_ROAMING, //GPRS roaming on/off + VM_SETTING_CELLULAR_CONNECTION_SIM, //SIM selection in multiple SIM case + VM_SETTING_NETWORK_ACCOUNTS, //network accounts + VM_SETTING_DATETIME, //system datetime + VM_SETTING_SCHEDULE_POWER_ON_OFF, //system schedule power on/off + VM_SETTING_NETWORK_TIME_AUTO_UPDATE,//network time auto update on/off + VM_SETTING_SIM_GPRS_TRANSFER_PREFER,//call perfer or data prefer + VM_SETTING_GPS_SYNC_TIME,//GPS sync time setting + VM_SETTING_ENUM_NUM +}vmsettingModuleTypes; + +/*Operation Type Enum for Each module*/ + +/* +**Operation type for SETTING_CELLULAR_GPRS_SERVICE +*/ +typedef enum +{ + VM_OPERATION_GPRS_SERVICE_ON, //GPRS on + VM_OPERATION_GPRS_SERVICE_OFF, //GPRS off + VM_OPERATION_GPRS_SERVICE_GET_STATUS, //get current GPRS status + VM_OPERATION_GPRS_SERVICE_NUM +}vmoperationTypesGPRSSrv; + + +/* +**Operation type for SETTING_CELLULAR_GPRS_ROAMING +*/ +typedef enum +{ + VM_OPERATION_GPRS_ROAMING_ON, //GPRS roaming on + VM_OPERATION_GPRS_ROAMING_OFF, //GPRS roaming off + VM_OPERATION_GPRS_ROAMING_GET_STATUS,//get current roaming status + VM_OPERATION_GPRS_ROAMING_NUM +}vmoperationTypesGPRSRoaming; + +/* +**Operation type for SETTING_CELLULAR_CONNECTION_SIM +*/ +typedef enum +{ + VM_OPERATION_CONNECTION_SIM_SET, //set currently connection SIM id, example SIM1 or SIM2 + VM_OPERATION_CONNECTION_SIM_GET_CURRENT_SIM, //get currently connection SIM id + VM_OPERATION_CONNECTION_SIM_NUM +}vmoperationTypesGPRSConnectionSIM; + +/* +**Operation type for SETTING_NETWORK_ACCOUNTS +*/ +typedef enum +{ + VM_OPERATION_NETWORK_ACCOUNTS_ADD, //add network accounts + VM_OPERATION_NETWORK_ACCOUNTS_EDIT, //edit network accounts + VM_OPERATION_NETOWRK_ACCOUNTS_DELETE, //delete network accounts + VM_OPERATION_NETWORK_ACCOUNTS_GET_ACCOUNT_LIST,//get exist accounts list + VM_OPERATION_NETWORK_ACCOUNTS_NUM +}vmoperationTypesNetworkAccounts; + +/* +**Operation type for SETTING_DATETIME +*/ +typedef enum +{ + VM_OPERATION_DATETIME_SET, //set system datetime + VM_OPERATION_DATETIME_GET, //get system datetime + VM_OPERATION_DATETIME_NUM +}vmoperationTypesDatetime; + +/* +**Operation type for SETTING_SCHEDULE_POWER_ON_OFF +*/ +typedef enum +{ + VM_OPERATION_SET_SCHEDULE_POWER_ON_STATUS, //switch schedule power on to on/off + VM_OPERATION_SET_SCHEDULE_POWER_OFF_STATUS, //switch schedule power off to on/off + VM_OPERATION_SCHEDULE_POWER_ON_OFF_NUM +}vmoperationTypesSchedulePowerOnOff; + +/* +**Operation type for SETTING_NETWORK_TIME_AUTO_UPDATE +*/ +typedef enum +{ + VM_OPERATION_NETWORK_TIME_ON, //set network time auto update on + VM_OPERATION_NETWORK_TIME_OFF, //set network time auto update off + VM_OPERATION_NETWORK_TIME_GET_STATUS, //get network time auto update status + VM_OPERATION_NETWORK_TIME_NUM +}vmoperationTypesNetowrkTime; + +/* +**Operation type for SETTING_SIM_GPRS_TRANSFER_PREFER +*/ +typedef enum +{ + VM_OPERATION_SIM_GPRS_TRANSFER_SET_CALL_PREFER, //set GPRS transfer call prefer + VM_OPERATION_SIM_GPRS_TRANSFER_SET_DATA_PREFER, //set GPRS transfer data prefer + VM_OPERATION_SIM_GPRS_TRANSFER_GET_STATUS, //get GPRS transfer status + VM_OPERATION_SIM_GPRS_TRANSFER_PREFER_NUM +}vmoperationTypesGPRSTranferPref; + + +/* +**OPERATION TYPE FOR +*/ +typedef enum +{ + VM_OPERATION_DATETIME_GPS_TIME_SYNC_ON, //ALLOW GPS TO UPDATE TIME + VM_OPERATION_DATETIME_GPS_TIME_SYNC_OFF,//DEFUSE GPS TO UPDATE TIME + VM_OPERATION_DATETIME_GPS_TIME_SYNC_GET,//GET GPS UPDATED TIME + VM_OPERATION_DATETIME_GPS_TIME_SYNC_NUM +}vmoperationTypesDTGPSSyncTime; + + + +/* +** Data Account profile sim type enum +*/ +typedef enum +{ + VM_SRV_DTCNT_SIM_TYPE_NONE = 0, + VM_SRV_DTCNT_SIM_TYPE_1, /*SIM 1*/ + VM_SRV_DTCNT_SIM_TYPE_2, /*SIM 2*/ + VM_SRV_DTCNT_SIM_TYPE_3, /*SIM 2*/ + VM_SRV_DTCNT_SIM_TYPE_4, /*SIM 4*/ + VM_SRV_DTCNT_SIM_TYPE_TOTAL +} vm_srv_dtcnt_sim_type_enum; + + +/* Data Account bearer enum */ +typedef enum +{ + VM_SRV_DTCNT_BEARER_UNKNOWN = 0, /* unknown type profile */ + VM_SRV_DTCNT_BEARER_CSD = 1, /* For csd type profile */ + VM_SRV_DTCNT_BEARER_GPRS = 2, /* For GPRS type profile */ + VM_SRV_DTCNT_BEARER_WIFI = 4, /* For WIFI type profile */ + VM_SRV_DTCNT_BEARER_TOTAL +} vm_srv_dtcnt_bearer_enum; + +/* Data Account services result enum */ +typedef enum +{ + VM_SRV_DTCNT_RESULT_SUCCESS = 0, /* success */ + VM_SRV_DTCNT_RESULT_FAILED, /* general failed case */ + VM_SRV_DTCNT_RESULT_PROCESSING, /* processing state implies Event notify */ + VM_SRV_DTCNT_RESULT_STATE_ERROR, /* service status error */ + VM_SRV_DTCNT_RESULT_INVALID_INPUT, /* the input parameter is invalid */ + VM_SRV_DTCNT_RESULT_ABORTED, /* the process is aborted */ + VM_SRV_DTCNT_RESULT_TERMINATED, /* the process is terminated */ + VM_SRV_DTCNT_RESULT_ONE_STORE_EXISTS, /* currently only support one store */ + VM_SRV_DTCNT_RESULT_STORE_NOT_COMMIT, /* store doesn't be config commited before */ + VM_SRV_DTCNT_RESULT_INVALID_STORE, /* store invalid */ + VM_SRV_DTCNT_RESULT_STORE_FULL, /* reach maximum profile storage */ + VM_SRV_DTCNT_RESULT_READ_ONLY, /* can't delete or update read_only profile */ + VM_SRV_DTCNT_RESULT_FIRST_BOOTUP, /* first bootup rerurn code for store open */ + VM_SRV_DTCNT_RESULT_RESET_FACTORY, /* the data base sim profiles folder is deleted */ + VM_SRV_DTCNT_RESULT_FS_ERROR, /* the database file system error */ + VM_SRV_DTCNT_RESULT_IGNORE, + VM_SRV_DTCNT_RESULT_TOTAL +} vm_srv_dtcnt_result_enum; + +/* this struct is designed for Data account store profile content operations*/ +typedef struct +{ + void *prof_data; /* profile data pointer */ + VMUINT32 prof_fields; /* profile enabled attributes */ + vm_srv_dtcnt_bearer_enum prof_type; /* profile bearer type */ +} vm_srv_dtcnt_store_prof_data_struct; + +/***************************************************************************** + * + * FUNCTION + * vm_srv_dtcnt_store_delete_cb_func_ptr + * DESCRIPTION + * store account deleting callback function + * PARAMETERS + * user_data : [IN] APP's piggyback user_data + * deleting_acc_id : [IN] the account id to be deleted + * RETURNS + * void + *****************************************************************************/ +typedef void (*vm_srv_dtcnt_store_delete_cb_func_ptr) (VMUINT32 deleting_acc_id, void *user_data); + +/* Data Account profile type enum */ +typedef enum +{ + VM_SRV_DTCNT_PROF_TYPE_USER_CONF = 0, /* user configured account */ + VM_SRV_DTCNT_PROF_TYPE_OTA_CONF, /* OTA configured account */ + VM_SRV_DTCNT_PROF_TYPE_FACTORY_CONF, /* Factory default */ + VM_SRV_DTCNT_PROF_TYPE_SIM_PROF, /* SIM provisioning account */ + VM_SRV_DTCNT_PROF_TYPE_DM_CONF, /* DM configured account */ + VM_SRV_DTCNT_PROF_TYPE_TOTAL +} vm_srv_dtcnt_prof_acc_type_enum; + +/* this struct is designed for Data account store query operation */ +typedef struct +{ + vm_srv_dtcnt_sim_type_enum sim_qry_info; /* sim query data for filter settings (used if OR'd set in filters) */ + vm_srv_dtcnt_bearer_enum bearer_qry_info; /* bearer query data for filter settings (used if OR'd set in filters) */ + vm_srv_dtcnt_prof_acc_type_enum acc_type_info; /* account type query data for filter settings (used if OR'd set in filters) */ + VMUINT16 filters; /* query settings (OR'd operation by srv_dtcnt_store_qry_type_enum) */ + VMUINT64 app_type; /* app_type query data for filter settings (used if OR'd set in filters) */ +} vm_srv_dtcnt_store_prof_qry_filter_struct; + +/* this struct is designed for Data account store query operation */ +#define VM_SRV_DTCNT_STORE_IDS_QRY_MAX_SIZE (64) /* maximum size of ids query id buffer */ +typedef struct +{ + vm_srv_dtcnt_store_prof_qry_filter_struct qry_info; /* query information from DA APP */ + VMUINT32 ids[VM_SRV_DTCNT_STORE_IDS_QRY_MAX_SIZE]; /* account id list query result */ + VMUINT8 num_ids; /* the number of queried id list */ +} vm_srv_dtcnt_store_prof_qry_struct; + +/* srv dtcnt add prof cntx struct */ +typedef struct +{ + vm_srv_dtcnt_store_prof_data_struct *prof; + VMUINT32 *acc_prof_id; + vm_srv_dtcnt_result_enum operate_result; +} vm_srv_dtcnt_add_prof_cntx_struct; + +/* srv dtcnt update prof cntx */ +typedef struct +{ + vm_srv_dtcnt_store_prof_data_struct *prof; + VMUINT32 acc_prof_id; + vm_srv_dtcnt_result_enum operate_result; +} vm_srv_dtcnt_update_prof_cntx_struct; + +/* srv dtcnt delete prof cntx */ +typedef struct +{ + VMUINT32 acc_prof_id; + VMBOOL force_exec; + void *user_data; + vm_srv_dtcnt_store_delete_cb_func_ptr callback; + vm_srv_dtcnt_result_enum operate_result; +}vm_srv_dtcnt_delete_prof_cntx_struct; + +/* srv dtcnt get prof ids cntx*/ +typedef struct +{ + vm_srv_dtcnt_store_prof_qry_struct *qry; + vm_srv_dtcnt_result_enum operate_result; +} vm_srv_dtcnt_get_prof_ids_cntx_struct; + + +/* time struct for setting srv */ +typedef struct +{ + VMUINT16 nYear; + VMUINT8 nMonth; + VMUINT8 nDay; + VMUINT8 nHour; + VMUINT8 nMin; + VMUINT8 nSec; + VMUINT8 DayIndex; /* 0=Sunday */ +} vm_time_struct; + + +/* spof nvram struct for mre */ +typedef struct +{ + VMBYTE Type; + VMBYTE Status; + VMBYTE Hour; + VMBYTE Min; +} vm_spof_nvram_struct; + + +/* nitz status */ +typedef enum +{ + VM_SRV_NITZ_OFF, + VM_SRV_NITZ_CONFIRM_FIRST, + VM_SRV_NITZ_ON +}vm_srv_nitz_type_enum; + + +typedef enum +{ + VM_SIM_NONE = 0, /* No bit-wise operation for none case */ + VM_SIM1 = 0x0001, + VM_SIM2 = 0x0002, + VM_SIM3 = 0x0004, + VM_SIM4 = 0x0008, + VM_SIM_END_OF_ENUM +}vm_setting_sim_enum; + +typedef struct +{ + /* Event id */ + VMUINT16 evt_id; + /* Event structure size */ + VMUINT16 size; + /* User data pointer */ + void *user_data; +}vm_mmi_event_struct; + +/* vm mmi proc function type */ +typedef VMINT (*vm_mmi_proc_func) (vm_mmi_event_struct *param); + +/* srv gprs tranfer cntx */ +typedef struct +{ + vm_setting_sim_enum sim_type; + vm_mmi_proc_func ptr_func; + void *user_data; +} vm_srv_gprs_tranfer_cntx_struct; + + +//Error code +/*ok means setting apply done*/ +#define VM_SETTING_RESULT_OK 0 +/*fail means system error when apply setting*/ +#define VM_SETTING_RESULT_FAIL -1 +/*would block means current setting is a asynchronous mode, result and data will notify to callback*/ +#define VM_SETTING_RESULT_WOULD_BLOCK -2 +/*invalid means wrong type and operation combination*/ +#define VM_SETTING_RESULT_INVALID -3 + +/*Interface and callback function*/ + +/***************************************************************************** + * + * FUNCTION + * srv_setting_result_callback + * DESCRIPTION + * setting result callback funtion, app should provide a callback funtion when apply + * settings, and this function will be called if current setting is asynchronous mode + * PARAMETERS + * result: [IN] Operation result + * user_data: [IN] User data + * RETURN VALUES + * void + *****************************************************************************/ +typedef void(* vm_setting_srv_result_callback)(VMINT32 result, void *user_data); + + +/*vm_setting_srv_enum*/ +typedef enum +{ + VM_SETTING_SRV_NO_ERROR = 0,//operator suceed + VM_SETTING_SRV_GET_MEM_FAIL = -1,//memory is not enough + VM_SETTING_SRV_ERROR_OF_RES = -2,// out of resource + VM_SETTING_SRV_ERROR_INVALID_ID = -3, //Invalid res id + VM_SETTING_SRV_ERROR_OF_PROCESS = -4,//process error + VM_SETTING_SRV_ERR_OTHERS = -65535,// other errors + VM_SETTING_SRV_ERR_END = -65536//end mark +}vm_setting_srv_enum; + + +/***************************************************************************** + * + * FUNCTION + * vm_settings_srv_command + * DESCRIPTION + * General setting command interface, which is use to set/get platfrom related settings + * + * PARAMETERS + * type: [IN] setting type, refer enum settingModuleTypes + * user_data: [IN] setting operation, refer to setting operation enum for each setting type + * in: [IN] in parameters, if you use set/add/edit/delete related operaitons, + * please provide in para + * out: [OUT] out data, if you use get/query related operations, please provide out para + * srv_setting_result_callback: [IN] setting result callback funtion, will be called by + * system when current setting is asynchronous mode + * RETURN VALUES + * void + * + * EXAMPLE + * + * Sample Code1 + * //switch on mobile data connection. + * VMINT32 result = VM_SETTING_SRV_NO_ERROR; + * result = vm_setting_srv_command(VM_SETTING_CELLULAR_GPRS_SERVICE, VM_OPERATION_GPRS_SERVICE_ON, NULL, NULL, NULL, NULL); + * if (result == VM_SETTING_RESULT_OK) + * { + * vm_log_debug("This case is passed"); + * } + * else if (result == VM_SETTING_RESULT_INVALID) + * { + * vm_log_debug("This case is not support"); + * } + * else + * { + * vm_log_debug("This case is failed."); + * } + * + * Sample Code2 + * //set system time + * VMINT32 result = VM_SETTING_SRV_NO_ERROR; + * vm_time_struct get_time, set_time; + * vm_setting_srv_command(VM_SETTING_DATETIME, VM_OPERATION_DATETIME_GET, NULL, &get_time, NULL, NULL); + * set_time = get_time; + * set_time.nHour = 12; + * set_time.nMin = 14; + * result = vm_setting_srv_command(VM_SETTING_DATETIME, VM_OPERATION_DATETIME_SET, &set_time, NULL, NULL, NULL); + * if (result == VM_SETTING_RESULT_OK) + * { + * vm_log_debug("This case is passed"); + * } + * else if (result == VM_SETTING_RESULT_INVALID) + * { + * vm_log_debug("This case is not support"); + * } + * else + * { + * vm_log_debug("This case is failed"); + * } + * + *****************************************************************************/ +VMINT32 vm_setting_srv_command(VMUINT16 type, + VMUINT16 operation, + void *in, + void *out, + vm_setting_srv_result_callback cb, + void *user_data); + + + +typedef void (*vm_srv_sensor_hr_data_cb)(void *sensor_data); +typedef void (*vm_srv_sensor_acc_data_cb)(void *acc_x, void *acc_y, void *acc_z); + +void vm_srv_sensor_hr_data_rigister_cb(vm_srv_sensor_hr_data_cb event_hdlr); +void vm_srv_sensor_acc_data_rigister_cb(vm_srv_sensor_acc_data_cb event_hdlr); + +typedef void (*vm_idle_swatch_pedometer_cb)(void *data); +void vm_idle_swatch_pedometer_register_callback(vm_idle_swatch_pedometer_cb event_hdlr); +void vm_switch_bt_call(VMBOOL on); +VMBOOL vm_is_bt_call_allowed(void); + +#ifdef __cplusplus +} +#endif + +#endif /* VMSETTINGS_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmsim.h b/hardware/arduino/mtk/system/libmtk/include/vmsim.h new file mode 100644 index 00000000..23ed9ce6 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmsim.h @@ -0,0 +1,417 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef VMSIM_SDK_H_ +#define VMSIM_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/* Operator */ +typedef enum +{ + NO_SIM_CARD = 0, /* No SIM card. */ + UNKOWN_OPERATOR, /* Unknown operator. */ + CMCC, /* China Mobile. */ + UNICOM, /* China Unicom. */ + CNC, /* China Netcom. */ + CNTELCOM, /* China Telecom. */ + ALL /* All the operator. */ +} operator_t; + +/* The return value of vm_get_sim_card_status(). */ +typedef enum +{ + VM_SIM_STATE_ERROR = -1, /* Get failed. */ + VM_SIM_STATE_VACANT = 0, /* No SIM card or the SIM card not work. */ + VM_SIM_STATE_WORKING = 1 /* The SIM card is working. */ +} vm_sim_state_t; + +typedef void (*vm_sim_get_iccid_cb)(VMCHAR* iccid, void* user_data); + +#define VM_SIM_NO 0 /* No SIM card */ +#define VM_SIM_SIM1 1 /* SIM card 1 */ +#define VM_SIM_SIM2 2 /* SIM card 2 */ +#define VM_SIM_SIM3 3 /* SIM card 3 */ +#define VM_SIM_SIM4 4 /* SIM card 4 */ + +/***************************************************************************** + * FUNCTION + * vm_get_operator + * DESCRIPTION + * Get the active operator. + * RETURNS + * The operator code. + * RETURN VALUES + * NO_SIM_CARD : No SIM card. + * UNKOWN_OPERATOR : Unknown operator. + * CMCC : China Mobile. + * UNICOM : China Unicom. + * CNC : China Netcom. + * CNTELCOM : China Telecom. + *****************************************************************************/ +operator_t vm_get_operator(void); + +/***************************************************************************** + * FUNCTION + * vm_has_sim_card + * DESCRIPTION + * To query whether the SIM is available or not. + * RETURNS + * TRUE if any SIM is available. + * RETURN VALUES + * TRUE : A SIM available. + * FALSE : No SIM available. + *****************************************************************************/ +VMINT vm_has_sim_card(void); + +/***************************************************************************** + * FUNCTION + * vm_get_imei + * DESCRIPTION + * Get the IMEI of the phone. If the phone support dual card, it will get the IMEI of the selected SIM card. + * RETURNS + * IMEI string for the phone in ASCII format. + * RETURN VALUES + * NULL : The request of IMEI is in progress, please try again later. + *****************************************************************************/ +VMSTR vm_get_imei(void); + +/***************************************************************************** + * FUNCTION + * vm_get_imsi + * DESCRIPTION + * Get the IMSI of selected SIM card. + * RETURNS + * IMSI string of the selected SIM card. + * RETURN VALUES + * NULL : The request of IMSI is in progress, please try again later. + *****************************************************************************/ +VMSTR vm_get_imsi(void); + +/***************************************************************************** + * FUNCTION + * vm_sim_card_count + * DESCRIPTION + * Get the number of SIM cards. + * RETURNS + * The number of SIM cards. + * RETURN VALUES + * 99 : Flight mode. + * VM_SIM_NO : No SIM. + * 1 : One SIM card. + * 2 : Two SIM card. + *****************************************************************************/ +VMINT vm_sim_card_count(void); + +/***************************************************************************** + * FUNCTION + * vm_set_active_sim_card + * DESCRIPTION + * Set active SIM card. + * PARAMETERS + * card_id : [IN] Index of SIM card, 1-SIM1, 2-SIM2. + * RETURN VALUES + * TRUE : If successful. + * FALSE : If failed. + *****************************************************************************/ +VMINT vm_set_active_sim_card(VMINT card_id); + +/***************************************************************************** + * FUNCTION + * vm_get_sim_card_status + * DESCRIPTION + * Get the status of the given SIM card. + * PARAMETERS + * card_id : [IN] Index of SIM card, 1-SIM1, 2-SIM2. + * RETURNS + * The status of the given SIM card. + * RETURN VALUES + * VM_SIM_STATE_ERROR : Get failed. + * VM_SIM_STATE_VACANT : No SIM card or the SIM card not work. + * VM_SIM_STATE_WORKING : The given SIM card is working. + *****************************************************************************/ +vm_sim_state_t vm_get_sim_card_status(VMINT card_id); + +/* The maximum length of operator code */ +#define VM_MAX_OPERATOR_CODE_SIZE (7) + +/***************************************************************************** + * FUNCTION + * vm_query_operator_code + * DESCRIPTION + * Get the operator code. + * PARAMETERS + * buffer : [OUT] Buffer stores operator code. + * buffer_size : [IN] Size of the buffer. + * RETURNS + * The error code of the operation. + * RETURN VALUES + * 0 : If successful. + * Other error code: If unsuccessful. + *****************************************************************************/ +VMINT vm_query_operator_code(VMCHAR *buffer, VMUINT buffer_size); + +/***************************************************************************** + * FUNCTION + * vm_sim_get_iccid + * DESCRIPTION + * Get the iccid of sim card. + * PARAMETERS + * sim : [IN] which sim card :1,2,3,4.... + * callback : [IN] callback function. + * iccid : [IN] buff to receive iccid + * buff_len : [IN] buff length + * user_data : [IN] user data in callback. + * RETURNS + * The error code of the operation. + * RETURN VALUES + * 0 : If successful. + * Other error code: If unsuccessful. + *****************************************************************************/ +VMINT vm_sim_get_iccid(VMINT sim, vm_sim_get_iccid_cb callback, VMCHAR* iccid, VMINT buff_len, void* user_data); + +/***************************************************************************** + * FUNCTION + * vm_sim_get_active_sim_card + * DESCRIPTION + * Get the active sim card. + * PARAMETERS + * + * RETURNS + * sim card 1,2,3,4... + * RETURN VALUES + * 0 : no active sim card + *****************************************************************************/ +VMINT vm_sim_get_active_sim_card(void); + +/***************************************************************************** + * FUNCTION + * vm_sim_max_card_count + * DESCRIPTION + * Get the max card phone support + * PARAMETERS + * + * RETURNS + * 1,2,3,4... + * RETURN VALUES + * + *****************************************************************************/ +VMINT vm_sim_max_card_count(void); + +/***************************************************************************** + * FUNCTION + * vm_sim_get_prefer_sim_card + * DESCRIPTION + * Get the user prefer sim card + * PARAMETERS + * + * RETURNS + * 1,2,3,4... + * RETURN VALUES + * + *****************************************************************************/ +VMINT vm_sim_get_prefer_sim_card(void); + +/***************************************************************************** + * FUNCTION + * vm_get_imei + * DESCRIPTION + * Get the IMEI of the phone. + * PARAMETERS + * sim : [IN] which sim card :1,2,3,4.... + * RETURNS + * IMEI string for the phone in ASCII format. + * RETURN VALUES + * NULL : The request of IMEI is in progress, please try again later. + *****************************************************************************/ +VMSTR vm_get_imei_ext(VMINT sim); + + +/* NEW */ +/***************************************************************************** + * FUNCTION + * vm_sim_get_imei + * DESCRIPTION + * Get the IMEI of the phone. If the phone support dual card, it will get the IMEI of the selected SIM card. + * RETURNS + * IMEI string for the phone in ASCII format. + * RETURN VALUES + * NULL : The request of IMEI is in progress, please try again later. + *****************************************************************************/ +VMSTR vm_sim_get_imei(void); +/***************************************************************************** + * FUNCTION + * vm_get_imsi + * DESCRIPTION + * Get the IMSI of selected SIM card. + * RETURNS + * IMSI string of the selected SIM card. + * RETURN VALUES + * NULL : The request of IMSI is in progress, please try again later. + *****************************************************************************/ +VMSTR vm_sim_get_imsi(void); +/***************************************************************************** + * FUNCTION + * vm_sim_get_imei_ext + * DESCRIPTION + * Get the IMEI of the phone. + * PARAMETERS + * sim : [IN] which sim card :1,2,3,4.... + * RETURNS + * IMEI string for the phone in ASCII format. + * RETURN VALUES + * NULL : The request of IMEI is in progress, please try again later. + *****************************************************************************/ +VMSTR vm_sim_get_imei_ext(VMINT sim); +/***************************************************************************** + * FUNCTION + * vm_sim_get_operator + * DESCRIPTION + * Get the active operator. + * RETURNS + * The operator code. + * RETURN VALUES + * NO_SIM_CARD : No SIM card. + * UNKOWN_OPERATOR : Unknown operator. + * CMCC : China Mobile. + * UNICOM : China Unicom. + * CNC : China Netcom. + * CNTELCOM : China Telecom. + *****************************************************************************/ +operator_t vm_sim_get_operator(void); + +/***************************************************************************** + * FUNCTION + * vm_get_sim_card_status + * DESCRIPTION + * Get the status of the given SIM card. + * PARAMETERS + * card_id : [IN] Index of SIM card, 1-SIM1, 2-SIM2. + * RETURNS + * The status of the given SIM card. + * RETURN VALUES + * VM_SIM_STATE_ERROR : Get failed. + * VM_SIM_STATE_VACANT : No SIM card or the SIM card not work. + * VM_SIM_STATE_WORKING : The given SIM card is working. + *****************************************************************************/ +vm_sim_state_t vm_sim_get_card_status(VMINT sim); + +/***************************************************************************** + * FUNCTION + * vm_has_sim_card + * DESCRIPTION + * To query whether the SIM is available or not. + * RETURNS + * TRUE if any SIM is available. + * RETURN VALUES + * TRUE : A SIM available. + * FALSE : No SIM available. + *****************************************************************************/ +VMBOOL vm_sim_has_card(void); +/***************************************************************************** + * FUNCTION + * vm_query_operator_code + * DESCRIPTION + * Get the operator code. + * PARAMETERS + * buffer : [OUT] Buffer stores operator code. + * buffer_size : [IN] Size of the buffer. + * RETURNS + * The error code of the operation. + * RETURN VALUES + * 0 : If successful. + * Other error code: If unsuccessful. + *****************************************************************************/ +VMINT vm_sim_query_operator_code(VMCHAR* buffer, VMUINT buffer_size); +/***************************************************************************** + * FUNCTION + * vm_sim_get_active_sim_card + * DESCRIPTION + * Get the active sim card. + * PARAMETERS + * + * RETURNS + * sim card 1,2,3,4... + * RETURN VALUES + * 0 : no active sim card + *****************************************************************************/ +VMBOOL vm_sim_set_active_card(VMINT sim); + +#define VM_MAX_PLMN_LEN 6 +/***************************************************************************** + * FUNCTION + * vm_sim_get_home_plmn + * DESCRIPTION + * Get the SIM PLMN. + * PARAMETERS + * sim : [IN] Index of SIM card, 1-SIM1, 2-SIM2. + * buffer : [OUT] Buffer stores operator code. The size shall be + * (VM_MAX_PLMN_LEN + 1) at minimum. + * buffer_size : [IN] Size of the buffer. It shall be >= + * (VM_MAX_PLMN_LEN + 1) + * RETURNS + * The error code of the operation. + * RETURN VALUES + * 0 : If successful. + * Other error code: If unsuccessful. + *****************************************************************************/ +VMINT vm_sim_get_home_plmn(VMINT sim, VMCHAR* buffer, VMUINT buffer_size); + + +/***************************************************************************** + * FUNCTION + * vm_nw_info_get_nw_plmn + * DESCRIPTION + * Get network PLMN. + * PARAMETERS + * sim : [IN] Which protocol layer of SIM + * buffer : [OUT] PLMN buffer to be filled in. The size shall be + * (VM_MAX_PLMN_LEN + 1) at minimum. + * buffer_size : [IN] The size of out_plmn_buffer[]. It shall be >= + * (VM_MAX_PLMN_LEN + 1). + * RETURN VALUES + * 0 : If returned PLMN is valid. + * else : If PLMN is not available; for example, no service state. + *****************************************************************************/ +VMINT vm_nw_info_get_nw_plmn(VMINT sim, VMCHAR* buffer, VMUINT buffer_size); +#ifdef __cplusplus +} +#endif + +#endif /* VMSIM_H_ */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmsm.h b/hardware/arduino/mtk/system/libmtk/include/vmsm.h new file mode 100644 index 00000000..aab820c1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmsm.h @@ -0,0 +1,310 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMSM_SDK_H_ +#define VMSM_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" +#include "vmpromng.h" + +/* Search all SMs in removable & phone memory and compare their versions while loading. The newest one will be loaded. */ +#define MRE_SM_LOAD_VER_CMP + +/* SM is being loaded. */ +#define VM_SM_MSG_LOAD (1) + +/* Invoker is querying for entries of SM API. */ +#define VM_SM_MSG_QUERY (5) + +/* SM is being unloaded. */ +#define VM_SM_MSG_UNLOAD (9) + + +/* Definitions of SM's return value */ +#define VM_SM_SUCCESS (0) /* SM operation success */ +#define VM_SM_FAILED (-1) /* SM operation failed */ +#define VM_SM_PARAM_ERROR (-2) /* SM parameter error */ +#define VM_SM_FILE_NOT_FOUND (-3) /* SM file not found */ +#define VM_SM_INVALID_INVOKER (-4) /* SM invalid invoker */ +#define VM_SM_CREATE_FAILED (-5) /* SM failed to create pcb */ +#define VM_SM_CREATE_COPY_FAILED (-6) /* SM failed to create copy */ +#define VM_SM_MSG_FAILED (-7) /* SM failed to handle messages */ +#define VM_SM_NAME_MISMATCH (-8) /* SM name mis-match with name in file tag */ +#define VM_SM_MEMORY_INSUFFICIENT (-9) /* SM memory insifficient */ + +/* SM flag to identify PCB's type, phase out*/ +enum { + MRE_APP = 0, /* app launch vsm */ + MRE_SM /* vsm launch vsm (not support) */ +}; + + +typedef struct _vm_sm_info_t { + VMCHAR version[6]; +} vm_sm_info_t; + +VMINT vm_sm_query_info(VMSTR sm_name, vm_sm_info_t * sm_info); + +#ifdef __LINKIT_SDK__ + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +/* Definitions for explicit SM invoking */ +typedef void (*void_void_t)(void); +typedef VMINT (*int_void_t)(void); +typedef VMINT (*int_int_t)(VMINT); + +/* Macros for SM */ +#define SM_PROCESS_BEGIN() {\ + if (((int_int_t)vm_get_sym_entry("vm_sm_set_sb_by_ptr"))((VMINT)handle_smevt) == 0) { + +#define SM_PROCESS_RETURN() ((void_void_t)vm_get_sym_entry("vm_sm_reset_sb"))(); + +#define SM_PROCESS_END() SM_PROCESS_RETURN() } } + +#define SM_CALLBACK_BEGIN() {\ + if (((int_void_t)vm_get_sym_entry("vm_sm_set_sb_for_invoker"))() == 0) { + +#define SM_CALLBACK_END() SM_PROCESS_END() + +#define SM_SAFE_CALLBACK(PTR) \ + SM_CALLBACK_BEGIN() \ + PTR; \ + SM_CALLBACK_END() + +#define SM_SAFE_CALLBACK_RETURN(PTR, RET) \ + SM_CALLBACK_BEGIN() \ + RET = PTR; \ + SM_CALLBACK_END() + +/* Macros for SM STUB */ +#define SM_INVOKE_BEGIN(SM) {\ + if (((int_int_t)vm_get_sym_entry("vm_sm_set_sb_by_handle"))(SM) == 0) { + +#define SM_INVOKE_END() SM_PROCESS_END() + +#define SM_SAFE_INVOKE(SM, PTR) \ + SM_INVOKE_BEGIN(SM) \ + PTR; \ + SM_INVOKE_END() + +#define SM_SAFE_INVOKE_RETURN(SM, PTR, RET) \ + SM_INVOKE_BEGIN(SM) \ + RET = PTR; \ + SM_INVOKE_END() + +#endif + + +/***************************************************************************** + * FUNCTION + * vm_sm_reg_callback + * DESCRIPTION + * register SM system event callback function. + * PARAMETERS + * smHandler : [IN] callback function pointer. + * RETURN VALUES + * + *****************************************************************************/ +void vm_sm_reg_callback(VMINT (*smHandler)(VMINT message, VMINT param)); + + +/***************************************************************************** + * FUNCTION + * vm_sm_get_filename + * DESCRIPTION + * Get running sm full path (UCS2). + * PARAMETERS + * filename : [OUT] sm file name, get memory form invoker. + * RETURN VALUES + * VM_SM_SUCCESS : If successful. + * VM_SM_FAILED : If unsuccessful. + *****************************************************************************/ +VMINT vm_sm_get_filename(VMWSTR filename); + +/***************************************************************************** + * FUNCTION + * vm_sm_load + * DESCRIPTION + * load sm file. + * PARAMETERS + * sm_name : [IN] sm file name without suffix. + * RETURN VALUES + * >0 : sm handle. + * VM_SM_FAILED : If unsuccessful. + * VM_SM_PARAM_ERROR : If unsuccessful. + * VM_SM_FILE_NOT_FOUND : If unsuccessful. + * VM_SM_FAILED : If unsuccessful. + * VM_SM_CREATE_FAILED : If unsuccessful. + * VM_SM_CREATE_COPY_FAILED : If unsuccessful. + * VM_SM_MSG_FAILED : If unsuccessful. + * VM_SM_NAME_MISMATCH : If unsuccessful. + * SEE ALSO + * vm_sm_loadw + * vm_sm_unload + * EXAMPLE + * + * VMINT sm_hdl = vm_sm_load("sm_charge"); + * if (sm_hdl > 0) + * { + * ... + * } + * vm_sm_unload(sm_hdl); + * + *****************************************************************************/ +VMINT vm_sm_load(VMSTR sm_name); + + +/***************************************************************************** + * FUNCTION + * vm_sm_loadw + * DESCRIPTION + * load sm file use unicorn. + * PARAMETERS + * sm_name : [IN] sm file name without suffix. + * RETURN VALUES + * >0 : sm handle. + * VM_SM_FAILED : If unsuccessful. + * VM_SM_PARAM_ERROR : If unsuccessful. + * VM_SM_FILE_NOT_FOUND : If unsuccessful. + * VM_SM_FAILED : If unsuccessful. + * VM_SM_CREATE_FAILED : If unsuccessful. + * VM_SM_CREATE_COPY_FAILED : If unsuccessful. + * VM_SM_MSG_FAILED : If unsuccessful. + * VM_SM_NAME_MISMATCH : If unsuccessful. + * SEE ALSO + * vm_sm_load + *****************************************************************************/ +VMINT vm_sm_loadw(VMWSTR sm_name); + + +/***************************************************************************** + * FUNCTION + * vm_sm_get_func_entry + * DESCRIPTION + * get function pointer form sm file. + * PARAMETERS + * sm_hdl : [IN] sm file handler. + * api_id : [IN] app id provide by sm headfile. + * RETURN VALUES + * >0 : If successful. + * NULL : If unsuccessful. + * EXAMPLE + * + * VMINT sm_hdl = vm_sm_load("sm_charge"); + * func_t func_ptr = NULL; + * if (sm_hdl > 0) + * { + * func_ptr = vm_sm_get_func_entry(sm_hdl, id_func); + * if (func_ptr) + * { + * func_ptr(x, y, z); + * } + * } + * vm_sm_unload(sm_hdl); + * + *****************************************************************************/ +VMINT vm_sm_get_func_entry(VMINT sm_hdl, VMINT api_id); + + +/***************************************************************************** + * FUNCTION + * vm_sm_unload + * DESCRIPTION + * unload sm file. + * PARAMETERS + * sm_hdl : [IN] sm file handler. + * RETURN VALUES + * VM_SM_SUCCESS : If successful. + * VM_SM_FAILED : If unsuccessful. + * SEE ALSO + * vm_sm_load + * EXAMPLE + * + * VMINT sm_hdl = vm_sm_load("sm_charge"); + * if (sm_hdl > 0) + * { + * ... + * } + * vm_sm_unload(sm_hdl); + * + *****************************************************************************/ +VMINT vm_sm_unload(VMINT sm_hdl); + + +/***************************************************************************** + * FUNCTION + * vm_sm_reg_msg_proc + * DESCRIPTION + * register msg proc handle + * PARAMETERS + * proc : [IN] proc handle + * RETURN VALUES + * void + *****************************************************************************/ +void vm_sm_reg_msg_proc(VM_MESSAGE_PROC proc); + + +/***************************************************************************** + * FUNCTION + * vm_sm_get_handle_by_package_name + * DESCRIPTION + * get handle + * PARAMETERS + * name : [IN] package name of vsm file. + * RETURN VALUES + * handle : If successful. + * 0 : If unsuccessful. + *****************************************************************************/ +VMINT vm_sm_get_handle_by_package_name(VMSTR name); + + +VMINT vm_sm_set_sb_by_ptr(VMINT ptr); +VMINT vm_sm_reset_sb(void); +void vm_sm_exit(void); +VMINT vm_sm_set_sb_for_invoker(void); +VMINT vm_sm_set_sb_by_handle(VMINT sm_hdl); + + +#ifdef __cplusplus +} +#endif + +#endif /* VMSM_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmsms.h b/hardware/arduino/mtk/system/libmtk/include/vmsms.h new file mode 100644 index 00000000..e8c09b77 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmsms.h @@ -0,0 +1,822 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMSMS_SDK_H_ +#define VMSMS_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +#define VM_SMS_MSG_CONTENT_LEN 500 + +#define VM_SMS_MAX_ADDR_LEN 21 + +#define VM_SMS_MSG_INFO_CONTENT_LEN (61 + 19) + +#define VM_SMS_SUPPORT_SYN_SCA 1 +#define VM_SMS_NOT_SUPPORT_SYN_SCA -2 + +typedef enum +{ + VM_SMS_IDENTIFY_ERROR = -4, + VM_SMS_MIBR_NOT_IN_PROCESS_SPACE = -3, + VM_SMS_MIBR_ERROR = -2, + VM_SMS_REQ_ERROR = -1, /*SMS operation request failure*/ + VM_SMS_REQ_NO_ERROR, /*SMS operation request succeed*/ + VM_SMS_REQ_CALLBACK_REGISTERED +} vm_sms_error_enum; + + +typedef enum +{ + VM_SMS_BOX_INBOX = 0x01, /*inbox*/ + VM_SMS_BOX_OUTBOX = 0x02, /*sent box*/ + VM_SMS_BOX_DRAFTS = 0x04, /*draft box*/ + VM_SMS_BOX_UNSENT = 0x08, /*to be sent box*/ + VM_SMS_BOX_SIM = 0x10, /*sim card*/ + VM_SMS_BOX_ARCHIVE = 0x20, /*archive box */ + + VM_SMS_BOX_RESERVED = 0x40 + +} vm_sms_box_enum; + +/* Message Folder Type */ +typedef enum +{ + VM_SMS_FOLDER_DEFAULT, /* default folder */ + VM_SMS_FOLDER_ARCHIVE /* archive folder */ +} vm_sms_folder_enum; + +/* Message Storage Type */ +typedef enum +{ + + VM_SMS_STATUS_UNREAD = 0x01, /*unread*/ + VM_SMS_STATUS_READ = 0x02, /*read*/ + VM_SMS_STATUS_SENT = 0x04, /*sent*/ + VM_SMS_STATUS_UNSENT = 0x08, /*to be sent*/ + VM_SMS_STATUS_DRAFT = 0x10, /*draft*/ + + VM_SMS_STATUS_UNSUPPORTED = 0x20 +} vm_sms_status_enum; + + +/* Message Type Indication */ +typedef enum +{ + VM_SMS_MTI_DELIVER = 0x00, /* deliver type */ + VM_SMS_MTI_DELIVER_REPORT = 0x00, /* deliver report type */ + VM_SMS_MTI_SUBMIT = 0x01, /* submit type */ + VM_SMS_MTI_SUBMIT_REPORT = 0x01, /* submit report type */ + VM_SMS_MTI_STATUS_REPORT = 0x02, /* status report type */ + VM_SMS_MTI_COMMAND = 0x02, /* command type */ + VM_SMS_MTI_RESERVED = 0x03 +} vm_sms_mti_enum; + + +/* Message Storage Type */ +typedef enum +{ + VM_SMS_STORAGE_ME, /*phone*/ + VM_SMS_STORAGE_SIM, /*SIM card*/ + + VM_SMS_STORAGE_UNSPECIFIC +} vm_sms_storage_enum; + +typedef enum +{ + VM_MMI_SIM_1 = 0x0001, /* SIM 1 */ + VM_MMI_SIM_2 = 0x0002, /* SIM 2 */ + VM_MMI_SIM_3 = 0x0004, /* SIM 1 */ + VM_MMI_SIM_4 = 0x0008 /* SIM 2 */ + }vm_sim_enum; + +/* network type*/ +typedef enum +{ + VM_MMI_GSM = 0x0100 /* GSM network */ + } vm_network_enum; + +/* SIM Card Type */ +typedef enum +{ + VM_SMS_SIM_1 = VM_MMI_GSM | VM_MMI_SIM_1, /* sim1 */ + VM_SMS_SIM_2 = VM_MMI_GSM | VM_MMI_SIM_2, /* sim2 */ + VM_SMS_SIM_3 = VM_MMI_GSM | VM_MMI_SIM_3, /* SIM Card 3, the SIM card inserted in the slot 3 */ + VM_SMS_SIM_4 = VM_MMI_GSM | VM_MMI_SIM_4, /* SIM Card 4, the SIM card inserted in the slot 4 */ + VM_SMS_TOTAL +} vm_sms_sim_enum; + + +/* Message Class Type */ +typedef enum +{ + VM_SMS_CLASS_0 = 0x00, /* class 0 */ + VM_SMS_CLASS_1 = 0x01, /* class 1 */ + VM_SMS_CLASS_2 = 0x02, /* class 2 */ + VM_SMS_CLASS_3 = 0x03 /* class 3 */ +} vm_sms_class_enum; + + +/* Validity-Period */ +typedef enum +{ + VM_SMS_VP_1_HR = 11, /* 1 hour */ + VM_SMS_VP_6_HR = 71, /* 6 hours */ + VM_SMS_VP_12_HR = 143, /* 12 hours */ + VM_SMS_VP_24_HR = 167, /* 24 hours */ + VM_SMS_VP_72_HR = 169, /* 72 hours */ + VM_SMS_VP_1_WEEK = 173, /* 1 week */ + VM_SMS_VP_MAX = 255 +} vm_sms_vp_enum; + + +/* SMS DCS */ +typedef enum +{ + VM_SMS_DCS_7BIT = 0x00, /* GSM 7 bit default alphabet */ + VM_SMS_DCS_8BIT = 0x04, /* 8 bit data */ + VM_SMS_DCS_UCS2 = 0x08, /* UCS2 (16bit) */ + VM_SMS_DCS_RESERVED = 0x0c +} vm_sms_dcs_enum; + + +/* Protocol Identifier */ +typedef enum +{ + VM_SMS_PID_DEFAULT = 0x00, /* Text SMS */ + VM_SMS_PID_EMAIL = 0x32, /* Internet Electronic Mail */ + + VM_SMS_PID_TYPE_0 = 0x40, /* Short Message Type 0 */ + VM_SMS_PID_REPLACE_TYPE_1 = 0x41, /* Replace Short Message Type 1 */ + VM_SMS_PID_REPLACE_TYPE_2 = 0x42, /* Replace Short Message Type 2 */ + VM_SMS_PID_REPLACE_TYPE_3 = 0x43, /* Replace Short Message Type 3 */ + VM_SMS_PID_REPLACE_TYPE_4 = 0x44, /* Replace Short Message Type 4 */ + VM_SMS_PID_REPLACE_TYPE_5 = 0x45, /* Replace Short Message Type 5 */ + VM_SMS_PID_REPLACE_TYPE_6 = 0x46, /* Replace Short Message Type 6 */ + VM_SMS_PID_REPLACE_TYPE_7 = 0x47, /* Replace Short Message Type 7 */ + + VM_SMS_PID_RETURN_CALL_MSG = 0x5F, /* Return Call Message */ + VM_SMS_PID_ANSI_136_RDATA = 0x7C, /* ANSI-136 R-DATA */ + VM_SMS_PID_ME_DOWNLOAD = 0x7D, /* ME Data Download */ + VM_SMS_PID_ME_DE_PERSONAL = 0x7E, /* ME De-personalization Short Message */ + VM_SMS_PID_SIM_DOWNLOAD = 0x7F, /* (U)SIM Data Download */ + + VM_SMS_PID_RESERVED +} vm_sms_pid_enum; + + +/* SMS Action Type */ +typedef enum +{ + VM_SMS_ACTION_NONE, /* no action */ + VM_SMS_ACTION_SEND, /* send action */ + VM_SMS_ACTION_READ, /* read action */ + VM_SMS_ACTION_DELETE, /* delete action */ + VM_SMS_ACTION_SAVE, /* save action */ + VM_SMS_ACTION_UPDATE, /* update action */ + VM_SMS_ACTION_COPY, /* copy action */ + VM_SMS_ACTION_MOVE, /* move action */ + VM_SMS_ACTION_QUERY, /* query action */ + VM_SMS_ACTION_CHANGE_STATUS, /* change status action */ + VM_SMS_ACTION_MOVE_TO_ARCHIVE, /* move to archive action */ + VM_SMS_ACTION_GET_CONTENT, /* get content action */ + VM_SMS_ACTION_GET_SIM_NUM, /* get sim number action */ + VM_SMS_ACTION_GET_SC_ADDR /* get SMS center address action */ +} vm_sms_action_enum; + + +/* SMS Cause Tpye, and MMI defined error codes for others */ +typedef enum +{ + VM_SMS_CAUSE_NO_ERROR = 0, + + + VM_SMS_CAUSE_ME_FAILURE = 300, /* Reference TS 27.005 Clause 3.2.5, For AT Command and MMI */ + VM_SMS_CAUSE_OP_NOT_ALLOWED = 302, /* Reference TS 27.005 Clause 3.2.5, For AT Command and MMI */ + VM_SMS_CAUSE_OP_NOT_SUPPORTED = 303, /* Reference TS 27.005 Clause 3.2.5, For AT Command and MMI */ + VM_SMS_CAUSE_INVALID_PDU_PARA = 304, /* Reference TS 27.005 Clause 3.2.5, For AT Command and MMI */ + VM_SMS_CAUSE_INVALID_TEXT_PARA = 305, /* Reference TS 27.005 Clause 3.2.5, For AT Command and MMI */ + VM_SMS_CAUSE_SIM_NOT_INSERTED = 310, /* Reference TS 27.005 Clause 3.2.5, For AT Command and MMI */ + VM_SMS_CAUSE_SIM_FAILURE = 313, /* Reference TS 27.005 Clause 3.2.5, For AT Command and MMI */ + VM_SMS_CAUSE_MEMORY_FAILURE = 320, /* Reference TS 27.005 Clause 3.2.5, For AT Command and MMI */ + VM_SMS_CAUSE_INVALID_MEM_INDEX = 321, /* Reference TS 27.005 Clause 3.2.5, For AT Command and MMI */ + VM_SMS_CAUSE_MEM_FULL = 322, /* Reference TS 27.005 Clause 3.2.5, For AT Command and MMI */ + VM_SMS_CAUSE_SCA_UNKNOWN = 330, /* Reference TS 27.005 Clause 3.2.5, For AT Command and MMI */ + + VM_SMS_CAUSE_NOT_READY = 341, /*SMS not ready*/ + VM_SMS_CAUSE_SEND_BUSY, /*busy on sending*/ + VM_SMS_CAUSE_SEND_ABORT, + VM_SMS_CAUSE_MEM_INSUFFICIENT, /*memory insufficient*/ + VM_SMS_CAUSE_DATA_INVALID, /*invalid data*/ + VM_SMS_CAUSE_DATA_EXCEED, /*data exceed*/ + VM_SMS_CAUSE_NUMBER_EMPTY, /*destination number is empty*/ + VM_SMS_CAUSE_NUMBER_INVALID, /*destination number is invalid*/ + VM_SMS_CAUSE_SC_EMPTY, /*SMS center number is empty*/ + VM_SMS_CAUSE_SC_INVALID, /*SMS center number is invalid*/ + VM_SMS_CAUSE_FDL_FAIL, /* FDL fail */ + VM_SMS_CAUSE_AT_CONFLICT, /* AT conflict */ + VM_SMS_CAUSE_OP_CONFLICT, /* OP conflict */ + VM_SMS_CAUSE_EMAIL_NO_SPACE, /* email no space */ + VM_SMS_CAUSE_FS_ERROR, /* FS error */ + + VM_SMS_CAUSE_UNKNOWN_ERROR = 500 +} vm_sms_cause_enum; + +/* SMS Parameter Flag */ +typedef enum +{ + VM_SMS_PARA_NONE = 0x00000000, + + VM_SMS_PARA_NUM = 0x00000001, /* parameter of number */ + VM_SMS_PARA_SCA = 0x00000002, /* parameter of SCA */ + VM_SMS_PARA_PID = 0x00000004, /* parameter of PID */ + VM_SMS_PARA_DCS = 0x00000008, /* parameter of DCS */ + VM_SMS_PARA_VP = 0x00000010, /* parameter of VP */ + VM_SMS_PARA_STATUS_REPORT = 0x00000020, /* parameter of status report */ + VM_SMS_PARA_REPLY_PATH = 0x00000040, /* parameter of reply path */ + VM_SMS_PARA_PORT = 0x00000080, /* parameter of port */ + VM_SMS_PARA_CLASS = 0x00000100, /* parameter of class */ + VM_SMS_PARA_MMS = 0x00000200, /* parameter of MMS */ + VM_SMS_PARA_FO = 0x00000400, /* parameter of FO */ + + VM_SMS_PARA_STATUS = 0x00000800, /* parameter of status */ + VM_SMS_PARA_SIM_ID = 0x00001000, /* parameter of SIM ID */ + VM_SMS_PARA_STORAGE_TYPE = 0x00002000, /* parameter of storage type */ + VM_SMS_PARA_TIMESTAMP = 0x00004000, /* parameter of time stamp */ + + VM_SMS_PARA_CONTENT_EMS = 0x00008000, /* parameter of EMS */ + VM_SMS_PARA_CONTENT_BUFF = 0x00010000, /* parameter of buffer */ + VM_SMS_PARA_CONTENT_FILE = 0x00020000 /* parameter of file */ +} vm_sms_para_enum; + + + +/* SMS Sort Type */ +typedef enum +{ + VM_SMS_SORT_NONE, + VM_SMS_SORT_TIMESTAMP, /*by timestamp*/ + VM_SMS_SORT_MSG_TYPE, /*by message type*/ + VM_SMS_SORT_STORAGE_TYPE, /*by storage type*/ + VM_SMS_SORT_NUMBER, /*by number*/ + VM_SMS_SORT_CONTENT, /*by content*/ + VM_SMS_SORT_PID, /*by PID*/ + VM_SMS_SORT_SIM_ID /*by SIM*/ + +} vm_sms_sort_enum; + + +/* SMS Sorting Order */ +typedef enum +{ + VM_SMS_ORDER_DEFAULT, /*default order*/ + VM_SMS_ORDER_ASC, /*ascending*/ + VM_SMS_ORDER_DESC /*descending*/ +} vm_sms_order_enum; + + +/* SMS new message event type*/ +typedef enum +{ + + VM_EVT_ID_SMS_NEW_MSG, /* SMS event of new message */ + VM_EVT_ID_SMS_NEW_MSG_EX +} vm_sms_event_enum; + +typedef enum +{ + VM_SMS_ADDR_PHONE_NUM = 0, + VM_SMS_ADDR_EMAIL, + VM_SMS_ADDR_IP +}vm_sms_addr_type_enum; + +/* SMS Operation Callback Data Structure */ +typedef struct +{ + VMINT result; /* 1: operation succeed; 0: operation failure */ + vm_sms_cause_enum cause; /* cause description, refer to vm_sms_cause_enum */ + vm_sms_action_enum action; /* action type, refer to vm_sms_action_enum */ + void *action_data; /* action data depending on action type */ + void *user_data; /* user data */ +} vm_sms_callback_t; + +/* SMS Event Structure */ +typedef struct +{ + VMINT event_id; /* event ID registered */ + VMINT size; /* event information size */ + void * user_data; /* user data */ + void *event_info; /* event information pointer */ +} vm_sms_event_t; + + +/* Message Data Struture */ +typedef struct +{ + VMINT8 number[(VM_SMS_MAX_ADDR_LEN + 1)*2 ]; /* SMS number */ + vm_sms_status_enum status; /* SMS status */ + vm_sms_mti_enum mti; /* mti */ + + VMUINT8 tp_st; /* TP-Status, for Status Report */ + vm_sms_folder_enum folder_id; /* folder */ + + vm_sms_para_enum para_flag; /* parameter flag */ + + vm_sms_storage_enum storage_type; /* storage type */ + vm_sms_sim_enum sim_id; /* SIM ID */ + vm_time_t timestamp; /* time stamp */ + + VMINT8 sc_address[(VM_SMS_MAX_ADDR_LEN + 1)*2]; /* SMS center address */ + vm_sms_pid_enum pid; /* pid */ + vm_sms_vp_enum vp; /* vp */ + + VMINT status_report; /* status report */ + VMINT reply_path; /* reply path */ + + VMUINT16 src_port; /* source port */ + VMUINT16 dest_port; /* destination port */ + vm_sms_dcs_enum dcs; /* dcs */ + vm_sms_class_enum msg_class; /* message class */ + VMUINT16 content_buff_size; /* content buffer size */ + VMINT8 *content_buff; /* content buffer */ + VMINT8 *content_file_path; /* content file path */ + + void *content_ems; /* content ems */ +} vm_sms_msg_data_t; + +/* Add Message Callback Data Structure */ +typedef struct +{ + vm_sms_status_enum status; /* status */ + vm_sms_sim_enum sim_id; /* SIM ID */ + vm_sms_storage_enum storage_type; /* storage type */ + vm_time_t timestamp; /* time stamp */ + VMUINT16 content_size; /* content buffer size */ + VMINT8 *content; /* content buffer */ + VMINT8 number[(VM_SMS_MAX_ADDR_LEN + 1)*2 ]; /* destination number */ +} vm_sms_add_msg_data_t; + + +/* Query Data Structure */ +typedef struct +{ + vm_sms_sort_enum sort_flag; /* sort flag */ + vm_sms_order_enum order_flag; /* order flag */ + vm_sms_status_enum status; /* status */ + +} vm_sms_query_t; + + +/* new Message Data Structure */ +typedef struct +{ + VMUINT16 msg_id; + VMUINT16 dest_port; /* destination port */ + VMUINT16 src_port; /* source port */ + VMUINT16 message_len; /* message length */ + VMUINT16 ref; /* concat. message reference */ + VMUINT8 number[VM_SMS_MAX_ADDR_LEN + 1]; /* source number */ + VMUINT8 sc_number[VM_SMS_MAX_ADDR_LEN + 1]; + vm_time_t timestamp; /* timestamp of service center*/ + VMUINT8 total_seg; /* total segment */ + VMUINT8 seg; /* segment number */ + VMUINT8 dcs; /* encoding format */ + VMUINT8 mti; /* message type identication */ + VMUINT8 pid; /* protocol ID */ + VMUINT8 fo; + VMUINT8 data[1]; /* data */ + vm_sms_sim_enum sim_id; /* SIM ID */ + vm_sms_storage_enum storage_type; /* storage */ +} vm_sms_new_msg_t; + + +/* Read Message Callback Data Structure */ +typedef struct +{ + vm_sms_msg_data_t *msg_data; /* message data */ +} vm_sms_read_msg_cb_t; + + +/* Add Message Callback Data Structure */ +typedef struct +{ + VMUINT16 msg_id; /* message ID */ +} vm_sms_save_msg_cb_t; + + +/* Delete Message Callback Data Structure */ +typedef struct +{ + void *dummy; /* dummy */ +} vm_sms_delete_msg_cb_t; + + +/* Delete Message List Callback Data Structure */ +typedef struct +{ + VMUINT16 deleted_msg_num; /* number of deleted message */ +} vm_sms_delete_msg_list_cb_t; + + + +/* Query Message Callback Data Structure */ +typedef struct +{ + VMUINT16 msg_num; /* message number */ + VMUINT16 *msg_id_list; /* message ID list */ +} vm_sms_query_msg_cb_t; + + +/* Message New SMS Interrupt Event Callback Data Structure */ +typedef struct +{ + VMUINT16 msg_id; /* message ID */ + VMUINT8 *content; + void *msg_data; /* new msg structure (vm_sms_new_msg_t ) */ +} vm_sms_event_new_sms_t; + +/* get SMS center number Callback Data Structure */ +typedef struct +{ + VMINT8 sc_addr[VM_SMS_MAX_ADDR_LEN + 1]; +}vm_sms_get_sc_addr_cb_t; + +typedef struct +{ + VMINT sim; // sim card :1,2,3,4 + vm_sms_addr_type_enum addr_type; + VMWCHAR* addr; // address UCS2 + VMWCHAR* subject; //subject UCS2 + VMWCHAR* content; //content UCS2 +}vm_sms_launch_data; + + +/***************************************************************************** + * + * FUNCTION + * VmSmsCallbackFunc + * DESCRIPTION + * SMS operation callback function + * PARAMETERS + * callback_data : [IN] refer to vm_sms_callback_t + * +*****************************************************************************/ +typedef void(*VmSmsCallbackFunc)(vm_sms_callback_t* callback_data); + + +/***************************************************************************** + * + * FUNCTION + * VmSmsEventFunc + * DESCRIPTION + * SMS event callback function + * PARAMETERS + * event_data : [IN] refer to vm_sms_event_t + * RETURNS + * +*****************************************************************************/ +typedef VMINT(*VmSmsEventFunc)(vm_sms_event_t* event_data); + + +/***************************************************************************** + * FUNCTION + * vm_sms_read_msg + * DESCRIPTION + * 1. Read Message's Data, included message status, number, content and other attributes + * (Storage Type, SIM Card, Profile element, etc.) indicated by the flag; + * 2. The buffer to save the content should be provided by caller. + * 3. The Callback Action Data Structure is srv_sms_read_msg_cb_struct; + * PARAMETERS + * msg_id : [IN] Message ID + * change_status : [IN] Whether change the UNREAD Msg to READ + * msg_data : [IN/OUT] Message Data For Filling back read data + * callback_func : [IN] Callback Function + * user_data : [IN] User Data + * RETURNS + * refer to vm_sms_error_enum + *****************************************************************************/ +VMINT vm_sms_read_msg(VMUINT16 msg_id, VMINT change_status, vm_sms_msg_data_t* msg_data, + VmSmsCallbackFunc callback_func, void* user_data); + + +/***************************************************************************** + * FUNCTION + * vm_sms_add_msg + * DESCRIPTION + * 1. Save a new message to SMS Storage. + * 2. If Caller specify those parameters (Status, Address, Content, SIM Card, Storage Type, + * Profile element, we will use them, otherwise, it will user the defaut value (If the + * parameters is in the SMS setting, it will use the setting's value as defaut). + * 3. The Callback Action Data Struct is vm_sms_save_msg_cb_t. + * PARAMETERS + * msg_data : [IN] message data to be added + * callback_func : [IN] Callback Function + * user_data : [IN] User Data + * RETURNS + * refer to vm_sms_error_enum + *****************************************************************************/ +VMINT vm_sms_add_msg(vm_sms_add_msg_data_t * msg_data, VmSmsCallbackFunc callback_func, void* user_data); + + +/***************************************************************************** + * FUNCTION + * vm_sms_delete_msg + * DESCRIPTION + * 1. Delete an existed message; + * 2. If the message is not existed, the result is FALSE; + * 3. The Callback Action Data Structure is vm_sms_delete_msg_cb_t; + * PARAMETERS + * msg_id : [IN] Message ID + * callback_func : [IN] Callback Function + * user_data : [IN] User Data + * RETURNS + * refer to vm_sms_error_enum + *****************************************************************************/ +VMINT vm_sms_delete_msg(VMUINT16 msg_id, VmSmsCallbackFunc callback_func, void* user_data); + + +/***************************************************************************** + * FUNCTION + * vm_sms_delete_msg_list + * DESCRIPTION + * 1. Delete all the existed message of specified list + * 2. If the message is not existed, the result is FALSE; + * 3. The Callback Action Data Structure is vm_sms_delete_msg_list_cb_t; + * PARAMETERS + * box_type : [IN] refer to vm_sms_box_enum, can be combination of multiple boxes. + * sim_id : [IN] refer to vm_sms_sim_enum + * callback_func : [IN] Callback Function + * user_data : [IN] User Data + * RETURNS + * refer to vm_sms_error_enum + *****************************************************************************/ +VMINT vm_sms_delete_msg_list(vm_sms_box_enum box_type, vm_sms_sim_enum sim_id, VmSmsCallbackFunc callback_func, void* user_data); + + +/***************************************************************************** + * FUNCTION + * vm_sms_get_msg_id_list + * DESCRIPTION + * 1. Query the messages with some properties. + * 2. The caller can set the query_flag, and the corresponding paramenters of + * the propertied they wanted. The folder ID is mandatory in the current version; + * 3. The caller also can specify the sort flag, in the current version, we only + * support sorting by timestamp. + * 4. The Callback Action Data Structure is srv_sms_query_msg_cb_struct; + * PARAMETERS + * query_data : [IN] Query Data + * callback_func : [IN] Callback Function + * user_data : [IN] User Data + * RETURNS + * refer to vm_sms_error_enum + *****************************************************************************/ +VMINT vm_sms_get_msg_id_list(vm_sms_query_t* query_data, VmSmsCallbackFunc callback_func, void* user_data); + + +/***************************************************************************** + * FUNCTION + * vm_sms_get_msg_id + * DESCRIPTION + * Get message ID of the message in the box list + * PARAMETERS + * box_type : [IN] Message Box List Type + * msg_index : [IN] The position of message in the Box List + * for example: msg_id_list[msg_index] = msg_id; + * msg_id_list[0]=0 msg_id_list[0]=0 msg_id_list[0]=0 + * msg_id_list[1]=1 delete msg_id=2 msg_id_list[1]= 1 add a message msg_id_list[1]=1 + * msg_id_list[2]=2 -------------->msg_id_list[2]= 3 ------------>msg_id_list[2]=2 + * msg_id_list[3]=3 msg_id_list[3]=3 + * RETURNS + * msg_id if non-negative number, -1 means the msg-index does not exist. + *****************************************************************************/ +VMINT16 vm_sms_get_msg_id(vm_sms_box_enum box_type, VMUINT16 msg_index); + + +/***************************************************************************** + * FUNCTION + * vm_sms_get_box_size + * DESCRIPTION + * Get number of the messages in a box list + * PARAMETERS + * box_type : [IN] Message Box List Type, refer to vm_sms_box_enum + * RETURNS + * number of message + *****************************************************************************/ +VMINT16 vm_sms_get_box_size(vm_sms_box_enum box_type); + +/***************************************************************************** + * FUNCTION + * vm_sms_get_sc_address + * DESCRIPTION + * Get SC number (asyn) + * PARAMETERS + * sim_id : [IN] SIM card, refer to vm_sms_sim_enum. + * callback_func : [IN] Callback Function. + * user_data : [IN] user data + * RETURNS + * refer to vm_sms_error_enum + *****************************************************************************/ +VMINT vm_sms_get_sc_address( vm_sms_sim_enum sim_id, VmSmsCallbackFunc callback_func, void* user_data); + +/***************************************************************************** + * FUNCTION + * vm_sms_set_interrupt_event_handler + * DESCRIPTION + * Set Interrupt Event Handler of the Event + * PARAMETERS + * event_id : [IN] Event ID + * event_func : [IN] Event Handler Function + * user_data : [IN] User Data + * RETURNS + * refer to vm_sms_error_enum + *****************************************************************************/ +VMINT vm_sms_set_interrupt_event_handler(vm_sms_event_enum event_id, VmSmsEventFunc event_func, void* user_data); + + +/***************************************************************************** + * FUNCTION + * vm_sms_clear_interrupt_event_handler + * DESCRIPTION + * Clear Interrupt Event Handler of the Event + * PARAMETERS + * event_id : [IN] Event ID + * event_func : [IN] Event Handler Function + * user_data : [IN] User Data + * RETURNS + * refer to vm_sms_error_enum + *****************************************************************************/ +VMINT vm_sms_clear_interrupt_event_handler(vm_sms_event_enum event_id, VmSmsEventFunc event_func, void* user_data); + +/***************************************************************************** + * FUNCTION + * vm_sms_get_sc_address_syn + * DESCRIPTION + * Get SC number (sync) + * PARAMETERS + * vm_sc_addr : [OUT] output SC number + * sim_id : [IN] SIM card + * RETURNS + * result of get sc address. +* RETURN VALUES + * VM_SMS_REQ_ERROR : support sync mode, request failed. + * VM_SMS_SUPPORT_SYN_SCA : support sync mode, request succeed. + * VM_SMS_NOT_SUPPORT_SYN_SCA : not support sync mode, request failed. + *****************************************************************************/ +VMINT vm_sms_get_sc_address_syn(vm_sms_get_sc_addr_cb_t * vm_sc_addr, vm_sms_sim_enum sim_id); +/***************************************************************************** + * FUNCTION + * vm_sms_set_interrupt_event_handler_forpay + * DESCRIPTION + * Set Interrupt Event Handler of the Event + * PARAMETERS + * event_id : [IN] Event ID + * event_func : [IN] Event Handler Function + * user_data : [IN] User Data + * RETURNS + * refer to vm_sms_error_enum + *****************************************************************************/ +VMINT vm_sms_set_interrupt_event_handler_forpay(vm_sms_event_enum event_id, VmSmsEventFunc event_func, void* user_data); + +/***************************************************************************** + * FUNCTION + * vm_sms_clear_interrupt_event_handler_forpay + * DESCRIPTION + * Clear Interrupt Event Handler of the Event + * PARAMETERS + * event_id : [IN] Event ID + * event_func : [IN] Event Handler Function + * user_data : [IN] User Data + * RETURNS + * refer to vm_sms_error_enum + *****************************************************************************/ +VMINT vm_sms_clear_interrupt_event_handler_forpay(vm_sms_event_enum event_id, VmSmsEventFunc event_func, void* user_data); +/***************************************************************************** + * FUNCTION + * vm_sms_delete_msg_forpay + * DESCRIPTION + * 1. Delete an existed message; + * 2. If the message is not existed, the result is FALSE; + * 3. The Callback Action Data Structure is vm_sms_delete_msg_cb_t; + * PARAMETERS + * event_id : [IN] Event ID + * callback_func : [IN] Event Handler Function + * user_data : [IN] User Data + * RETURNS + * refer to vm_sms_error_enum + *****************************************************************************/ +VMINT vm_sms_delete_msg_forpay(VMUINT16 msg_id, VmSmsCallbackFunc callback_func, void* user_data); + +/***************************************************************************** + * FUNCTION + * vm_sms_launch + * DESCRIPTION + * 1. Launch a sms editor to edit sms + * PARAMETERS + * vm_sms_launch_data : [IN] launch data + * data_size : [IN] size of launch data + * RETURNS + * 0:success + *****************************************************************************/ +VMINT vm_sms_launch(vm_sms_launch_data* data, VMINT data_size); + +/** + * send SMS successfully + */ +#define VM_SMS_RESULT_OK 1 + +/** + * failed to send SMS + */ +#define VM_SMS_RESULT_ERROR 2 + +/** + * Cancel sending SMS + */ +#define VM_SMS_RESULT_ABORT 3 + +/***************************************************************************** +* FUNCTION + * vm_send_sms + * DESCRIPTION + * send SMS + * PARAMETERS + * phone_number : [IN] destination phone number. + * content : [IN] SMS content. + * callback : [IN] callback function for sending SMS + * RETURNS + * result of sending SMS request + * RETURN VALUES + * TRUE : request succeed. + * FALSE : request failure + * +*****************************************************************************/ +VMINT vm_send_sms(VMWSTR phone_number, VMWSTR content, void (*callback)(VMINT result)); + +/***************************************************************************** +* FUNCTION + * vm_cancel_send_sms + * DESCRIPTION + * cancel sending SMS. + * The function can be used only when: 1) after call the function vm_send_sms() and return TRUE + * 2) before callback is invoked + * Or the function will be invalid. + * +*****************************************************************************/ +void vm_cancel_send_sms(void); + +/***************************************************************************** + * FUNCTION + * vm_sms_is_sms_ready + * DESCRIPTION + * check whether sms is ready + * PARAMETERS + * void + * RETURNS + * result of whether sms is ready + * RETURN VALUES + * VM_TRUE : sms is ready + * VM_FALSE : sms is not ready + *****************************************************************************/ +VMBOOL vm_sms_is_sms_ready(void); + +#ifdef __cplusplus +} +#endif + +#endif /* VMSMS_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmso.h b/hardware/arduino/mtk/system/libmtk/include/vmso.h new file mode 100644 index 00000000..4681cb6e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmso.h @@ -0,0 +1,150 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMSO_SDK_H_ +#define VMSO_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/* SO is being loaded. */ +#define VM_SO_MSG_LOAD (1) + +/* SO is being unloaded. */ +#define VM_SO_MSG_UNLOAD (9) + +/************************************************************************/ + +#define VM_SO_SUCCESS (0) /* SO operation success */ +#define VM_SO_FAILED (-1) /* SO operation failed */ +#define VM_SO_PARAM_ERROR (-2) /* SO parameter error */ +#define VM_SO_FILE_NOT_FOUND (-3) /* SO file not found */ +#define VM_SO_CREATE_FAILED (-5) /* SO failed to create pcb */ + +/***************************************************************************** + * FUNCTION + * vm_load_library + * DESCRIPTION + * load so file. + * PARAMETERS + * sm_name : [IN] so file name without suffix. + * RETURN VALUES + * >0 : so handle. + * <=0 : If unsuccessful. + * EXAMPLE + * + * VMINT so_hdl = vm_load_library("test"); + * if (so_hdl > 0) + * { + * ... + * } + * + *****************************************************************************/ +VMINT vm_load_library(VMSTR so_name); + + +/***************************************************************************** + * FUNCTION + * vm_load_ibraryw + * DESCRIPTION + * load so file. + * PARAMETERS + * name : [IN] so file name without suffix. + * RETURN VALUES + * >0 : so handle. + * <=0 : If unsuccessful. + *****************************************************************************/ +VMINT vm_load_libraryw(VMWSTR name); + + +/***************************************************************************** + * FUNCTION + * vm_get_symbol + * DESCRIPTION + * get function pointer form so file. + * PARAMETERS + * so_hdl : [IN] so file handler. + * func_name : [IN] function name string. + * RETURN VALUES + * >0 : If successful. + * <=0 : If unsuccessful. + * EXAMPLE + * + * VMINT so_hdl = vm_load_library("test"); + * func_t func_ptr = NULL; + * if (so_hdl > 0) + * { + * func_ptr = vm_get_symbol(so_hdl, "func_name"); + * if (func_ptr) + * { + * func_ptr(x, y, z); + * } + * } + * vm_free_library(so_hdl); + * + *****************************************************************************/ +VMINT vm_get_symbol(VMINT so_hdl, VMSTR func_name); + +/***************************************************************************** + * FUNCTION + * vm_free_library + * DESCRIPTION + * unload so file. + * PARAMETERS + * sm_hdl : [IN] so file handler. + * RETURN VALUES + * >0 : If successful. + * <=0 : If unsuccessful. + * EXAMPLE + * + * VMINT so_hdl = vm_load_library("test"); + * if (so_hdl > 0) + * { + * ... + * } + * vm_free_library(so_hdl); + * + *****************************************************************************/ +VMINT vm_free_library(VMINT so_hdl); + +#ifdef __cplusplus +} +#endif + +#endif /* VMSO_SDK_H_ */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmsock.h b/hardware/arduino/mtk/system/libmtk/include/vmsock.h new file mode 100644 index 00000000..808d48de --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmsock.h @@ -0,0 +1,1545 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VM_SOCK_SDK_H +#define VM_SOCK_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +#include "vmconn.h" +#include "vmtcp.h" +#include "vmudp.h" + + + + +/* This enum is used to define bearer status */ +typedef enum +{ + VM_CBM_DEACTIVATED = 0x01, /* bearer deactivated */ + VM_CBM_ACTIVATING = 0x02, /* bearer activating */ + VM_CBM_ACTIVATED = 0x04, /* bearer activated */ + VM_CBM_DEACTIVATING = 0x08, /* bearer deactivating */ + VM_CBM_CSD_AUTO_DISC_TIMEOUT = 0x10, /* csd auto disconnection timeout */ + VM_CBM_GPRS_AUTO_DISC_TIMEOUT = 0x20, /* gprs auto disconnection timeout */ + VM_CBM_NWK_NEG_QOS_MODIFY = 0x040, /* negotiated network qos modify notification */ + VM_CBM_BEARER_STATE_TOTAL +} vm_cbm_bearer_state_enum; + + +/* error cause */ +typedef enum +{ + VM_CBM_OK = 0, /* success */ + VM_CBM_ERROR = -1, /* error */ + VM_CBM_WOULDBLOCK = -2, /* would block */ + VM_CBM_LIMIT_RESOURCE = -3, /* limited resource */ + VM_CBM_INVALID_ACCT_ID = -4, /* invalid account id*/ + VM_CBM_INVALID_AP_ID = -5, /* invalid application id*/ + VM_CBM_INVALID_SIM_ID = -6, /* invalid SIM id */ + VM_CBM_BEARER_FAIL = -7, /* bearer fail */ + VM_CBM_DHCP_ERROR = -8, /* DHCP get IP error */ + VM_CBM_CANCEL_ACT_BEARER = -9, /* cancel the account query screen, such as always ask or bearer fallback screen */ + VM_CBM_DISC_BY_CM = -10,/* bearer is deactivated by the connection management */ + VM_CBM_IPV6_ERROR = -11,/* IP get V6 address error */ +} vm_cbm_result_error_enum; + + + + +/* ip type */ +typedef enum +{ + VM_CBM_IP_NONE = 0, + VM_CBM_IPV4 = 0x01, /* IPv4 */ + VM_CBM_IPV6 = 0x02, /* IPv6 */ + VM_CBM_IPV4V6 = VM_CBM_IPV4 | VM_CBM_IPV6, /* IPv4v6 */ + VM_CBM_IP_TYPE_TOTAL, +} vm_cbm_ip_type_enum; + + + +typedef struct +{ + VMUINT account_id; /* network account id */ + vm_cbm_bearer_state_enum state; /* bearer state */ + vm_cbm_result_error_enum error; /* error */ + VMINT error_cause; /* network error cause */ + vm_cbm_ip_type_enum ip_type; /* IP type */ +}vm_cbm_bearer_info_struct; + + +/***************************************************************************** + * FUNCTION + * vm_bearer_open_ex + * DESCRIPTION + * Open the bearer. + * + * P.S. We assume applications shall set its module id or register the application id + * before calling this API. + * + * Please remember to wrap API by __TCPIP__ if you may call this API when network is disable + * PARAMETERS + * apn : [IN] apn index + * user_data : [IN] user data + * callback_ex : [IN] callback function + * ip : [IN] ip type vm_cbm_ip_type_enum + * RETURN VALUES + * VM_CBM_OK : bearer is in activated state. + * VM_CBM_INVALID_AP_ID : invalid application id. + * VM_CBM_INVALID_ACCT_ID : invalid network account id. + * VM_CBM_WOULDBLOCK : the bearer is in deactivating state and the bearer info + * will be reported later. + *****************************************************************************/ +VMINT vm_bearer_open_ex(VMINT apn, void *user_data, void (*callback_ex)(VMINT handle, VMINT event, void *param, void *user_data), vm_cbm_ip_type_enum ip); + +/* The structure for DNS A RR entry */ +typedef struct +{ + VMUINT8 address[4]; /* resolved IP address for queried domain name */ +}vm_soc_dns_a_struct; + +typedef struct +{ + VMUINT8 addr[16]; /* resolved IP address for queried domain name of ipv6*/ +}vm_soc_dns_aaaa_struct; + +typedef struct +{ + vm_soc_dns_aaaa_struct address[VM_SOC_DNS_MAX_ADDR]; /* address set */ + VMINT num; /* the numbers of address */ + VMINT error_cause; /* vm_ps_cause_enum */ +}vm_soc_dns_v6_result; + + + +/***************************************************************************** + * FUNCTION + * vm_soc_gethostbynamev6 + * DESCRIPTION + * this function retrieves IPv6 addresses associated with the specified host name. + * PARAMETERS + * apn : [IN] + * host : [IN] domain to be resolved. + * result : [OUT] DNS parsed result. + * callback : [IN] point to the callback. + * user_data : [IN] user data. + * RETURNS + * success if 0, else failure. + * RETURN VALUES + * VM_E_SOC_SUCCESS : Get IP address successfully, result is filled. + * VM_E_SOC_WOULDBLOCK : wait response from network, result could be gotten from callback. + * VM_E_SOC_INVAL : invalid arguments: null domain_name, etc. + * VM_E_SOC_ERROR : unspecified error + * VM_E_SOC_LIMIT_RESOURCE : socket resources not available + * VM_E_SOC_INVALID_ACCOUNT : invalid data account id +*****************************************************************************/ +VMINT vm_soc_gethostbynamev6(VMINT apn, + const VMCHAR * host, + vm_soc_dns_v6_result * result, + VMINT (*callback)(VMINT, vm_soc_dns_v6_result *, void *), void *user_data); + + +/***************************************************************************** + * FUNCTION + * vm_bearer_open + * DESCRIPTION + * Open the bearer. + * + * P.S. We assume applications shall set its module id or register the application id + * before calling this API. + * + * Please remember to wrap API by __TCPIP__ if you may call this API when network is disable + * PARAMETERS + * account_id : [IN] account id which contains the application id. + * App id must to be encoded in the account id + * RETURN VALUES + * VM_CBM_OK : bearer is in activated state. + * VM_CBM_INVALID_AP_ID : invalid application id. + * VM_CBM_INVALID_ACCT_ID : invalid network account id. + * VM_CBM_WOULDBLOCK : the bearer is in deactivating state and the bearer info + * will be reported later. + *****************************************************************************/ +VMINT vm_bearer_open(VMINT apn, void *user_data, void (*callback)(VMINT handle, VMINT event, VMUINT param, void *user_data)); + +/***************************************************************************** + * FUNCTION + * cbm_release_bearer + * DESCRIPTION + * This API is used to release all bearers which are opened by this application. + * The bearer will be released only when all sockets are closed. + * If the sockets are all closed and this API is called, the bearer will be + * deactivated. Otherwise, the bearer will be deactivated only when + * all sockets which belong to this application are closed. + * If the bearer is opened by application directly through the API + * "cbm_open_bearer", the bearer can be directly deactivated when + * application calls the API cbm_release_bearer. + * + * P.S. We assume applications shall set its module id or register the application id + * before calling this API. + * + * Please remember to wrap API by __TCPIP__ if you may call this API when network is disable + * PARAMETERS + * app_id : [IN] application id + * RETURN VALUES + * CBM_OK : bearer is in deactivated state. + * CBM_INVALID_AP_ID : invalid application id. + * CBM_WOULDBLOCK : the bearer is in deactivating state and the bearer info + * will be reported later. + * SEE ALSO + * cbm_hold_bearer + * EXAMPLE + * + * kal_uint8 ap_id; + * kal_int8 ret; + * ap_id = cbm_get_app_id ((kal_uint32)account_id); + * ... + * if ((ret = cbm_release_bearer (ap_id)) == CBM_OK) + * { + * //bearer is deactivated + * } + * else + * { + * if (ret == CBM_WOULDBLOCK) + * { + * //bearer is not completely deactivated yet + * } + * } + * + * After the bearer is deactivated: + * + * app_cbm_bearer_info_ind_hdlr(local_para_struct *msg) + * { + * app_cbm_bearer_info_ind_struct *ind_ptr; + * ind_ptr = (app_cbm_bearer_info_ind_struct *)local_para_ptr; + * switch (ind_ptr->state) + * { + * case CBM_DEACTIVATED: + * app_bearer_deactivated_hdlr(); + * break; + * ... + * } + * } + * + *****************************************************************************/ +VMINT vm_bearer_close(VMINT hdl); + + + +#define PF_INET (0) /* ipv4 */ +#define PF_INET6 (1) /* ipv6 */ + + +#define SOCK_STREAM (0) /* stream socket, TCP */ +#define SOCK_DGRAM (1) /* datagram socket, UDP */ + + +/* + * + * + * Control message protocol. Currently, only allow applicaion to set this type when RAW_SOCKET is used + */ +#define IPPROTO_ICMP (1) + +/* for SOC/TCP/IP internal use, application shall NOT use */ + +/* + * + * + * dummy for IP + */ +#define IPPROTO_IP (0) + +/* + * + * + * IP6 hop-by-hop options + */ +#define IPPROTO_HOPOPTS (0) + +/* + * + * + * group mgmt protocol + */ +#define IPPROTO_IGMP (2) + +/* + * + * + * IPv4 encapsulation + */ +#define IPPROTO_IPV4 (4) + +/* + * + * + * for compatibility + */ +#define IPPROTO_IPIP IPPROTO_IPV4 + +/* + * + * + * tcp protocol + */ +#define IPPROTO_TCP (6) + +/* + * + * + * user datagram protocol + */ +#define IPPROTO_UDP (17) + +/* + * + * + * raw IP packet + */ +#define IPPROTO_RAW (255) + +/// Generic Socket Address structure +typedef struct sockaddr { + VMUINT16 sa_family; ///< Address family + VMINT8 sa_data[14]; ///< Direct address (up to 14 bytes) +} SOCKADDR; + +/// Generic IPv4 Address structure +typedef struct in_addr { + union { + struct { + VMUINT8 s_b1; + VMUINT8 s_b2; + VMUINT8 s_b3; + VMUINT8 s_b4; ///< IP address, byte access + }S_un_b; + struct { + VMUINT16 s_w1; + VMUINT16 s_w2; ///< IP address, short int access + }S_un_w; + VMUINT32 s_addr; ///< IP address in network byte order + }S_un; +} IN_ADDR; + + +/// IPv4 Socket Address structure +typedef struct sockaddr_in { + VMINT16 sin_family; ///< Socket domain + VMUINT16 sin_port; ///< Port + IN_ADDR sin_addr; ///< IP address + VMINT8 sin_zero[8]; ///< reserved +} SOCKADDR_IN; + +/// Generic IPv6 Address structure +typedef struct in6_addr { + union { + VMUINT8 s6_u8[16]; + VMUINT32 s6_u32[4]; + VMUINT64 s6_u64[2]; + }S_all; +} IN6_ADDR; + +/// IPv6 Socket Address structure +typedef struct sockaddr_in6 { + VMINT16 sin_family; ///< Socket domain + VMUINT16 sin_port; ///< Port + VMUINT32 sin6_flowinfo; /// IPv6 traffic class & flow info + IN6_ADDR sin6_addr; ///< IP address + VMUINT32 sin6_scop_id; /// set of interfaces for a scope +} SOCKADDR_IN6; + + +/*=================================================== + * + * Socket APIs prototypes + * + *===================================================*/ + +/***************************************************************************** +* FUNCTION +* socket +* DESCRIPTION +* This function creates a socket. +* note: here is an advice for API usage. please use BSD socket API all in one sub thread. +* PARAMETERS +* family : [IN] Address family specification. PF_INET / PF_INET6 +* type : [IN] Type specification for the new socket. +* SOCK_STREAM = connection based type, +* SOCK_DGRAM = datagram connectionless type. +* protocol : [IN] Particular protocol to be used with the socket that is specific to the indicated address family +* RETURN VALUES +* A descriptor referencing the new socket indicates that no error occurred. +* >=0 : socket id +* VM_SOC_INVAL : wrong parameters, domain, type, protocol +* VM_SOC_LIMIT_RESOURCE : no socket available +* VM_SOC_BEARER_FAIL : bearer broken +*****************************************************************************/ +int vm_socket(int family, int type, int protocol); + +/***************************************************************************** +* FUNCTION +* socket_ex +* DESCRIPTION +* This function creates a socket. +* note: here is an advice for API usage. please use BSD socket API all in one sub thread. +* PARAMETERS +* family : [IN] Address family specification. PF_INET / PF_INET6 +* type : [IN] Type specification for the new socket. +* SOCK_STREAM = connection based type, +* SOCK_DGRAM = datagram connectionless type. +* protocol : [IN] Particular protocol to be used with the socket that is specific to the indicated address family +* data_account : [IN] data account for network which get from the callback param of vm_open_bearer. +* RETURN VALUES +* A descriptor referencing the new socket indicates that no error occurred. +* >=0 : socket id +* VM_SOC_INVAL : wrong parameters, domain, type, protocol +* VM_SOC_LIMIT_RESOURCE : no socket available +* VM_SOC_BEARER_FAIL : bearer broken +*****************************************************************************/ +int vm_socket_ex(int family, int type, int protocol, VMUINT32 data_account); + +/***************************************************************************** +* FUNCTION +* closesocket +* DESCRIPTION +* Receive data from endpoint node. +* PARAMETERS +* sock : [IN] Descriptor that identifies an unbound socket. +* RETURN VALUES +* VM_E_SOC_SUCCESS : success +* VM_E_SOC_INVALID_SOCKET : invalid socket id +*****************************************************************************/ +int vm_closesocket(int sock); + +/***************************************************************************** +* FUNCTION +* bind +* DESCRIPTION +* This function associates a local address with a socket. +* PARAMETERS +* sock : [IN] Descriptor that identifies an unbound socket. +* addr : [IN] Address to assign to the socket from the SOCKADDR structure. +* addrlen : [IN] Length of the name. +* type : [IN] Type specification for the new socket. +* SOCK_STREAM = connection based type, +* SOCK_DGRAM = datagram connectionless type. +* RETURN VALUES +* A descriptor referencing the new socket indicates that no error occurred. +* VM_E_SOC_SUCCESS : success +* VM_E_SOC_INVALID_SOCKET : invalid socket id +* VM_E_SOC_BEARER_FAIL : bearer broken +* VM_E_SOC_ERROR : unspecified error +* VM_E_SOC_ADDRINUSE : the local port has been bound by other socket +*****************************************************************************/ +int vm_bind(int sock, const SOCKADDR *addr, int addrlen, int type); + +/***************************************************************************** +* FUNCTION +* listen +* DESCRIPTION +* This function prepares a socket to listen for incoming connections. +* PARAMETERS +* sock : [IN] Descriptor that identifies an unbound socket. +* backlog : [IN] number of connection requests that can be queued +* RETURN VALUES +* A descriptor referencing the new socket indicates that no error occurred. +* VM_E_SOC_SUCCESS : success +* VM_E_SOC_INVALID_SOCKET : invalid socket id +* VM_E_SOC_BEARER_FAIL : bearer broken +* VM_E_SOC_OPNOTSUPP : only TCP can be listened +* VM_E_SOC_ALREADY : already listened +* VM_E_SOC_ERROR : unspecified error +* VM_E_SOC_BEARER_FAIL : bearer broken +*****************************************************************************/ +int vm_listen(int sock, int backlog); + +/***************************************************************************** +* FUNCTION +* accept +* DESCRIPTION +* This function accepts a connection on a socket. +* PARAMETERS +* sock : [IN] Descriptor that identifies an unbound socket. +* addr : [IN] Address to assign to the socket from the SOCKADDR structure. +* addrlen : [IN] Length of the name. +* RETURN VALUES +* A descriptor referencing the new socket indicates that no error occurred. +* >=0 : socket id of new connection +* VM_E_SOC_INVALID_SOCKET : invalid socket id +* VM_E_SOC_INVAL : socket is not calling soc_listen +* VM_E_SOC_WOULDBLOCK : non-blocking +* VM_E_SOC_CONNABORTED : server socket cannot receive anymore +* VM_E_SOC_BEARER_FAIL : bearer broken +* VM_E_SOC_ERROR : unspecified error +*****************************************************************************/ +int vm_accept(int sock, SOCKADDR *addr, int *addrlen); + +/***************************************************************************** +* FUNCTION +* connect +* DESCRIPTION +* Connect a socket to a remote host. +* PARAMETERS +* sock : [IN] Descriptor that identifies an unbound socket. +* addr : [IN] Address to assign to the socket from the SOCKADDR structure. +* addrlen : [IN] Length of the name. +* RETURN VALUES +* A descriptor referencing the new socket indicates that no error occurred. +* >=0 : socket id of new connection +* VM_E_SOC_INVALID_SOCKET : invalid socket id +* VM_E_SOC_INVAL : socket is not calling soc_listen +* VM_E_SOC_WOULDBLOCK : non-blocking +* VM_E_SOC_CONNABORTED : server socket cannot receive anymore +* VM_E_SOC_BEARER_FAIL : bearer broken +* VM_E_SOC_ERROR : unspecified error +*****************************************************************************/ + +int vm_connect(int sock, SOCKADDR *addr, int addrlen); +/***************************************************************************** +* FUNCTION +* send +* DESCRIPTION +* Send data on already connected socket. +* PARAMETERS +* sock : [IN] Descriptor that identifies an unbound socket. +* buf : [IN] pointer to application data buffer to transmit. +* len : [IN]length of data (in bytes). +* flags : [IN]message flags: +* RETURN VALUES +* A descriptor referencing the new socket indicates that no error occurred. +* >=0 : socket id of new connection +* VM_E_SOC_INVALID_SOCKET : invalid socket id +* VM_E_SOC_INVAL : socket is not calling soc_listen +* VM_E_SOC_WOULDBLOCK : non-blocking +* VM_E_SOC_CONNABORTED : server socket cannot receive anymore +* VM_E_SOC_BEARER_FAIL : bearer broken +* VM_E_SOC_ERROR : unspecified error +*****************************************************************************/ + +int vm_send(int sock, const char *buf, int len, int flags); +/***************************************************************************** +* FUNCTION +* sendto +* DESCRIPTION +* Send data to endpoint node. +* PARAMETERS +* sock : [IN] Descriptor that identifies an unbound socket. +* buf : [IN] pointer to application data buffer to transmit. +* len : [IN]length of data (in bytes). +* flags : [IN]message flags: +* to : [IN] structure containing remote IP address and port. +* tolen : [IN] length of \ref SOCKADDR structure. +* RETURN VALUES +* >=0 : SUCCESS +* VM_E_SOC_INVALID_SOCKET : invalid socket id +* VM_E_SOC_INVAL : buf is NULL or len equals to zero +* VM_E_SOC_WOULDBLOCK : buffer not available or bearer is establishing +* VM_E_SOC_BEARER_FAIL : bearer broken +* VM_E_SOC_NOTCONN : socket is not connected in case of TCP +* VM_E_SOC_PIPE : socket is already been shutdown +* VM_E_SOC_MSGSIZE : message is too long +* VM_E_SOC_ERROR : unspecified error +* VM_E_SOC_NOTBIND : in case of sending ICMP Echo Request, shall bind before +*****************************************************************************/ +int vm_sendto(int sock, const char *buf, int len, int flags, const SOCKADDR *to, int tolen); +/***************************************************************************** +* FUNCTION +* recv +* DESCRIPTION +* Receive data on already connected socket. +* PARAMETERS +* sock : [IN] Descriptor that identifies an unbound socket. +* buf : [OUT] pointer to application data buffer to transmit. +* len : [IN]length of data (in bytes). +* flags : [IN]message flags: +* RETURN VALUES +* >0 : number of bytes received +* 0 : receive the FIN from the server +* VM_E_SOC_INVALID_SOCKET : invalid socket id +* VM_E_SOC_INVAL : buf is NULL or len equals to zero +* VM_E_SOC_WOULDBLOCK : no data available +* VM_E_SOC_BEARER_FAIL : bearer broken +* VM_E_SOC_NOTCONN : socket is not connected in case of TCP +* VM_E_SOC_PIPE : socket is already been shutdown +* VM_E_SOC_ERROR : unspecified error +*****************************************************************************/ +int vm_recv(int sock, char *buf, int len, int flags); + +/***************************************************************************** +* FUNCTION +* recvfrom +* DESCRIPTION +* Receive data from endpoint node. +* PARAMETERS +* sock : [IN] Descriptor that identifies an unbound socket. +* buf : [OUT] pointer to application data buffer to transmit. +* len : [IN]length of data (in bytes). +* flags : [IN]message flags: +* from : [OUT]structure containing remote IP address and port +* fromlen : [IN/OUT]length of \ref SOCKADDR structure: +* RETURN VALUES +* 0 : receive the FIN from the server +* VM_E_SOC_INVALID_SOCKET : invalid socket id +* VM_E_SOC_INVAL : buf is NULL or len equals to zero +* VM_E_SOC_WOULDBLOCK : no data available +* VM_E_SOC_BEARER_FAIL : bearer broken +* VM_E_SOC_NOTCONN : socket is not connected in case of TCP +* VM_E_SOC_PIPE : socket is already been shutdown +* VM_E_SOC_ERROR : unspecified error +*****************************************************************************/ +int vm_recvfrom(int sock, char *buf, int len, int flags, SOCKADDR *from, int *fromlen); + +#define VM_FD_SETSIZE 25 + +/* Macros for SOC_SELECT */ +typedef struct +{ + VMUINT8 fds_bits[VM_FD_SETSIZE]; /* select set based on socket id */ +} vm_fd_set; + +#ifdef fd_set +#undef fd_set +#define fd_set vm_fd_set +#else +#define fd_set vm_fd_set +#endif + +/* + * + * + * set the socket id which you want to select + */ + +#ifdef FD_SET +#undef FD_SET +#define FD_SET(s, p) ((p)->fds_bits[s] |= 0x01) +#else +#define FD_SET(s, p) ((p)->fds_bits[s] |= 0x01) +#endif + +/* + * + * + * clear the socket id which you don't want to select + */ + +#ifdef FD_CLR +#undef FD_CLR +#define FD_CLR(s, p) ((p)->fds_bits[s] &= ~(0x01)) +#else +#define FD_CLR(s, p) ((p)->fds_bits[s] &= ~(0x01)) +#endif + +/* + * + * + * check if the socket id is selected + */ +#ifdef FD_ISSET +#undef FD_ISSET +#define FD_ISSET(s, p) ((p)->fds_bits[s] & 0x02) +#else +#define FD_ISSET(s, p) ((p)->fds_bits[s] & 0x02) +#endif + +/* + * + * + * clear the select set + */ +#ifdef FD_ZERO +#undef FD_ZERO +#define FD_ZERO(p) memset(p, 0x00, sizeof(*(p))) +#else +#define FD_ZERO(p) memset(p, 0x00, sizeof(*(p))) +#endif + + + +/* select timeout structure */ +typedef struct +{ + VMUINT32 tv_sec; /* select timeout: no. of second */ + VMUINT32 tv_usec; /* select timeout: no. of microsecond */ +} timeval; + + +/***************************************************************************** + * + * + * FUNCTION + * select + * DESCRIPTION + * Allow the application to query the status of multiple sockets. + * If tv is null, soc_select will wait indefinitely until the first socket is ready. + * If both tv_sec and tv_msec are zero, soc_select will timeout immediately for + * polling the sockets in the set. + * in: + * 1. If listen has been called and a connection is pending, accept will succeed. + * 2. Data is available for reading (includes OOB data if VM_SOC_OOBINLINE is enabled). + * 3. Connection has been closed/reset/terminated + * out: + * 1. If processing a connect request (non-blocking mode), connection has succeeded. + * 2. Data can be sent. + * ex: + * If processing a connect request (non-blocking mode), connection attempt failed. + * OOB data is available for reading (only if VM_SOC_OOBINLINE is disabled). + * Useful Macros: + * FD_ZERO(fd_set) reset fd_set + * FD_SET(s, fd_set) add a particular socket with id of s to fd_set + * FD_CLR(s, fd_set) remove a particular socket with id of s from fd_set + * FD_ISSET(s, fd_set) Nonzero if s is a member of the fd_set (s is ready). + * Otherwise, zero + * PARAMETERS + * nfds : [IN] max selected socket id plus 1 + * readfds : [IN] input fd_set (readfds) + * writefds : [IN] output fd_set (writefds) + * exceptfds : [IN] exception fd_set (exceptfds) + * timeout : [IN] specify the timeout value, + * timeout == NULL: block until ready + * timeout != NULL && value == 0: return immediately + * timeout != NULL && value != 0: return after timeout + * RETURN VALUES + * >0 : number of ready sockets + * 0 : timeout expires before anything interesting happens + * VM_E_SOC_INVALID_SOCKET : selected sockets are not belong to this module + * VM_E_SOC_INVAL : invalid arguments: ndesc, in, out, ex + * VM_E_SOC_WOULDBLOCK : non-blocking + * VM_E_SOC_BEARER_FAIL : bearer broken + * VM_E_SOC_ERROR : unspecified error + * EXAMPLE + * + * timeval timeout; + * fd_set writefds; + * timeout.tv_sec = 0; + * timeout.tv_usec = 2000; + * FD_ZERO(&writefds); + * FD_SET((bf_u32)sockIds[sock].id, &writefds); + * if (select(sockIds[sock].id+1, 0, &writefds, 0, &timeout) >= 0) + * { + * if (FD_ISSET(sockIds[sock].id, &writefds)) + * { + * //socket is ready for writting data + * } + * } + * + *****************************************************************************/ +int vm_select(int nfds, + fd_set *readfds, + fd_set *writefds, + fd_set *exceptfds, + const timeval *timeout); + + +/* howto arguments for shutdown(2), specified by Posix.1g. */ +typedef enum +{ + VM_SHUT_RD = 0x01, /* shut down the reading side */ + VM_SHUT_WR = 0x02, /* shut down the writing side */ + VM_SHUT_RDWR = VM_SHUT_RD | VM_SHUT_WR /* shut down both sides */ +} vm_shutdown_enum; + +/***************************************************************************** + * FUNCTION + * shutdown + * DESCRIPTION + * This function shutdowns the connection in aspects of reading, writing + * or both. + * For the read-half, soc_shutdown discards the received data that applications haven't yet + * and any incoming data. For the write-half of TCP, the remaining data will be sent first, + * then FIN will be sent to close the connection. + * PARAMETERS + * sock : [IN] socket id + * how : [IN] specify shutdown read/write/both + * RETURN VALUES + * VM_E_SOC_SUCCESS : success + * VM_E_SOC_INVALID_SOCKET : invalid socket id + * VM_E_SOC_INVAL : invalid how + * VM_E_SOC_ERROR : unspecified error + * EXAMPLE + * + * INT handle; + * shutdown((kal_int8) handle, SHUT_WR); + * + *****************************************************************************/ +int vm_shutdown(int sock, int how); + + +/* Socket Options */ +typedef enum +{ + VM_SOC_OOBINLINE = 0x01 << 0, /* not support yet */ + VM_SOC_LINGER = 0x01 << 1, /* linger on close */ + VM_SOC_NBIO = 0x01 << 2, /* Nonblocking */ + VM_SOC_ASYNC = 0x01 << 3, /* Asynchronous notification */ + + VM_SOC_NODELAY = 0x01 << 4, /* disable Nagle algorithm or not */ + VM_SOC_KEEPALIVE = 0x01 << 5, /* enable/disable the keepalive */ + VM_SOC_RCVBUF = 0x01 << 6, /* set the socket receive buffer size */ + VM_SOC_SENDBUF = 0x01 << 7, /* set the socket send buffer size */ + + VM_SOC_NREAD = 0x01 << 8, /* no. of bytes for read, only for soc_getsockopt */ + VM_SOC_PKT_SIZE = 0x01 << 9, /* datagram max packet size */ + VM_SOC_SILENT_LISTEN = 0x01 << 10, /* SOC_SOCK_SMS property */ + VM_SOC_QOS = 0x01 << 11, /* set the socket qos */ + + VM_SOC_TCP_MAXSEG = 0x01 << 12, /* set the max segmemnt size */ + VM_SOC_IP_TTL = 0x01 << 13, /* set the IP TTL value */ + VM_SOC_LISTEN_BEARER = 0x01 << 14, /* enable listen bearer */ + VM_SOC_UDP_ANY_FPORT = 0x01 << 15, /* enable UDP any foreign port */ + + VM_SOC_WIFI_NOWAKEUP = 0x01 << 16, /* send packet in power saving mode */ + VM_SOC_UDP_NEED_ICMP = 0x01 << 17, /* deliver NOTIFY(close) for ICMP error */ + VM_SOC_IP_HDRINCL = 0x01 << 18, /* IP header included for raw sockets */ + VM_SOC_IPSEC_POLICY = 0x01 << 19, /* ip security policy */ + VM_SOC_TCP_ACKED_DATA = 0x01 << 20, /* TCPIP acked data */ + VM_SOC_TCP_DELAYED_ACK = 0x01 << 21, /* TCP delayed ack */ + VM_SOC_TCP_SACK = 0x01 << 22, /* TCP selective ack */ + VM_SOC_TCP_TIME_STAMP = 0x01 << 23, /* TCP time stamp */ + VM_SOC_TCP_ACK_MSEG = 0x01 << 24 /* TCP ACK multiple segment */ +} option_enum; + + +/***************************************************************************** + * FUNCTION + * setsockopt + * DESCRIPTION + * This function sets the socket options. + * PARAMETERS + * sock : [IN] socket id + * option : [IN] option type (soc_option_enum) + * val : [IN] option value (soc_event_enum for SOC_ASYNC) + * val_size : [IN] option value size + * RETURN VALUES + * VM_E_SOC_SUCCESS : success + * VM_E_SOC_INVALID_SOCKET : invalid socket id + * VM_E_SOC_INVAL : invalid arguments: option, val and val_size + * VM_E_SOC_ERROR : unspecified error + * SEE ALSO + * getsockopt + * EXAMPLE + * VM_SOC_NBIO: + * this option must to be set if you want to use the non-blocking mode or + * non-blocking plus asyn mode. + * val contains KAL_TRUE indicates non-blocking shall be adopted, + * KAL_FALSE indicates blocking mode shall be adopted. + * For example, set a socket to non-blocking mode: + * kal_bool val = KAL_TRUE; + * setsockopt(sock, SOC_NBIO, &val, sizeof(kal_bool)); + * + * VM_SOC_SILENT_LISTEN: + * val contains KAL_TRUE indicates the silent listen shall be adopted, + * KAL_FALSE indicates non-silent listen shall be adopted. + * This is SOC_SOCK_SMS property. For example, if you want to let the socket be + * the passive to activate the bear, you can set a socket to silent listen mode: + * For example: + * kal_bool val = KAL_TRUE; + * setsockopt(sock, VM_SOC_SILENT_LISTEN, &val, sizeof(kal_bool)) + * + * VM_SOC_UDP_NEED_ICMP: + * This option is used to deliver NOTIFY(close) for ICMP error. + * val contains KAL_TRUE indicates this option shall be enabled, + * KAL_FALSE indicates this option shall be disabled. + * For example, if you want to let set a socket to UDP NEED ICMP mode: + * kal_bool val = KAL_TRUE; + * setsockopt(sock, VM_SOC_UDP_NEED_ICMP, &val, sizeof(kal_bool)) + * + * VM_SOC_ASYNC: + * this option needs to be set if you want to use the non-blocking plus asyn mode. + * val contains the events application wants to receive. + * For example, if application wants to receive + * READ/WRITE/CLOSE/CONNECT events, + * it shall call soc_setsockopt like the following: + * kal_uint8 val = 0; + * val = SOC_READ | SOC_WRITE | SOC_CLOSE | SOC_CONNECT; + * setsockopt(sock, VM_SOC_ASYNC, &val, sizeof(kal_uint8)); + * P.S. if you are using the server socket, please remember to set the SOC_ACCPET event. + * + * VM_SOC_TCP_MAXSEG: + * A process can only decrease the MSS. When a TCP socket is created, + * the default MSS is set to 512. The MSS is updated according to the value announced + * from peer TCP after the socket completes TCP three-way handshake. + * Therefore, after a socket is created but before connected, a process can only decrease + * the MSS from its default of 512. After a connection is established, + * the process can decrease the MSS from the new updated value. + * + * The value of TCP MSS is reduced to fit the interface MTU if the application set an + * unacceptable large value. + * For example: + * kal_uint8 val = 512; + * setsockopt(sock, VM_SOC_TCP_MAXSEG, &val, sizeof(kal_uint8)); + * + * VM_SOC_LISTEN_BEARER: + * val contains bear type indicates which kind of bear we want to receive packets from. + * For example, set a socket to receive the WiFi bear: + * kal_uint8 val = SOC_BEARER_WIFI; + * setsockopt(sock, VM_SOC_LISTEN_BEARER, &val, sizeof(kal_uint8)); + * + * VM_SOC_WIFI_NOWAKEUP: + * val contains KAL_TRUE indicates this option shall be enabled, + * KAL_FALSE indicates this option shall be disabled. + * This option is to make WNDRV sends outgoing packet to in power saving mode. + * For example: + * kal_bool val = KAL_TRUE; + * setsockopt(sock, VM_SOC_WIFI_NOWAKEUP, &val, sizeof(kal_bool)) + * + * VM_SOC_IP_HDRINCL: + * val contains KAL_TRUE indicates this option shall be enabled, + * KAL_FALSE indicates this option shall be disabled. If this option is set for a raw IP socket, + * we must build our own IP header for all the datagrams that we send on the raw socket. + * We can only set this socket option if the socket type in soc_create is + * SOC_SOCK_RAW(raw socket) and protocol in soc_create is not SOC_IPPROTO_ICMP. + * For example: + * kal_bool val = KAL_TRUE; + * setsockopt(sock, VM_SOC_IP_HDRINCL, &val, sizeof(kal_bool)) + * + * VM_SOC_UDP_ANY_FPORT: + * val contains KAL_TRUE indicates this option shall be enabled, + * KAL_FALSE indicates this option shall be disabled. For a connected UDP socket, + * this option makes socket deliver incoming packet from the same remote + * address but different remote port. + * For example: + * kal_bool val = KAL_TRUE; + * setsockopt(sock, VM_SOC_UDP_ANY_FPORT, &val, sizeof(kal_bool)) + * + * VM_SOC_IP_TTL: + * val contains the TTL values . If you want to change the default TTL (64), + * you can set this option. For example: + * kal_uint8 val = 128; + * setsockopt(sock, VM_SOC_IP_TTL, &val, sizeof(kal_uint8)) + * + * VM_SOC_QOS: + * val contains the TOS values . If you want to set the TOS values, you can set this option. + * For example: + * kal_uint8 val = 0x80; + * setsockopt(sock, VM_SOC_QOS, &val, sizeof(kal_uint8)) + * + * VM_SOC_KEEPALIVE: + * val contains KAL_TRUE indicates this option shall be enabled, + * KAL_FALSE indicates this option shall be disabled. + * You can use this option to enable or disable the keep-alive timer in TCP. + * For example: + * kal_bool val = KAL_TRUE; + * setsockopt(sock, VM_SOC_KEEPALIVE, &val, sizeof(kal_bool)) + * + * VM_SOC_NODELAY: + * val contains KAL_TRUE indicates this option shall be enabled, + * KAL_FALSE indicates this option shall be disabled. + * If you want to send the packet directly without waiting a packet size larger than MSS, + * you can set this option. For example: + * kal_bool val = KAL_TRUE; + * soc_setsockopt(sock, VM_SOC_NODELAY, &val, sizeof(kal_bool)) + * + * VM_SOC_SENDBUF: + * val contains the value of send buffer's high water mark. + * If you want to set the high water mark, you can set this option. + * If the value you set is smaller than the MSS, the mss would be adjusted to this value. + * The value must be greater than 0 and smaller than the SSPDU + SSPDU_GROW. + * For example: + * kal_uint32 val = 1024; + * setsockopt(sock, VM_SOC_SENDBUF, &val, sizeof(kal_uint32)) + * + * VM_SOC_RECVBUF: + * val contains the value of receive buffer's high water mark. + * If you want to set the high water mark, you can set this option. + * This value must be greater than 0 and smaller than the SRPDU size. + * For example: + * kal_uint32 val = 4096; + * soc_setsockopt(sock, VM_SOC_RECVBUF, &val, sizeof(kal_uint32)) + * + * VM_SOC_LINGER: + * val contains the value of enable/diable LINGER option and the value of LINGER time. + * This option is used in linger on close. + * For example: + * soc_linger_struct val; + * val.onoff = KAL_TRUE; val. + * linger_time = 3; (sec) + * setsockopt(sock, VM_SOC_LINGER, &val, sizeof(soc_linger_struct_val)); + * + * VM_SOC_IPSEC_POLICY: + * val contains sadb_x_policy structure content. + * You can set this option to set the IPSEC policy. + * If you want to get the IPSEC policy, + * you can set this option. For example: + * struct sadb_x_policy policy; + * policy.sadb_x_policy_len = PFKEY_UNIT64(sizeof(policy)); + * policy.sadb_x_policy_exttype = SADB_X_EXT_POLICY; + * policy.sadb_x_policy_type = 4; // IPSEC_POLICY_BYPASS; + * policy.sadb_x_policy_dir = 1; // IPSEC_DIR_INBOUND; + * setsockopt(sock, VM_SOC_IPSEC_POLICY, &policy, sizeof(sadb_x_policy)) + * + * VM_SOC_TCP_DELAYED_ACK: + * The VM_SOC_TCP_DELAYED_ACK function is enable by default. That is to say, + * if you don't set this option. The default VM_SOC_TCP_DELAYED_ACK value is TRUE. + * val contains KAL_TRUE indicates this option shall be enabled, + * KAL_FALSE indicates this option shall be disabled. + * If you want to enable the "TCP no delay" function, + * you can set this option. For example: + * kal_bool val = KAL_TRUE; + * setsockopt(sock, VM_SOC_TCP_DELAYED_ACK, &val, sizeof(kal_bool)) + * + * VM_SOC_TCP_SACK: + * The VM_SOC_TCP_SACK function is enable by default. That is to say, + * if you don't set this option. The default VM_SOC_TCP_SACK value is TRUE. + * val contains KAL_TRUE indicates this option shall be enabled, + * KAL_FALSE indicates this option shall be disabled. + * If you want to enable the "TCP SACK" function, + * you can set this option. For example: + * kal_bool val = KAL_TRUE; + * setsockopt(sock, VM_SOC_TCP_SACK, &val, sizeof(kal_bool)) + * + * VM_SOC_TCP_TIME_STAMP: + * The VM_SOC_TCP_TIME_STAMP function is enable by default. That is to say, + * if you don't set this option. The default VM_SOC_TCP_TIME_STAMP value is TRUE. + * val contains KAL_TRUE indicates this option shall be enabled, + * KAL_FALSE indicates this option shall be disabled. + * If you want to enable the "TCP TIME STAMP" function, + * you can set this option. For example: + * kal_bool val = KAL_TRUE; + * setsockopt(sock, VM_SOC_TCP_TIME_STAMP, &val, sizeof(kal_bool)) + * + *****************************************************************************/ +int vm_setsockopt(int sock, VMUINT32 option, void *val, VMUINT8 val_size); + +/***************************************************************************** + * FUNCTION + * getsockopt + * DESCRIPTION + * This function gets the socket options. + * PARAMETERS + * sock : [IN] socket id + * option : [IN] option type (soc_option_enum) + * val : [IN] option value + * val_size : [IN] option value size + * RETURN VALUES + * VM_E_SOC_SUCCESS : get the socket option successfully + * VM_E_SOC_INVALID_SOCKET : invalid socket id + * VM_E_SOC_INVAL : invalid arguments: option, val and val_size + * VM_E_SOC_ERROR : unspecified error + * SEE ALSO + * setsockopt + * EXAMPLE + * + * VM_SOC_TCP_DELAYED_ACK: + * val contains kal_bool to hold the option behavior. + * If you don't set this option, the default value you get is KAL_TRUE. + * If you to get this option, you can do: + * + * kal_bool val; + * getsockopt(sock, SOC_TCP_DELAYED_ACK, &val, sizeof(kal_bool)) + * + * + * VM_SOC_TCP_SACK: + * val contains kal_bool to hold the option behavior. + * If you don't set this option, the default value you get is KAL_TRUE. + * If you to get this option, you can do: + * + * kal_bool val; + * getsockopt(sock, SOC_TCP_SACK, &val, sizeof(kal_bool)) + * + * + * VM_SOC_TCP_TIME_STAMP: + * val contains kal_bool to hold the option behavior. + * If you don't set this option, the default value you get is KAL_TRUE. + * If you to get this option, you can do: + * + * kal_bool val; + * getsockopt(sock, SOC_TCP_TIME_STAMP, &val, sizeof(kal_bool)) + * + *****************************************************************************/ + int vm_getsockopt(int sock, VMUINT32 option, void *val, VMUINT8 val_size); + +/***************************************************************************** + * FUNCTION + * getsockname + * DESCRIPTION + * Retrieve local IP address and port number. + * PARAMETERS + * sock [IN] socket descriptor obtained with socket. + * addr [OUT] structure that will receive IP address and port number. + * len [OUT] length of SOCKADDR structure. + * RETURNS + * refer to vm_soc_error_enum + *****************************************************************************/ +int vm_getsockname(int s, SOCKADDR *addr, int *len); + +/***************************************************************************** + * FUNCTION + * getpeername + * DESCRIPTION + * Retrieve IP address and port number of the endpoint node. + * PARAMETERS + * sock [IN] socket descriptor obtained with socket. + * addr [OUT] addr that will receive IP address and port number. + * len [OUT] length of SOCKADDR structure. + * RETURNS + * refer to vm_soc_error_enum + *****************************************************************************/ +int vm_getpeername(int s, SOCKADDR *addr, int *len); + + +/***************************************************************************** + * FUNCTION + * htonl + * DESCRIPTION + * Convert long integer (32 bits) from host byte order to network byte order + * PARAMETERS + * a : [IN] + * RETURNS + * converted result in unsigned integer + * EXAMPLE + * + * loopback = htonl(0x7f000001); + * + *****************************************************************************/ +VMUINT32 vm_htonl(VMUINT32 a); + + +/***************************************************************************** + * FUNCTION + * htons + * DESCRIPTION + * Convert short integer (16 bits) from host byte order to network byte order + * PARAMETERS + * a : [IN] + * RETURNS + * converted result in unsigned integer + * EXAMPLE + * + * sockaddr sock_addr; + * ((struct SOCKADDR_IN *) sock_addr)->sin_port = htons(port); + * + *****************************************************************************/ +VMUINT16 vm_htons(VMUINT16 a); + + +/***************************************************************************** + * FUNCTION + * inet_addr + * DESCRIPTION + * This function converts a string containing a dotted address into a network address in the format of an IN_ADDR structure. + * PARAMETERS + * addr : [IN] + * RETURNS + * VMUINT + *****************************************************************************/ +VMUINT vm_inet_addr(const char* addr); + +/***************************************************************************** + * FUNCTION + * inet_ntoa + * DESCRIPTION + * This function converts a network address into a string in dotted format. + * PARAMETERS + * in : [IN] + * RETURNS + * char * + *****************************************************************************/ +char* vm_inet_ntoa(IN_ADDR in); + + + +/***************************************************************************** + * FUNCTION + * inet_pton + * DESCRIPTION + * Convert an IPV4 or IPV6 address in its standard text presentation form into + * its numeric binary form in network byte order. + * Format of 'x:x:x:x:x:x:d.d.d.d' is not supported. + * PARAMETERS + * af : [IN] 0 - IPV4; 1 - IPV6 + * src : [IN] IP address with standard text presentation form ends with '\0'. + * dst : [OUT] IP address with numeric binary form in network byte order + * For IPV4, it's a kal_uint8 array with size of at least 4. + * For IPV6, it's an ipv6_addr_struct variable or compatible + * kal_uint8 array with size of at least 16. + * RETURNS + * no-zero: converted successfully. + * EXAMPLE + * // IPV4 + * + * kal_char ipv4[] = {"192.168.1.1"}; + * kal_uint8 ipv4_dst[4] = {0}; + * kal_bool ret = KAL_FALSE; + * ret = soc_inet_pton(0, ipv4, ipv4_dst); + * if (ret) + * { + * // successfully + * } + * + * // IPV6 + * + * VMCHAR ipv6[] = {"FF::EE"}; + * VMUINT8 ipv6_dst[16] = {0}; + * VMINT ret; + * ret = soc_inet_pton(1, ipv6, ipv6_dst); + * if (ret) + * { + * // successfully + * } + * + *****************************************************************************/ +int vm_inet_pton(int af, const char *src, void *dst); + + +/***************************************************************************** + * inet_ntop + * DESCRIPTION + * Convert an IPV4 or IPV6 address in its numeric binary form in network byte order + * into its standard text presentation form. + * Format of 'x:x:x:x:x:x:d.d.d.d' is not supported. + * PARAMETERS + * af : [IN] 0 - IPV4; 1 - IPV6 + * src : [IN] IP address with numeric binary form in network byte order + * For IPV4, it's a kal_uint8 array with size of at least 4. + * For IPV6, it's an ipv6_addr_struct variable or compatible + * kal_uint8 array with size of at least 16. And src should obey + * 4-byte alignment. + * dst : [OUT] IP address with standard text presentation form ends with '\0'. + * The memory that dst provided should be big enough to contain the + * whole IP address. Otherwise, conversion will fail. + * For IPV4, safe size is 16. + * For IPV6, safe size is 40. + * size : [IN] The size of memory in bytes dst provided. + * RETURNS + * dst: converted successfully. + * NULL: failed. + * EXAMPLE + * // IPV4 + * + * VMUINT8 ipv4[] = {192, 168, 0, 1}; + * VMCHAR ipv4_addr[16] = {0}, *addr = NULL; + * addr = inet_ntop(0, ipv4, ipv4_addr, 16); + * if (addr) + * { + * // successfully + * } + * + * // IPV6 + * + * VMUINT8 ipv6[] = {0xff, 0xee, 0xdd, 0xcc, 0xaa, 99, 88, 77, 66, 55, 44, 33, 22, 11, 00, 00}; + * VMCHAR ipv6_addr[16] = {0}; + * const VMCHAR *addr = NULL; + * addr = soc_inet_ntop(1, ipv6, ipv6_addr, 40); + * if (addr) + * { + * // successfully + * } + * + *****************************************************************************/ +const char *vm_inet_ntop(int af, const void *src, char *dst, VMUINT8 size); + + +/***************************************************************************** + * FUNCTION + * vm_soc_get_account_localip + * DESCRIPTION + * This function is used to get the local IP held by this socket id. + * PARAMETERS + * sock : [IN] Socket id + * local_ip : [OUT] copy the IP address, used as return + * RETURN VALUES + * VM_E_SOC_SUCCESS : Get IP address successfully + * VM_E_SOC_INVAL : invalid argument: null local_ip. + * VM_E_SOC_BEARER_FAIL : bearer is not activated + * VM_E_SOC_INVALID_SOCKET : invalid socket + * VM_E_SOC_INVALID_ACCOUNT : invalid account + * EXAMPLE + * + * static VMUINT8 ip[4]; + * VMINT result; + * result = vm_soc_get_account_localip(fd, ip); + * if (result == VM_E_SOC_SUCCESS) + * { + * //get the local IP address successfully + * } + * + *****************************************************************************/ +VMINT vm_soc_get_account_localip(VMINT8 sock, VMUINT8 *local_ip); + + +/***************************************************************************** + * FUNCTION + * vm_soc_get_account_localipv6 + * DESCRIPTION + * This function is used to get local IPv6 address held by specific socket id. + * The IPv6 address obtained is in numeric binary form with network byte order. + * Only socket id for IPv6 is valid for this function. + * PARAMETERS + * sock : [IN] Socket id + * local_ipv6 : [OUT] copy the IP address, used as return + * RETURN VALUES + * VM_E_SOC_SUCCESS : Get IP address successfully + * VM_E_SOC_INVAL : invalid argument: null local_ip. + * VM_E_SOC_BEARER_FAIL : bearer is not activated + * VM_E_SOC_INVALID_SOCKET : invalid socket + * VM_E_SOC_INVALID_ACCOUNT : invalid account + * EXAMPLE + * + * static VMUINT8 ip[16]; + * VMINT result; + * result = vm_soc_get_account_localipv6(fd, ip); + * if (result == VM_E_SOC_SUCCESS) + * { + * //get the local IP address successfully + * } + * + *****************************************************************************/ +VMINT vm_soc_get_account_localipv6(int sock, VMUINT8 *local_ipv6); + + + + +typedef struct +{ + VMUSHORT sa_family; + VMCHAR sa_data[16]; +}vm_soc_addr; + +/* this struct is for getaddrinfo function only */ +typedef struct +{ + VMINT32 ai_flags; + VMINT32 ai_family; + VMINT32 ai_socktype; + VMINT32 ai_protocol; + VMUINT16 ai_addrlen; + VMCHAR *ai_canonname; + VMBOOL ai_ipv6_first; + vm_soc_addr *ai_addr; + +}vm_soc_addrinfo; + +typedef enum +{ + VM_DNS_AF_INET = 0, /* INET QUERY */ + VM_DNS_AF_INET6, /* IPV6 QUERY */ + VM_DNS_AF_UNSPEC, /* UNSPEC QUERY */ + VM_DNS_AF_END +}vm_soc_dns_family_enum; + +typedef enum +{ + VM_DNS_NO_RESPONSE_YET = 0, + VM_DNS_IPV4_WAIT = 0x01, + VM_DNS_IPV4_COMPLETE = 0x02, + VM_DNS_IPV6_WAIT = 0x04, + VM_DNS_IPV6_COMPLETE = 0x08, + VM_DNS_IPV4_FAILED = 0x10, + VM_DNS_IPV6_FAILED = 0x20, + VM_DNS_STATUS_SUCCESS, + VM_DNS_STATUS_END +}vm_dns_getaddrinfo_status_enum; + +#define VM_SOC_MAX_A_ENTRY (5) + + +/* For vm_soc_getaddrinfo() */ +typedef struct vm_soc_addrinfo_struct +{ + VMINT32 ai_flags; /* soc_ai_flags_enum */ + VMINT32 ai_family; + VMINT32 ai_socktype; + VMINT32 ai_protocol; + VMUINT32 ai_addrlen; + VMCHAR *ai_canonname; + vm_sockaddr_struct *ai_addr; + struct vm_soc_addrinfo_struct *ai_next; +}vm_soc_addrinfo_struct; + +typedef struct +{ + VMUINT8 ref_count; + VMUINT16 msg_len; + VMINT8 error_cause; /* bearer fail */ + VMINT32 detail_cause; /* refer to vm_ps_cause_enum if error_cause + * is VM_E_SOC_BEARER_FAIL */ + VMINT32 request_id; /* request id */ + VMUINT32 account_id; /* network account id */ + VMUINT8 access_id; /* access id */ + VMBOOL result; /* the result of soc_gethostbyname */ + void *res; /* vm_soc_addrinfo_struct */ +} vm_app_soc_get_addr_info_ind_struct; + + +typedef void (*FP_dns_cb)(vm_app_soc_get_addr_info_ind_struct *ind); + + +/***************************************************************************** + * FUNCTION + * vm_soc_getaddrinfo + * DESCRIPTION + * This function gets the address information (both ipv6 and ipv4 address) of the given domain name. + * Get a host address (i.e., IP address) by its domain name. + * If the bearer is not activated when this API is called, + * the bearer activation would be triggered. However, + * if the account id is not specified in soc_gethostbyname, + * an account query would be displayed to ask the user which account + * s/he wants to use. + * + * This API only supports the non-blokcing mode, i.e., + * is_blocking shall be set to KAL_FALSE. + * Thus, soc_getaddrinfo will be returned immediately instead of + * blocking and waiting for the result. + * If user doesn't get the returned value directly after it calls this API, + * the returned value "VM_E_SOC_WOULDBLOCK" will be returned normally. + * SOC will send a notification to application when it gets the response + * of previous DNS query later. + * On the contrary, if user gets the result directly, the result will be + * returned directly in the parameter "addr". + * + * this api can query ipv4 and ipv6 at same time and also can query ipv4 or ipv6 single. + * hits->ai_family = VM_DNS_AF_UNSPEC; query ipv4 and ipv6 same time + * hits->ai_family = VM_DNS_AF_INET6; only query ipv6 + * hits->ai_family = VM_DNS_AF_INET; only query ipv4 + * + * PARAMETERS + * is_blocking : [IN] whether block or non-block mode are used, + * currently only support non-block mode + * mod_id : [IN] module id + * request_id : [IN] embedded in response message + * nodename : [IN] Domain_name + * servicename : [IN] pass NULL now + * hits : [IN] set some query method + * addr : [IN] resolved address + * addr_len : [IN/OUT] address length + * access_id : [IN] embedded in response message + * res : [IN] pass NULL now + * nwk_account_id : [IN] Nwk_account_id + * RETURN VALUES + * VM_E_SOC_INVAL : invalid arguments: null domain_name, etc. + * VM_E_SOC_ERROR : unspecified error + * VM_E_SOC_WOULDBLOCK : wait response from network + * VM_E_SOC_LIMIT_RESOURCE : socket resources not available + * EXAMPLE + * + * vm_soc_addrinfo info; + * vm_soc_addrinfo *hits = &info; + * memset(hits, 0, sizeof(vm_soc_addrinfo)); + * hits->ai_family = VM_DNS_AF_UNSPEC; // query ipv4 and ipv6 at same time. + * hits->ai_ipv6_first = KAL_TRUE; // if query both ipv4 and ipv6, app can decide which query first + * ret = soc_getaddrinfo( + * KAL_FALSE, + * soc_id, + * (const kal_char*)domain_name, + * hits + * ch->stun_ip_addr.addr, + * (kal_uint8*) & ch->stun_ip_addr.addr_len, + * 0, + * ch->data_account_id); + * + * if (ret == VM_E_SOC_WOULDBLOCK) + * { + * //processing the wouldblock state + * ĦK.. + * } + * + * + *****************************************************************************/ +VMINT vm_soc_getaddrinfo(VMBOOL is_blocking, + VMINT32 request_id, + const VMCHAR *nodename, + const VMCHAR *servicename, + const vm_soc_addrinfo_struct *hits, + vm_soc_addrinfo_struct **res, + VMINT32 access_id, + VMUINT32 nwk_account_id, + FP_dns_cb dns_cb); + + + +/* refer to vm_socket */ +#define socket(family, type, protocol) vm_socket(family, type, protocol) +/* refer to vm_socket_ex */ +#define socket_ex(family, type, protocol, account) vm_socket_ex(family, type, protocol, account) +/* refer to vm_closesocket */ +#define closesocket(s) vm_closesocket(s) +/* refer to vm_bind */ +#define bind(s, addr, len, type) vm_bind(s, addr, len, type) +/* refer to vm_listen */ +#define listen(s, bl) vm_listen(s, bl) +/* refer to vm_accept */ +#define accept(s, addr, len) vm_accept(s, addr, len) +/* refer to vm_connect */ +#define connect(s, addr, len) vm_connect(s, addr, len) +/* refer to vm_send */ +#define send(s, buf, len, flags) vm_send(s, buf, len, flags) +/* refer to vm_sendto */ +#define sendto(s, buf, len, flags, to, tlen) vm_sendto(s, buf, len, flags, to, tlen) +/* refer to vm_recv */ +#define recv(s, buf, len, flags) vm_recv(s, buf, len, flags) +/* refer to vm_recvfrom */ +#define recvfrom(s, buf, len, flags, from, flen) vm_recvfrom(s, buf, len, flags, from, flen) +/* refer to vm_select */ +#define select(fds, reads, writes, except, timeout) vm_select(fds, reads, writes, except, timeout) +/* refer to vm_shutdown */ +#define shutdowns(s, how) vm_shutdown(s, how) +/* refer to vm_setsockopt */ +#define setsockopt(s, opt, val, size) vm_setsockopt(s, opt, val, size) +/* refer to vm_getsockopt */ +#define getsockopt(s, opt, val, size) vm_getsockopt(s, opt, val, size) +/* refer to vm_getsockname */ +#define getsockname(s, addr, len) vm_getsockname(s, addr, len) +/* refer to vm_getpeername */ +#define getpeername(s, addr, len) vm_getpeername(s, addr, len) + +/* refer to vm_htonl */ +#define htonl(a) vm_htonl(a) +/* refer to vm_htons */ +#define htons(a) vm_htons(a) +/* refer to vm_htonl */ +#define ntohl(a) vm_htonl(a) +/* refer to vm_htons */ +#define ntohs(a) vm_htons(a) + +/* refer to vm_inet_addr */ +#define inet_addr(a) vm_inet_addr(a) +/* refer to vm_inet_ntoa */ +#define inet_ntoa(in) vm_inet_ntoa(in) +/* refer to vm_inet_pton */ +#define inet_pton(af, src, dst) vm_inet_pton(af, src, dst) +/* refer to vm_inet_ntop */ +#define inet_ntop(af, src, dst, size) vm_inet_ntop(af, src, dst, size) + +#ifdef __cplusplus +} +#endif + +#endif /* VM_SOCK_SDK_H */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmsrvmng.h b/hardware/arduino/mtk/system/libmtk/include/vmsrvmng.h new file mode 100644 index 00000000..1afb34a7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmsrvmng.h @@ -0,0 +1,51 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef __VM_SRVMNG_SDK_H__ +#define __VM_SRVMNG_SDK_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "vmsys.h" +VMINT vm_create_service(VMINT clsid, VMINT iid, void ** pptr); + +#ifdef __cplusplus +} +#endif + +#endif /* __VM_SRVMNG_SDK_H__ */ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmssl.h b/hardware/arduino/mtk/system/libmtk/include/vmssl.h new file mode 100644 index 00000000..79cb23a4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmssl.h @@ -0,0 +1,328 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef _VMSSL_SDK_H_ +#define _VMSSL_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + + + +#define VM_SSL_VERIFY_NONE 0 /* peer certificate is not checked (default), this is insecure and SHOULD be avoided. */ +#define VM_SSL_VERIFY_OPTIONAL 1 /* peer certificate is checked, however the + handshake continues even if verification failed; */ +#define VM_SSL_VERIFY_REQUIRED 2 /* peer *must* present a valid certificate, handshake is aborted if verification failed. */ + + + +/* connected status */ +#define VM_SSL_EVT_CONNECTED 1 + +/* write status */ +#define VM_SSL_EVT_CAN_WRITE 2 + +/* read status */ +#define VM_SSL_EVT_CAN_READ 3 + +/* broken status */ +#define VM_SSL_EVT_PIPE_BROKEN 4 + +/* not find host */ +#define VM_SSL_EVT_HOST_NOT_FOUND 5 + +/* tcp pipe closed */ +#define VM_SSL_EVT_PIPE_CLOSED 6 + +/* ssl handshake failed */ +#define VM_SSL_EVT_HANDSHAKE_FAILED 7 + +/* ssl certificate failed */ +#define VM_SSL_EVT_CERTIFICATE_VALIDATION_FAILED 8 + + +/* + * Rteurn Errror Values from Xyssl Library + */ +#define VM_XYSSL_ADP_ERR_SSL_FEATURE_UNAVAILABLE -0x1000 +#define VM_XYSSL_ADP_ERR_SSL_BAD_INPUT_DATA -0x1800 +#define VM_XYSSL_ADP_ERR_SSL_INVALID_MAC -0x2000 +#define VM_XYSSL_ADP_ERR_SSL_INVALID_RECORD -0x2800 +#define VM_XYSSL_ADP_ERR_SSL_INVALID_MODULUS_SIZE -0x3000 +#define VM_XYSSL_ADP_ERR_SSL_UNKNOWN_CIPHER -0x3800 +#define VM_XYSSL_ADP_ERR_SSL_NO_CIPHER_CHOSEN -0x4000 +#define VM_XYSSL_ADP_ERR_SSL_NO_SESSION_FOUND -0x4800 +#define VM_XYSSL_ADP_ERR_SSL_NO_CLIENT_CERTIFICATE -0x5000 +#define VM_XYSSL_ADP_ERR_SSL_CERTIFICATE_TOO_LARGE -0x5800 +#define VM_XYSSL_ADP_ERR_SSL_CERTIFICATE_REQUIRED -0x6000 +#define VM_XYSSL_ADP_ERR_SSL_BAD_HS_SERVER_HELLO_DONE -0xC000 +#define VM_XYSSL_ADP_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE -0xC800 +#define VM_XYSSL_ADP_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY -0xD000 +#define VM_XYSSL_ADP_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC -0xD800 +#define VM_XYSSL_ADP_ERR_SSL_BAD_HS_FINISHED -0xE000 + + +/* +* XYSSL VERIFY RESULT ERROR VALUES +*/ +#define VM_XYSSL_ADP_BADCERT_EXPIRED 0x01 /**< The certificate validity has expired. */ +#define VM_XYSSL_ADP_BADCERT_REVOKED 0x02 /**< The certificate has been revoked (is on a CRL). */ +#define VM_XYSSL_ADP_BADCERT_CN_MISMATCH 0x04 /**< The certificate Common Name (CN) does not match with the expected CN. */ +#define VM_XYSSL_ADP_BADCERT_NOT_TRUSTED 0x08 /**< The certificate is not correctly signed by the trusted CA. */ + + +/* +* XYSSL X509 ERROR VALUES +*/ +#define VM_XYSSL_ADP_ERR_X509_FEATURE_UNAVAILABLE -0x0020 +#define VM_XYSSL_ADP_ERR_X509_CERT_INVALID_PEM -0x0040 +#define VM_XYSSL_ADP_ERR_X509_CERT_INVALID_FORMAT -0x0060 +#define VM_XYSSL_ADP_ERR_X509_CERT_INVALID_VERSION -0x0080 +#define VM_XYSSL_ADP_ERR_X509_CERT_INVALID_SERIAL -0x00A0 +#define VM_XYSSL_ADP_ERR_X509_CERT_INVALID_ALG -0x00C0 +#define VM_XYSSL_ADP_ERR_X509_CERT_INVALID_NAME -0x00E0 +#define VM_XYSSL_ADP_ERR_X509_CERT_INVALID_DATE -0x0100 +#define VM_XYSSL_ADP_ERR_X509_CERT_INVALID_PUBKEY -0x0120 +#define VM_XYSSL_ADP_ERR_X509_CERT_INVALID_SIGNATURE -0x0140 +#define VM_XYSSL_ADP_ERR_X509_CERT_INVALID_EXTENSIONS -0x0160 +#define VM_XYSSL_ADP_ERR_X509_CERT_UNKNOWN_VERSION -0x0180 +#define VM_XYSSL_ADP_ERR_X509_CERT_UNKNOWN_SIG_ALG -0x01A0 +#define VM_XYSSL_ADP_ERR_X509_CERT_UNKNOWN_PK_ALG -0x01C0 +#define VM_XYSSL_ADP_ERR_X509_CERT_SIG_MISMATCH -0x01E0 +#define VM_XYSSL_ADP_ERR_X509_CERT_VERIFY_FAILED -0x0200 +#define VM_XYSSL_ADP_ERR_X509_KEY_INVALID_PEM -0x0220 +#define VM_XYSSL_ADP_ERR_X509_KEY_INVALID_VERSION -0x0240 +#define VM_XYSSL_ADP_ERR_X509_KEY_INVALID_FORMAT -0x0260 +#define VM_XYSSL_ADP_ERR_X509_KEY_INVALID_ENC_IV -0x0280 +#define VM_XYSSL_ADP_ERR_X509_KEY_UNKNOWN_ENC_ALG -0x02A0 +#define VM_XYSSL_ADP_ERR_X509_KEY_PASSWORD_REQUIRED -0x02C0 +#define VM_XYSSL_ADP_ERR_X509_KEY_PASSWORD_MISMATCH -0x02E0 +#define VM_XYSSL_ADP_ERR_X509_POINT_ERROR -0x0300 +#define VM_XYSSL_ADP_ERR_X509_VALUE_TO_LENGTH -0x0320 + + +/* +* XYSSL BASE64 ERROR VALUES +*/ +#define XYSSL_ADP_ERR_BASE64_BUFFER_TOO_SMALL -0x0010 +#define XYSSL_ADP_ERR_BASE64_INVALID_CHARACTER -0x0012 + + + + +/* +* XYSSL VERIFY RESULT ERROR VALUES +*/ +#define XYSSL_ADP_BADCERT_EXPIRED 0x01 /**< The certificate validity has expired. */ +#define XYSSL_ADP_BADCERT_REVOKED 0x02 /**< The certificate has been revoked (is on a CRL). */ +#define XYSSL_ADP_BADCERT_CN_MISMATCH 0x04 /**< The certificate Common Name (CN) does not match with the expected CN. */ +#define XYSSL_ADP_BADCERT_NOT_TRUSTED 0x08 /**< The certificate is not correctly signed by the trusted CA. */ + + +typedef struct _vm_ssl_cntx{ + VMCHAR* host; /* host to which connection will be made */ + VMINT port; /* port at which connection will be made */ + void (*connection_callback)(VMINT handle, VMINT event); /* callback funtion to notify app about actions, like in vm_tcp_connect */ + VMINT authmod; /* what type of certification verification is required: NONE, OPTIONAL, REQUIRED */ + VMCHAR *ua; +}vm_ssl_cntx; + +/***************************************************************************** + * FUNCTION + * vm_ssl_is_support + * DESCRIPTION + * query if ssl be supported + * PARAMETERS + * void + * RETURNS + * non-zero value if successfully, else not support. +*****************************************************************************/ +VMINT vm_ssl_is_support(void); + + +/***************************************************************************** + * FUNCTION + * vm_ssl_connect + * DESCRIPTION + * create a ssl connection + * PARAMETERS + * ctx : [IN] ssl context, refer to vm_ssl_cntx + * RETURNS + * non-negative handle if successfully, and error code if failed to create. +*****************************************************************************/ +VMINT vm_ssl_connect(const vm_ssl_cntx *ctx); + + +/***************************************************************************** + * FUNCTION + * vm_ssl_load_ca_chain_cert + * DESCRIPTION + * load ca_chain certification + * PARAMETERS + * handle : [IN] ssl handle + * cert_buf : [IN] cert data, the raw data get from resource of app + * buf_len : [IN] length of cert data. + * RETURNS + * 0 if successfully, else failed. + * RETURN VALUES + * XYSSL X509 ERROR VALUES +*****************************************************************************/ +VMINT vm_ssl_load_ca_chain_cert(VMINT handle, const void *cert_buf, VMINT buf_len); + +/***************************************************************************** + * FUNCTION + * vm_ssl_read + * DESCRIPTION + * read data from ssl connection. + * PARAMETERS + * handle : [IN] ssl handle. + * buf : [OUT] data buffer. + * len : [IN] data length. + * RETURNS + * read data size. + * RETURN VALUES + * read size +*****************************************************************************/ +VMINT vm_ssl_read(VMINT handle, VMUINT8 *buf, VMINT len); + + +/***************************************************************************** + * FUNCTION + * vm_ssl_write + * DESCRIPTION + * write data from ssl connection. + * PARAMETERS + * handle : [IN] ssl handle. + * buf : [OUT] data buffer. + * len : [IN] data length. + * RETURNS + * read data size. + * RETURN VALUES + * read size +*****************************************************************************/ +VMINT vm_ssl_write(VMINT handle, const VMUINT8 *buf, VMINT len); + + +/***************************************************************************** + * FUNCTION + * vm_ssl_close + * DESCRIPTION + * close ssl connection. + * PARAMETERS + * handle : [IN] ssl handle. +*****************************************************************************/ +VMINT vm_ssl_close(VMINT handle); + +/***************************************************************************** + * FUNCTION + * vm_ssl_get_verify_result + * DESCRIPTION + * get the verify result. + * PARAMETERS + * handle : [IN] ssl handle. + * RETURNS + * result + * RETURN VALUES + * 0 if successful, or a combination of: + * XYSSL VERIFY RESULT ERROR VALUES +*****************************************************************************/ +VMINT vm_ssl_get_verify_result(VMINT handle); + + +/***************************************************************************** + * FUNCTION + * vm_ssl_base64_encode + * Call this function with *dlen = 0 to obtain the required buffer size in *dlen + * DESCRIPTION + * base64 encode. + * PARAMETERS + * dst : [OUT] destination buffer. + * dlen : [OUT] size of the buffer. + * src : [IN] source buffer. + * slen : [IN] amount of data to be encoded. + * RETURNS + * result + * RETURN VALUES + * 0 if successful, or XYSSL_ERR_BASE64_BUFFER_TOO_SMALL. + * *dlen is always updated to reflect the amount of data that has (or would have) been written. +*****************************************************************************/ +VMINT vm_ssl_base64_encode(VMBYTE *dst, VMINT *dlen, VMBYTE *src, VMINT slen); + +/***************************************************************************** +* FUNCTION +* vm_ssl_base64_decode +* Call this function with *dlen = 0 to obtain the required buffer size in *dlen +* DESCRIPTION +* base64 decode. +* PARAMETERS +* dst : [OUT] destination buffer. +* dlen : [OUT] size of the buffer. +* src : [IN] source buffer. +* slen : [IN] amount of data to be decoded. +* RETURNS +* result +* RETURN VALUES +* 0 if successful, XYSSL_ERR_BASE64_BUFFER_TOO_SMALL, or +* XYSSL_ERR_BASE64_INVALID_DATA if the input data is not +* correct. *dlen is always updated to reflect the amount +* of data that has (or would have) been written. +*****************************************************************************/ +VMINT vm_ssl_base64_decode(VMBYTE *dst, VMINT *dlen, VMBYTE *src, VMINT slen); + +/***************************************************************************** +* FUNCTION +* vm_ssl_sha1_hmac +* DESCRIPTION +* get the verify result. +* PARAMETERS +* key : [IN] HMAC secret key. +* keylen : [IN] length of the HMAC key. +* input : [IN] buffer holding the data. +* ilen : [IN] length of the input data. +* output : [OUT] HMAC-SHA-1 result. +* RETURNS +* result +*****************************************************************************/ +VMINT vm_ssl_sha1_hmac(VMBYTE *key, VMINT keylen, VMBYTE *input, VMINT ilen, VMBYTE output[20]); + +#ifdef __cplusplus +} +#endif + +#endif /*_VMSSL_SDK_H_*/ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmsso.h b/hardware/arduino/mtk/system/libmtk/include/vmsso.h new file mode 100644 index 00000000..57e40fe3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmsso.h @@ -0,0 +1,446 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmpromng.c + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * + * + * Author: + * ------- + * + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ + * $Log$ + * + * 07 05 2012 feng.lin + * [MAUI_03211419] It allways shows invalid username or password error notice while logging in yahoo services. + * . + * + * 06 14 2012 feng.lin + * [MAUI_03202717] update sso srv callback prototype + * . + * + * 06 07 2012 feng.lin + * [MAUI_03159675] MRE of SSO + * . + * + * 06 04 2012 feng.lin + * [MAUI_03159675] MRE of SSO + * . + * + * 05 14 2012 feng.lin + * [MAUI_03159675] MRE of SSO + * sso sdk. + * + * 05 14 2012 feng.lin + * [MAUI_03159675] MRE of SSO + * sso sdk. + * + * 04 25 2012 feng.lin + * [MAUI_03159675] MRE of SSO + * . + * + * 04 19 2012 feng.lin + * [MAUI_03159675] MRE of SSO + * . + * + * 04 18 2012 feng.lin + * [MAUI_03159675] MRE of SSO + * . + * + * 03 30 2012 feng.lin + * [MAUI_03159675] MRE of SSO + * . + * + * *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== + *******************************************************************************/ + +#ifndef VM_SSO_SDK_H +#define VM_SSO_SDK_H + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "vmsys.h" + +#define VM_SSO_NAME_SIZE 64 +#define VM_SSO_ACCESS_TOKEN 256 +#define VM_SSO_REFRESH_TOKEN 256 +#define VM_SSO_SCOPE 128 +#define VM_SSO_EXTENSION 256 + +#define VM_SSO_EXT_YAHOO_COOKIE 300 +#define VM_SSO_EXT_YAHOO_CRUMB 256 + + +typedef enum +{ + VM_SSO_ICON_LARGE, + VM_SSO_ICON_SMALL, + VM_SSO_ICON_TOTAL, +}vm_sso_icon_enum; + +typedef enum +{ + VM_SSO_LOGIN_DONT_CARE, + VM_SSO_LOGIN_TRUE, + VM_SSO_LOGIN_FALSE, + VM_SSO_LOGIN_TOTAL +}vm_sso_login_state; + +typedef enum +{ + VM_SSO_CREDENTIAL_OAUTH, + VM_SSO_CREDENTIAL_USERPASS, + VM_SSO_CREDENTIAL_YAHOO, + VM_SSO_CREDENTIAL_TOTAL +}vm_sso_credential_enum; + +typedef enum +{ + VM_SSO_OK, + VM_SRV_SSO_UNKNOWN_ERROR = -999, + VM_SRV_SSO_CARD_PLUG_OUT, + VM_SRV_SSO_USB_MS_MODE, + VM_SRV_SSO_PROVIDER_NOT_FOUND, + VM_SRV_SSO_ACCOUNT_NOT_FOUND, + VM_SRV_SSO_BUSY, + VM_SRV_SSO_CONNECTION_FAIL, + VM_SRV_SSO_INCORRECT_ID_PW, + VM_SRV_SSO_NOT_FULL_EMAIL, + VM_SRV_SSO_CANCELLED, + VM_SRV_SSO_UPGRADING, + VM_SRV_SSO_FAIL_TO_LOAD_PLUGIN +}vm_sso_result; + + +typedef struct +{ + VMUINT32 provider; + VMUINT8 accounts_total; // number of total accounts + VMUINT8 accounts_loggedin; // number of accounts which are logged-in +}vm_sso_provider_struct; + +typedef struct +{ + VMUINT32 provider; + VMUINT8 account; + VMUINT8 is_login; +} vm_sso_account_struct; + +typedef struct +{ + vm_sso_credential_enum type; + union + { + struct + { + VMCHAR access_token[VM_SSO_ACCESS_TOKEN]; + VMCHAR refresh_token[VM_SSO_REFRESH_TOKEN]; + VMCHAR scope[VM_SSO_SCOPE]; + VMCHAR extension[VM_SSO_EXTENSION]; + } oauth; + struct + { + VMCHAR username[VM_SSO_NAME_SIZE]; + VMCHAR password[VM_SSO_NAME_SIZE]; + } userpass; + struct + { + VMCHAR security_token[VM_SSO_ACCESS_TOKEN]; + VMCHAR ycookie[VM_SSO_EXT_YAHOO_COOKIE]; + VMCHAR tcookie[VM_SSO_EXT_YAHOO_COOKIE]; + VMCHAR crumb[VM_SSO_EXT_YAHOO_CRUMB]; + } yahoo; + } value; +}vm_sso_credential_struct; + +typedef void (*vm_sso_account_callback)(VMINT req_id, vm_sso_result result, VMUINT32 provider, VMUINT8 account, void * user_data); + +typedef void (*vm_sso_result_callback)(VMINT req_id, vm_sso_result result, void * user_data); + + +/****************************************************************************** + * FUNCTION + * vm_sso_get_provider_count + * DESCRIPTION + * get the number of providers + * RETURNS + * return the nubmer of providers if positive number, else failure + ******************************************************************************/ +VMINT vm_sso_get_provider_count(void); + +/****************************************************************************** + * FUNCTION + * vm_sso_get_providers + * DESCRIPTION + * get info for all providers + * PARAMETERS + * buffer: [OUT] memory allocated by caller to hold the provider structure + * buffer_items: [IN] number of items the buffer can hold + * RETURNS + * return the nubmer of available providers if positive number, else failure + ******************************************************************************/ +VMINT vm_sso_get_providers(vm_sso_provider_struct * buffer, VMUINT8 buffer_items); + +/****************************************************************************** + * FUNCTION + * vm_sso_get_provider + * DESCRIPTION + * get info for specific providers + * PARAMETERS + * provider: [IN] the provider id as in vm_sso_provider_struct.provider + * buffer: [OUT] refer to vm_sso_provider_struct + * RETURNS + * success if 0, else failure. + ******************************************************************************/ +VMINT vm_sso_get_provider(VMUINT32 provider, vm_sso_provider_struct * buffer); + +/****************************************************************************** + * FUNCTION + * vm_sso_get_provider_icon + * DESCRIPTION + * get the name of a provider by its id + * PARAMETERS + * provider: [IN] the provider id as in vm_sso_provider_struct.provider + * type: [IN] the size of icon to get + * icon_path [OUT] icon_path + * RETURNS + * success if 0, else failure. + ******************************************************************************/ +VMINT vm_sso_get_provider_icon(VMUINT32 provider, vm_sso_icon_enum type, VMWCHAR ** icon_path); + +/****************************************************************************** + * FUNCTION + * vm_sso_get_provider_name + * DESCRIPTION + * get the name of a provider by its id + * PARAMETERS + * provider: [IN] the provider id as in vm_sso_provider_struct.provider + * buffer: [OUT] memory allocated by caller to hold the name of the provider + * must be at least VM_SSO_NAME_SIZE bytes + * RETURNS + * success if 0, else failure. + ******************************************************************************/ +VMINT vm_sso_get_provider_name(VMUINT32 provider, VMWCHAR * buffer); + +/****************************************************************************** + * FUNCTION + * vm_sso_get_account_count + * DESCRIPTION + * get the number of accounts for a provider according the login state + * PARAMETERS + * provider: [IN] the provider id as in vm_sso_provider_struct.provider + * login_state: [IN] login state to filter accounts + * RETURNS + * return the nubmer of accounts if positive number, else failure + ******************************************************************************/ +VMINT vm_sso_get_account_count(VMUINT32 provider, vm_sso_login_state login_state); + +/****************************************************************************** + * FUNCTION + * vm_sso_get_accounts + * DESCRIPTION + * get the info of accounts for a provider according the login state + * PARAMETERS + * provider: [IN] the provider id as in vm_sso_provider_struct.provider + * login_state: [IN] login state to filter accounts + * buffer: [OUT] memory allocated by caller to hold the vm_sso_account_struct + * buffer_items: [IN] number of items the buffer can hold + * RETURNS + * return the nubmer of accounts if positive number, else failure + ******************************************************************************/ +VMINT vm_sso_get_accounts(VMUINT32 provider, vm_sso_login_state login_state, vm_sso_account_struct * buffer, VMUINT8 buffer_items); + +/****************************************************************************** + * FUNCTION + * vm_sso_get_account + * DESCRIPTION + * get the info of accounts for a provider according the login state + * PARAMETERS + * provider: [IN] the provider id as in vm_sso_provider_struct.provider + * account: [IN] the account as in vm_sso_account_struct.account + * buffer: [OUT] refer to vm_sso_account_struct + * RETURNS + * return the nubmer of accounts if positive number, else failure + ******************************************************************************/ +VMINT vm_sso_get_account(VMUINT32 provider, VMUINT8 account, vm_sso_account_struct * buffer); + +/****************************************************************************** + * FUNCTION + * vm_sso_get_account_name + * DESCRIPTION + * get the username of an account by its provider and account + * PARAMETERS + * provider: [IN] the provider id as in vm_sso_account_struct.provider + * account: [IN] the account as in vm_sso_account_struct.account + * buffer: [OUT] memory allocated by caller to hold the username of the account + * must be at least VM_SSO_NAME_SIZE bytes + * RETURNS + * success if 0, else failure. + ******************************************************************************/ +VMINT vm_sso_get_account_name(VMUINT32 provider, VMUINT8 account, VMWCHAR * buffer); + +/****************************************************************************** + * FUNCTION + * vm_sso_get_credentials + * DESCRIPTION + * get the credentials of an account by its provider and account + * PARAMETERS + * provider: [IN] the provider id as in vm_sso_provider_struct.provider + * account: [IN] the account as in vm_sso_provider_struct.account + * buffer: [OUT] memory allocated by caller to hold the credentials of the account + * must be at least sizeof(vm_sso_credential_struct) bytes + * RETURNS + * success if 0, else failure. + ******************************************************************************/ +VMINT vm_sso_get_credentials(VMUINT32 provider, VMUINT8 account, vm_sso_credential_struct * buffer); + +/****************************************************************************** + * FUNCTION + * vm_sso_add_account + * DESCRIPTION + * launch plugin to prompt user for username/password in exchange for credentials + * PARAMETERS + * provider: [IN] the provider id as in vm_sso_provider_struct.provider + * username: [IN] username of account + * password: [IN] password of account + * callback: [IN] will be called when the operation is done, no matter success or failure + * user_data: [IN] user data to be pass along by the callback function + * RETURNS + * success if >= 0, else failure. + ******************************************************************************/ +VMINT vm_sso_add_account(VMUINT32 provider, const VMWCHAR * username, const VMWCHAR * password, vm_sso_account_callback callback, void * user_data); + +/****************************************************************************** + * FUNCTION + * vm_sso_login_account + * DESCRIPTION + * log in to an existing account which has been logged out + * PARAMETERS + * provider: [IN] the provider id as in vm_sso_provider_struct.provider + * account: [IN] the account as in vm_sso_provider_struct.account + * password: [IN] password of account, user needs to enter again + * callback: [IN] will be called when the operation is done, no matter success or failure + * user_data: [IN] user data to be pass along by the callback function + * RETURNS + * success if >= 0, else failure. + ******************************************************************************/ +VMINT vm_sso_login_account(VMUINT32 provider, VMUINT8 account, const VMWCHAR * password, vm_sso_account_callback callback, void * user_data); + +/****************************************************************************** + * FUNCTION + * vm_sso_logout_account + * DESCRIPTION + * logout account but still keep it for log-in later + * PARAMETERS + * provider: [IN] the provider id as in vm_sso_provider_struct.provider + * account: [IN] the account as in vm_sso_provider_struct.account + * callback: [IN] will be called when the operation is done, no matter success or failure + * user_data: [IN] user data to be pass along by the callback function + * RETURNS + * success if >= 0, else failure. + ******************************************************************************/ +VMINT vm_sso_logout_account(VMUINT32 provider, VMUINT8 account, vm_sso_result_callback callback, void * user_data); + +/****************************************************************************** + * FUNCTION + * vm_sso_del_account + * DESCRIPTION + * delete account and do the necessary clean-ups + * PARAMETERS + * provider: [IN] the provider id as in srv_sso_account_struct.provider + * account: [IN] the account as in srv_sso_account_struct.account + * callback: [IN] will be called when the operation is done, no matter success or failure + * user_data: [IN] user data to be pass along by the callback function + * RETURNS + * success if >= 0, else failure. + ******************************************************************************/ +VMINT vm_sso_del_account(VMUINT32 provider, VMUINT8 account, vm_sso_result_callback callback, void * user_data); + +/****************************************************************************** + * FUNCTION + * vm_sso_refresh_credentials + * DESCRIPTION + * ask plugin to refresh access token by using refresh token or extension + * PARAMETERS + * provider: [IN] the provider id as in srv_sso_account_struct.provider + * account: [IN] the account as in srv_sso_account_struct.account + * callback: [IN] will be called when the operation is done, no matter success or failure + * user_data: [IN] user data to be pass along by the callback function + * RETURNS + * success if >= 0, else failure. + ******************************************************************************/ +VMINT vm_sso_refresh_credentials(VMUINT32 provider, VMUINT8 account, vm_sso_result_callback callback, void * user_data); + +/****************************************************************************** + * FUNCTION + * vm_sso_cancel + * DESCRIPTION + * cancel an running operation + * PARAMETERS + * req_id: [IN] request id + * RETURNS + * success if 0, else failure. + ******************************************************************************/ +VMINT vm_sso_cancel(VMINT req_id); + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + + + +#endif /* VM_SSO_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmstatusbar.h b/hardware/arduino/mtk/system/libmtk/include/vmstatusbar.h new file mode 100644 index 00000000..8f19f7b6 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmstatusbar.h @@ -0,0 +1,269 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +#ifndef VMSTATUSBAR_SDK_H +#define VMSTATUSBAR_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" +#include "vmpromng.h" + +#ifndef MAX_APP_NAME_LEN +#define MAX_APP_NAME_LEN (260) +#endif + +/***************************************************************************** +* FUNCTION + * vm_pmng_apply_to_run_in_fg + * DESCRIPTION + * apply to foreground running for background running application by specified mode. + * PARAMETERS + * notify_type : [IN] notification mode, refer to VM_FG_NOTIFY_TYPE + * EXAMPLE [this TAG is optional] + * + * vm_pmng_apply_to_run_in_fg(VM_NOTIFY_TYPE_SOUND); //by sound mode + * + * +*****************************************************************************/ +VMINT vm_pmng_apply_to_run_in_fg(VMINT notify_type); + +/* DOM-NOT_FOR_SDK-BEGIN */ +void vm_graphic_status_icon_bar_hide_callback(void); +void vm_graphic_show_status_icon_bar(void); +void vm_graphic_reset_status_icon_bar(void); + +typedef struct mmi_mre_data +{ + VMUWSTR subText; + VMUWSTR timeText; + VMUSTR imageBuffer; +}mmi_mre_data; + +typedef enum mmi_mre_image_type +{ + MRE_IMAGE_TYPE_INVALID = 0, + MRE_IMAGE_TYPE_BMP = 1, + MRE_IMAGE_TYPE_GIF = 3, + MRE_IMAGE_TYPE_JPG = 9, + MRE_IMAGE_TYPE_PNG = 19, +}mmi_mre_image_type; + + +typedef struct vm_status_bar_icon_t +{ + VMINT icon_id; /**< ICON ID */ + VMINT pHandle; /**< ICON Handle */ + VMINT b_used; + VMWCHAR fullFilename[MAX_APP_NAME_LEN + 1]; /**< full file name of bg running app */ + VMUSTR image_buffer_show; /**< ICON Show Image */ + VMUSTR image_buffer_blink; /**< ICON BlinkImage */ + mmi_mre_data* ncenter_cell_buf; + struct vm_status_bar_icon_t* pNext; /**< next icon */ +}vm_status_bar_icon_t; +/* DOM-NOT_FOR_SDK-END */ + +typedef enum +{ + VM_ICON_SHOW=1 , /**< icon image is show */ + VM_ICON_BLINK, /**< icon image is blink */ + VM_ICON_NCENTER_CELL, /**< icon image is notification-center cell */ + VM_ICON_HIDE /**< icon image is hide */ +}VM_ICON_STATUS_TYPE; + +typedef struct vm_status_bar_icon_image_info +{ + VMUINT8 image_type; /**< image type such as BMP|PNG|JPEG|GIF */ + VMUINT image_frame_num; /**< how many frame does Image have */ + VMUINT image_size; /**< image size */ + VMUINT image_width; /**< image width */ + VMUINT image_height; /**< image height */ + VMUSTR image_data_buf; /**< pointer to image data buf */ +}VM_ICON_STATUS_ICON_IMAGE_INFO; + +typedef struct vm_status_bar_new_message_info +{ + VMUWSTR us_subText; /**< sub text */ + VMUWSTR us_timeText; /**< time text */ + VMINT subText_lenth; /**< sub text lenth */ + VMINT timeText_lenth; /**< time text lenth */ + VM_ICON_STATUS_ICON_IMAGE_INFO* uc_imageBuffer; /**< image data buf */ +}VM_NEW_MESSAGE_INFO; + +/***************************************************************************** +* FUNCTION + * vm_graphic_show_status_icon_bar + * DESCRIPTION + * normally MRE application is full screen ,this api will show status bar in + * application's screen + * PARAMETERS + * NULL + * EXAMPLE [this TAG is optional] + * + * vm_statusbar_new_message(&new_message); + * + * +*****************************************************************************/ +void vm_graphic_show_status_icon_bar(void); + +/***************************************************************************** +* FUNCTION + * vm_graphic_reset_status_icon_bar + * DESCRIPTION + * after called vm_graphic_show_status_icon_bar(),status bar will be shown. + * vm_graphic_reset_status_icon_bar() will hide status bar again. + * PARAMETERS + * NULL + * EXAMPLE [this TAG is optional] + * + * vm_statusbar_new_message(&new_message); + * + * +*****************************************************************************/ +void vm_graphic_reset_status_icon_bar(void); + +/***************************************************************************** +* FUNCTION + * vm_statusbar_new_message + * DESCRIPTION + * notify statusbar has a new message coming,detail will be in paramater of + * new_message_info. + * PARAMETERS + * new_message_info : [IN] new message content + * EXAMPLE [this TAG is optional] + * + * VM_NEW_MESSAGE_INFO new_message; + * new_message.us_subText = XXXX; + * new_message.us_timeText = XXXX; + * new_message.subText_lenth = XXXX; + * new_message.timeText_lenth = XXXX; + * new_message.uc_imageBuffer = XXXX; + * vm_statusbar_new_message(&new_message); + * + * +*****************************************************************************/ +VMINT vm_statusbar_new_message(VM_NEW_MESSAGE_INFO* new_message_info); + +/***************************************************************************** +* FUNCTION + * vm_statusbar_set_image + * DESCRIPTION + * set image of statusbar. + * PARAMETERS + * Status_type : [IN] notification mode, refer to VM_ICON_STATUS_TYPE + * VM_ICON_SHOW // icon image will be show + * VM_ICON_BLINK // icon image will be blink + * VM_ICON_NCENTER_CELL // icon image will be show on N-center cell + * VM_ICON_HIDE // icon image will be hide + * image_info : [IN] information of image. + * image_type; // image type. + * image_frame_num; // image frame number it should be 1,if it is a static image. + * image_size; // size of image. + * image_width; // width of image. + * image_height; // height of image + * image_data_buf; // image resource buffer. + * EXAMPLE [this TAG is optional] + * + * VM_ICON_STATUS_ICON_IMAGE_INFO image_icon_info; + * image_icon_info.image_type = XXXX; + * image_icon_info.image_frame_num = XXXX; + * image_icon_info.image_size = XXXX; + * image_icon_info.image_width = XXXX; + * image_icon_info.image_height = XXXX; + * image_icon_info.image_data_buf = XXXX; + * vm_statusbar_set_image(VM_ICON_SHOW,&image_icon_info); + * + * +*****************************************************************************/ +VMINT vm_statusbar_set_image(VM_ICON_STATUS_TYPE Status_type ,VM_ICON_STATUS_ICON_IMAGE_INFO*image_info); + +/***************************************************************************** +* FUNCTION + * vm_statusbar_set_image_ex + * DESCRIPTION + * set image of statusbar, and you can decide which notify type will be used. + * PARAMETERS + * Status_type : [IN] notification mode, refer to VM_ICON_STATUS_TYPE + * VM_ICON_SHOW // icon image will be show + * VM_ICON_BLINK // icon image will be blink + * VM_ICON_NCENTER_CELL // icon image will be show on N-center cell + * VM_ICON_HIDE // icon image will be hide + * image_info : [IN] information of image. + * image_type; // image type. + * image_frame_num; // image frame number it should be 1,if it is a static image. + * image_size; // size of image. + * image_width; // width of image. + * image_height; // height of image + * image_data_buf; // image resource buffer. + * notify_type : [IN] type of notification. + * VM_NOTIFY_TYPE_DEFAULT // by default mode (follow engine control) + * VM_NOTIFY_TYPE_SOUND // by sound mode + * VM_NOTIFY_TYPE_VIBRATILITY // by vibration mode + * EXAMPLE [this TAG is optional] + * + * VM_ICON_STATUS_ICON_IMAGE_INFO image_icon_info; + * image_icon_info.image_type = XXXX; + * image_icon_info.image_frame_num = XXXX; + * image_icon_info.image_size = XXXX; + * image_icon_info.image_width = XXXX; + * image_icon_info.image_height = XXXX; + * image_icon_info.image_data_buf = XXXX; + * vm_statusbar_set_image(VM_ICON_SHOW,&image_icon_info,VM_NOTIFY_TYPE_DEFAULT); + * + * +*****************************************************************************/ +VMINT vm_statusbar_set_image_ex( + VM_ICON_STATUS_TYPE status_type, + VM_ICON_STATUS_ICON_IMAGE_INFO *image_info, + VMINT notify_type); + +/****************************************************************************** + * FUNCTION + * vm_statusbar_get_height + * DESCRIPTION + * get the height of statusbar. + * PARAMETER + * void + * RETURNS + * the height (in pixels) of statusbar. + ******************************************************************************/ +VMINT vm_statusbar_get_height(void); + +#ifdef __cplusplus +} +#endif + +#endif /* VMSTATUSBAR_SDK_H */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmstdlib.h b/hardware/arduino/mtk/system/libmtk/include/vmstdlib.h new file mode 100644 index 00000000..9bfe4163 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmstdlib.h @@ -0,0 +1,681 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMSTDLIB_SDK_H_ +#define VMSTDLIB_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "vmsys.h" + +#define VM_CACHE_SIZE 4096 + + +#if defined(__COMPILER_RVCT__) || defined(__COMPILER_GCC__) +#undef vsprintf +#undef sprintf +#undef sscanf + +int vm_vsprintf(char *buf, const char *fmt, va_list args); +int vm_sprintf( char * buf, const char * fmt, ... ); +int vm_sscanf(const char *str, const char *format, ...); + +#define vsprintf vm_vsprintf +#define sprintf vm_sprintf +#define sscanf vm_sscanf +#endif + + +/** +* cache structure to transfer block io mode to stream io mode +*/ +struct vm_cache_t { + VMINT eof; /* end of stream */ + VMINT avail; /* data still available from stream */ + VMINT count; /* number of byte of remaining data from stream */ + VMUINT8 buf[VM_CACHE_SIZE]; /* data buffer */ +}; +typedef struct vm_cache_t vm_cache_t; + +/***************************************************************************** + * FUNCTION + * strtoi + * DESCRIPTION + * transfer a number format from string to integer. + * PARAMETERS + * s : [IN] string to be transfered. + * RETURNS + * result of transition. -1 means failed. + *****************************************************************************/ +int strtoi(char* s); + +/***************************************************************************** + * FUNCTION + * vm_get_filename + * DESCRIPTION + * get file name from full path. + * PARAMETERS + * path: [IN] full path string encoding with UCS2. + * filename : [OUT] output file name encoding with UCS2. + *****************************************************************************/ +void vm_get_filename(VMWSTR path, VMWSTR filename); + +/***************************************************************************** + * FUNCTION + * vm_get_path + * DESCRIPTION + * get file path from full path. + * PARAMETERS + * fullpath: [IN] full path string encoding with UCS2. + * path : [OUT] output file path encoding with UCS2. + * RETURNS + * 0 means successfully + *****************************************************************************/ +VMINT vm_get_path(VMWSTR fullpath, VMWSTR path); + +/* DOM-NOT_FOR_SDK-BEGIN */ +/***************************************************************************** + * FUNCTION + * get_today_from_2000 + * DESCRIPTION + * get the number of day from 2000/01/01 to now. + * RETURNS + * number of day, -1 means failed. + *****************************************************************************/ +VMINT get_today_from_2000(void); +/* DOM-NOT_FOR_SDK-END */ + +/***************************************************************************** + * FUNCTION + * vm_upper_case + * DESCRIPTION + * convert the lower case character to upper case character + * PARAMETERS + * dst : [OUT] output the upper case of string + * src : [IN] string to be converted. + *****************************************************************************/ +void vm_upper_case(char* dst, char* src); + +/***************************************************************************** + * FUNCTION + * vm_upper_case + * DESCRIPTION + * convert the upper case character to lower case character + * PARAMETERS + * dst: [OUT] output the lower case of string + * src : [IN] string to be converted. + *****************************************************************************/ +void vm_lower_case(char* dst, char* src); + +/***************************************************************************** + * FUNCTION + * vm_string_equals_ignore_case + * DESCRIPTION + * compare string without case sensitive + * PARAMETERS + * s1: [IN] the first string. + * s2 : [IN] the second string. + * RETURNS + * 0 means the two string are same, -1 means they are different. + *****************************************************************************/ +VMINT vm_string_equals_ignore_case(const char *s1, const char *s2); + +/***************************************************************************** + * FUNCTION + * vm_write_cache + * DESCRIPTION + * write data to cache by stream mode. + * PARAMETERS + * cache: [IN] cache pointer. + * buf : [IN] buffer address. + * buf_len : [IN] buffer length. + * RETURNS + * number of bytes written + *****************************************************************************/ +VMINT vm_write_cache(vm_cache_t *cache, void *buf, VMINT buf_len); + + /***************************************************************************** + * FUNCTION + * vm_read_cache + * DESCRIPTION + * read data from cache by stream mode. + * PARAMETERS + * cache: [IN] cache pointer. + * buf : [OUT] buffer address. + * buf_size : [IN] buffer size + * len : [IN] number of bytes to read. + * RETURNS + * number of bytes read + *****************************************************************************/ +VMINT vm_read_cache(vm_cache_t *cache, void *buf, VMINT buf_size, VMINT len); + + /***************************************************************************** + * FUNCTION + * vm_cache_read_char + * DESCRIPTION + * read a character from cache by stream mode. + * PARAMETERS + * cache: [IN] cache pointer. + * ch : [OUT] character. + * RETURNS + * 0 means succeed, else return error code. + *****************************************************************************/ +VMINT vm_cache_read_char(vm_cache_t *cache, char *ch); + + /***************************************************************************** + * FUNCTION + * vm_get_cache_free_space + * DESCRIPTION + * get free space of cache. + * PARAMETERS + * cache: [IN] cache pointer. + * RETURNS + * number of byte of free space + *****************************************************************************/ +VMINT vm_get_cache_free_space(vm_cache_t *cache); + + /***************************************************************************** + * FUNCTION + * vm_read_line + * DESCRIPTION + * read a line of string from cache. + * PARAMETERS + * line: [OUT] string pointer to read + * size : [IN] line buffer size + * cache : [IN] cache pointer. + * RETURNS + * 0 means succeed, else return error code. + *****************************************************************************/ +VMINT vm_read_line(char* line, VMINT size, vm_cache_t* cache); + +/* DOM-NOT_FOR_SDK-BEGIN */ +/***************************************************************************** +* FUNCTION +* vm_memcpy +* DESCRIPTION +* memory copy. +* PARAMETERS +* dst: [OUT] destination data buffer. +* src : [IN] source data buffer. +* count : [IN] number of byte to be copied. +*****************************************************************************/ +void vm_memcpy(void* dst, void* src, VMINT count); +/* DOM-NOT_FOR_SDK-END */ + +/** +* dynamic array +*/ +typedef struct _vm_dyn_array_t { +/** +* size of block. + */ + VMINT block_size; + + /** + * initial size. + */ + VMINT init_size; + + /** + * increased size. + */ + VMINT inc_size; + + /** + * count of saved block + */ + VMINT count; + + /** + * capacity of the array + */ + VMINT capacity; + + /** + *pointer of array + */ + void *ptr; +} vm_dyn_array_t; + +/***************************************************************************** + * FUNCTION + * vm_create_dyn_array + * DESCRIPTION + * create dynamic array. + * PARAMETERS + * init_size: [IN] initial size of dynamic array. + * inc_size : [IN] increased size each time + * block_size : [IN] structure size of data stored in the array + * RETURNS + * 0 means succeed, else return error code. + *****************************************************************************/ +vm_dyn_array_t* vm_create_dyn_array(VMINT init_size, VMINT inc_size, VMINT block_size); + +/***************************************************************************** + * FUNCTION + * vm_dyn_array_add + * DESCRIPTION + * add new data to the end of dynamic array . + * PARAMETERS + * array: [IN] array pointer. + * data : [IN] data to be added. + * RETURNS + * 0 means succeed, else return error code. + *****************************************************************************/ +VMINT vm_dyn_array_add(vm_dyn_array_t *array, void* data); + +/***************************************************************************** + * FUNCTION + * vm_dyn_array_del + * DESCRIPTION + * delete the data item of specified index of the array . + * PARAMETERS + * array: [IN] array pointer. + * idx : [IN] index to be deleted. + * RETURNS + * 0 means succeed, else return error code. + *****************************************************************************/ +VMINT vm_dyn_array_del(vm_dyn_array_t *array, VMINT idx); + +/***************************************************************************** + * FUNCTION + * vm_dyn_array_del_all + * DESCRIPTION + * delete all the data from the specified array . + * PARAMETERS + * array: [IN] array pointer. + * RETURNS + * 0 means succeed, else return error code. + *****************************************************************************/ +VMINT vm_dyn_array_del_all(vm_dyn_array_t *array); + +/***************************************************************************** + * FUNCTION + * vm_free_dyn_array + * DESCRIPTION + * free the memory of the dynamic array . + * PARAMETERS + * array: [IN] array pointer. + *****************************************************************************/ +void vm_free_dyn_array(vm_dyn_array_t *array); + +/** + * stack operation succeed + */ +#define STACK_OPERATE_SUCCESS (0) + +/** + * stack operation fail + */ +#define STACK_PARAM_ERROR (-1) + +/** + * stack operation fail for lack of resource + */ +#define STACK_LEAK_RESOUCE (-2) + +/** + * stack push fail for overflow + */ +#define STACK_PUSH_OVERFLOW (-3) + +/** +* stack pop fail for empty stack +*/ +#define STACK_OPERATE_EMPTY_STACK (-4) + +/** + * stack operation fail for handler error + */ +#define STACK_HANDLE_ERROR (-5) + +/***************************************************************************** + * FUNCTION + * vm_create_array_stack + * DESCRIPTION + * create an array stack, when not use this, please use vm_destory_stack to destroy it. + * PARAMETERS + * capability : [IN] stack's capability. + * handle : [OUT] the handle of stack. + * RETURNS + * create an array stack success or not. + * RETURN VALUES + * STACK_OPERATE_SUCCESS : create stack success. + * STACK_PARAM_ERROR : parameter is wrong. + * STACK_LEAK_RESOUCE : resource error. + *****************************************************************************/ +VMINT vm_create_array_stack(VMINT capability, VMINT* handle); + + +/***************************************************************************** + * FUNCTION + * vm_create_linked_stack + * DESCRIPTION + * create an linked stack, memory will dynamicly allocate,when not use this, please use vm_destory_stack to destroy it. + * PARAMETERS + * capability : [IN] stack's capability. + * handle : [OUT] the handle of stack. + * RETURNS + * create an linked stack success or not. + * RETURN VALUES + * STACK_OPERATE_SUCCESS : create stack success. + * STACK_PARAM_ERROR : parameter is wrong. + * STACK_LEAK_RESOUCE : resource error. + *****************************************************************************/ +VMINT vm_create_linked_stack(VMINT capability, VMINT* handle); + + +/***************************************************************************** + * FUNCTION + * vm_is_empty_stack + * DESCRIPTION + * check stack empty or not. + * PARAMETERS + * stackHandle : [IN] stack's handle when created by vm_create_linked_stack. + * RETURNS + * stack empty or not. + * RETURN VALUES + * FALSE : stack is not empty. + * TRUE : stack is empty. + *****************************************************************************/ +VMINT vm_is_empty_stack(VMINT stackHandle); + + +/***************************************************************************** + * FUNCTION + * vm_push_stack + * DESCRIPTION + * push data to stack. + * PARAMETERS + * stackHandle : [IN] stack's handle. + * ptr : [IN] data for pushing. + * RETURNS + * push data to stack success or not. + * RETURN VALUES + * STACK_OPERATE_SUCCESS : push data success. + * STACK_PUSH_OVERFLOW : stack is full. + * STACK_LEAK_RESOUCE : memory is not enough. + * STACK_HANDLE_ERROR : stackHandle is wrong. + *****************************************************************************/ +VMINT vm_push_stack(VMINT stackHandle, void* ptr); + + +/***************************************************************************** + * FUNCTION + * vm_popup_stack + * DESCRIPTION + * popup data from stack. + * PARAMETERS + * stackHandle : [IN] stack's handle. + * ptr : [OUT] data get from stack. + * RETURNS + * popup data success or not. + * RETURN VALUES + * STACK_OPERATE_SUCCESS : popup data success. + * STACK_OPERATE_EMPTY_STACK : stack is empty. + * STACK_HANDLE_ERROR : stackHandle is wrong. + *****************************************************************************/ +VMINT vm_popup_stack(VMINT stackHandle, void** ptr); + + +/***************************************************************************** + * FUNCTION + * vm_peek_stack + * DESCRIPTION + * get next data from stack but not popup. + * PARAMETERS + * stackHandle : [IN] stack's handle. + * ptr : [OUT] data get from stack. + * RETURNS + * get next data from stack success or not. + * RETURN VALUES + * STACK_OPERATE_SUCCESS : popup data success. + * STACK_OPERATE_EMPTY_STACK : stack is empty. + * STACK_HANDLE_ERROR : stackHandle is wrong. + *****************************************************************************/ +VMINT vm_peek_stack(VMINT stackHandle, void** ptr); + + +/***************************************************************************** + * FUNCTION + * vm_reset_stack + * DESCRIPTION + * clear all stack's data. + * PARAMETERS + * stackHandle : [IN] stack's handle. + * RETURNS + * clear all stack's data success or not. + * RETURN VALUES + * STACK_OPERATE_SUCCESS : clear data success. + * STACK_HANDLE_ERROR : stackHandle is wrong. + *****************************************************************************/ +VMINT vm_reset_stack(VMINT stackHandle); + + +/***************************************************************************** + * FUNCTION + * vm_is_exist_stack + * DESCRIPTION + * check data in or not in stack. + * PARAMETERS + * stackHandle : [IN] stack's handle. + * ptr : [IN] data. + * RETURNS + * return data in or not in stack. + * RETURN VALUES + * TRUE : in stack. + * FALSE : not in stack. + *****************************************************************************/ +VMINT vm_is_exist_stack(VMINT stackHandle, void* ptr); + + +/***************************************************************************** + * FUNCTION + * vm_destroy_stack + * DESCRIPTION + * check data in or not in stack. + * PARAMETERS + * stackHandle : [IN] stack's handle. + * RETURNS + * destroy stack success or not. + * RETURN VALUES + * STACK_OPERATE_SUCCESS : destroy stack success. + * STACK_HANDLE_ERROR : stackHandle is wrong. + *****************************************************************************/ +VMINT vm_destroy_stack(VMINT stackHandle); + +/***************************************************************************** + * FUNCTION + * vm_ends_with + * DESCRIPTION + * check specified string is end with specified string + * PARAMETERS + * s1 : [IN] string to check + * s2 : [IN] ending string + * RETURNS + * 0 if s1 ended with s2, else return others. + *****************************************************************************/ +VMINT vm_ends_with(const char *s1, const char *s2); + +/***************************************************************************** + * FUNCTION + * vm_ends_with + * DESCRIPTION + * check specified string is end with specified string, and both of the two strings are encoding with UCS2 + * PARAMETERS + * s1 : [IN] string to check + * s2 : [IN] ending string + * RETURNS + * 0 if s1 ended with s2, else return others. + *****************************************************************************/ +VMINT vm_wends_with(const VMWSTR s1, const VMWSTR s2); + +/* DOM-NOT_FOR_SDK-BEGIN */ +/***************************************************************************** + * FUNCTION + * vm_tmp_filename + * DESCRIPTION + * generate a temp file name which will be unique. + * PARAMETERS + * prefix : [IN] prefix to temp file name, normally is path. + * filename : [OUT] temp file name length is 128 including '\0'. + *****************************************************************************/ +void vm_tmp_filename(char* prefix, char* filename); +/* DOM-NOT_FOR_SDK-END */ + +/***************************************************************************** + * FUNCTION + * vm_safe_wstrcpy + * DESCRIPTION + * safe wstrcpy. When destination buffer is not enough, the extra part will be cut. + * PARAMETERS + * dest : [OUT] destination string. + * size : [IN] length of string. + * src : [IN] source string. + * RETURNS + * length of string copied actually. + *****************************************************************************/ +VMINT vm_safe_wstrcpy(VMWSTR dest, VMINT size, VMWSTR src); + +#define wstrlen vm_wstrlen +/***************************************************************************** + * FUNCTION + * vm_wstrcpy + * DESCRIPTION + * get the length of UCS2 string. + * PARAMETERS + * s : [IN] string to be checked teminated with '\0'. + * RETURNS + * length of string. + *****************************************************************************/ +VMINT vm_wstrlen(VMWSTR s); + +#define wstrcpy vm_wstrcpy +/***************************************************************************** + * FUNCTION + * vm_wstrcpy + * DESCRIPTION + * UCS2 string copy + * PARAMETERS + * dest : [OUT] destination string. + * src : [IN] source string. + * RETURNS + * length of string copied actually. + *****************************************************************************/ +VMINT vm_wstrcpy(VMWSTR dst, const VMWSTR src); + +#define wstrcat vm_wstrcat +/***************************************************************************** + * FUNCTION + * vm_wstrcat + * DESCRIPTION + * UCS2 string append. + * PARAMETERS + * dest : [OUT] destination string. + * src : [IN] source string. + *****************************************************************************/ +VMINT vm_wstrcat(VMWSTR dst, const VMWSTR src); + +#define wstrncpy vm_wstrncpy +/***************************************************************************** + * FUNCTION + * vm_wstrncpy + * DESCRIPTION + * UCS2 string N copy + * PARAMETERS + * dest : [OUT] destination string. + * src : [IN] source string. + * length : [IN] lenth of string to be copied. + * RETURNS + * length of string copied actually. + *****************************************************************************/ +VMINT vm_wstrncpy(VMWSTR dst, const VMWSTR src, VMINT length); + +#define wstrcmp vm_wstrcmp + +/***************************************************************************** + * FUNCTION + * vm_wstrcmp + * DESCRIPTION + * UCS2 string compare + * PARAMETERS + * str_1 : [IN] string 1 + * str_2 : [IN] string 2 + * RETURNS + * 0 means the two string are same, non-zero means they are different. + *****************************************************************************/ +VMINT vm_wstrcmp(VMWSTR str_1, VMWSTR str_2); + +/* DOM-NOT_FOR_SDK-BEGIN */ +/***************************************************************************** + * FUNCTION + * vm_wstrcmp_ignore_case + * DESCRIPTION + * UCS2 string compare without case sensitive + * PARAMETERS + * str_1 : [IN] string 1 + * str_2 : [IN] string 2 + * RETURNS + * 0 means the two string are same, non-zero means they are different. + *****************************************************************************/ +VMINT vm_wstrcmp_ignore_case(VMWSTR str_1, VMWSTR str_2); +/* DOM-NOT_FOR_SDK-END */ + +/***************************************************************************** + * FUNCTION + * vm_wstarts_with + * DESCRIPTION + * check specified string is started with specified string, and both of the two strings are encoding with UCS2 + * PARAMETERS + * s1 : [IN] string to check + * s2 : [IN] starting string + * RETURNS + * 0 if s1 start with s2, else return others. + *****************************************************************************/ +VMINT vm_wstarts_with(VMWSTR a, VMWSTR b); + +VMINT vm_vwsprintf(VMWSTR outstr, VMINT size, const VMWSTR fmt, va_list args); +VMINT vm_wsprintf(VMWSTR outstr, VMINT size, const VMWSTR fmt, ...); + + +#ifdef __cplusplus +} +#endif + +#endif /* VMSTDLIB_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmstream.h b/hardware/arduino/mtk/system/libmtk/include/vmstream.h new file mode 100644 index 00000000..1b64928d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmstream.h @@ -0,0 +1,172 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMSTREAM_SDK_H_ +#define VMSTREAM_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +#define VM_STREAM_MAX_PROXY_ADDR_LEN (63) +#define VM_STREAM_MAX_IP_LEN 4 + +/* stream scenario enum */ +typedef enum +{ + VM_STREAM_DECODER, // not used + VM_STREAM_QVGA, // not used + VM_STREAM_PREVIEW, // not used + VM_STREAM_CIF, // not used + VM_STREAM_INFO, // not used + VM_STREAM_MPEG4_DECODER, // not used + VM_STREAM_DECODER_N_SUBTITLE, // not used + VM_STREAM_UPTO_QVGA, // not used + VM_STREAM_UPTO_CIF, // not used + VM_STREAM_QVGA_MPEG4SP, // not used + VM_STREAM_MAX_SCENARIO = 0xFF +}vm_stream_scenario_enum; + +/* stream connect struct */ +typedef struct +{ + VMUINT8 session_id; // not used + VMUINT16 request_id; // not used + VMUINT32 net_id; // not used + VMUINT8 type; // not used + VMBOOL use_proxy; // not used + VMUINT8 proxy_addr[VM_STREAM_MAX_PROXY_ADDR_LEN]; // not used + VMUINT16 proxy_port; // not used + VMUINT16 lowest_udp_port; // not used + VMUINT16 highest_udp_port; // not used + vm_stream_scenario_enum scenario; // not used + VMUINT16 prefer_transport; // not used + VMUINT8 host_ip[VM_STREAM_MAX_IP_LEN]; // remote IP, format is like host_ip[0] = 127; host_ip[1] = 0; host_ip[2] = 0; host_ip[3] = 1 + VMUINT8 local_ip[VM_STREAM_MAX_IP_LEN]; // local IP , format is like local_ip[0] = 127; host_ip[1] = 0; host_ip[2] = 0; host_ip[3] = 1 + VMUINT16 host_port; // remote port + VMUINT16 local_port; // local port + +}vm_stream_connect_struct; + +/* volume type */ +typedef enum +{ + VM_STREAM_VOLUME_MIC, /* microphone */ + VM_STREAM_VOLUME_MEDIA, /* Multi-Media */ + VM_STREAM_MAX_VOLUME_TYPE +}vm_stream_volume_enum; + +/* Audio volume level enum for 7 level volume */ +typedef enum +{ + VM_STREAM_VOL_0, /* Volume level 0 (Not mute) */ + VM_STREAM_VOL_1, /* Volume level 1 */ + VM_STREAM_VOL_2, /* Volume level 2 */ + VM_STREAM_VOL_3, /* Volume level 3 */ + VM_STREAM_VOL_4, /* Volume level 4 */ + VM_STREAM_VOL_5, /* Volume level 5 */ + VM_STREAM_VOL_6, /* Volume level 6 */ + VM_STREAM_VOL_NUM /* Total volume level */ +}vm_stream_mic_vol_enum; + +/* Audio volume level enum for 16 level volume */ +typedef enum +{ + VM_STREAM_VOL_EX_0, /* Volume level 0 (Not mute) */ + VM_STREAM_VOL_EX_1, /* Volume level 1 */ + VM_STREAM_VOL_EX_2, /* Volume level 2 */ + VM_STREAM_VOL_EX_3, /* Volume level 3 */ + VM_STREAM_VOL_EX_4, /* Volume level 4 */ + VM_STREAM_VOL_EX_5, /* Volume level 5 */ + VM_STREAM_VOL_EX_6, /* Volume level 6 */ + VM_STREAM_VOL_EX_7, /* Volume level 7 */ + VM_STREAM_VOL_EX_8, /* Volume level 8 */ + VM_STREAM_VOL_EX_9, /* Volume level 9 */ + VM_STREAM_VOL_EX_10, /* Volume level 10 */ + VM_STREAM_VOL_EX_11, /* Volume level 11 */ + VM_STREAM_VOL_EX_12, /* Volume level 12 */ + VM_STREAM_VOL_EX_13, /* Volume level 13 */ + VM_STREAM_VOL_EX_14, /* Volume level 14 */ + VM_STREAM_VOL_EX_15, /* Volume level 15 */ + VM_STREAM_VOL_EX_NUM /* Total volume level */ +}vm_stream_media_vol_enum; + + + +/***************************************************************************** + * FUNCTION + * vm_stream_connect + * DESCRIPTION + * connect by remote device external IP/port and current device local IP/port + * PARAMETERS + * connect_info : [IN] please refer the structure vm_stream_connect_struct + * RETURNS + * stream handle / failure + *****************************************************************************/ +VMINT vm_stream_connect(vm_stream_connect_struct connect_info); + + +/***************************************************************************** + * FUNCTION + * vm_stream_disconnect + * DESCRIPTION + * disconnect session + * PARAMETERS + * session_id : [IN] not used, default: 0 + * RETURNS + * stream handle / failure + *****************************************************************************/ +VMINT vm_stream_disconnect(VMUINT8 session_id); + +/***************************************************************************** + * FUNCTION + * vm_stream_set_volume + * DESCRIPTION + * set loudspeaker volume + * PARAMETERS + * type : [IN]please refer vm_stream_volume_enum + * value : [IN] volume level refer vm_stream_mic_vol_enum/vm_stream_media_vol_enum + * RETURNS + * + *****************************************************************************/ +void vm_stream_set_volume(vm_stream_volume_enum type, VMUINT value); + +#ifdef __cplusplus +} +#endif + +#endif /* VMSTREAM_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmsys.h b/hardware/arduino/mtk/system/libmtk/include/vmsys.h new file mode 100644 index 00000000..54dcae7e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmsys.h @@ -0,0 +1,330 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMSYS_SDK_H_ +#define VMSYS_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef TRUE +#define TRUE 1 /*1*/ +#endif + +#ifndef FALSE +#define FALSE 0/*0*/ +#endif + +#ifndef NULL +#define NULL 0/*0*/ +#endif + + +/* start LinkIt environment normally */ +#define VM_NORMAL_START_MRE_ENV 1 + + +typedef unsigned char VMUINT8;/*unsigned char*/ +typedef unsigned short VMUINT16;/*unsigned short*/ +typedef unsigned int VMUINT;/*unsigned int*/ +typedef unsigned long VMUINT32;/*unsigned long*/ + + +typedef unsigned long long VMUINT64 ;/*unsigned long long*/ +typedef long long VMINT64 ;/*long long*/ + + +typedef char VMINT8;/*char*/ +typedef short VMINT16;/*short*/ +typedef int VMINT;/*int */ +typedef long VMINT32;/*long */ + +typedef VMUINT8 VMUCHAR;/*VMUINT8*/ +typedef VMUINT16 VMUWCHAR;/*VMUINT16*/ +typedef VMUINT8 * VMUSTR;/*VMUINT8 * */ +typedef VMUINT16 * VMUWSTR;/*VMUINT16 * */ + +typedef VMINT8 VMCHAR;/*VMINT8*/ +typedef VMINT16 VMWCHAR;/*VMINT16*/ +typedef VMINT8 * VMSTR;/* VMINT8 * */ +typedef VMINT16 * VMWSTR;/* VMINT16 * */ + +typedef unsigned char VMBYTE;/*unsigned char*/ +typedef unsigned short VMUSHORT;/*unsigned short*/ +typedef short VMSHORT;/*short*/ + +typedef VMINT VMFILE;/*VMINT*/ +typedef VMINT VMBOOL;/*VMINT*/ +#include "vmdatetime.h" +#include "vmuimisc.h" +#include "vmpwr.h" +#include "vmota.h" +#include "vmappmgr.h" +#include "vmpromng.h" +/*the statistic of memory using status */ +typedef struct malloc_stat_t { + /* the number if the malloc memory API is called, including vm_malloc(),vm_realloc(), * vm_calloc() */ + VMINT malloc_count; + + /*the number of free memory API is called */ + VMINT free_count; + + /*current used memory */ + VMINT current; + + /*peak memory*/ + VMINT peak; + + /*the number of memory malloc fail*/ + VMINT fail_times; + + /* the max size that malloc memory failed */ + VMINT max_fail_size; + + /* current avail heap size */ + VMINT avail_heap_size; +} malloc_stat_t; + + + +typedef VMUINT32 VMCOLOR32;/*VMUINT32*/ + +typedef float VMFLOAT;/*float*/ + +typedef VMINT32 VMMSEC;/*VMINT32*/ + +typedef VMINT32 VMRESID;/*VMINT32*/ + +typedef VMINT32 VMID;/*VMINT32*/ + +#define VM_TRUE TRUE/*VM_TRUE*/ +#define VM_FALSE FALSE/*VM_FALSE*/ + +/* DOM-NOT_FOR_SDK-BEGIN */ +/***************************************************************************** + * FUNCTION + * vm_get_malloc_stat + * DESCRIPTION + * get current memory management data after the memory management is available + * PARAMETERS + * void + * RETURNS + * the memory status structure pointer + *****************************************************************************/ +malloc_stat_t* vm_get_malloc_stat(void); +/* DOM-NOT_FOR_SDK-END */ + +/***************************************************************************** +* FUNCTION + * vm_malloc + * DESCRIPTION + * allocate specified size of memory + * PARAMETERS + * size : [IN] size of byte to be allocated. + * RETURNS + * memory pointer allocated, NULL means allocation failed. +*****************************************************************************/ +void *vm_malloc(int size); + +/***************************************************************************** +* FUNCTION + * vm_calloc + * DESCRIPTION + * allocate specified size of memory and clean as zero. + * PARAMETERS + * size : [IN] size of byte to be allocated. + * RETURNS + * memory pointer allocated, NULL means allocation failed. +*****************************************************************************/ +void *vm_calloc(int size); + +/***************************************************************************** +* FUNCTION + * vm_realloc + * DESCRIPTION + * reallocate specified size of memory for the memory already allocated before. + * PARAMETERS + * p : [IN] memory pointer to be realloced. + * size : [IN] size of byte to be allocated. + * RETURNS + * memory pointer allocated; NULL means allocation failed, but the original pointer will not free. +*****************************************************************************/ +void *vm_realloc(void* p, int size); + +/***************************************************************************** +* FUNCTION + * vm_free + * DESCRIPTION + * free memory allocated by vm_malloc(), vm_calloc(), or vm_realloc(). + * PARAMETERS + * ptr : [IN] memory pointer to be free. +*****************************************************************************/ +void vm_free(void* ptr); + +/* DOM-NOT_FOR_SDK-BEGIN */ +/***************************************************************************** +* FUNCTION + * vm_global_malloc + * DESCRIPTION + * allocate extra memory excluding the size announced when packing, size must larger than 10KB. + * PARAMETERS + * size : [IN] size of byte to be allocated. + * RETURNS + * memory pointer allocated, NULL means allocation failed. +*****************************************************************************/ +void *vm_global_malloc(unsigned int size); +/***************************************************************************** +* FUNCTION + * vm_free + * DESCRIPTION + * free memory allocated by vm_global_malloc(); + * PARAMETERS + * ptr : [IN] memory pointer to be free. +*****************************************************************************/ +void vm_global_free(void* ptr); + +/***************************************************************************** +* FUNCTION + * vm_global_get_max_alloc_size + * DESCRIPTION + * Get the max possible size of single allocation from app-based ASM. + * + * Remark: we can use this function to dynamically decide the allocation size + * (for example, use larger image cache when there is more memory) + * + * However, sometimes we cannot allocate 2 * 10KB blocks if the maximum allocation size + * is 20KB because of the overheads of memory management bookkeeping. + * + * It is suggested to use "fail-safe" allocation regardless the internal + * implementation of ASM if we want to allocate more memory adaptively according + * to the free space + * Step 1. Decide the size of free space => e.g. 100KB + * Step 2. Allocate 100KB + * Step 3. If failed, allocate 95 KB + * Step 4. If failed, allocate 90 KB + * Step 5. ... + * PARAMETERS + * void + * RETURNS + * memory size +*****************************************************************************/ +VMINT vm_global_get_max_alloc_size(void); + +/***************************************************************************** +* FUNCTION + * vm_malloc + * DESCRIPTION + * allocate non-cacheable memory + * PARAMETERS + * size : [IN] size of byte to be allocated. + * RETURNS + * memory pointer allocated, NULL means allocation failed. +*****************************************************************************/ +void *vm_malloc_nc(int size); +/***************************************************************************** +* FUNCTION + * vm_malloc_nc_topmost + * DESCRIPTION + * allocate specified size of non-cachable memory from topmost address + * PARAMETERS + * size : [IN] size of byte to be allocated. + * RETURNS + * memory pointer allocated, NULL means allocation failed. +*****************************************************************************/ +void *vm_malloc_nc_topmost(int size); + +typedef enum +{ + VM_SLA_STOP, + VM_SLA_START, + VM_SLA_LABEL +} vm_sla_action_type; + +/***************************************************************************** +* FUNCTION + * vm_sla_custom_logging + * DESCRIPTION + * SWLA custom logging function + * PARAMETERS + * custom_label : [IN] the custom label. + * action : [IN] the logging action +*****************************************************************************/ +void vm_sla_custom_logging(VMSTR custom_label, vm_sla_action_type action); + +#define vm_get_mre_total_mem_size vm_get_total_mem_size +/* DOM-NOT_FOR_SDK-END */ + +/***************************************************************************** + * FUNCTION + * vm_get_total_mem_size + * DESCRIPTION + * get LinkIt total memory size + * PARAMETERS + * + * RETURNS + * memory size + *****************************************************************************/ +VMUINT vm_get_total_mem_size(void); + +/***************************************************************************** +* FUNCTION + * vm_malloc_nc_topmost + * DESCRIPTION + * allocate specified size of memory from topmost address + * PARAMETERS + * size : [IN] size of byte to be allocated. + * RETURNS + * memory pointer allocated, NULL means allocation failed. +*****************************************************************************/ +void *vm_malloc_topmost(int size); + +/***************************************************************************** +* FUNCTION + * vm_malloc_nc_topmost + * DESCRIPTION + * re-allocate specified size of memory from topmost address + * PARAMETERS + * size : [IN] size of byte to be allocated. + * RETURNS + * memory pointer allocated, NULL means allocation failed. +*****************************************************************************/ +void *vm_realloc_topmost(void * p,int size); + +#ifdef __cplusplus +} +#endif + +#endif /* VMSYS_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmtcp.h b/hardware/arduino/mtk/system/libmtk/include/vmtcp.h new file mode 100644 index 00000000..71c618d1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmtcp.h @@ -0,0 +1,961 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMTCP_SDK_H +#define VMTCP_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/* tcp connected */ +#define VM_TCP_EVT_CONNECTED 1 + +/* write status */ +#define VM_TCP_EVT_CAN_WRITE 2 + +/* read status */ +#define VM_TCP_EVT_CAN_READ 3 + +/* broken status */ +#define VM_TCP_EVT_PIPE_BROKEN 4 + +/* not find host */ +#define VM_TCP_EVT_HOST_NOT_FOUND 5 + +/* tcp pipe closed */ +#define VM_TCP_EVT_PIPE_CLOSED 6 + +/* no enough resource to create tcp connection */ +#define VM_TCP_ERR_NO_ENOUGH_RES -1 + +/* create tcp connection failed */ +#define VM_TCP_ERR_CREATE_FAILED -2 + +/* use cmnet to connect */ +#define VM_TCP_APN_CMNET (1) + +/* use cmwap to connect */ +#define VM_TCP_APN_CMWAP (2) + +/* use wifi to connect */ +#define VM_TCP_APN_WIFI (3) + +/* only use cmnet to connect */ +#define VM_TCP_APN_CMNET_ONLY (4) + +/* only use cmwap to connect */ +#define VM_TCP_APN_CMWAP_ONLY (5) + +/* only use when conbined with vm_dtacct_set */ +//#define VM_APN_USER_DEFINE (6) + +/* wifi hot spot account id */ +#define VM_APN_WIFI_HS (7) + +/* wifi ap mode account id */ +#define VM_APN_AP_MODE (8) + + + + +/***************************************************************************** + * FUNCTION + * vm_tcp_connect + * DESCRIPTION + * create tcp connection. + * PARAMETERS + * host : [IN] dest host ip. + * port : [IN] dest host port. + * apn : [IN] apn id, only support VM_TCP_APN_CMNET,VM_TCP_APN_CMWAP,VM_TCP_APN_WIFI. + * callback : [IN] callback function for tcp connection. + * RETURNS + * create tcp success or not. + * RETURN VALUES + * tcp handle, if value >=0, that is right, else is wrong + * EXAMPLE + * + * static VMINT g_hl_tcp_hd; + * void hl_tcp_connect(void) + * { + * vm_enable_proxy(FALSE); + * g_hl_tcp_hd = vm_tcp_connect("www.mediatek.com", 80, VM_TCP_APN_CMNET, hl_tcp_conn_cb); + * } + * +*****************************************************************************/ +VMINT vm_tcp_connect(const char* host, const VMINT port, const VMINT apn, + void (*callback)(VMINT handle, VMINT event)); + +/***************************************************************************** + * FUNCTION + * vm_tcp_connect + * DESCRIPTION + * create tcp connection. + * PARAMETERS + * host : [IN] dest host ip. + * port : [IN] dest host port. + * apn : [IN] apn id, only support VM_TCP_APN_CMNET,VM_TCP_APN_CMWAP,VM_TCP_APN_WIFI. + * user_data : [IN] user_data. + * callback : [IN] callback function for tcp connection. + * RETURNS + * create tcp success or not. + * RETURN VALUES + * tcp handle, if value >=0, that is right, else is wrong + * EXAMPLE + * + * static VMINT g_hl_tcp_hd; + * void hl_tcp_conn_cb_ex(VMINT handle, VMINT event, void* user_data) + * { + * char* my_data = (char*)user_data; + * switch (event) + * { + * case VM_TCP_EVT_CONNECTED: + * vm_tcp_close(handle); + * return; + * default: + * return; + * } + * } + * void hl_tcp_connect(void) + * { + * char* my_data; + * my_data = (char*)vm_malloc(10); + * strcpy(my_data, "aa"); + * vm_enable_proxy(FALSE); + * g_hl_tcp_hd = vm_tcp_connect_ex("www.mediatek.com", 80, VM_TCP_APN_CMNET, (void*)my_data, hl_tcp_conn_cb_ex); + * } + * +*****************************************************************************/ +VMINT vm_tcp_connect_ex(const char* host, const VMINT port, const VMINT apn, void *user_data, + void (*callback)(VMINT handle, VMINT event, void *user_data)); + + +/***************************************************************************** + * FUNCTION + * vm_tcp_close + * DESCRIPTION + * close tcp connection. + * PARAMETERS + * handle : [IN] tcp handle. + * EXAMPLE + * + * void hl_tcp_conn_cb(VMINT handle, VMINT event) + * { + * switch (event) + * { + * case VM_TCP_EVT_CONNECTED: + * vm_tcp_close(handle); + * return; + * default: + * return; + * } + * } + * +*****************************************************************************/ +void vm_tcp_close(VMINT handle); + +#define VM_TCP_READ_EOF (-1) + +/***************************************************************************** + * FUNCTION + * vm_tcp_read + * DESCRIPTION + * read data from tcp connection. + * PARAMETERS + * handle : [IN] tcp handle. + * buf : [OUT] data buffer. + * len : [OUT] data length. + * RETURNS + * read data size. + * RETURN VALUES + * read size, if value = VM_TCP_READ_EOF, means finishing reading. + * EXAMPLE + * + * void hl_tcp_conn_cb(VMINT handle, VMINT event) + * { + * char buf[100]; + * VMINT nread, nwrite; + * switch (event) + * { + * case VM_TCP_EVT_CONNECTED: + * nwrite = vm_tcp_write( + * handle, + * "GET www.mediatek.com HTTP/1.1\r\nHost: www.mediatek.com\r\n\r\n", + * strlen("GET www.mediatek.com HTTP/1.1\r\nHost: www.mediatek.com\r\n\r\n")); + * break; + * case VM_TCP_EVT_CAN_READ: + * memset(buf, 0, 100); + * nread = vm_tcp_read(handle, buf, 100); + * vm_tcp_close(handle); + * return; + * default: + * return; + * } + * return; + * } + * +*****************************************************************************/ +VMINT vm_tcp_read(VMINT handle, void* buf, VMINT len); + +/***************************************************************************** + * FUNCTION + * vm_tcp_write + * DESCRIPTION + * write data to tcp connection. + * PARAMETERS + * handle : [IN] tcp handle. + * buf : [IN] data to write. + * len : [IN] data length. + * RETURNS + * write data success or not. + * RETURN VALUES + * if value >= 0 , it is right, else is wrong. + * EXAMPLE + * + * void hl_tcp_conn_cb(VMINT handle, VMINT event) + * { + * VMINT nwrite; + * switch (event) + * { + * case VM_TCP_EVT_CONNECTED: + * nwrite = vm_tcp_write( + * handle, + * "GET www.mediatek.com HTTP/1.1\r\nHost: www.mediatek.com\r\n\r\n", + * strlen("GET www.mediatek.com HTTP/1.1\r\nHost: www.mediatek.com\r\n\r\n")); + * break; + * default: + * return; + * } + * return; + * } + * +*****************************************************************************/ +VMINT vm_tcp_write(VMINT handle, void* buf, VMINT len); + +VMINT vm_tcp_get_soc_id(VMINT hdl); + +/***************************************************************************** + * FUNCTION + * vm_tcp_connect_sync + * DESCRIPTION + * create tcp connection. + * PARAMETERS + * pi: [IN] dest host ip. format is "123.123.123.123" + * port : [IN] dest host port. + * apn : [IN] apn id. + * RETURNS + * create tcp success or not. + * RETURN VALUES + * tcp handle, if value >=0, that is right, else is wrong + * EXAMPLE + * + * static VMINT g_tcp_sync_hd; + * void hl_tcp_sync(void) + * { + * g_tcp_sync_hd = vm_tcp_connect_sync("172.21.90.164", 80, VM_TCP_APN_CMNET); + * } + * +*****************************************************************************/ +VMINT vm_tcp_connect_sync(const char* ip, const VMINT port, VMINT apn); +/***************************************************************************** + * FUNCTION + * vm_tcp_read_sync + * DESCRIPTION + * read data from tcp connection. + * PARAMETERS + * handle : [IN] tcp handle. + * buf : [OUT] data buffer. + * len : [OUT] data length. + * RETURNS + * read data size. + * RETURN VALUES + * read size, if value = VM_TCP_READ_EOF, means finishing reading. + * EXAMPLE + * + * static VMINT g_tcp_sync_hd; + * void hl_tcp_sync(void) + * { + * VMINT read_data; + * VMBYTE buf[1024]; + * VMINT ret; + * g_tcp_sync_hd = vm_tcp_connect_sync("172.21.90.164", 80, VM_TCP_APN_CMNET); + * read_data = vm_tcp_read_sync(g_tcp_sync_hd, buf, 1024); + * ret = vm_tcp_close_sync(g_tcp_sync_hd); + * } + * +*****************************************************************************/ +VMINT vm_tcp_read_sync(VMINT handle, void* buf, VMINT len); +/***************************************************************************** + * FUNCTION + * vm_tcp_write_sync + * DESCRIPTION + * write data to tcp connection. + * PARAMETERS + * handle : [IN] tcp handle. + * buf : [IN] data to write. + * len : [IN] data length. + * RETURNS + * write data success or not. + * RETURN VALUES + * if value >= 0 , it is right, else is wrong. + * EXAMPLE + * + * static VMINT g_tcp_sync_hd; + * #define send ("GET / HTTP/1.1\r\nHost: www.mediatek.com:80\r\n\r\n") + * void hl_tcp_sync(void) + * { + * VMINT read_data; + * VMINT ret; + * g_tcp_sync_hd = vm_tcp_connect_sync("172.21.90.164", 80, VM_TCP_APN_CMNET); + * ret = vm_tcp_write_sync(g_tcp_sync_hd, send, strlen(send)); + * ret = vm_tcp_close_sync(g_tcp_sync_hd); + * } + * +*****************************************************************************/ +VMINT vm_tcp_write_sync(VMINT handle, void* buf, VMINT len); +/***************************************************************************** + * FUNCTION + * vm_tcp_close_sync + * DESCRIPTION + * close tcp connection. + * PARAMETERS + * handle : [IN] tcp handle. + * EXAMPLE + * + * static VMINT g_tcp_sync_hd; + * void hl_tcp_sync(void) + * { + * g_tcp_sync_hd = vm_tcp_connect_sync("172.21.90.164", 80, VM_TCP_APN_CMNET); + * ret = vm_tcp_close_sync(g_tcp_sync_hd); + * } + * +*****************************************************************************/ +VMINT vm_tcp_close_sync(VMINT handle); + +/* Http server event */ +typedef enum +{ + VM_SOC_SVR_EVT_ACCEPT, /* Notify for accept */ + VM_SOC_SVR_EVT_READ, /* Notify for read */ + VM_SOC_SVR_EVT_WRITE, /* Notify for write */ + VM_SOC_SVR_EVT_CLOSED, /* Notify for close */ + VM_SOC_SVR_EVT_ACTIVED, /* Notify for actived */ + VM_SOC_SVR_EVT_DEACTIVATED, /* Notify for deactived */ + VM_SOC_SVR_EVT_FAILED, /* Notify for failed */ + VM_SOC_SVR_EVT_MAX +}vm_http_server_evt_t; + +/***************************************************************************** + * FUNCTION + * vm_soc_svr_init + * DESCRIPTION + * Initiate server socket + * PARAMETERS + * apn : [IN] apn id. + * port: [IN] the port of server + * user_data: [IN] user's data, engine can pass it to callback + * callback: [IN] app's callback function + * RETURNS + * if successed return server handle, else return error code + * EXAMPLE + * + * static VMINT svr_async_hdl; + * static VMINT clt_async_hdl; + * #define MAX_SIZE 1024*2 + * VMBYTE buf[MAX_SIZE] = {0}; + * static void svr_callback_async_cb(VMINT handle, VMINT event, VMINT param, void *user_data) + * { + * + * if (handle == svr_async_hdl || -8 == svr_async_hdl) + * { + * vm_trace("evt[%d]", event); + * + * switch (event) + * { + * case VM_SOC_SVR_EVT_ACTIVED: + * { + * svr_async_hdl = handle; + * vm_trace("ACTIVED"); + * vm_trace("[async svr] shdl[%d] [%d]", svr_async_hdl, (VMINT)user_data); + * } + * break; + * case VM_SOC_SVR_EVT_ACCEPT: + * { + * clt_async_hdl = param; + * vm_trace("ACCEPTED"); + * vm_trace("[async svr] chdl[%d] [%d]", clt_async_hdl, (VMINT)user_data); + * } + * break; + * case VM_SOC_SVR_EVT_READ: + * { + * VMINT ret = 0; + * ret = vm_soc_svr_read(svr_async_hdl, clt_async_hdl, buf, MAX_SIZE); + * vm_trace("READ [%d/%d]", ret, MAX_SIZE); + * ret = vm_soc_svr_send(svr_async_hdl, clt_async_hdl, "abc", 3); + * vm_trace("SENT [%d]", ret); + * vm_soc_svr_close_client(clt_async_hdl); + * } + * break; + * case VM_SOC_SVR_EVT_WRITE: + * break; + * case VM_SOC_SVR_EVT_CLOSED: + * break; + * default: + * break; + * } + * } + * } + * void hl_tcp_srv(void) + * { + * svr_async_hdl = vm_soc_svr_init(1, 3501, (void*)1, svr_callback_async_cb); + * } + * +*****************************************************************************/ +VMINT vm_soc_svr_init(VMINT apn, VMINT port, void *user_data, void (*callback)(VMINT handle, VMINT event, VMINT param, void *user_data)); + +/***************************************************************************** + * FUNCTION + * vm_soc_svr_send + * DESCRIPTION + * Send data + * PARAMETERS + * s_hdl : [IN]server handle. + * c_hdl: [IN] client handle. + * data: [IN] data to be sent + * len: [IN] data length + * RETURNS + * if >=0 means number of bytes sent, else send failed + * EXAMPLE + * + * static VMINT svr_async_hdl; + * static VMINT clt_async_hdl; + * #define MAX_SIZE 1024*2 + * VMBYTE buf[MAX_SIZE] = {0}; + * static void svr_callback_async_cb(VMINT handle, VMINT event, VMINT param, void *user_data) + * { + * + * if (handle == svr_async_hdl || -8 == svr_async_hdl) + * { + * vm_trace("evt[%d]", event); + * + * switch (event) + * { + * case VM_SOC_SVR_EVT_ACTIVED: + * { + * svr_async_hdl = handle; + * vm_trace("ACTIVED"); + * vm_trace("[async svr] shdl[%d] [%d]", svr_async_hdl, (VMINT)user_data); + * } + * break; + * case VM_SOC_SVR_EVT_ACCEPT: + * { + * clt_async_hdl = param; + * vm_trace("ACCEPTED"); + * vm_trace("[async svr] chdl[%d] [%d]", clt_async_hdl, (VMINT)user_data); + * } + * break; + * case VM_SOC_SVR_EVT_READ: + * { + * VMINT ret = 0; + * ret = vm_soc_svr_read(svr_async_hdl, clt_async_hdl, buf, MAX_SIZE); + * vm_trace("READ [%d/%d]", ret, MAX_SIZE); + * ret = vm_soc_svr_send(svr_async_hdl, clt_async_hdl, "abc", 3); + * vm_trace("SENT [%d]", ret); + * vm_soc_svr_close_client(clt_async_hdl); + * } + * break; + * case VM_SOC_SVR_EVT_WRITE: + * break; + * case VM_SOC_SVR_EVT_CLOSED: + * break; + * default: + * break; + * } + * } + * } + * void hl_tcp_srv(void) + * { + * svr_async_hdl = vm_soc_svr_init(1, 3501, (void*)1, svr_callback_async_cb); + * } + * +*****************************************************************************/ +VMINT vm_soc_svr_send(VMINT s_hdl, VMINT c_hdl, const void *data, VMUINT len); + +/***************************************************************************** + * FUNCTION + * vm_soc_svr_read + * DESCRIPTION + * Read data + * PARAMETERS + * s_hdl : [IN]server handle. + * c_hdl: [IN] client handle. + * data: [IN] data to be sent + * len: [IN] data length + * RETURNS + * if >=0 means number of bytes received, else receive failed + * EXAMPLE + * + * static VMINT svr_async_hdl; + * static VMINT clt_async_hdl; + * #define MAX_SIZE 1024*2 + * VMBYTE buf[MAX_SIZE] = {0}; + * static void svr_callback_async_cb(VMINT handle, VMINT event, VMINT param, void *user_data) + * { + * + * if (handle == svr_async_hdl || -8 == svr_async_hdl) + * { + * vm_trace("evt[%d]", event); + * + * switch (event) + * { + * case VM_SOC_SVR_EVT_ACTIVED: + * { + * svr_async_hdl = handle; + * vm_trace("ACTIVED"); + * vm_trace("[async svr] shdl[%d] [%d]", svr_async_hdl, (VMINT)user_data); + * } + * break; + * case VM_SOC_SVR_EVT_ACCEPT: + * { + * clt_async_hdl = param; + * vm_trace("ACCEPTED"); + * vm_trace("[async svr] chdl[%d] [%d]", clt_async_hdl, (VMINT)user_data); + * } + * break; + * case VM_SOC_SVR_EVT_READ: + * { + * VMINT ret = 0; + * ret = vm_soc_svr_read(svr_async_hdl, clt_async_hdl, buf, MAX_SIZE); + * vm_trace("READ [%d/%d]", ret, MAX_SIZE); + * ret = vm_soc_svr_send(svr_async_hdl, clt_async_hdl, "abc", 3); + * vm_trace("SENT [%d]", ret); + * vm_soc_svr_close_client(clt_async_hdl); + * } + * break; + * case VM_SOC_SVR_EVT_WRITE: + * break; + * case VM_SOC_SVR_EVT_CLOSED: + * break; + * default: + * break; + * } + * } + * } + * void hl_tcp_srv(void) + * { + * svr_async_hdl = vm_soc_svr_init(1, 3501, (void*)1, svr_callback_async_cb); + * } + * +*****************************************************************************/ +VMINT vm_soc_svr_read(VMINT s_hdl, VMINT c_hdl, void *data, VMUINT len); + +/***************************************************************************** + * FUNCTION + * vm_soc_svr_close_client + * DESCRIPTION + * Close client + * PARAMETERS + * c_hdl: [IN] client handle. + * RETURNS + * If return 0 means success, else fail. + * EXAMPLE + * + * static VMINT svr_async_hdl; + * static VMINT clt_async_hdl; + * #define MAX_SIZE 1024*2 + * VMBYTE buf[MAX_SIZE] = {0}; + * static void svr_callback_async_cb(VMINT handle, VMINT event, VMINT param, void *user_data) + * { + * + * if (handle == svr_async_hdl || -8 == svr_async_hdl) + * { + * vm_trace("evt[%d]", event); + * + * switch (event) + * { + * case VM_SOC_SVR_EVT_ACTIVED: + * { + * svr_async_hdl = handle; + * vm_trace("ACTIVED"); + * vm_trace("[async svr] shdl[%d] [%d]", svr_async_hdl, (VMINT)user_data); + * } + * break; + * case VM_SOC_SVR_EVT_ACCEPT: + * { + * clt_async_hdl = param; + * vm_trace("ACCEPTED"); + * vm_trace("[async svr] chdl[%d] [%d]", clt_async_hdl, (VMINT)user_data); + * } + * break; + * case VM_SOC_SVR_EVT_READ: + * { + * VMINT ret = 0; + * ret = vm_soc_svr_read(svr_async_hdl, clt_async_hdl, buf, MAX_SIZE); + * vm_trace("READ [%d/%d]", ret, MAX_SIZE); + * ret = vm_soc_svr_send(svr_async_hdl, clt_async_hdl, "abc", 3); + * vm_trace("SENT [%d]", ret); + * vm_soc_svr_close_client(clt_async_hdl); + * } + * break; + * case VM_SOC_SVR_EVT_WRITE: + * break; + * case VM_SOC_SVR_EVT_CLOSED: + * break; + * default: + * break; + * } + * } + * } + * void hl_tcp_srv(void) + * { + * svr_async_hdl = vm_soc_svr_init(1, 3501, (void*)1, svr_callback_async_cb); + * } + * +*****************************************************************************/ +VMINT vm_soc_svr_close_client(VMINT c_hdl); + +/***************************************************************************** + * FUNCTION + * vm_soc_svr_deinit + * DESCRIPTION + * Deinit socket server + * PARAMETERS + * handle: [IN] server handle. + * RETURNS + * 0 + * EXAMPLE + * + * static VMINT svr_async_hdl; + * static VMINT clt_async_hdl; + * #define MAX_SIZE 1024*2 + * VMBYTE buf[MAX_SIZE] = {0}; + * static void svr_callback_async_cb(VMINT handle, VMINT event, VMINT param, void *user_data) + * { + * + * if (handle == svr_async_hdl || -8 == svr_async_hdl) + * { + * vm_trace("evt[%d]", event); + * + * switch (event) + * { + * case VM_SOC_SVR_EVT_ACTIVED: + * { + * svr_async_hdl = handle; + * vm_trace("ACTIVED"); + * vm_trace("[async svr] shdl[%d] [%d]", svr_async_hdl, (VMINT)user_data); + * } + * break; + * case VM_SOC_SVR_EVT_ACCEPT: + * { + * clt_async_hdl = param; + * vm_trace("ACCEPTED"); + * vm_trace("[async svr] chdl[%d] [%d]", clt_async_hdl, (VMINT)user_data); + * } + * break; + * case VM_SOC_SVR_EVT_READ: + * { + * VMINT ret = 0; + * ret = vm_soc_svr_read(svr_async_hdl, clt_async_hdl, buf, MAX_SIZE); + * vm_trace("READ [%d/%d]", ret, MAX_SIZE); + * ret = vm_soc_svr_send(svr_async_hdl, clt_async_hdl, "abc", 3); + * vm_trace("SENT [%d]", ret); + * vm_soc_svr_close_client(clt_async_hdl); + * vm_soc_svr_deinit(svr_async_hdl); + * } + * break; + * case VM_SOC_SVR_EVT_WRITE: + * break; + * case VM_SOC_SVR_EVT_CLOSED: + * break; + * default: + * break; + * } + * } + * } + * void hl_tcp_srv(void) + * { + * svr_async_hdl = vm_soc_svr_init(1, 3501, (void*)1, svr_callback_async_cb); + * } + * +*****************************************************************************/ +VMINT vm_soc_svr_deinit(VMINT handle); + +/***************************************************************************** + * FUNCTION + * vm_soc_svr_get_soc_id + * DESCRIPTION + * Get the socket id of the server + * PARAMETERS + * handle: [IN] server handle. + * RETURNS + * return -2 if failed, else return the socket id + * EXAMPLE + * + * static VMINT svr_async_hdl; + * static VMINT clt_async_hdl; + * #define MAX_SIZE 1024*2 + * VMBYTE buf[MAX_SIZE] = {0}; + * static void svr_callback_async_cb(VMINT handle, VMINT event, VMINT param, void *user_data) + * { + * VMINT svr_soc_id; + * if (handle == svr_async_hdl || -8 == svr_async_hdl) + * { + * vm_trace("evt[%d]", event); + * + * switch (event) + * { + * case VM_SOC_SVR_EVT_ACTIVED: + * { + * svr_async_hdl = handle; + * svr_soc_id = vm_soc_svr_get_soc_id(svr_async_hdl); + * vm_trace("ACTIVED"); + * vm_trace("[async svr] shdl[%d] soc_id[%d] [%d]", svr_async_hdl, svr_soc_id, (VMINT)user_data); + * } + * break; + * case VM_SOC_SVR_EVT_ACCEPT: + * { + * clt_async_hdl = param; + * vm_trace("ACCEPTED"); + * vm_trace("[async svr] chdl[%d] [%d]", clt_async_hdl, (VMINT)user_data); + * } + * break; + * case VM_SOC_SVR_EVT_READ: + * { + * VMINT ret = 0; + * ret = vm_soc_svr_read(svr_async_hdl, clt_async_hdl, buf, MAX_SIZE); + * vm_trace("READ [%d/%d]", ret, MAX_SIZE); + * ret = vm_soc_svr_send(svr_async_hdl, clt_async_hdl, "abc", 3); + * vm_trace("SENT [%d]", ret); + * vm_soc_svr_close_client(clt_async_hdl); + * vm_soc_svr_deinit(svr_async_hdl); + * } + * break; + * case VM_SOC_SVR_EVT_WRITE: + * break; + * case VM_SOC_SVR_EVT_CLOSED: + * break; + * default: + * break; + * } + * } + * } + * void hl_tcp_srv(void) + * { + * svr_async_hdl = vm_soc_svr_init(1, 3501, (void*)1, svr_callback_async_cb); + * } + * +*****************************************************************************/ +VMINT vm_soc_svr_get_soc_id(VMINT handle); + + +/***************************************************************************** + * FUNCTION + * vm_soc_svr_init_sync + * DESCRIPTION + * Initiate socket server synchronously + * PARAMETERS + * apn: [IN] apn id. + * port: [IN] port number associate to the server. + * RETURNS + * if successed return server handle, else return error code + * EXAMPLE + * + * void hl_tcp_sync_srv(void) + * { + * vm_sockaddr_struct addr; + * VMINT ret; + * char buf[1024] = {0}; + * VMINT hdl_c; + * VMINT hdl_s = vm_soc_svr_init_sync(1, 3500); + * hdl_c = vm_soc_svr_accept_sync(hdl_s, &addr); + * ret = vm_soc_svr_read_sync(hdl_c, buf, 1024); + * ret = vm_soc_svr_send_sync(hdl_c, "aaa", 3); + * vm_soc_svr_close_client_sync(hdl_c); + * } + * +*****************************************************************************/ +VMINT vm_soc_svr_init_sync(VMINT apn, VMINT port); + +/***************************************************************************** + * FUNCTION + * vm_soc_svr_accept_sync + * DESCRIPTION + * Waits for the incoming connections and return a socket handle + * of new connection. + * PARAMETERS + * s_hdl: [IN] server handle. + * addr: [IN] address of foreign host + * RETURNS + * if successed return a socket handle, else return error code + * EXAMPLE + * + * void hl_tcp_sync_srv(void) + * { + * vm_sockaddr_struct addr; + * VMINT ret; + * char buf[1024] = {0}; + * VMINT hdl_c; + * VMINT hdl_s = vm_soc_svr_init_sync(1, 3500); + * hdl_c = vm_soc_svr_accept_sync(hdl_s, &addr); + * ret = vm_soc_svr_read_sync(hdl_c, buf, 1024); + * ret = vm_soc_svr_send_sync(hdl_c, "aaa", 3); + * vm_soc_svr_close_client_sync(hdl_c); + * } + * +*****************************************************************************/ +VMINT vm_soc_svr_accept_sync(VMINT s_hdl, vm_sockaddr_struct *addr); + +/***************************************************************************** + * FUNCTION + * vm_soc_svr_send_sync + * DESCRIPTION + * sends data to a host which already connected previously. + * PARAMETERS + * c_hdl: [IN] apn id. + * data: [IN] data to be sent. + * len: [IN] data length + * RETURNS + * if >=0 means number of bytes sent, else sent failed + * EXAMPLE + * + * void hl_tcp_sync_srv(void) + * { + * vm_sockaddr_struct addr; + * VMINT ret; + * char buf[1024] = {0}; + * VMINT hdl_c; + * VMINT hdl_s = vm_soc_svr_init_sync(1, 3500); + * hdl_c = vm_soc_svr_accept_sync(hdl_s, &addr); + * ret = vm_soc_svr_read_sync(hdl_c, buf, 1024); + * ret = vm_soc_svr_send_sync(hdl_c, "aaa", 3); + * vm_soc_svr_close_client_sync(hdl_c); + * } + * +*****************************************************************************/ +VMINT vm_soc_svr_send_sync(VMINT c_hdl, const void *data, VMUINT len); + +/***************************************************************************** + * FUNCTION + * vm_soc_svr_read_sync + * DESCRIPTION + * Read data synchronously + * PARAMETERS + * c_hdl: [IN] client handle. + * data: [IN] buffer for read data. + * len: [IN} buffer length + * RETURNS + * if >=0 means number of bytes read, else read failed + * EXAMPLE + * + * void hl_tcp_sync_srv(void) + * { + * vm_sockaddr_struct addr; + * VMINT ret; + * char buf[1024] = {0}; + * VMINT hdl_c; + * VMINT hdl_s = vm_soc_svr_init_sync(1, 3500); + * hdl_c = vm_soc_svr_accept_sync(hdl_s, &addr); + * ret = vm_soc_svr_read_sync(hdl_c, buf, 1024); + * ret = vm_soc_svr_send_sync(hdl_c, "aaa", 3); + * vm_soc_svr_close_client_sync(hdl_c); + * } + * +*****************************************************************************/ +VMINT vm_soc_svr_read_sync(VMINT c_hdl, void *data, VMUINT len); + +/***************************************************************************** + * FUNCTION + * vm_soc_svr_close_client_sync + * DESCRIPTION + * Close client socket synchronously + * PARAMETERS + * c_hdl [IN] Client handle + * RETURNS + * If return 0 means success, else fail. + * EXAMPLE + * + * void hl_tcp_sync_srv(void) + * { + * vm_sockaddr_struct addr; + * VMINT ret; + * char buf[1024] = {0}; + * VMINT hdl_c; + * VMINT hdl_s = vm_soc_svr_init_sync(1, 3500); + * hdl_c = vm_soc_svr_accept_sync(hdl_s, &addr); + * ret = vm_soc_svr_read_sync(hdl_c, buf, 1024); + * ret = vm_soc_svr_send_sync(hdl_c, "aaa", 3); + * vm_soc_svr_close_client_sync(hdl_c); + * } + * +*****************************************************************************/ +VMINT vm_soc_svr_close_client_sync(VMINT c_hdl); + +/***************************************************************************** + * FUNCTION + * vm_soc_svr_deinit_sync + * DESCRIPTION + * Deinitiate socket server synchronously + * PARAMETERS + * s_hdl [IN] server handle + * RETURNS + * if return 0 means operate successfully, else failed + * EXAMPLE + * + * void hl_tcp_sync_srv(void) + * { + * vm_sockaddr_struct addr; + * VMINT ret; + * char buf[1024] = {0}; + * VMINT hdl_c; + * VMINT hdl_s = vm_soc_svr_init_sync(1, 3500); + * hdl_c = vm_soc_svr_accept_sync(hdl_s, &addr); + * ret = vm_soc_svr_read_sync(hdl_c, buf, 1024); + * ret = vm_soc_svr_send_sync(hdl_c, "aaa", 3); + * vm_soc_svr_close_client_sync(hdl_c); + * vm_soc_svr_deinit_sync(hdl_s); + * } + * +*****************************************************************************/ +VMINT vm_soc_svr_deinit_sync(VMINT s_hdl); + + +#ifdef __cplusplus +} +#endif + +#endif /* VMTCP_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmtel.h b/hardware/arduino/mtk/system/libmtk/include/vmtel.h new file mode 100644 index 00000000..e5af7637 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmtel.h @@ -0,0 +1,405 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMTEL_SDK_H +#define VMTEL_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + + +typedef enum +{ + VM_CALLOUT_ERR_STATE = -7, /* application is not foreground state */ + VM_CALLOUT_ERR_NO_SIM , /* No SIM */ + VM_CALLOUT_ERR_FLIGHT, /* flight mode */ + VM_CALLOUT_ERR_BUSY, /* device busy */ + VM_CALLOUT_ERR_PHONE_NUM, /* destination number error */ + VM_CALLOUT_ERR_PROCESS, /* process error */ + VM_CALLOUT_ERR_NO_RES, /* resource unavailable*/ + VM_CALLOUT_NO_ERR +}vm_callout_error_t; + +typedef enum +{ + VM_CALLOUT_IDEL = 0, + VM_CALLOUT_BUSY +}vm_callout_status_t; + +/***************************************************************************** +* +* + * FUNCTION + * VM_CALLOUT_RESPONSE_T + * DESCRIPTION + * callback function of callout + * PARAMETERS + * VMWSTR : [IN] destination phone number string encoding with UCS2 format + * VMINT : [IN] calling result. +*****************************************************************************/ +typedef void (*VM_CALLOUT_RESPONSE_T)(VMWSTR, VMINT); + +/***************************************************************************** +* FUNCTION + * vm_callout + * DESCRIPTION + * make call. + * Application can use this funtion only during foreground running and END key + * will be handled by call application for hang up calling firstly. + * PARAMETERS + * phnum : [IN] destination phone number string encoding with UCS2 format. +*****************************************************************************/ +void vm_callout(VMWSTR phnum); + +/***************************************************************************** +* FUNCTION + * vm_callout + * DESCRIPTION + * make call. + * Application can use this funtion only during foreground running and END key + * will be handled by call application for hang up calling firstly. + * PARAMETERS + * phnum : [IN] destination phone number string encoding with UCS2 format. + * callback : [IN] callback function +* RETURNS + * refer to vm_callout_error_t +*****************************************************************************/ +VMINT vm_callout_ex(VMWSTR phnum, VM_CALLOUT_RESPONSE_T callback); + + + +/***************************************************************************** + * FUNCTION + * vm_dialer_launch + * DESCRIPTION + * 1. Launch a dialer + * PARAMETERS + * phone_num : [IN] phone num, can be NULL + * RETURNS + * 0:success + *****************************************************************************/ +VMINT vm_dialer_launch(VMWSTR phone_num); + + +/** + *Open URL successfully + */ +#define VM_OPEN_WAP_URL_SUCCESS (0) +/** + * Parameter error + */ +#define VM_OPEN_WAP_URL_ERROR_PARAM (-1) +/** + * No WAP service + */ +#define VM_OPEN_WAP_URL_NO_SERVICE (-2) +/** + * Process not during foreground running + */ +#define VM_OPEN_WAP_URL_ERROR_STATUS (-3) + +/***************************************************************************** +* FUNCTION + * vm_open_wap_url + * DESCRIPTION + * Lauch WAP brower and go to specified address. + * PARAMETERS + * url : [IN] WAP address. + * RETURNS + * result of Open browser URL + * RETURN VALUES + * VM_OPEN_WAP_URL_SUCCESS : Open URL successfully. + * VM_OPEN_WAP_URL_ERROR_PARAM : Parameter error. + * VM_OPEN_WAP_URL_NO_SERVICE : No WAP service. + * VM_OPEN_WAP_URL_ERROR_STATUS : Process not during foreground running. + * +*****************************************************************************/ +VMINT vm_open_wap_url(VMWSTR url); + +typedef enum +{ + VM_IVR_FAIL = -1,//vm_ivr_call fail + VM_IVR_CALLED_OUT, //already called out + VM_IVR_INTERRUPT, //end by interrupt (incoming call) + VM_IVR_CALL_END, //call end normally +}vm_ivr_status_enum; + +typedef struct +{ + vm_ivr_status_enum status; + void* user_data; +}ivr_callback_data; + +typedef void (*vm_ivr_cb)(ivr_callback_data* data); + +typedef struct +{ + VMWSTR phone_num; //destination phone number + VMINT sim_card; //sim card: 1,2,3,4... + vm_ivr_cb callback; + void* user_data; +}vm_ivr_call_data; + +/***************************************************************************** +* FUNCTION + * vm_ivr_call + * DESCRIPTION + * start call in background + * PARAMETERS + * vm_ivr_call_data : [IN] + * RETURNS + * 0 means success, others fail +*****************************************************************************/ +VMINT vm_ivr_call(vm_ivr_call_data* data); + +/***************************************************************************** +* FUNCTION + * vm_ivr_dial_number + * DESCRIPTION + * dial number after vm_ivr_call invoked + * PARAMETERS + * number : [IN] number to dial. e.g. "3"; + * RETURNS + * 0 means success, others fail +*****************************************************************************/ +VMINT vm_ivr_dial_number(VMCHAR number); + +/***************************************************************************** +* FUNCTION + * vm_ivr_end + * DESCRIPTION + * end call start by vm_ivr_call + * PARAMETERS + * + * RETURNS + * 0 means success, others fail +*****************************************************************************/ +VMINT vm_ivr_end(void); + + +/* Maximum number length */ +#define VM_UCM_MAX_NUM_URI_LEN (41) + +/* Maximum error message length */ +#define VM_UCM_MAX_ERR_MSG_LEN (50) + +/* Maximum IP number length */ +#define VM_UCM_MAX_IP_NUMBER_LEN (10) + +/* UCM error cause enum */ +typedef enum +{ + VM_UCM_RESULT_OK, /* OK */ + VM_UCM_RESULT_UNSPECIFIED_ERROR, /* Unspecified error */ + VM_UCM_RESULT_CANCEL, /* Cancel */ + VM_UCM_RESULT_USER_ABORT, /* User abort */ + VM_UCM_RESULT_ACTION_NOT_ALLOWED, /* Action not allowed */ + VM_UCM_RESULT_NOT_ALLOWED_TO_DIAL, /* Not allowed to dial */ + VM_UCM_RESULT_NOT_ALLOWED_TO_ACCEPT, /* Not allowed to accept */ + VM_UCM_RESULT_NO_ACTIVE_CALL, /* No active call */ + VM_UCM_RESULT_CALLED_PARTY_BUSY, /* Called party busy */ + VM_UCM_RESULT_NETWORK_NOT_AVAILABLE, /* Network not available */ + VM_UCM_RESULT_CALLED_PARTY_NOT_ANSWERED, /* Called party not answered */ + VM_UCM_RESULT_SOS_NUMBER_ONLY, /* SOS number only */ + VM_UCM_RESULT_INVALID_NUMBER, /* Invalid number */ + VM_UCM_RESULT_EMPTY_NUMBER, /* Empty number */ + VM_UCM_RESULT_SOS_CALL_EXISTS, /* Exist SOS call */ + VM_UCM_RESULT_PREFERRED_MODE_PROHIBIT, /* Preferred mode prohibit */ + VM_UCM_RESULT_FLIGHT_MODE_PROHIBIT, /* Flight mode prohibit */ + VM_UCM_RESULT_LOW_BATTERY, /* Low battery */ + VM_UCM_RESULT_UCM_BUSY, /* Busy */ + VM_UCM_RESULT_VT_FALLBACK, /* VT fallback */ + VM_UCM_RESULT_END_OF_ENUM /* end of the enum */ +} vm_ucm_result_enum; + + + +/* Indication opcode enum */ +typedef enum +{ + VM_UCM_INCOMING_CALL_IND = 0,//incomming + VM_UCM_OUTGOING_CALL_IND, //outcomming + VM_UCM_CALL_END, //call end normally +}vm_ucm_ind_opcode_enum; + +/* Call id struct, should be unique */ +typedef struct +{ + vm_ucm_ind_opcode_enum call_type; /* Call type */ + VMUINT16 group_id; /* group id */ + VMUINT16 call_id; /* call id*/ +} vm_ucm_id_info_struct; + +typedef struct +{ + vm_ucm_id_info_struct uid_info; /* Call id */ + VMUINT8 num_uri[VM_UCM_MAX_NUM_URI_LEN + 1]; /* Number, ascii */ +} vm_ucm_incoming_call_ind_struct; + + +/* Outgoing call indication struct */ +typedef struct +{ + vm_ucm_id_info_struct uid_info; /* Call id */ + VMUINT8 num_uri[VM_UCM_MAX_NUM_URI_LEN + 1]; /* Number, ascii */ +} vm_ucm_outgoing_call_ind_struct; + +/* Listen call event callback structure */ +typedef struct +{ + vm_ucm_ind_opcode_enum type_op; // vm_call_type incomming ,outcomming + void* data; //data of the event +}vm_call_listener_data; + +typedef void (*vm_call_listener_func)(vm_call_listener_data* data); + + + +/* Action opcode enum */ +typedef enum +{ + VM_UCM_NO_ACT = 0, /* No action */ + VM_UCM_DIAL_ACT, /* Dial action, vm_ucm_dial_act_req_struct, vm_ucm_act_rsp_struct*/ + VM_UCM_ACCEPT_ACT, /* Accept action, vm_ucm_single_call_act_req_struct, vm_ucm_act_rsp_struct*/ + VM_UCM_HOLD_ACT, /* Hold action, vm_ucm_single_group_act_req_struct, vm_ucm_act_rsp_struct*/ + VM_UCM_END_SINGLE_ACT, /* End single action, vm_ucm_single_call_act_req_struct, vm_ucm_act_rsp_struct */ +}vm_call_action_type; + +/* Call type enum */ +typedef enum +{ + VM_UCM_VOICE_CALL_TYPE = 0x0001, /* SIM1 voice call type */ + VM_UCM_VOICE_CALL_TYPE_SIM2 = 0x0020, /* SIM2 voice call type */ + VM_UCM_VOICE_CALL_TYPE_SIM3 = 0x0200, /* SIM3 voice call type */ + VM_UCM_VOICE_CALL_TYPE_SIM4 = 0x1000, /* SIM4 voice call type */ +} vm_ucm_call_type_enum; + + + +/* action struct VM_UCM_DIAL_ACT */ +typedef struct +{ + vm_ucm_call_type_enum call_type; /* Call type */ + VMUINT16 num_uri[VM_UCM_MAX_NUM_URI_LEN + 1]; /* Number, ucs2 */ + VMUINT8 module_id; /* Initiate module id, set 0 as default */ + VMBOOL is_ip_dial; /* IP dial, currently only for GSM&3G, set 0 as default */ + void *phb_data; /* Bypass phonebook data for call service to query caller info. set NULL as default*/ +} vm_ucm_dial_act_req_struct; + +/* action struct VM_UCM_ACCEPT_ACT & VM_UCM_END_SINGLE_ACT */ +typedef struct +{ + vm_ucm_id_info_struct action_uid; /* Call id */ +} vm_ucm_single_call_act_req_struct; + +/* action struct VM_UCM_HOLD_ACT */ +typedef struct +{ + vm_ucm_call_type_enum call_type; /* Call type */ + VMUINT16 action_group; /* Group id */ +} vm_ucm_single_group_act_req_struct; + + + + +/* Action CALLBACK structure */ +typedef struct +{ + vm_ucm_result_enum result; /* Result */ + VMUINT16 error_msg[VM_UCM_MAX_ERR_MSG_LEN + 1]; /* Recommand error message, ucs2 */ +} vm_ucm_result_info_struct; + +typedef struct +{ + vm_ucm_result_info_struct result_info; /* Result */ + VMBOOL no_counter; /* Start to count duration or not, only for accept action */ +} vm_ucm_act_rsp_struct; + +typedef struct +{ + vm_call_action_type type_act; // action type accept ,hold on, end + vm_ucm_act_rsp_struct data_act_rsp; //data of the action callback struct + void* userdata; //userdata of APP +}vm_call_actions_callback_data; + +typedef void (*vm_call_actions_func)(vm_call_actions_callback_data* data); + + + +/* Action structure */ +typedef struct +{ + vm_call_action_type type_act; // action type accept ,hold on, end + void* data_act; //data of the action struct + void* userdata; //user data of APP + vm_call_actions_func callback; //callback function of the action +}vm_call_actions_data; + + + +/***************************************************************************** +* FUNCTION + * vm_call_reg_listener + * DESCRIPTION + * APP use this function to register a callback function to listen call events + * PARAMETERS + * func : [IN] callback functions, reference vm_call_listener_func +* RETURNS + * 0 is success +*****************************************************************************/ +VMINT vm_call_reg_listener(vm_call_listener_func func); + + +/***************************************************************************** +* FUNCTION + * vm_call_actions + * DESCRIPTION + * APP use this function to control call progress, accept a incoming call, + * or hold on/ hung up a going call + * PARAMETERS + * data : [IN] Action command , please reference vm_call_actions_data +* RETURNS + * 0 is success +*****************************************************************************/ +VMINT vm_call_actions(const vm_call_actions_data* data); + +#ifdef __cplusplus +} +#endif + +#endif /* VMTEL_SDK_H */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmthread.h b/hardware/arduino/mtk/system/libmtk/include/vmthread.h new file mode 100644 index 00000000..b135d383 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmthread.h @@ -0,0 +1,618 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmthread_sdk.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * + * + * Author: + * ------- + * + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ + * $Log$ + * + * 01 24 2014 zhiwei.yang + * [MAUI_03477387] [Blocking]Stuck on uploading screen while uploading image from file manager + * . + * + * 01 20 2014 xiufeng.zhang + * [MAUI_03479763] [IOT]Merge IOT code to 11C + * . + * + * 01 20 2014 xiufeng.zhang + * [MAUI_03479763] [IOT]Merge IOT code to 11C + * . + * + * 01 17 2014 xiufeng.zhang + * [MAUI_03479763] [IOT]Merge IOT code to 11C + * . + * + * *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== + *******************************************************************************/ + +#ifndef VMTHREAD_SDK_H +#define VMTHREAD_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + + +/* thread handle, return by vm_thread_create */ +#define VM_THREAD_HANDLE VMUINT32 + +/* signal id, return by vm_signal_init */ +#define VM_SIGNAL_ID VMUINT32 + +/* wake up by the signal */ +#define VM_SIGNAL_RESULT_SUCCESS 0 +/* time out */ +#define VM_SIGNAL_RESULT_TIMEOUT 1 +/* wake up forcely without the signal */ +#define VM_SIGNAL_RESULT_CANCEL 2 + + +/* used for storing message. */ +typedef struct +{ + VMUINT16 message_id; /* the value of message id */ + void* user_data; /* the content data of the message */ +}VM_MSG_STRUCT; + +typedef struct +{ + VMUINT8 unused; +}*vm_taskid; + + +typedef struct _vm_mutex_list_note +{ + VMUINT8 unused; +}vm_mutex_list_note; + +/* used for creating mutex. */ +typedef struct +{ + VMUINT32 guard; /* system used, initialyze when ivoking vm_mutex_create. */ + vm_mutex_list_note* mutex_info; /* system used, initialyze when ivoking vm_mutex_create. */ +}vm_thread_mutex_struct; + + +/***************************************************************************** + * FUNCTION + * VM_THREAD_FUNC + * DESCRIPTION + * Thread main function type, and the thread will be closed when it returned. + * PARAMETERS + * thread_handle [IN] The thread handler, used for thread management + * user_data [IN] The create param transfer to main function. + * RETURNS + * return + *****************************************************************************/ +typedef VMINT32 (*VM_THREAD_FUNC)(VM_THREAD_HANDLE thread_handle, void* user_data); + +/***************************************************************************** + * FUNCTION + * vm_thread_create + * DESCRIPTION + * used for create a thread. + * PARAMETERS + * thread_function [IN] The thread main function. + * data [IN] The param of thread_function. + * priority [IN] Thread priority, + * 1 is the highest priority, 255 is the lowest priority, and main thread's priority + * is higher than 129 and lower than 128. 0 is default priority lower than main thread. + * RETURNS + * return The handle of the creating thread. + * + * Example + * + * + * VMINT vm_sub_thread_proc(VM_THREAD_HANDLE thread_handle, void* user_data) + * { + * //do_some_thing(); + * return 0; + * } + * + * vm_thread_create(vm_sub_thread_proc, NULL, 0 ); + * + * + *****************************************************************************/ +extern VM_THREAD_HANDLE vm_thread_create(VM_THREAD_FUNC thread_function, void* data,VMUINT8 priority); + +/***************************************************************************** + * FUNCTION + * vm_thread_get_current_handle + * DESCRIPTION + * used for get thread handle. this API does not support in main thread. + * PARAMETERS + * None + * RETURNS + * return The handle of current thread. + * SEE ALSO + * vm_thread_get_main_handle + *****************************************************************************/ +extern VM_THREAD_HANDLE vm_thread_get_current_handle(void); + +/***************************************************************************** + * FUNCTION + * vm_thread_get_main_handle + * DESCRIPTION + * used for get main thread handle. + * PARAMETERS + * None + * RETURNS + * return The handle of main thread. + * SEE ALSO + * vm_thread_get_current_handle + *****************************************************************************/ +extern VM_THREAD_HANDLE vm_thread_get_main_handle(void); + +/***************************************************************************** + * FUNCTION + * vm_thread_send_msg + * DESCRIPTION + * used for sending msg between threads. + * PARAMETERS + * thread [IN] The thread handler of reciever. + * msg_id [IN] The message id to be send. + * user_data [IN] The customer data of the message. + * RETURNS + * None. + * + * Example + * + * VMINT32 vm_sub_thread_proc(VM_THREAD_HANDLE thread_handle, void* user_data) + * { + * VM_THREAD_HANDLE main_handle; + * //do_some_thing(); + * main_handle = vm_thread_get_main_handle(); + * vm_thread_send_msg(main_handle, MSG_ID_XXX, NULL); + * return 0; + * } + * + *****************************************************************************/ +extern void vm_thread_send_msg(VM_THREAD_HANDLE thread_handle, VMUINT32 msg_id, void* user_data); + +/***************************************************************************** + * FUNCTION + * vm_thread_get_msg + * DESCRIPTION + * used for read msg from ext msg queue, and it will be blocked if the queue is empty. + * PARAMETERS + * msg [OUT] The msg content. + * RETURNS + * None + * + * Example + * + * VMINT vm_sub_thread_proc(VM_THREAD_HANDLE thread_handle, void* user_data) + * { + * VM_MSG_STRUCT msg; + * + * vm_thread_get_msg(&msg); + * if (msg.message_id == MSG_ID_XXX) + * { + * //do_some_thing(); + * } + * return 0; + * } + * + *****************************************************************************/ +extern void vm_thread_get_msg(VM_MSG_STRUCT* msg); + +/***************************************************************************** + * FUNCTION + * vm_signal_init + * DESCRIPTION + * Initial a signal for thread communication. + * PARAMETERS + * None + * RETURNS + * The signal id of create. + * + * Example + * + * VM_SIGNAL_ID s_id; + * + * + * VMINT vm_sub_thread_proc(VM_THREAD_HANDLE thread_handle, void* user_data) + * { + * //do_some_thing(); + * + * // wait main thread handle MSG_ID_XXX. + * vm_signal_wait(s_id); + * do_other_thing(); + * return 0; + * } + * + * void handle_sysevt(VMINT message, VMINT param) + * { + * switch (message) + * { + * case VM_MSG_CREATE: + * //create signal. + * s_id = vm_signal_init(); + * sub_thread_proc(vm_sub_thread_proc, NULL, 0 ); + * + * break; + * case VM_MSG_QUIT: + * //release signal. + * vm_signal_deinit(s_id); + * break; + * case VM_MSG_XXX: + * handle_xxx_msg(); + * //post signal + * vm_signal_post(s_id); + * break; + * } + * } + * } + * + * + *****************************************************************************/ +extern VM_SIGNAL_ID vm_signal_init(void); + +/***************************************************************************** + * FUNCTION + * vm_signal_clean + * DESCRIPTION + * The id of the signal which was clean. + * PARAMETERS + * None + * RETURNS + * The signal id of create. + *****************************************************************************/ +extern void vm_signal_clean(VM_SIGNAL_ID s_id); + +/***************************************************************************** + * FUNCTION + * vm_signal_post + * DESCRIPTION + * post a signal then all the threads, which are waiting for it, will be waken up. + * the signal id is get from vm_signal_init(void) + * PARAMETERS + * The id of the signal which was post. + * RETURNS + * None. + * EXAMPLE + * + * VM_SIGNAL_ID s_id; + * + * + * VMINT vm_sub_thread_proc(VM_THREAD_HANDLE thread_handle, void* user_data) + * { + * //do_some_thing(); + * + * // wait main thread handle MSG_ID_XXX. + * vm_signal_wait(s_id); + * do_other_thing(); + * return 0; + * } + * + * void handle_sysevt(VMINT message, VMINT param) + * { + * switch (message) + * { + * case VM_MSG_CREATE: + * //create signal. + * s_id = vm_signal_init(); + * sub_thread_proc(vm_sub_thread_proc, NULL, 0 ); + * + * break; + * case VM_MSG_QUIT: + * //release signal. + * vm_signal_deinit(s_id); + * break; + * case VM_MSG_XXX: + * handle_xxx_msg(); + * //post signal + * vm_signal_post(s_id); + * break; + * } + * } + * } + * + * + *****************************************************************************/ +extern void vm_signal_post(VM_SIGNAL_ID s_id); + +/***************************************************************************** + * FUNCTION + * vm_signal_wait + * DESCRIPTION + * wait a signal then the thread will getting blocking if the signal was not set. + * then it will geting wake up when other thread post the signal. + * and this API only support in sub-thread, it can't be invoke from main thread. + * PARAMETERS + * the waiting for signal id. + * RETURNS + * VM_SIGNAL_RESULT_SUCCESS, if it is wake up by the signal. + * VM_SIGNAL_RESULT_CANCEL, if it is wake up forcely without the signal, FW doesn't suply force waking up API. + * EXAMPLE + * + * VM_SIGNAL_ID s_id; + * + * + * VMINT vm_sub_thread_proc(VM_THREAD_HANDLE thread_handle, void* user_data) + * { + * //do_some_thing(); + * + * // wait main thread handle MSG_ID_XXX. + * vm_signal_wait(s_id); + * do_other_thing(); + * return 0; + * } + * + * void handle_sysevt(VMINT message, VMINT param) + * { + * switch (message) + * { + * case VM_MSG_CREATE: + * //create signal. + * s_id = vm_signal_init(); + * sub_thread_proc(vm_sub_thread_proc, NULL, 0 ); + * + * break; + * case VM_MSG_QUIT: + * //release signal. + * vm_signal_deinit(s_id); + * break; + * case VM_MSG_XXX: + * handle_xxx_msg(); + * //post signal + * vm_signal_post(s_id); + * break; + * } + * } + * } + * + * + *****************************************************************************/ +extern VMINT32 vm_signal_wait(VM_SIGNAL_ID s_id); + +/***************************************************************************** + * FUNCTION + * vm_signal_timedwait + * DESCRIPTION + * wait a signal then the thread will getting blocking if the signal was not set. + * then it will geting wake up when other thread post the signal. + * and this API only support in sub-thread, it can't be invoke from main task. + * PARAMETERS + * s_id: [IN] the waiting for signal id. + * time_count: [IN] the max time to wait..(microsecond) + * RETURNS + * VM_SIGNAL_RESULT_SUCCESS, if it is wake up by the signal. + * VM_SIGNAL_RESULT_TIMEOUT, if time out. + * VM_SIGNAL_RESULT_CANCEL, if it is wake up forcely without the signal. + *****************************************************************************/ +extern VMINT32 vm_signal_timedwait(VM_SIGNAL_ID s_id, VMUINT32 time_count); + +/***************************************************************************** + * FUNCTION + * vm_signal_deinit + * DESCRIPTION + * destory a signal when app will not use it any more. + * PARAMETERS + * the signal id of deinit. + * RETURNS + * None + * EXAMPLE + * + * VM_SIGNAL_ID s_id; + * + * + * VMINT vm_sub_thread_proc(VM_THREAD_HANDLE thread_handle, void* user_data) + * { + * //do_some_thing(); + * + * // wait main thread handle MSG_ID_XXX. + * vm_signal_wait(s_id); + * do_other_thing(); + * return 0; + * } + * + * void handle_sysevt(VMINT message, VMINT param) + * { + * switch (message) + * { + * case VM_MSG_CREATE: + * //create signal. + * s_id = vm_signal_init(); + * sub_thread_proc(vm_sub_thread_proc, NULL, 0 ); + * + * break; + * case VM_MSG_QUIT: + * //release signal. + * vm_signal_deinit(s_id); + * break; + * case VM_MSG_XXX: + * handle_xxx_msg(); + * //post signal + * vm_signal_post(s_id); + * break; + * } + * } + * } + * + * *****************************************************************************/ +extern void vm_signal_deinit(VM_SIGNAL_ID s_id); + +/***************************************************************************** + * FUNCTION + * vm_mutex_create + * DESCRIPTION + * create a mutex. And it need not destroy, + * PARAMETERS + * mutex : [OUT] the mutex that needs to create. + * RETURNS + * void + * Example + * + * static vm_thread_mutex_struct my_mutex; + * + * VMINT vm_sub_thread1_proc(VM_THREAD_HANDLE thread_handle, void* user_data) + * { + * vm_mutex_create(&my_mutex); + * vm_mutex_lock(&my_mutex); + * //access global data; + * change_global_data(); + * vm_mutex_unlock(&my_mutex); + * } + * + * VMINT vm_sub_thread2_proc(VM_THREAD_HANDLE thread_handle, void* user_data) + * { + * do_some_thing(); + * vm_mutex_lock(&my_mutex); //suppose my_mutex has already been created. + * //access global data; + * change_global_data(); + * vm_mutex_unlock(&my_mutex); + * } + * + *****************************************************************************/ +extern void vm_mutex_create(vm_thread_mutex_struct *mutex); + +/***************************************************************************** + * FUNCTION + * vm_mutex_lock + * DESCRIPTION + * get the mutex. + * PARAMETERS + * mutex : [IN] The mutex + * RETURNS + * void + * Example + * + * static vm_thread_mutex_struct my_mutex; + * + * VMINT vm_sub_thread1_proc(VM_THREAD_HANDLE thread_handle, void* user_data) + * { + * vm_mutex_create(&my_mutex); + * vm_mutex_lock(&my_mutex); + * //access global data; + * change_global_data(); + * vm_mutex_unlock(&my_mutex); + * } + * + * VMINT vm_sub_thread2_proc(VM_THREAD_HANDLE thread_handle, void* user_data) + * { + * do_some_thing(); + * vm_mutex_lock(&my_mutex); //suppose my_mutex has already been created. + * //access global data; + * change_global_data(); + * vm_mutex_unlock(&my_mutex); + * } + * + *****************************************************************************/ +extern void vm_mutex_lock(vm_thread_mutex_struct *mutex); + +/***************************************************************************** + * FUNCTION + * vm_mutex_unlock + * DESCRIPTION + * release the mutex. + * PARAMETERS + * mutex : [IN] The mutex + * RETURNS + * void + * Example + * + * static vm_thread_mutex_struct my_mutex; + * + * VMINT vm_sub_thread1_proc(VM_THREAD_HANDLE thread_handle, void* user_data) + * { + * vm_mutex_create(&my_mutex); + * vm_mutex_lock(&my_mutex); + * //access global data; + * change_global_data(); + * vm_mutex_unlock(&my_mutex); + * } + * + * VMINT vm_sub_thread2_proc(VM_THREAD_HANDLE thread_handle, void* user_data) + * { + * do_some_thing(); + * vm_mutex_lock(&my_mutex); //suppose my_mutex has already been created. + * //access global data; + * change_global_data(); + * vm_mutex_unlock(&my_mutex); + * } + * + *****************************************************************************/ +extern void vm_mutex_unlock(vm_thread_mutex_struct *mutex); + +/***************************************************************************** + * FUNCTION + * vm_thread_sleep + * DESCRIPTION + * sleep one thread. + * PARAMETERS + * timeout : [IN] time to sleep (milli_secs) + * RETURNS + * void + * + * + * VMINT vm_sub_thread_proc(VM_THREAD_HANDLE thread_handle, void* user_data) + * { + * //do someting + * vm_thread_sleep(3000); + * } + * + * + *****************************************************************************/ +extern void vm_thread_sleep(VMUINT32 timeout); + +#ifdef __cplusplus +} +#endif + +#endif /* VMXML_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmtimer.h b/hardware/arduino/mtk/system/libmtk/include/vmtimer.h new file mode 100644 index 00000000..bf13b936 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmtimer.h @@ -0,0 +1,227 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMTIMER_SDK_H_ +#define VMTIMER_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +typedef enum +{ + + VM_TIMER_MTK_TIMER_NO_FREE = -5, + VM_TIMER_ERROR_OF_PROCESS, + VM_TIMER_ERROR_OF_RES , + VM_TIMER_ERROR_OF_MEM , + VM_TIMER_ERROR , + VM_TIMER_OK +} vm_timer_error_t; + +typedef struct +{ + VMUINT8 unused; +}*vm_kal_timerid; + +/* prototype of timer callback function */ +typedef void (*vm_kal_timer_func_ptr)(void *param_ptr); + +/*callback function VM_TIMERPROC_T */ +typedef void (*VM_TIMERPROC_T)(VMINT tid); + +/***************************************************************************** + * FUNCTION + * vm_create_timer + * DESCRIPTION + * create timer. + * Once the timer is created, it will be looply called till user delete it. It is a non-aligned timer, so it is a precise timer and will be stopped + * when the LCD backlight is off. For one application , the max number of this kind of timer is 10 + * PARAMETERS + * millisec : [IN] the length if the interval. The unit of interval is millisecond + * timerproc : [IN] the callback function when the timer is over time + * RETURNS + * The timer handle,the handle >0 when succeed,otherwise, handle <0 + * EAMPLE + * + * void customer_timer_example_proc(VMINT tid) + * { + * static VMINT s_restore_num = 0; + * s_restore_num++; + * if(s_restore_num > 10) + * { + * vm_delete_timer(tid); + * } + * } + * + * void customer_run_timer(void) + * { + * VMINT timer_id = 0; + * timer_id = vm_create_timer(1000, (VM_TIMERPROC_T)customer_timer_example_proc); + * if(timer_id < 0) + * { + * vm_log_debug("customer_run_timer create timer fail"); + * } + * } + * + *****************************************************************************/ +VMINT vm_create_timer(VMUINT32 millisec, VM_TIMERPROC_T timerproc); + + +/***************************************************************************** + * FUNCTION + * vm_delete_timer + * DESCRIPTION + * delete the timer created by vm_create_timer + * PARAMETERS + * timerid : [IN] the timer handler + * RETURNS + * succeed when return 0,otherwise, fail + * EXAMPLE + * + * refer from vm_create_timer code example + * + *****************************************************************************/ +VMINT vm_delete_timer(VMINT timerid); + + + +/***************************************************************************** + * FUNCTION + * vm_create_timer_ex + * DESCRIPTION + * create timer. + * Once the timer is created, it will be looply called till user delete it. It is an aligned timer, so it is not a precise timer. but it will still work + * when the LCD backlight is off. For one application , the max number of this kind of timer is 10 + * PARAMETERS + * millisec : [IN] the length if the interval. The unit of interval is millisecond + * timerproc : [IN] the callback function when the timer is over time + * RETURNS + * The timer handle,the handle >0 when succeed,otherwise, handle <0 + * EAMPLE + * + * void customer_timer_example_proc_ex(VMINT tid) + * { + * static VMINT s_restore_num = 0; + * s_restore_num++; + * if(s_restore_num > 10) + * { + * vm_delete_timer_ex(tid); + * } + * } + * + * void customer_run_timer_ex(void) + * { + * VMINT timer_id = 0; + * timer_id = vm_create_timer_ex(1000, (VM_TIMERPROC_T)customer_timer_example_proc_ex); + * if(timer_id < 0) + * { + * vm_log_debug("customer_run_timer_ex create timer fail!"); + * } + * } + * + *****************************************************************************/ +VMINT vm_create_timer_ex(VMUINT32 millisec, VM_TIMERPROC_T timerproc); + + +/***************************************************************************** + * FUNCTION + * vm_delete_timer_ex + * DESCRIPTION + * delete the timer created by vm_create_timer_ex + * PARAMETERS + * timerid : [IN] the timer handler + * RETURNS + * succeed when return 0,otherwise, fail + * EXAMPLE + * + * refer from vm_create_timer_ex code example + * + *****************************************************************************/ +VMINT vm_delete_timer_ex(VMINT timerid); + +/***************************************************************************** +* FUNCTION +* vm_create_kal_timer +* DESCRIPTION +* This interface used to create a kal timer, the priority higher than mmi task, it is related with interrupt. +* PARAMETERS +* timer_name : [IN] timer name. It's used for debug only, and only the +* first 8 characters retain. +* RETURN VALUES +* Success: timer pointer. +* Error: system enter fatal error handling. +*****************************************************************************/ +vm_kal_timerid vm_create_kal_timer(VMINT8 *timer_name); + +/***************************************************************************** +* FUNCTION +* vm_set_kal_timer +* DESCRIPTION +* This interface used to start a timer. this will cancel previous set timeout event , and start a new one. +* PARAMETERS +* timer_ptr : [IN] timer pointer. +* handler_func_ptr: [IN] pointer of timeout handler, it will be called after +* timeout happens, not use LinkIt API +* handler_param_ptr: [IN] user supply argument for handler_func_ptr +* delay: [IN] timeout duration in terms of time ticks, the maximum value is 0xFFFFFFFF +* reschedule_time: [IN] reset delay to reschedule_time after timeout happens. +* If it's zero, no reschedule happens and the timer is one-shot. +* Otherwise, it's a periodic timer. +* RETURN VALUES +* pointer of timder id, NULL means failed to create +*****************************************************************************/ +void vm_set_kal_timer(vm_kal_timerid timer_ptr, vm_kal_timer_func_ptr handler_func_ptr,void *handler_param_ptr, VMUINT32 delay, VMUINT32 reshedule_time); + +/***************************************************************************** +* FUNCTION +* vm_cancel_kal_timer +* DESCRIPTION +* This interface used to cancel a timer. Please note that canceling timer inside HISR may cancel a timer which is +* in expired stage but the callback function not yet been serviced. +* PARAMETERS +* ext_timer : [IN] timer pointer. +* RETURN VALUES +* pointer of timder id, NULL means failed to create +*****************************************************************************/ +void vm_cancel_kal_timer(vm_kal_timerid timer_ptr); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/hardware/arduino/mtk/system/libmtk/include/vmtls.h b/hardware/arduino/mtk/system/libmtk/include/vmtls.h new file mode 100644 index 00000000..4c94e4cc --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmtls.h @@ -0,0 +1,508 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VM_TLS_SDK_H +#define VM_TLS_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "vmsys.h" +#include "vmsock.h" + +typedef enum { + VM_TLS_ERR_NONE = 0, /* No error. */ + VM_TLS_ERR_WOULDBLOCK = -1, /* Operation cannot complete now. */ + VM_TLS_ERR_NO_FREE_CTX = -2, /* No free global context slots. */ + VM_TLS_ERR_NO_MEMORY = -3, /* Allocate memory failed. */ + VM_TLS_ERR_INVALID_CONTEXT = -4, /* Invalid global context id. */ + VM_TLS_ERR_INVALID_CIPHER = -5, /* Invalid cipher enum value. */ + VM_TLS_ERR_EXCESS_MAX_CIPHERS = -6, /* Too many ciphers. */ + VM_TLS_ERR_INVALID_PARAMS = -7, /* Invalid parameter. */ + VM_TLS_ERR_INVALID_ROOT_CERT = -8, /* Invalid root certificate id. */ + VM_TLS_ERR_INVALID_PRIV_KEY = -9, /* Invalid private key id. */ + VM_TLS_ERR_INVALID_PERSONAL_CERT = -10, /* Invalid personal certificate id. */ + VM_TLS_ERR_INVALID_FILE_TYPE = -11, /* Invalid file encoding type. */ + VM_TLS_ERR_INVALID_AUTH_MODE = -12, /* Invalid client auth mode. */ + VM_TLS_ERR_EXCESS_MAX_AUTH_MODES = -13, /* Too many client auth modes. */ + VM_TLS_ERR_ALREADY = -14, /* The operation is progressing. */ + VM_TLS_ERR_HANDSHAKED = -15, /* Handshaked completed. */ + VM_TLS_ERR_INVALID_SOCK_ID = -16, /* Invalid socket id. */ + VM_TLS_ERR_NO_CONN_CTX = -17, /* No associated connection context. */ + VM_TLS_ERR_HANDSHAKING = -18, /* Opreation denied when connection is handshaking. */ + VM_TLS_ERR_REHANDSHAKING = -19, /* Connection is rehandshaking. */ + VM_TLS_ERR_REHANDSHAKED = -20, /* TLS auto re-handshaked completed. */ + VM_TLS_ERR_SHUTDOWNED = -21, /* Opreation denied when connection is shutdowned. */ + VM_TLS_ERR_REQ_HANDSHAKE = -22, /* TLS peer requested handshake. */ + VM_TLS_ERR_NEED_HANDSHAKE = -23, /* Need handshake first. */ + VM_TLS_ERR_REHANDSHAKE_REJ = -24, /* Peer rejects our renegotiation, connection still valid. */ + VM_TLS_ERR_CONN_CLOSED = -25, /* Connection closed by peer. */ + VM_TLS_ERR_IO_ERROR = -26, /* Lower-layer IO error. */ + VM_TLS_ERR_OP_DENIED = -27, /* Operation denied due to incorrect state. */ + VM_TLS_ERR_READ_REQUIRED = -28, /* Application data need to be read before processing rehandshake. */ + VM_TLS_ERR_CERT_VALIDATE = -29, /* Certificate validation failed. */ + VM_TLS_ERR_PRNG_FAIL = -30, /* Set PRNG failed. */ + VM_TLS_ERR_WAITING_CERT = -32, /* Waiting certificate confirm from CERTMAN. */ + VM_TLS_ERR_FILESYS = -33, /* File system operation failed. */ + VM_TLS_ERR_TASK_NOT_READY = -34, /* TLS task not ready, waiting for CERTMAN confirm message. */ + VM_TLS_ERR_SSL_INTERNAL = -100,/* SSL layer internal error. */ + VM_TLS_ERR_SOC_INTERNAL = -101,/* Socket layer internal error. */ + VM_TLS_ERR_CERTMAN_INTERNAL = -102 /* Certman internal error. */ +} vm_tls_error_enum; + +typedef enum { + VM_TLS_ALL_VERSIONS = 0, /* ALL supported SSL/TLS versions */ + VM_SSLv2 = 0x01u << 0, /* SSLv2 */ + VM_SSLv3 = 0x01u << 1, /* SSLv3 */ + VM_TLSv1 = 0x01u << 2, /* TLSv1 */ + VM_TLS_UNKNOWN_VERSION = 0xffu /* Unknown */ +} vm_tls_version_enum; + +typedef enum { + VM_TLS_CLIENT_SIDE = 0, /* Client side */ + VM_TLS_SERVER_SIDE = 1 /* Server side */ +} vm_tls_side_enum; + +typedef enum { + VM_TLS_NULL_MD5 = 0, /* 0x0001, TLS_RSA_WITH_NULL_MD5. */ + VM_TLS_EXP_RC4_MD5 = 1, /* 0x0003, TLS_RSA_EXPORT_WITH_RC4_40_MD5.(*) */ + VM_TLS_RC4_MD5 = 2, /* 0x0004, TLS_RSA_WITH_RC4_128_MD5. */ + VM_TLS_RC4_SHA = 3, /* 0x0005, TLS_RSA_WITH_RC4_128_SHA, TLS Profile MUST. */ + VM_TLS_EXP_DES_CBC_SHA = 4, /* 0x0008, TLS_RSA_EXPORT_WITH_DES40_CBC_SHA.(*) */ + VM_TLS_DES_CBC_SHA = 5, /* 0x0009, TLS_RSA_WITH_DES_CBC_SHA. */ + VM_TLS_DES_CBC3_SHA = 6, /* 0x000A, TLS_RSA_WITH_3DES_EDE_CBC_SHA, TLS Profile MUST. */ + VM_TLS_EXP_EDH_DSS_DES_CBC_SHA = 7, /* 0x0011, TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA.(*) */ + VM_TLS_EDH_DSS_CBC_SHA = 8, /* 0x0012, TLS_DHE_DSS_WITH_DES_CBC_SHA. */ + VM_TLS_EDH_DSS_DES_CBC3_SHA = 9, /* 0x0013, TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA. */ + VM_TLS_EXP_EDH_RSA_DES_CBC_SHA = 10, /* 0x0014, TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA.(*) */ + VM_TLS_EDH_RSA_DES_CBC_SHA = 11, /* 0x0015, TLS_DHE_RSA_WITH_DES_CBC_SHA. */ + VM_TLS_EDH_RSA_DES_CBC3_SHA = 12, /* 0x0016, TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA. */ + VM_TLS_EXP_ADH_RC4_MD5 = 13, /* 0x0017, TLS_DH_anon_EXPORT_WITH_RC4_40_MD5.(*) */ + VM_TLS_ADH_RC4_MD5 = 14, /* 0x0018, TLS_DH_anon_WITH_RC4_128_MD5. */ + VM_TLS_EXP_ADH_DES_CBC_SHA = 15, /* 0x0019, TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA.(*) */ + VM_TLS_ADH_DES_CBC_SHA = 16, /* 0x001A, TLS_DH_anon_WITH_DES_CBC_SHA. */ + VM_TLS_ADH_DES_CBC3_SHA = 17, /* 0x001B, TLS_DH_anon_WITH_3DES_EDE_CBC_SHA. */ + + VM_TLS_AES128_SHA = 18, /* 0x002F, TLS_RSA_WITH_AES_128_CBC_SHA. */ + VM_TLS_AES256_SHA = 19, /* 0x0035, TLS_RSA_WITH_AES_256_CBC_SHA. */ + + VM_TLS_EXP1024_DES_CBC_SHA = 20, /* 0x0062, TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA. */ + VM_TLS_EXP1024_RC4_SHA = 21, /* 0x0064, TLS_RSA_EXPORT1024_WITH_RC4_56_SHA. */ + VM_TLS_DHE_DSS_RC4_SHA = 22, /* 0x0066, TLS_DHE_DSS_WITH_RC4_128_SHA. */ + + VM_TLS_ECDH_SECT163K1_RC4_SHA = 23, /* 0xC002 in RFC 4492, TLS_ECDH_ECDSA_WITH_RC4_128_SHA. */ + VM_TLS_ECDH_SECT163K1_NULL_SHA = 24, /* 0xC001 in RFC 4492, TLS_ECDH_ECDSA_WITH_NULL_SHA. */ + + VM_TLS_PSK_AES128_SHA = 25, /* 0x008C in RFC 4279, TLS_PSK_WITH_AES_128_CBC_SHA. */ + VM_TLS_PSK_DES_CBC3_SHA = 26, /* 0x008B in RFC 4279, TLS_PSK_WITH_3DES_EDE_CBC_SHA. */ + VM_TLS_UNKNOWN_CIPHER, + VM_TLS_TOTAL_CIPHER_NUM = VM_TLS_UNKNOWN_CIPHER +} vm_tls_cipher_enum ; + +typedef enum { + VM_TLS_NULL_WITH_NULL_NULL = 0x0000, /* (NULL, NULL, NULL)*/ + + VM_TLS_RSA_WITH_NULL_MD5 = 0x0001, /* (RSA, NULL, MD5) */ + VM_TLS_RSA_WITH_NULL_SHA = 0x0002, /* (RSA, NULL, SHA) */ + VM_TLS_RSA_EXPORT_WITH_RC4_40_MD5 = 0x0003, /* (RSA_EXPORT, RC4_40), MD5, TLS 1.0 */ + VM_TLS_RSA_WITH_RC4_128_MD5 = 0x0004, /* (RSA, RC4_128, MD5) */ + VM_TLS_RSA_WITH_RC4_128_SHA = 0x0005, /* (RSA, RC4_128, SHA) */ + VM_TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 = 0x0006, /* (RSA_EXPORT, RC2_CBC_40, MD5), TLS 1.0 */ + VM_TLS_RSA_WITH_IDEA_CBC_SHA = 0x0007, /* (RSA, IDEA_CBC, SHA) */ + VM_TLS_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x0008, /* (RSA_EXPORT, DES40_CBC, SHA), TLS 1.0 */ + VM_TLS_RSA_WITH_DES_CBC_SHA = 0x0009, /* (RSA, DES_CBC, SHA) */ + VM_TLS_RSA_WITH_3DES_EDE_CBC_SHA = 0x000A, /* (RSA, 3DES_EDE_CBC, SHA) */ + + VM_TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA = 0x000B, /* (DH_DSS_EXPORT, DES40_CBC, SHA), TLS 1.0 */ + VM_TLS_DH_DSS_WITH_DES_CBC_SHA = 0x000C, /* (DH_DSS, DES_CBC, SHA) */ + VM_TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA = 0x000D, /* (DH_DSS, 3DES_EDE_CBC, SHA) */ + VM_TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x000E, /* (DH_RSA_EXPORT, DES40_CBC, SHA), TLS 1.0 */ + VM_TLS_DH_RSA_WITH_DES_CBC_SHA = 0x000F, /* (DH_RSA, DES_CBC, SHA) */ + VM_TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA = 0x0010, /* (DH_RSA, 3DES_EDE_CBC, SHA) */ + VM_TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = 0x0011, /* (DHE_DSS_EXPORT, DES40_CBC, SHA), TLS 1.0 */ + VM_TLS_DHE_DSS_WITH_DES_CBC_SHA = 0x0012, /* (DHE_DSS, DES_CBCi, SHA) */ + VM_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 0x0013, /* (DHE_DSS, 3DES_EDE_CBC, SHA) */ + VM_TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x0014, /* (DHE_RSA_EXPORT, DES40_CBC, SHA), TLS 1.0 */ + VM_TLS_DHE_RSA_WITH_DES_CBC_SHA = 0x0015, /* (DHE_RSA, DES_CBCi, SHA) */ + VM_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 0x0016, /* (DHE_RSA, 3DES_EDE_CBC, SHA) */ + + VM_TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 = 0x0017, /* (DH_anon_EXPORT, RC4_40, MD5), TLS 1.0 */ + VM_TLS_DH_anon_WITH_RC4_128_MD5 = 0x0018, /* (DH_anon, RC4_128, MD5) */ + VM_TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA = 0x0019, /* (DH_anon, DES40_CBC, SHA), TLS 1.0 */ + VM_TLS_DH_anon_WITH_DES_CBC_SHA = 0x001A, /* (DH_anon, DES_CBC, SHA) */ + VM_TLS_DH_anon_WITH_3DES_EDE_CBC_SHA = 0x001B, /* (DH_anon, DES_CBC, SHA) */ + + VM_TLS_KRB5_WITH_DES_CBC_SHA = 0x001E, /* (Kerberos, DES_CBC, SHA) */ + VM_TLS_KRB5_WITH_3DES_EDE_CBC_SHA = 0x001F, /* (Kerberos, 3DES_EDE_CBC, SHA) */ + VM_TLS_KRB5_WITH_RC4_128_SHA = 0x0020, /* (Kerberos, RC4_128, SHA) */ + VM_TLS_KRB5_WITH_IDEA_CBC_SHA = 0x0021, /* (Kerberos, IDEA_CBC, SHA) */ + VM_TLS_KRB5_WITH_DES_CBC_MD5 = 0x0022, /* (Kerberos, DES_CBC, MD5) */ + VM_TLS_KRB5_WITH_3DES_EDE_CBC_MD5 = 0x0023, /* (Kerberos, 3DES_EDE_CBC, MD5) */ + VM_TLS_KRB5_WITH_RC4_128_MD5 = 0x0024, /* (Kerberos, RC4_128, MD5) */ + VM_TLS_KRB5_WITH_IDEA_CBC_MD5 = 0x0025, /* (Kerberos, IDEA_CBC, MD5) */ + + VM_TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA = 0x0026, /* (Kerberos, DES_CBC_40, SHA), MUST NOT */ + VM_TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA = 0x0027, /* (Kerberos, RC2_CBC_40, SHA), MUST NOT */ + VM_TLS_KRB5_EXPORT_WITH_RC4_40_SHA = 0x0028, /* (Kerberos, RC4_40, SHA), MUST NOT */ + VM_TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 = 0x0029, /* (Kerberos, DES_DBC_40, MD5), MUST NOT */ + VM_TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5 = 0x002A, /* (Kerberos, RC2_CBC_40, MD5), MUST NOT */ + VM_TLS_KRB5_EXPORT_WITH_RC4_40_MD5 = 0x002B, /* (Kerberos, RC4_40, MD5), MUST NOT */ + + VM_TLS_RSA_WITH_AES_128_CBC_SHA = 0x002F, /* (RSA, AES_128_CBC, SHA) */ + VM_TLS_DH_DSS_WITH_AES_128_CBC_SHA = 0x0030, /* (DH_DSS, AES_128_CBC, SHA) */ + VM_TLS_DH_RSA_WITH_AES_128_CBC_SHA = 0x0031, /* (DH_RSA, AES_128_CBC, SHA) */ + VM_TLS_DHE_DSS_WITH_AES_128_CBC_SHA = 0x0032, /* (DHE_DSS, AES_128_CBC, SHA) */ + VM_TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 0x0033, /* (DHE_RSA, AES_128_CBC, SHA) */ + VM_TLS_DH_anon_WITH_AES_128_CBC_SHA = 0x0034, /* (DH_anon, AES_128_CBC, SHA) */ + VM_TLS_RSA_WITH_AES_256_CBC_SHA = 0x0035, /* (RSA, AES_256_CBC, SHA) */ + VM_TLS_DH_DSS_WITH_AES_256_CBC_SHA = 0x0036, /* (DH_DSS, AES_256_CBC, SHA) */ + VM_TLS_DH_RSA_WITH_AES_256_CBC_SHA = 0x0037, /* (DHE_RSA, AES_256_CBC, SHA) */ + VM_TLS_DHE_DSS_WITH_AES_256_CBC_SHA = 0x0038, /* (DHE_RSA, AES_256_CBC, SHA) */ + VM_TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 0x0039, /* (DH_anon, AES_256_CBC, SHA) */ + VM_TLS_DH_anon_WITH_AES_256_CBC_SHA = 0x003A, /* (DH_anon, AES_256_CBC, SHA) */ + VM_TLS_CIPHER_UNKNOWN = 0xFFFF +} vm_tls_ciphersuites_enum; + + +typedef enum { + VM_TLS_FILETYPE_PEM = 0, /* PEM encoding */ + VM_TLS_FILETYPE_DER /* DER encoding */ +} vm_tls_filetype_enum; + +typedef enum { + VM_TLS_CLIENT_AUTH_BEGIN, + VM_TLS_CLIENT_AUTH_RSA_CLIENT, /* RSA client side */ + VM_TLS_CLIENT_AUTH_RSA_SERVER, /* RSA server side */ + VM_TLS_CLIENT_AUTH_DSS_CLIENT, /* DSS(DSA) cient side */ + VM_TLS_CLIENT_AUTH_DSS_SERVER, /* DSS(DSA) server side */ + VM_TLS_CLIENT_AUTH_END = 0xff +} vm_tls_auth_mode_enum; + + +typedef enum { + VM_TLS_ENC_ALGO_UNKNOWN, + VM_TLS_ENC_ALGO_NULL, /* NULL */ + + VM_TLS_ENC_ALGO_DES_40, /* DES 40 */ + VM_TLS_ENC_ALGO_DES, /* DES(56) */ + VM_TLS_ENC_ALGO_3DES, /* 3DES */ + + VM_TLS_ENC_ALGO_RC5, /* RC5 */ + VM_TLS_ENC_ALGO_RC5_56, /* RC5_56 */ + + VM_TLS_ENC_ALGO_AES_128, /* AES_128 */ + VM_TLS_ENC_ALGO_AES_192, /* AES_192, new for OpenSSL */ + VM_TLS_ENC_ALGO_AES_256, /* AES_256 */ + + VM_TLS_ENC_ALGO_ARC4_40, /* RC4_40 */ + VM_TLS_ENC_ALGO_ARC4_56, /* RC4_56, new for OpenSSL */ + VM_TLS_ENC_ALGO_ARC4_64, /* RC4_64, new for OpenSSL */ + VM_TLS_ENC_ALGO_ARC4_128, /* RC4_128 */ + + VM_TLS_ENC_ALGO_ARC2_40, /* RC2_40 */ + VM_TLS_ENC_ALGO_ARC2_56, /* RC2_56, new for OpenSSL */ + VM_TLS_ENC_ALGO_ARC2_64, /* RC4_64 */ + VM_TLS_ENC_ALGO_ARC2_128 /* RC2_128 */ +} vm_tls_encryption_enum; + +typedef enum { + VM_TLS_KEY_ALGO_UNKNOWN, + VM_TLS_KEY_ALGO_RSA, /* RSA */ + VM_TLS_KEY_ALGO_RSA_EXPORT, /* RSA_EXPORT */ + VM_TLS_KEY_ALGO_DH, /* DH */ + VM_TLS_KEY_ALGO_DH_EXPORT, /* DH_EXPORT */ + VM_TLS_KEY_ALGO_DHE, /* DH */ + VM_TLS_KEY_ALGO_DHE_EXPORT, /* DH_EXPORT */ + VM_TLS_KEY_ALGO_ECDH, /* ECDH */ + VM_TLS_KEY_ALGO_ECDHE, /* ECDHE */ + VM_TLS_KEY_ALGO_ECMQV, /* ECMQV */ + VM_TLS_KEY_ALGO_DSA, /* DSA */ + VM_TLS_KEY_ALGO_PSK, /* PSK */ + VM_TLS_KEY_ALGO_DHE_PSK, /* DHE_PSK */ + VM_TLS_KEY_ALGO_RSA_PSK, /* RSA_PSK */ + VM_TLS_KEY_ALGO_MAX +} vm_tls_key_exchange_enum; + +typedef enum { + VM_TLS_AUTH_ALGO_UNKNOWN, + VM_TLS_AUTH_ALGO_ANON, /* ANON */ + VM_TLS_AUTH_ALGO_RSA, /* RSA */ + VM_TLS_AUTH_ALGO_DSS, /* DSS */ + VM_TLS_AUTH_ALGO_ECDSA, /* ECDSA */ + VM_TLS_AUTH_ALGO_PSK /* PSK */ +} vm_tls_auth_enum; + +typedef enum { + VM_TLS_HASH_UNKNOWN, + VM_TLS_HASH_MD2, /* MD2 */ + VM_TLS_HASH_MD4, /* MD4 */ + VM_TLS_HASH_MD5, /* MD5 */ + VM_TLS_HASH_SHA1, /* SHA1 */ + VM_TLS_HASH_SHA224, /* SHA224 */ + VM_TLS_HASH_SHA256, /* SHA256 */ + VM_TLS_HASH_SHA384, /* SHA384 */ + VM_TLS_HASH_SHA512 /* SHA512 */ +} vm_tls_hash_enum; + +typedef struct { + vm_tls_version_enum version; /* SSL version number */ + vm_tls_encryption_enum enc; /* bulk encryption algrotithm */ + vm_tls_key_exchange_enum key_ex; /* key exchange algorithm */ + vm_tls_auth_enum auth; /* authentication algorithm */ + vm_tls_hash_enum hash; /* message digest algorithm */ +} vm_tls_cipher_info_struct; + + +/* Socket Type */ +typedef enum +{ + VM_SOC_SOCK_STREAM = 0, /* stream socket, TCP */ + VM_SOC_SOCK_DGRAM, /* datagram socket, UDP */ + VM_SOC_SOCK_SMS, /* SMS bearer */ + VM_SOC_SOCK_RAW /* raw socket */ +} vm_socket_type_enum; + +typedef enum { + VM_TLS_HANDSHAKE_READY = 0x01u << 0, /* The connection is ready for performing handshake. */ + VM_TLS_HANDSHAKE_DONE = 0x01u << 1, /* Handshake procedure is finished, success or failure. */ + VM_TLS_READ = 0x01u << 2, /* There is data for reading. */ + VM_TLS_WRITE = 0x01u << 3, /* There is buffer for writing. */ + VM_TLS_CLOSE = 0x01u << 4 /* The SSL connection is closed. */ +} vm_tls_event_enum; + +typedef enum { + VM_TLS_ALERT_LV_WARNING = 1, /* Warning alert. */ + VM_TLS_ALERT_LV_FATAL = 2 /* Fatal alert, application MUST terminate the connection immediately. */ +} vm_tls_alert_level_enum; + +typedef enum { + VM_TLS_ALERT_CLOSE_NOTIFY = 0, /* Peer shuts down the connection. */ + VM_TLS_ALERT_UNEXPECTED_MESSAGE = 10, /* Received an unexped mesage, always a fatal. */ + VM_TLS_ALERT_BAD_RECORD_MAC = 20, /* Bad MAC, always a fatal. */ + VM_TLS_ALERT_DECRYPTION_FAILED = 21, /* Decryption failed, always a fatal. */ + VM_TLS_ALERT_RECORD_OVERFLOW = 22, /* Record size exceeds the limitation, always a fatal. */ + VM_TLS_ALERT_DECOMPRESSION_FAILURE = 30, /* Deccompression failed, always a fatal. */ + VM_TLS_ALERT_HANDSHAKE_FAILURE = 40, /* Handshake failed, fatal. */ + VM_TLS_ALERT_NOCERTIFICATE_RESERVED = 41, /* Response to a certification request if no appropriate certificate is available, SSLv3 only. */ + VM_TLS_ALERT_BAD_CERTIFICATE = 42, /* A certificate was corrupt, signatures that did not verify correctly. */ + VM_TLS_ALERT_UNSUPPORTED_CERTIFICATE = 43, /* Unsupported certificate type. */ + VM_TLS_ALERT_CERTIFICATE_REVOKED = 44, /* Received a revoked certificate from peer. */ + VM_TLS_ALERT_CERTIFICATE_EXPIRED = 45, /* A certificate has expired or not yet valid. */ + VM_TLS_ALERT_CERTIFICATE_UNKNOWN = 46, /* Some unspecificate issue in processing the certificate. */ + VM_TLS_ALERT_ILLEGAL_PARAMETER = 47, /* Illegal parameter in the message, always a fatal. */ + VM_TLS_ALERT_UNKNOWN_CA = 48, /* The certificate chain cannot be verified successfully due to untrusted CA, always a fatal. */ + VM_TLS_ALERT_ACCESS_DENIED = 49, /* sender decided not to proceed with negotiation when access control was applied, always a fatal. */ + VM_TLS_ALERT_DECODE_ERROR = 50, /* The field in a message is incorrect, always a fatal. */ + VM_TLS_ALERT_DECRYPT_ERROR = 51, /* a handshake cryptographic operation failed, including verify a signature, decrypt a key exchange, or validate a finished mesasge. */ + VM_TLS_ALERT_EXPORT_RESTRICTION_RESERVED = 60, /* A negotiation not in compliance with export restrictions was detected. */ + VM_TLS_ALERT_PROTOCOL_VERSION = 70, /* The protocol version proposed by client is not supported by server side, always a fatal. */ + VM_TLS_ALERT_INSUFFICIENT_SECURITY = 71, /* The server requires cphers more secure than those supported by the client, always a fatal. */ + VM_TLS_ALERT_INTERNAL_ERROR = 80, /* An internal error unrelated to the peer, always a fatal. */ + VM_TLS_ALERT_USER_CANCELLED = 90, /* The handshake is canceled for some reason unrelated to a protocol failure, generally a warning. */ + VM_TLS_ALERT_NO_RENEGOTIATION = 100 /* When peer suggest to renegotiate again but local rejects it, always a warning. */ +} vm_tls_alert_desc_enum; + +typedef enum { + VM_TLS_USER_REJECT = 0, /* User rejects the invalid certificate. */ + VM_TLS_USER_ACCEPT_ONCE = 1, /* User accepts the invalid certificate for this time */ + VM_TLS_USER_ACCEPT_FOREVER = 2 /* User accepts the invalid cert forever */ +} vm_tls_inval_cert_action; + +typedef struct +{ + vm_socket_type_enum sock_type; /* socket type */ + VMINT16 addr_len; /* address length */ + VMUINT16 port; /* port number */ + VMUINT8 addr[VM_MAX_SOCK_ADDR_LEN]; +}vm_sockaddr_ex_struct; + +typedef struct { + VMUINT32 len; /* The size of the certificate in bytes */ + VMUINT8 *data; /* Data of the certficate in DER format */ +} vm_tls_cert_struct; + +#define VM_MSG_ID_APP_SOC_NOTIFY_IND 0 +#define VM_MSG_ID_APP_TLS_NOTIFY_IND 1 +#define VM_MSG_ID_APP_TLS_ALERT_IND 2 +#define VM_MSG_ID_APP_TLS_INVALID_CERT_IND 3 +#define VM_MSG_ID_APP_TLS_CLIENT_AUTH_IND 4 + +#define VM_TLS_EVT_PARAM_HEADER \ + VMINT msg; \ + VMINT res_id; \ + VMINT soc_id + +typedef struct +{ + VM_TLS_EVT_PARAM_HEADER; +}vm_tls_event_struct; + + +/* event */ +typedef enum +{ + VM_SOC_READ = 0x01, /* Notify for read */ + VM_SOC_WRITE = 0x02, /* Notify for write */ + VM_SOC_ACCEPT = 0x04, /* Notify for accept */ + VM_SOC_CONNECT = 0x08, /* Notify for connect */ + VM_SOC_CLOSE = 0x10 /* Notify for close */ +} vm_soc_event_enum; + +typedef struct +{ + VM_TLS_EVT_PARAM_HEADER; + vm_soc_event_enum event_type; /* vm_soc_event_enum */ + VMINT result; /* notification result. KAL_TRUE: success, KAL_FALSE: error */ + VMINT error_cause; /* vm_soc_error_enum used only when EVENT is close/connect */ + VMINT detail_cause; /* refer to ps_cause_enum if error_cause is + * VM_SOC_BEARER_FAIL */ +}vm_tls_soc_notify_ind_struct; + +/*************************************************************************** + * + * + * Indication to app for a common event. + * Local parameter of MSG_ID_APP_TLS_NOTIFY_IND. + ***************************************************************************/ +typedef struct +{ + VM_TLS_EVT_PARAM_HEADER; + vm_tls_event_enum event; /* Reported event from TLS task. + Applications should verifiy the event type and calls the corresponding + handler. + + * VM_TLS_HANDSHAKE_READY is an indication of the result of connection context + creation procedure. vm_tls_new_conn() might return TLS_ERR_WAITING_CERT for + loading certificates and waiting response from MOD_CERTMAN. After received + this message, application can then call vm_tls_handshake() to start TLS + handshake procedure. + + * VM_TLS_HANDSHAKE_DONE is an indication of the handshake result procedure. + Application can call vm_tls_read() to receive data from or call tls_write() to + send data to the peer. + + * For VM_TLS_READ, application should call vm_tls_read() repeatedly until + WOULDBLOCK returned. + + * For VM_TLS_WRITE, application is allowed to transmit the holding data by + calling vm_tls_write(). + + * For VM_TLS_CLOSE, application should call vm_tls_delete_conn() to de-associate + the connection with a socket id. + */ + VMINT result; /* Success or failure of the notification. */ + VMINT error; /* Error code. */ + VMINT detail_cause; /* Detail error cause. */ +} vm_tls_notify_ind_struct; + +/*************************************************************************** + * + * + * Indication to app for received an alert from peer. + * Local parameter of MSG_ID_APP_TLS_ALERT_IND. + ***************************************************************************/ +typedef struct +{ + VM_TLS_EVT_PARAM_HEADER; + vm_tls_alert_level_enum alert_level; /* Alert level. */ + vm_tls_alert_desc_enum alert_desc; /* Alert description. */ + VMINT error; /* Error code. */ + VMINT cause; /* Detail error cause. */ +} vm_tls_alert_ind_struct; + +/*************************************************************************** + * + * + * Indication of invalid certificate. + * Local parameter of MSG_ID_APP_TLS_INVALID_CERT_IND. + ***************************************************************************/ +typedef struct +{ + VM_TLS_EVT_PARAM_HEADER; + VMINT result; /* TRUE: user confirms to proceed the handshake against the received invalid certificate */ + vm_tls_inval_cert_action action; /* User's decision */ +} vm_tls_invalid_cert_ind_struct; + +#define VM_TLS_MAX_CLIENT_AUTH (7) +/*************************************************************************** + * + * + * Indication of client authentication request freom server. + * Local parameter of MSG_ID_APP_TLS_CLIENT_AUTH_IND. + ***************************************************************************/ +typedef struct +{ + VM_TLS_EVT_PARAM_HEADER; + VMINT result; /* TRUE: user selects a positive answer to the client authentication */ + VMINT auth_mode_num; /* auth modes in the following auth_modes array */ + vm_tls_auth_mode_enum auth_modes[VM_TLS_MAX_CLIENT_AUTH]; /* authmodes in the certificate request message from server */ + VMUINT identity_id; /* user selected certificate id. This field would be zero if no user certificate meets the criteria in the certificate request message. */ +} vm_tls_client_auth_ind_struct; + +typedef void (*callback_t)(vm_tls_event_struct * data); + + +VMINT vm_tls_new_ctx(vm_tls_version_enum ver, vm_socket_type_enum sock_type, VMINT apn, vm_tls_side_enum side, callback_t cb); +VMINT vm_tls_delete_ctx(VMINT res_id); +VMINT vm_tls_set_ciphers(VMINT res_id, const vm_tls_cipher_enum ciphers[], VMINT num); +VMINT vm_tls_set_verify(VMINT res_id, VMUINT32 cert_id[], VMINT cert_num, vm_tls_filetype_enum type); +VMINT vm_tls_set_client_auth(VMINT res_id, vm_tls_auth_mode_enum modes[], VMINT num); +VMINT vm_tls_set_identity(VMINT res_id, VMUINT32 cert_id); + +VMINT vm_tls_new_conn(VMINT res_id, vm_sockaddr_ex_struct * faddr); +VMINT vm_tls_delete_conn(VMINT res_id); +VMINT vm_tls_get_cipher(VMINT res_id, vm_tls_ciphersuites_enum *cipher); +VMINT vm_tls_get_cipher_info(VMINT res_id, vm_tls_cipher_info_struct *cipher_info); +VMINT vm_tls_get_peer_cert(VMINT res_id, vm_tls_cert_struct *cert); +VMINT vm_tls_check_invalid_cert(VMINT res_id, VMINT onoff); +VMINT vm_tls_set_null_client_auth(VMINT res_id); +VMINT vm_tls_check_peer_name(VMINT res_id, const VMCHAR * name); +VMINT vm_tls_auto_rehandshake(VMINT res_id, VMINT onoff); +VMINT vm_tls_handshake(VMINT res_id); +VMINT vm_tls_rehandshake(VMINT res_id); +VMINT vm_tls_read(VMINT res_id, void* buf, VMINT32 len); +VMINT vm_tls_write(VMINT res_id, const void* buf, VMINT32 len); +VMINT vm_tls_shutdown(VMINT res_id); +VMINT vm_tls_connect(VMINT res_id, vm_sockaddr_ex_struct * faddr); +VMINT vm_tls_soc_connect(VMINT res_id, vm_sockaddr_ex_struct * faddr); +VMINT vm_tls_log_plaintext(VMINT onoff); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* VM_TLS_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmtouch.h b/hardware/arduino/mtk/system/libmtk/include/vmtouch.h new file mode 100644 index 00000000..ae46380a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmtouch.h @@ -0,0 +1,272 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMTOUCH_SDK_H +#define VMTOUCH_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +typedef enum +{ + VM_MULTI_TOUCH_ERR_NO_RES = -7, /* no avalible resource */ + VM_MULTI_TOUCH_ERR_PARAM, /* input invalid parameter */ + VM_MULTI_TOUCH_ERR_NO_MEMORY, /* no memmory */ + VM_MULTI_TOUCH_ERR_NO_DISK, /* driver path failure */ + VM_MULTI_TOUCH_ERR_EXCEPTION, /* exception */ + VM_MULTI_TOUCH_ERR_NOT_SUPPORT, /* platform dose not support */ + VM_MULTI_TOUCH_ERR_NOT_AUTHORIZED, /* no authrization */ + VM_MULTI_TOUCH_ERR_SUCCESS = 0 /* success */ +}vm_multi_touch_error_t; + + +/* Touch screen mode */ +typedef enum +{ + /* Single touch mode, just send one finger event to application, this is default behavior */ + VM_SINGLE_TOUCH, + /* Multi-touch mode, send several events to application, according to how many fingers on the screen, at most it is five */ + VM_MULTI_TOUCH, + /* Total touch event total, no need to handle this */ + VM_MULTI_TOUCH_TOTAL +} vm_touch_mode; + + +/* structure of Point */ +typedef struct +{ + /* x coordinate */ + VMINT16 x; + /* x coordinate */ + VMINT16 y; +} vm_pen_point_struct; + +/* The touch position structure */ +typedef struct +{ + /* The coordinates of this event */ + vm_pen_point_struct pos; + /* The timestamp of this event */ + VMUINT32 timestamp; +} vm_touch_pos_struct; + +/* + * Each finger touch data information + * Example: + * typedef struct + * { + * vm_pen_point_struct down_pos; // ((200, 110), 29999) + * VMUINT16 merge_num; // 2 + * vm_pen_point_struct* merge_points; // ((200, 200), 30010), ((200, 250), 30020) + * VMUINT16* merge_area; // (50, 40) + * } mmi_touch_data_struct; + */ +typedef struct +{ + VMUINT16 id; /* finger id */ + VMINT event; /* current touch event */ + vm_touch_pos_struct currpos; /* current touch info */ + VMUINT16 area; /* current finger area */ + VMINT pre_event; /* previous touch event */ + vm_touch_pos_struct pre_pos; /* previous touch info */ + vm_touch_pos_struct down_pos; /* pen down info */ + VMUINT16 merge_num; /* if there are several pen move events, we will send several pen move events together to application */ + vm_touch_pos_struct* merge_points; /* pen move events array */ + VMUINT16* merge_area; /* related pen move area */ +} vm_multi_touch_data_struct; + +typedef struct +{ + /* The finger number of this event, at most it is five */ + VMUINT16 touch_num; + /* The touch data of each event */ + vm_multi_touch_data_struct * touch_data; +}vm_multi_touch_event_struct; + +/***************************************************************************** + * FUNCTION + * vm_multi_touch_get_mode + * DESCRIPTION + * get current screen touch mode + * PARAMETERS + * void + * RETURNS + * VMINT + *****************************************************************************/ +VMINT vm_multi_touch_get_mode(void); + +/***************************************************************************** + * FUNCTION + * vm_multi_touch_set_mode + * DESCRIPTION + * set touch screen mode + * PARAMETERS + * mode : [IN] the parameter should be vm_touch_mode, single or multiple + * RETURNS + * VMINT + *****************************************************************************/ +VMINT vm_multi_touch_set_mode(vm_touch_mode mode); + +/***************************************************************************** + * + * FUNCTION + * vm_multi_touch_proc_t + * DESCRIPTION + * PARAMETERS + * param : [IN] vm_multi_touch_event_struct. + * user_data : [IN] user data. + * RETURNS + * VMINT + *****************************************************************************/ +typedef VMINT (*vm_multi_touch_proc_t) (vm_multi_touch_event_struct * evt_info, void * user_data); + +/***************************************************************************** + * FUNCTION + * vm_touch_register_proc + * DESCRIPTION + * Register touch proc by screen level, no need to reset, the single touch event or + * PARAMETERS + * proc : [IN] the proc, the event in the proc should be vm_multi_touch_event_struct. + * user_data : [IN] user data, framework will send this user_data to your proc + * RETURNS + * vm_touch_register_proc + *****************************************************************************/ +VMINT vm_multi_touch_register_proc(vm_multi_touch_proc_t proc, void *user_data); + + +/***************************************************************************** + * FUNCTION + * vm_pen_configure_sampling_period + * DESCRIPTION + * Config sampling period of Event-based + * PARAMETERS + * sp :[IN] (Pen Event)Sampling period in pen-moving (multiple of 10ms) + * RETURNS + * VMINT + * RETURN VALUES + * 0 : success + * non-zero : failure + * -1 : no authorization + *****************************************************************************/ +VMINT vm_pen_configure_sampling_period(VMUINT sp); + +/***************************************************************************** + * FUNCTION + * vm_is_finger_touch_version + * DESCRIPTION + * Check whether the phone support finger touch feature or not. + * PARAMETERS + * void + * RETURN VALUES + * TRUE : Supports finger touch feature. + * FALSE : Not support. + *****************************************************************************/ +VMINT vm_is_finger_touch_version(void); + +/***************************************************************************** + * FUNCTION + * vm_is_support_pen_touch + * DESCRIPTION + * Check whether the phone support touch panel or not. + * PARAMETERS + * void + * RETURN VALUES + * TRUE : Supports touch panel. + * FALSE : Not support. + *****************************************************************************/ +VMINT vm_is_support_pen_touch(void); + +/* Pen events supported by MRE. */ + +/* Pen down event */ +#define VM_PEN_EVENT_TAP 1 +/* Pen release event */ +#define VM_PEN_EVENT_RELEASE 2 +/* Pen move event */ +#define VM_PEN_EVENT_MOVE 3 + /* Pen long tap event. + Note: + 1. LongTap handler is invoked when the pen is tapped for a period of time + and stays at the same place where it is tapped down. + 2. If pen move happen after pen down, there will be no pen LongTap event. + 3. Pen long tap can only happen one time at most.*/ +#define VM_PEN_EVENT_LONG_TAP 4 +/* Pen double click event */ +#define VM_PEN_EVENT_DOUBLE_CLICK 5 +/* Pen repeat event. + Note: + 1. Repeat can happen after LongTap or move or another repeat. + 2. Repeat event's coordinate will follow the previous events.*/ +#define VM_PEN_EVENT_REPEAT 6 +/* Pen abort event */ +#define VM_PEN_EVENT_ABORT 7 + +/***************************************************************************** + * + * + * FUNCTION + * vm_pen_handler_t + * DESCRIPTION + * + * PARAMETERS + * event : [IN] Key event. + * x : [IN] x coordinate. + * y : [IN] y coordinate. + * RETURNS + * void + *****************************************************************************/ +typedef void (*vm_pen_handler_t)(VMINT event, VMINT x, VMINT y); + +/***************************************************************************** + * FUNCTION + * vm_reg_pen_callback + * DESCRIPTION + * Registers pen event handler. + * PARAMETERS + * handler : [IN] Pen event handler. + * RETURNS + * void + *****************************************************************************/ +void vm_reg_pen_callback(vm_pen_handler_t handler); + +#ifdef __cplusplus +} +#endif + +#endif /* VMTOUCH_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmtsdcl.h b/hardware/arduino/mtk/system/libmtk/include/vmtsdcl.h new file mode 100644 index 00000000..97b6acab --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmtsdcl.h @@ -0,0 +1,335 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef __VM_DCL_H__ +#define __VM_DCL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmtssys.h" + + +/***************************************************************************** + * DESCRIPTION + * VM_TS_DCL_DEV is the type used to represent a special device such as UART,I2C,GPIO and so on. + * The value for every device group is defined in VM_TS_DCL_DEV_T. + * The value of a special device is defined in the header file of the device. + *****************************************************************************/ +typedef VMUINT16 VM_TS_DCL_DEV; + + +/***************************************************************************** +* This is the device number group enum. +* Each group device may have several devices. +* The specific device number please reference to the device driver. +* DUMMY_DEV group is for other users(not driver user) to register it's callback +*****************************************************************************/ +typedef enum +{ + VM_TS_DCL_UART_GROUP_START = 0, /*UART device number starts.*/ + VM_TS_DCL_I2C_GROUP_START = 0x100,/*I2C device number starts.*/ + VM_TS_DCL_SPI_GROUP_START = 0x200, /*SPI device number starts.*/ + VM_TS_DCL_ADC_GROUP_START = 0x300, /*ADC device number starts.*/ + VM_TS_DCL_GPIO_GROUP_START = 0x400, /*GPIO device number starts.*/ + VM_TS_DCL_PWM_GROUP_START = 0x500, /*PWM device number starts.*/ + VM_TS_DCL_RTC_GROUP_START = 0xA00, /*RTC device number starts.*/ + VM_TS_DCL_PMU_GROUP_START = 0xB00, /*PMU device number starts.*/ + VM_TS_DCL_EINT_GROUP_START = 0x1C00, /* EINT device number starts. */ + VM_TS_DCL_DUMMY_DEV_GROUP_START = 0x8000 /*DUMMY device number starts. For other user(not user driver)register callback in tiny system*/ +} VM_TS_DCL_DEV_T; + +/***************************************************************************** +* This is enum define dummy device, it's for other users(not driver user) to register callback +*****************************************************************************/ +typedef enum +{ + VM_TS_DCL_DUMMY_DEV_START = VM_TS_DCL_DUMMY_DEV_GROUP_START, + VM_TS_DCL_DUMMY_DEV +}VM_TS_DCL_DUMMY_DEV_T; + +/***************************************************************************** + * DESCRIPTION + * VM_TS_DCL_FLAGS is the type used to represent the flag that pass to the vm_ts_dcl_open. + * The value depend on each special device. + *****************************************************************************/ +typedef VMUINT32 VM_TS_DCL_FLAGS; + + +/***************************************************************************** + * DESCRIPTION + * VM_TS_DCL_HANDLE is the type used to record a specific device that opened by vm_ts_dcl_open. + * This value will be pass to other API to tell the driver which device will response to the corresponding operation. + *****************************************************************************/ +typedef VMINT32 VM_TS_DCL_HANDLE; + + +/*Represent invalid handle, returned by vm_ts_dcl_open.*/ +#define VM_TS_DCL_HANDLE_INVALID (-1) + + +/***************************************************************************** + * DESCRIPTION + * VM_TS_DCL_EVENT is the type used to register three level callcbcack, VM_TS_DCL_EVENT_T show the detail. + * Driver(UART/I2C/EINT,etc.) user can use VM_TS_DCL_REGISTER_CALLBACK_LEVEL0 to register level0 callback, + * VM_TS_DCL_REGISTER_CALLBACK_LEVEL2 to register level2 callback,and use VM_TS_DCL_REGISTER_CALLBACK_LEVEL3 to register level3 callback; + * But,other user(not user driver) just can use VM_TS_DCL_REGISTER_CALLBACK_LEVEL2 to register level2 callback, + * and use VM_TS_DCL_REGISTER_CALLBACK_LEVEL3 to register level3 callback. + *****************************************************************************/ +typedef VMUINT32 VM_TS_DCL_EVENT; + +typedef enum +{ + VM_TS_DCL_REGISTER_CALLBACK_LEVEL0=0,/*register LISR level*/ + VM_TS_DCL_REGISTER_CALLBACK_LEVEL2, /*register HISR level1*/ + VM_TS_DCL_REGISTER_CALLBACK_LEVEL3 /*register HISR level2*/ +}VM_TS_DCL_EVENT_T; + + +/***************************************************************************** + * DESCRIPTION + * VM_TS_DCL_CALLBACK_LEVEL is the type used to active callcbcack, VM_TS_DCL_CALLBACK_LEVEL_T show the detail. + * user can use VM_TS_DCL_CALLBACK_LEVEL2 to active level2 callback, and use VM_TS_DCL_CALLBACK_LEVEL3 to active level3 callback + *****************************************************************************/ +typedef VMUINT32 VM_TS_DCL_CALLBACK_LEVEL; +typedef enum +{ + VM_TS_DCL_CALLBACK_LEVEL2,/* HISR level1*/ + VM_TS_DCL_CALLBACK_LEVEL3 /* HISR level2*/ +}VM_TS_DCL_CALLBACK_LEVEL_T; + + +/***************************************************************************** + * DESCRIPTION + * VM_TS_DCL_CB_LEVEL0 is the prototype of the level0 callback function, + * with input parameter for driver(UART/I2C/EINT,etc.)sync status with user + * VM_TS_DCL_CB_LEVEL2 is the prototype of the level2 callback function. + * VM_TS_DCL_CB_LEVEL3 is the prototype of the level3 callback function. + *****************************************************************************/ +typedef void (* VM_TS_DCL_CB_LEVEL0)(VMUINT32 para); +typedef void (* VM_TS_DCL_CB_LEVEL2)(void); +typedef void (* VM_TS_DCL_CB_LEVEL3)(void); + + +/***************************************************************************** + * DESCRIPTION + * VM_TS_DCL_CTRL_CMD is the type used to represent the operation the driver need to do. + * The value of the type variable is depend on specific device driver. + * The detail please reference to the command enum of driver. + *****************************************************************************/ +typedef VMUINT32 VM_TS_DCL_CTRL_CMD; + +/***************************************************************************** + * DESCRIPTION + * VM_TS_DCL_STATUS is the type used to represent the status the driver returned. + * The meaning of the value please reference to VM_TS_DCL_STATUS. + *****************************************************************************/ +typedef VMINT32 VM_TS_DCL_STATUS; + + +/* This used to represent the status of dcl operations.*/ +typedef enum +{ + VM_TS_DCL_STATUS_OK = 0, /*Operation success*/ + VM_TS_DCL_STATUS_FAIL = -1, /*Operation failed*/ + VM_TS_DCL_STATUS_INVALID_CMD = -2, /*The command send to device is invalid*/ + VM_TS_DCL_STATUS_UNSUPPORTED = -3, /*The device do not support the operation*/ + VM_TS_DCL_STATUS_NOT_OPENED = -4, /*The device isn't open*/ + VM_TS_DCL_STATUS_INVALID_EVENT = -5, /*The event is invalid*/ + VM_TS_DCL_STATUS_INVALID_DCL_HANDLE = -6, /*The handle used to operate the device is invalid. The invalid handle returned by vm_dcl_open is another value.*/ + VM_TS_DCL_STATUS_INVALID_CTRL_DATA = -7, /*The data used to control the device is invalid.*/ + VM_TS_DCL_STATUS_INVALID_ARGUMENT = -9, /*The data used to control the device is invalid.*/ + VM_TS_DCL_STATUS_ERROR_TIMEOUT = -10, /*Operation timeout.*/ + VM_TS_DCL_STATUS_ERROR_CRCERROR = -11, /*CRC error.*/ + VM_TS_DCL_STATUS_ERROR_READONLY = -12, /*device is readonly.*/ + VM_TS_DCL_STATUS_ERROR_WRONG_STATE = -13, /*wrong state.*/ + VM_TS_DCL_STATUS_INVALID_DEVICE = -14, /*invalid device.*/ + VM_TS_DCL_STATUS_ALREADY_OPENED = -15, /*device is already opened.*/ + VM_TS_DCL_STATUS_INVALID_OPERATION = -17, /*operation is invalid.*/ + VM_TS_DCL_STATUS_DEVICE_NOT_EXIST = -18,/*device is not exist.*/ + VM_TS_DCL_STATUS_DEVICE_IS_BUSY = -20,/*device is busy.*/ +} VM_TS_DCL_STATUS_T; + + + +/***************************************************************************** +* FUNCTION + * vm_ts_dcl_open + * DESCRIPTION + * 1 Open one device. Every device must be opened with this function before use it. + * The device number passed to this function was defined in device driver's header file(except dummy device). + * The returned handle is the device's identify which will be passed to the other functions at runtime + * PARAMETERS + * device: [IN] The number of device, given by device driver. It's a 16 bits integer. + * flags: [IN] The parameter needed for the device. It's a 32 bits unsigned integer. Some driver may not need this. + * RETURNS + * The return value is the handle which record the information of corresponding device. + * + * RETURN VALUES + * VM_TS_DCL_HANDLE: The handle record the information of corresponding device. + * If the value of returned handle equal to VM_TS_DCL_HANDLE_INVALID, the open operation failed. + * + * EXAMPLE + * + * VM_TS_DCL_HANDLE uart_handle; + * uart_handle = vm_dcl_open(vm_uart_port1,0); + * if(VM_TS_DCL_HANDLE_INVALID==uart_handle) + * return; + * else + * //Do something with the handle. + * +*****************************************************************************/ +VM_TS_DCL_HANDLE vm_ts_dcl_open(VM_TS_DCL_DEV dev, VM_TS_DCL_FLAGS flags); + + +/***************************************************************************** +* FUNCTION + * vm_ts_dcl_control + * DESCRIPTION + * Send command to control the device. + * This function used to control the device after open the device successfully. + * The command tell the driver what to do and the arg will give the information needed for the control to driver. + * The command is defined in device driver's header file and represent different meaning even have the same value + * for different device. So the handle, command and arg must be match, otherwise the operation maybe given to wrong + * device or do wrong operation. + * This function maybe synchronous or asynchronous operation depending on which devices' which command. + * The details please reference to the command description in the specific driver's document. + * PARAMETERS + * handle: [IN] The handle which returned by vm_dcl_open. + * cmd: [IN] The command used to control the device. The detail reference to the device document. + * arg: [IN] The argument used by the command. The detail reference to the device document. + * RETURNS + * The return value is status. The meaning reference to VM_TS_DCL_STATUS_T; + * + * RETURN VALUES + * VM_TS_DCL_STATUS : The return value is status.The meaning reference to VM_TS_DCL_STATUS_T; + * + * EXAMPLE + * + * VM_TS_DCL_STATUS status; + * vm_ts_sio_ctrl_dcb_t config; + * VM_TS_DCL_MODULE_TYPE_T usr_id; + * VM_TS_DCL_HANDLE uart_handle; + * + * uart_handle = vm_ts_dcl_open(vm_ts_uart_port1,usr_id); + * config.u4OwenrId = usr_id; + * config.rUARTConfig.fgDSRCheck = 0; + * config.rUARTConfig.u1DataBits = 8; + * config.rUARTConfig.u1FlowControl = VM_FC_NONE; + * config.rUARTConfig.u1Parity = VM_PA_NONE; + * config.rUARTConfig.u1StopBits = VM_SB_1; + * config.rUARTConfig.u4Baud = 115200; + * config.rUARTConfig.ucXoffChar = 0x13; + * config.rUARTConfig.ucXonChar = 0x11; + * status=vm_ts_dcl_control(uart_handle,VM_TS_SIO_CMD_SET_DCB_CONFIG,&config); + * +*****************************************************************************/ +VM_TS_DCL_STATUS vm_ts_dcl_control(VM_TS_DCL_HANDLE handle,VM_TS_DCL_CTRL_CMD cmd, void* arg); + + +/***************************************************************************** +* FUNCTION + * vm_ts_dcl_close + * DESCRIPTION + * Close the device, after the device finished the operation, user should close the device. + * PARAMETERS + * handle: [IN] The handle which returned by vm_dcl_open. + * RETURNS + * The return value is status. The meaning reference to VM_DCL_STATUS_T; + * + * RETURN VALUES + * VM_DCL_STATUS : The return value is status.The meaning reference to VM_DCL_STATUS_T; + * +* EXAMPLE + * + * status = vm_dcl_close(i2c_handle); + * status = vm_dcl_close(user_handle); + * +*****************************************************************************/ +VM_TS_DCL_STATUS vm_ts_dcl_close(VM_TS_DCL_HANDLE handle); + + +/***************************************************************************** +* FUNCTION + * vm_ts_dcl_register_callback + * DESCRIPTION + * Register user's callback. + * For Driver(UART/I2C/EINT,etc.) user, the callback is for device to do asynchronous operations. + * For other(not driver user) user,the callback support one context to run code. + * In both case, it's should be register the callback, before active it. + * The implementation of the callback please reference to prototype of the callback function. + * PARAMETERS + * handle: [IN] The handle which returned by vm_ts_dcl_open. + * event: [IN] The event indicate register which level of callback, include: VM_TS_DCL_REGISTER_CALLBACK_LEVEL0, + * VM_TS_DCL_REGISTER_CALLBACK_LEVEL2,VM_TS_DCL_REGISTER_CALLBACK_LEVEL3 + * callback: [IN] callback function. + * + * RETURN VALUES + * VM_TS_DCL_STATUS : The return value is status. + * +* EXAMPLE + * + + * +*****************************************************************************/ +VM_TS_DCL_STATUS vm_ts_dcl_register_callback(VM_TS_DCL_HANDLE handle,VM_TS_DCL_EVENT event, void* callback); + + +/***************************************************************************** + * FUNCTION + * vm_ts_dcl_active_callback + * DESCRIPTION + * Active callback,use to active just level2 or level3 callback,(not include level0 callback),if register before. + * PARAMETERS + * handle: [IN] The handle which returned by vm_ts_dcl_open. + * level: [IN] The level indicate active which level of callback, include: VM_TS_DCL_CALLBACK_LEVEL2, + * VM_TS_DCL_CALLBACK_LEVEL3 + * RETURN VALUES + * VM_TS_DCL_STATUS : The return value is status. + * + * EXAMPLE + * + + * +*****************************************************************************/ +void vm_ts_dcl_active_callback(VM_TS_DCL_HANDLE handle, VM_TS_DCL_CALLBACK_LEVEL level); + + +#ifdef __cplusplus +} +#endif + +#endif /* __VM_DCL_H__ */ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_eint.h b/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_eint.h new file mode 100644 index 00000000..3dc4d31a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_eint.h @@ -0,0 +1,80 @@ +#ifndef __VM_TS_DCL_EINT_H__ +#define __VM_TS_DCL_EINT_H__ + + +/****************************************************************** +* DESCRIPTION +* This enum defines the device for EINT module,used in vm_ts_dcl_open as a parameter. +* To control GPIOs, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vmtsdcl.h" +* VM_TS_DCL_HANDLE eint_handle; // Declare a VM_TS_DCL_HANDLE variable. +* eint_handle = vm_ts_dcl_open(VM_TS_DCL_EINT,12); // Call vm_ts_dcl_open to get a handle. 12 means eint's number is 12. +* +*******************************************************************/ +typedef enum +{ + VM_TS_EINT_GROUP_START = VM_TS_DCL_EINT_GROUP_START, + VM_TS_DCL_EINT /*This is for control normal eint function. */ +}VM_TS_DCL_EINT_DEV; + +/****************************************************************** +* DESCRIPTION +* This enum define the control command for EINT module,used in vm_ts_dcl_control as parameter. +* With different commands, user could control the different function of the EINT. +* To control EINT, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vmtsdcl.h" +* VM_TS_DCL_HANDLE eint_handle; // Declare a VM_TS_DCL_HANDLE variable. +* VM_TS_DCL_EINT_CTRL_CONFIG_T eint_config; //Declare a VM_TS_DCL_EINT_CTRL_CONFIG_T variable. +* VM_TS_DCL_EINT_CTRL_SET_HW_DEBOUNCE_T deboun_time; //Declare a VM_TS_DCL_EINT_CTRL_SET_HW_DEBOUNCE_T variable. +* eint_handle = vm_ts_dcl_open(VM_TS_DCL_EINT,19); // First, we call vm_ts_dcl_open to get a handle. 19 means eint19 +* vm_ts_dcl_control(eint_handle,VM_TS_EINT_CMD_MASK,NULL); // Usually, before we config eint, we mask it firstly. +* vm_ts_dcl_register_callback(eint_handle,VM_TS_DCL_REGISTER_CALLBACK_LEVEL2,(void)eint_callback); // register callback function,Note: eint calback is given by user +* deboun_time.debounce_time = 10; //Debounce time 10ms +* vm_ts_dcl_control(eint_handle,VM_TS_EINT_CMD_SET_HW_DEBOUNCE,(void *)&deboun_time); // Set debounce time +* eint_config.act_polarity = 0; // 1 means positive active, 0 means negative active. +* eint_config.debounce_en = 1; // 1 means enable hw debounce, 0 means disable. +* eint_config.act_sens = 1; // 1 means level, 0 means edge. +* vm_ts_dcl_control(eint_handle,VM_TS_EINT_CMD_CONFIG,(void *)&eint_config); // Please call this api finally, because we will unmask eint in this command. +* vm_ts_dcl_control(eint_handle,VM_TS_EINT_CMD_UNMASK,NULL); // call this function to unmask this eint. +* vm_ts_dcl_close(eint_handle); // Finally, if you are sure you will not use eint, you call vm_dcl_close ,otherwise, not call this api. +* +*******************************************************************/ +typedef enum{ + VM_TS_DCL_EINT_CMD_CONFIG, /* EINT config command. */ + VM_TS_DCL_EINT_CMD_SET_HW_DEBOUNCE, /* EINT set hardware debounce command. */ + VM_TS_DCL_EINT_CMD_MASK, /* EINT mask command. */ + VM_TS_DCL_EINT_CMD_UNMASK, /* EINT unmask command. */ + VM_TS_DCL_EINT_CMD_ACK, /* EINT ack command, after callback, user should act the eint*/ +}VM_TS_DCL_EINT_CTRL_CMD; + + + /****************************************************************** + * DESCRIPTION + * This struct is for VM_TS_DCL_EINT_CMD_CONFIG control command,used in vm_ts_dcl_control as parameter. + * You can find the sample code in the description of VM_TS_DCL_EINT_CTRL_CMD. + *******************************************************************/ +typedef struct +{ + VMUINT8 debounce_en; /* The value is 1 or 0. 1 means enable hw debounce, 0 means disable */ + VMUINT8 act_sens; /* The value is 1 0r 0. 1 means level trigger, 0 means edge trigger.*/ + VMUINT8 act_polarity; /* The value is 1 0r 0. 1 means positive active, 0 means negative active.*/ +}VM_TS_DCL_EINT_CTRL_CONFIG_T; + + /****************************************************************** + * DESCRIPTION + * This struct is for VM_TS_DCL_EINT_CMD_SET_HW_DEBOUNCE control command,used in vm_ts_dcl_control as parameter. + * You can find the sample code in the description of VM_TS_DCL_EINT_CTRL_CMD. + *******************************************************************/ +typedef struct +{ + VMUINT32 debounce_time;/* HW debounce time. the unit is ms.*/ +} VM_TS_DCL_EINT_CTRL_SET_HW_DEBOUNCE_T; + + + +#endif + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_gpio.h b/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_gpio.h new file mode 100644 index 00000000..dc9cf765 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_gpio.h @@ -0,0 +1,174 @@ +#ifndef __VM_TS_DCL_GPIO_H__ +#define __VM_TS_DCL_GPIO_H__ + + + +/****************************************************************** +* DESCRIPTION +* This enum defines the device for gpio module,used in vm_ts_dcl_open as a +parameter. +* To control GPIOs, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vmtsdcl.h" +* VM_TS_DCL_HANDLE gpio_handle; // Declare a VM_TS_DCL_HANDLE variable. +* gpio_handle = vm_ts_dcl_open(VM_TS_DCL_GPIO,55); // Call vm_ts_dcl_open to get a handle. 55 means gpio55 +* +*******************************************************************/ + +typedef enum +{ + VM_TS_GPIO_GROUP_START = VM_TS_DCL_GPIO_GROUP_START, + VM_TS_DCL_GPIO, /*This is for control normal gpio function. */ + VM_TS_DCL_GPIO_CLK /*This is for control clock out for some gpio. */ +}VM_TS_DCL_GPIO_DEV; + + +/****************************************************************** +* DESCRIPTION +* This enum is for VM_TS_DCL_GPIO_CMD_SET_CLK_OUT command,used in vm_ts_dcl_control as parameter. +* Please refer the introduction of VM_TS_DCL_GPIO_CTRL_SET_CLK_OUT_T for more details. +*******************************************************************/ +typedef enum { + VM_TS_MODE_DEFAULT = 0, /*The default mode is 0. User should refer to the GPIO datasheet to see the specified value*/ + VM_TS_MODE_F32K_CK = 0x82, /*Use this enum value to set the 32K clock out in a faster way*/ + VM_TS_MODE_MAX_NUM /*This value defines the max number of mode, do not exceed this value*/ + } VM_TS_DCL_GPIO_CLK_MODE; + + +/****************************************************************** +* DESCRIPTION +* This enum is for VM_TS_DCL_GPIO_CMD_SET_CLK_DIV,used in vm_ts_dcl_control as parameter. +* Please refer the introduction of VM_TS_DCL_GPIO_CTRL_SET_CLK_DIV_T for more details. +*******************************************************************/ +typedef enum { + VM_TS_DIV_MAX_NUM =16 /*This value defines the max number of div, do not exceed this value*/ +} VM_TS_DCL_GPIO_CLK_DIV; + + +/****************************************************************** +* DESCRIPTION +* This enum define the control command for GPIO module,used in vm_ts_dcl_control as parameter. +* With different commands, user could control the different function of the GPIOs. +* To control GPIOs, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vmtsdcl.h" +* VM_TS_DCL_HANDLE gpio_handle; // Declare a VM_TS_DCL_HANDLE variable. +* VM_TS_DCL_GPIO_CTRL_READ_T gpio_input_data; //Declare a variable for read IO. +* VM_TS_DCL_GPIO_CTRL_SET_PUPD_R0_R1_T pupd_r0r1_data; //Declare a VM_TS_DCL_GPIO_CTRL_SET_PUPD_R0_R1_T variable. +* gpio_handle = vm_ts_dcl_open(VM_TS_DCL_GPIO,55); // First, we call vm_ts_dcl_open to get a handle. 55 means gpio55 +* vm_ts_dcl_control(gpio_handle,VM_TS_DCL_GPIO_CMD_SET_MODE_3,NULL); // we call vm_ts_dcl_control to set gpio55 as mode3. +* vm_ts_dcl_control(gpio_handle,VM_TS_DCL_GPIO_CMD_READ,(void *)&gpio_input_data); // We call vm_ts_dcl_control to read gpio55 . +* vm_ts_dcl_control(gpio_handle,VM_TS_DCL_GPIO_CMD_WRITE_HIGH,0); // we call vm_ts_dcl_control to write gpio55 . +* pupd_r0r1_data.fgSetPupd = 1; // More details, please refer to the GPIO datasheet. +* pupd_r0r1_data.fgSetR0 = 1; // More details, please refer to the GPIO datasheet. +* pupd_r0r1_data.fgSetR1 = 0; // More details, please refer to the GPIO datasheet. +* vm_ts_dcl_control(gpio_handle,VM_TS_DCL_GPIO_CMD_SET_PUPD_R0_R1,(void *)&pupd_r0r1_data); //we call vm_ts_dcl_control to set pupd of gpio55 . +* vm_ts_dcl_close(gpio_handle); // Finally, we call vm_ts_dcl_close +* +*******************************************************************/ +typedef enum +{ + VM_TS_DCL_GPIO_CMD_READ, /*read data from GPIO Pin*/ + VM_TS_DCL_GPIO_CMD_WRITE_LOW, /*write low to GPIO pin*/ + VM_TS_DCL_GPIO_CMD_WRITE_HIGH, /*write high to GPIO Pin*/ + VM_TS_DCL_GPIO_CMD_SET_MODE_0, /*set GPIO mode as mode 0*/ + VM_TS_DCL_GPIO_CMD_SET_MODE_1, /*set GPIO mode as mode 1*/ + VM_TS_DCL_GPIO_CMD_SET_MODE_2, /*set GPIO mode as mode 2*/ + VM_TS_DCL_GPIO_CMD_SET_MODE_3, /*set GPIO mode as mode 3*/ + VM_TS_DCL_GPIO_CMD_SET_MODE_4, /*set GPIO mode as mode 4 ,only for chip support 4-bit mode*/ + VM_TS_DCL_GPIO_CMD_SET_MODE_5, /*set GPIO mode as mode 5*,only for chip support 4-bit mode*/ + VM_TS_DCL_GPIO_CMD_SET_MODE_6, /*set GPIO mode as mode 6*,only for chip support 4-bit mode*/ + VM_TS_DCL_GPIO_CMD_SET_MODE_7, /*set GPIO mode as mode 7*,only for chip support 4-bit mode*/ + VM_TS_DCL_GPIO_CMD_SET_MODE_8, /*set GPIO mode as mode 8*,only for chip support 4-bit mode*/ + VM_TS_DCL_GPIO_CMD_SET_MODE_9, /*set GPIO mode as mode 9*,only for chip support 4-bit mode*/ + VM_TS_DCL_GPIO_CMD_SET_MODE_10, /*set GPIO mode as mode 10*,only for chip support 4-bit mode*/ + VM_TS_DCL_GPIO_CMD_SET_DIR_OUT, /*set GPIO direction as output*/ + VM_TS_DCL_GPIO_CMD_SET_DIR_IN, /*set GPIO direction as input*/ + VM_TS_DCL_GPIO_CMD_ENABLE_PULL, /*enable GPIO pull-up/pull-down seting */ + VM_TS_DCL_GPIO_CMD_DISABLE_PULL, /*disable GPIO pull-up/pull-down seting*/ + VM_TS_DCL_GPIO_CMD_SET_PULL_HIGH, /*set GPIO as pull-up*/ + VM_TS_DCL_GPIO_CMD_SET_PULL_LOW, /*set GPIO as pull-down*/ + VM_TS_DCL_GPIO_CMD_SET_CLK_OUT, /*select the clock output source of GPIO*/ + VM_TS_DCL_GPIO_CMD_SET_CLK_DIV, /*select the clock div of GPIO*/ + VM_TS_DCL_GPIO_CMD_SET_PUPD_R0_R1, /*set the pupd ,r0,r1 register of gpio*/ +}VM_TS_DCL_GPIO_CTRL_CMD_T; + +/****************************************************************** +* DESCRIPTION +* This struct is for VM_TS_DCL_GPIO_CMD_READ control command,used in vm_ts_dcl_control as parameter. +* You can find the sample code in the description of VM_TS_DCL_GPIO_CTRL_CMD_T. +*******************************************************************/ +typedef struct +{ + VMUINT8 u1IOData; /* The returned value. 0 means the GPIO pin input level is low. 1 means level is high*/ +} VM_TS_DCL_GPIO_CTRL_READ_T; + +/****************************************************************** +* DESCRIPTION +* This struct is for VM_TS_DCL_GPIO_CMD_SET_PUPD_R0_R1 control command,used in vm_ts_dcl_control as parameter. +* With this command, you can set the pupd,r0,r1 funtion of a specified GPIOs. +* You can find the sample code in the description of VM_TS_DCL_GPIO_CTRL_CMD_T. +* All commands have similar usage. +*******************************************************************/ +typedef struct +{ + VMBOOL fgSetPupd; /*This function set the pull up/down resisters of some special GPIO pins. Different fgSetPupd,fgSetR0,fgSetR1 means defferent pull up/down resisters.Please get more details in datasheet.*/ + VMBOOL fgSetR0; /*This function set the pull up/down resisters of some special GPIO pins. Different fgSetPupd,fgSetR0,fgSetR1 means defferent pull up/down resisters.Please get more details in datasheet.*/ + VMBOOL fgSetR1; /*This function set the pull up/down resisters of some special GPIO pins. Different fgSetPupd,fgSetR0,fgSetR1 means defferent pull up/down resisters.Please get more details in datasheet.*/ +} VM_TS_DCL_GPIO_CTRL_SET_PUPD_R0_R1_T; + + +/****************************************************************** +* DESCRIPTION +* This struct is for VM_TS_DCL_GPIO_CMD_SET_CLK_OUT control command,used in vm_ts_dcl_control as parameter. +* To control GPIOs, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vmtsdcl.h" +* VM_TS_DCL_HANDLE gpio_handle; // Declare a VM_TS_DCL_HANDLE variable. +* VM_TS_DCL_GPIO_CTRL_SET_CLK_OUT_T clk_data; //Declare a VM_TS_DCL_GPIO_CTRL_SET_CLK_OUT_T variable. +* gpio_handle = vm_ts_dcl_open(VM_TS_DCL_GPIO_CLK,55);// Step1, we call open function to get a handle. 55 means gpio55. Notice the dev parameter is VM_TS_DCL_GPIO_CLK. +* clk_data.u2ClkNum = 2;// More details, please refer to the GPIO datasheet. +* clk_data.u2Mode = 4; //More details, please refer to the GPIO datasheet. +* vm_ts_dcl_control(gpio_handle,VM_TS_GPIO_CMD_SET_CLK_OUT,(void *)&clk_data); // Step2, we call control function to set clk of gpio. +* vm_ts_dcl_close(gpio_handle); // Finally, we call close function +* +*******************************************************************/ +typedef struct +{ + VMUINT16 u2ClkNum; /*The clock register number in datasheet.*/ + VM_TS_DCL_GPIO_CLK_MODE u2Mode; /*The clock mode in datasheet.different mode means different source clock selected*/ +} VM_TS_DCL_GPIO_CTRL_SET_CLK_OUT_T; + + +/****************************************************************** +* DESCRIPTION +* This struct is for VM_TS_DCL_GPIO_CMD_SET_CLK_DIV control command,used in vm_ts_dcl_control as parameter. +* To control GPIOs, you should use DCL(Driver Common Layer) APIs. +* Note,some platform do not have such functions and others may have. You should refer the datasheet before using GPIOs. +* EXAMPLE +* +* #include "vmtsdcl.h" +* VM_TS_DCL_HANDLE gpio_handle; // Declare a VM_TS_DCL_HANDLE variable. +* VM_TS_DCL_GPIO_CTRL_SET_CLK_DIV_T clk_data; //Declare a VM_TS_DCL_GPIO_CTRL_SET_CLK_DIV_T variable. +* gpio_handle = vm_ts_dcl_open(VM_TS_DCL_GPIO_CLK,55);// Step1, we call open function to get a handle. 55 means gpio55. Notice the dev parameter is VM_TS_DCL_GPIO_CLK. +* clk_data.u2ClkNum = 3;// More details, please refer to the GPIO datasheet. +* clk_data.u2Div = 2; //More details, please refer to the GPIO datasheet. +* vm_ts_dcl_control(gpio_handle,VM_TS_DCL_GPIO_CMD_SET_CLK_DIV,(void *)&clk_data); // Step2, we call control function to set clk div of gpio. +* vm_ts_dcl_close(gpio_handle); // Finally, we call close function +* +*******************************************************************/ +typedef struct +{ + VMUINT16 u2ClkNum; /*The clock register number in datasheet.*/ + VM_TS_DCL_GPIO_CLK_DIV u2Div; /*The division value in datasheet.Please get more details in datasheet.*/ +}VM_TS_DCL_GPIO_CTRL_SET_CLK_DIV_T; + + + + +#endif + + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_i2c.h b/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_i2c.h new file mode 100644 index 00000000..daccde73 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_i2c.h @@ -0,0 +1,116 @@ +#ifndef __VM_TS_DCL_I2C_H__ +#define __VM_TS_DCL_I2C_H__ + +/****************************************************************** +* DESCRIPTION +* This enum defines the device for I2C module,used in vm_ts_dcl_open as a parameter. +* To control I2C, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vmtsdcl.h" +* VM_TS_DCL_HANDLE i2c_handle; // Declare a VM_TS_DCL_HANDLE variable. +* i2c_handle = vm_ts_dcl_open(VM_TS_DCL_I2C,0); // Call vm_ts_dcl_open to get a handle. flag fill 0. +* +*******************************************************************/ +typedef enum +{ + VM_TS_I2C_GROUP_START = VM_TS_DCL_I2C_GROUP_START, + VM_TS_DCL_I2C +}VM_TS_DCL_I2C_DEV; + +/****************************************************************** +* DESCRIPTION +* This enum defines the I2C transaction state, it will be given to user by lisr callback +* For more details , refer the VM_TS_DCL_I2C_CTRL_CMD_T description. +*******************************************************************/ + typedef enum + { + VM_TS_DCL_I2C_TRANS_STA_FINISH = 1, /* transfer finish success */ + VM_TS_DCL_I2C_TRANS_STA_ACK_ERR, /* an ack error happened */ + VM_TS_DCL_I2C_TRANS_STA_NACK_ERR, /* an n-ack error happened */ + VM_TS_DCL_I2C_TRANS_STA_FAIL, /* unexpected error happend*/ + }VM_TS_DCL_I2C_TRANSACTION_STATE; + + /****************************************************************** + * DESCRIPTION + * This enum defines the I2C transaction mode. + * For more details , refer the VM_TS_DCL_I2C_CTRL_CONFIG_T description. + *******************************************************************/ +typedef enum +{ + VM_TS_DCL_I2C_TRANSACTION_FAST_MODE, /* Fast Mode: < 400kbps */ + VM_TS_DCL_I2C_TRANSACTION_HIGH_SPEED_MODE /* Hign Speed Mode: > 400kbps */ +}VM_TS_DCL_I2C_TRANSACTION_MODE; + +/****************************************************************** +* DESCRIPTION +* This enum define the control command for I2C module,used in vm_ts_dcl_control as parameter. +* With different commands, user could control the different function of the I2C. +* To control I2C, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vmtsdcl.h" +* VM_TS_DCL_HANDLE i2c_handle; // Declare a VM_TS_DCL_HANDLE variable. +* VM_TS_DCL_I2C_CTRL_CONFIG_T i2c_config; +* i2c_handle = vm_ts_dcl_open(VM_TS_DCL_I2C,0); // First, we call vm_ts_dcl_open to get a handle. 19 means eint19 +* vm_ts_dcl_register_callback(i2c_handle,VM_TS_DCL_REGISTER_CALLBACK_LEVEL2,(void)i2c_lisr_cb); // register callback function,Note:i2c_lisr_cb is given by user +* vm_ts_dcl_control(i2c_handle,VM_TS_DCL_I2C_CMD_CONFIG,(void *)&i2c_config); // Usually, before we config eint, we mask it firstly. +* vm_ts_dcl_control(i2c_handle,VM_TS_DCL_I2C_CMD_SINGLE_WRITE_ASYNC,NULL); // Usually, before we config eint, we mask it firstly. +* vm_ts_dcl_close(i2c_handle); // Finally, if you are sure you will not use eint, you call vm_dcl_close ,otherwise, not call this api. +* +*******************************************************************/ +typedef enum +{ + VM_TS_DCL_I2C_CMD_SINGLE_WRITE_ASYNC, /* Single write of none-blocking mode */ + VM_TS_DCL_I2C_CMD_SINGLE_READ_ASYNC, /* Single read of none-blocking mode */ + VM_TS_DCL_I2C_CMD_CONT_WRITE_ASYNC, /* Continue write of none-blocking mode */ + VM_TS_DCL_I2C_CMD_CONT_READ_ASYNC, /* Continue read of none-blocking mode */ + VM_TS_DCL_I2C_CMD_WRITE_AND_READ_ASYNC, /* Write and read of none-blocking mode */ + VM_TS_DCL_I2C_CMD_SINGLE_WRITE_SYNC, /* Single write of blocking mode */ + VM_TS_DCL_I2C_CMD_SINGLE_READ_SYNC, /* Single read of blocking mode */ + VM_TS_DCL_I2C_CMD_CONT_WRITE_SYNC, /* Continue write of blocking mode */ + VM_TS_DCL_I2C_CMD_CONT_READ_SYNC, /* Continue read of blocking mode */ + VM_TS_DCL_I2C_CMD_WRITE_AND_READ_SYNC, /* Write and read of blocking mode */ + VM_TS_DCL_I2C_CMD_CONFIG +}VM_TS_DCL_I2C_CTRL_CMD_T; + +/* For I2C_CMD_SINGLE_WRITE, I2C_CMD_SINGLE_READ command. */ +typedef struct +{ + VMUINT8 *pu1Data; /* Pointer to the buffer of data */ + VMUINT32 u4DataLen; /* Data length */ +}VM_TS_DCL_I2C_CTRL_SINGLE_WRITE_T, VM_TS_DCL_I2C_CTRL_SINGLE_READ_T; + +/* For I2C_CMD_CONT_WRITE, I2C_CMD_CONT_READ command. */ +typedef struct +{ + VMUINT8 *pu1Data; /* Pointer to the buffer of data */ + VMUINT32 u4DataLen; /* Data length of each transfer */ + VMUINT32 u4TransferNum; /* Transfer number */ +}VM_TS_DCL_I2C_CTRL_CONT_WRITE_T, VM_TS_DCL_I2C_CTRL_CONT_READ_T; + +/* For I2C_CMD_WRITE_AND_READ command. */ +typedef struct +{ + VMUINT8 *pu1InData; /* Pointer to the read data */ + VMUINT32 u4InDataLen; /* Read data length */ + VMUINT8 *pu1OutData; /* Pointer to the write data */ + VMUINT32 u4OutDataLen; /* Write data length */ +}VM_TS_DCL_I2C_CTRL_WRITE_AND_READE_T; + +/* DCL I2C configure structure */ +typedef struct +{ + VMUINT8 u1SlaveAddress; /* Slave address */ + VMUINT8 u1DelayLen; /* Wait delay between consecutive transfers (the unit is half pulse width) */ + VM_TS_DCL_I2C_TRANSACTION_MODE eTransactionMode; /* Fast mode or high speed mode */ + VMUINT32 u4FastModeSpeed; /* The transfer speed under fast mode. But even under high speed mode, you should alse configure this parameter */ + VMUINT32 u4HSModeSpeed; /* The transfer speed under high speed mode */ +} VM_TS_DCL_I2C_CTRL_CONFIG_T; + + +#endif + + + + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_rtc.h b/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_rtc.h new file mode 100644 index 00000000..8db5d031 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_rtc.h @@ -0,0 +1,100 @@ +#ifndef __VM_TS_DCL_RTC_H__ +#define __VM_TS_DCL_RTC_H__ + + +/****************************************************************** +* DESCRIPTION +* This enum defines the device for RTC module,used in vm_ts_dcl_open as a parameter. +* To control GPIOs, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vmtsdcl.h" +* VM_TS_DCL_HANDLE rtc_handle; // Declare a VM_TS_DCL_HANDLE variable. +* rtc_handle = vm_ts_dcl_open(VM_TS_DCL_RTC,0); // Call vm_ts_dcl_open to get a handle. +* +*******************************************************************/ +typedef enum +{ + VM_TS_RTC_GROUP_START = VM_TS_DCL_RTC_GROUP_START, + VM_TS_DCL_RTC /*This is for control normal rtc function. */ +}VM_TS_DCL_RTC_DEV; + +/****************************************************************** +* DESCRIPTION +* This enum define the control command for RTC module,used in vm_ts_dcl_control as parameter. +* With different commands, user could control the different function of the RTC. +* To control RTC, you should use DCL(Driver Common Layer) APIs. +* EXAMPLE +* +* #include "vmtsdcl.h" +* VM_TS_DCL_HANDLE rtc_handle; // Declare a VM_TS_DCL_HANDLE variable. +* VM_TS_DCL_RTC_CTRL_GET_TIME_T getTime; // Declare a VM_TS_DCL_RTC_CTRL_GET_TIME_T variable. +* VM_TS_DCL_RTC_CTRL_SET_TIME_UPDATE_PERIOD_T setTimeUpdatePeriod; // Declare a VM_TS_DCL_RTC_CTRL_SET_TIME_UPDATE_PERIOD_T variable. +* rtc_handle = vm_ts_dcl_open(VM_TS_DCL_RTC,0); // First, we call vm_ts_dcl_open to get a handle. +* vm_ts_dcl_register_callback(rtc_handle,VM_TS_DCL_REGISTER_CALLBACK_LEVEL2,(void)rtc_callback); // register callback function,Note: rtc calback is given by user +* setTimeUpdatePeriod.time_update_period = VM_TC_EN_ChkS; // Wish to get time update notify per second. +* vm_ts_dcl_control(rtc_handle, VM_TS_RTC_CMD_SET_TIME_UPDATE_PERIOD, (void *)&setTimeUpdatePeriod); // Set debounce time +* vm_ts_dcl_control(rtc_handle, VM_TS_RTC_CMD_GET_TIME,(void *)&getTime); // Get current RTC time; +* vm_ts_dcl_close(rtc_handle); // Finally, if you are sure you will not use rtc, you call vm_dcl_close ,otherwise, not call this api. +* +*******************************************************************/ +typedef enum { + VM_TS_RTC_CMD_GET_TIME, /* To Get Time*/ + VM_TS_RTC_CMD_SET_TIME_UPDATE_PERIOD, /* To Set Time Update Period*/ +}VM_TS_DCL_RTC_CTRL_CMD_T; + + /****************************************************************** + * DESCRIPTION + * This enum define the different time update period choices. + * You can find the sample code in the description of VM_TS_DCL_RTC_CTRL_CMD_T. + *******************************************************************/ +typedef enum{ + VM_TC_EN_None, /* Time Counter Enable None */ + VM_TC_EN_ChkS, /* Time Counter Enable Check Sec */ + VM_TC_EN_ChkM, /* Time Counter Enable Check Min & Sec */ + VM_TC_EN_ChkH, /* Time Counter Enable Check Hour, Min & Sec */ + VM_TC_EN_ChkD, /* Time Counter Enable Check DOM, Hour, Min & Sec */ + VM_TC_EN_ChkW, /* Time Counter Enable Check DOW, Hour, Min & Sec */ + VM_TC_EN_ChkMon, /* Time Counter Enable Check Month, DOM, Hour, Min & Sec */ + VM_TC_EN_ChkY, /* Time Counter Enable Check Year, Month, DOM, Hour, Min & Sec */ + VM_TC_EN_NoChange, /* Time Counter Enable No Change */ +}VM_TS_DCL_RTC_TIME_UPDATE_PERIOD; + + /****************************************************************** + * DESCRIPTION + * This struct is the member VM_TS_DCL_RTC_CTRL_GET_TIME_T. + * You can find the sample code in the description of VM_TS_DCL_RTC_CTRL_CMD_T. + *******************************************************************/ +typedef struct +{ + VMUINT8 rtc_sec; /* Seconds after the minute - [0,59] */ + VMUINT8 rtc_min; /* Minutes after the hour - [0,59] */ + VMUINT8 rtc_hour; /* Hours after the midnight - [0,23] */ + VMUINT8 rtc_day; /* Day of the month - [1,31] */ + VMUINT8 rtc_mon; /* Months - [1,12] */ + VMUINT8 rtc_wday; /* Days in a week - [1,7] */ + VMUINT8 rtc_year; /* Years - [0,127] */ +}VM_TS_DCL_RTC_TIME_T; + + /****************************************************************** + * DESCRIPTION + * This struct is for VM_TS_RTC_CMD_GET_TIME control command,used in vm_ts_dcl_control as parameter. + * You can find the sample code in the description of VM_TS_DCL_RTC_CTRL_CMD_T. + *******************************************************************/ +typedef struct +{ + VM_TS_DCL_RTC_TIME_T time; +}VM_TS_DCL_RTC_CTRL_GET_TIME_T; + + /****************************************************************** + * DESCRIPTION + * This struct is for VM_TS_RTC_CMD_SET_TIME_UPDATE_PERIOD control command,used in vm_ts_dcl_control as parameter. + * You can find the sample code in the description of VM_TS_DCL_RTC_CTRL_CMD_T. + *******************************************************************/ +typedef struct +{ + VM_TS_DCL_RTC_TIME_UPDATE_PERIOD time_update_period; +}VM_TS_DCL_RTC_CTRL_SET_TIME_UPDATE_PERIOD_T; + +#endif + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_uart.h b/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_uart.h new file mode 100644 index 00000000..3b8d3de0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmtsdcl_uart.h @@ -0,0 +1,291 @@ + +#ifndef __VM_TS_DCL_UART_H_STRUCT__ +#define __VM_TS_DCL_UART_H_STRUCT__ + +/***************************************************************************** + * DESCRIPTION + * VM_TS_UART_PORT is the type of VMDCL_UINT16 ,which define the type UART_PORT + * user select + *****************************************************************************/ +typedef VMDCL_UINT16 VM_TS_UART_PORT; + +/******************************************************************************* + * DESCRIPTION + * VM_TS_UART_T_OWNER_TO_HANDLE(owner) is the owner and handler mapping MACRO + *******************************************************************************/ +#define VM_TS_UART_T_OWNER_TO_HANDLE(owner) (owner | VM_TS_DCL_UART_T_DEV_MAGIC_NUM) + +/******************************************************************************* + * DESCRIPTION + * VM_TS_DCL_UART_T_DEV_MAGIC_NUM is the magic number + *******************************************************************************/ +#define VM_TS_DCL_UART_T_DEV_MAGIC_NUM 0xA0000000 + +/***************************************************************************** + * DESCRIPTION + * VM_TS_DCL_UART_DEV_T is the uart type ENUM, user can select one of + * the port to use + * EXAMPLE + * + * uart_handle = vm_ts_dcl_open(VM_TS_UART_PORT1,0); + * if(VM_TS_DCL_HANDLE_INVALID==uart_handle) return; + * //Do something with the handle. + * + *****************************************************************************/ +typedef enum +{ + VM_TS_UART_PORT1=VM_TS_DCL_UART_GROUP_START, + VM_TS_UART_PORT2, + VM_TS_UART_PORT3 +} VM_TS_DCL_UART_DEV_T; + + +/***************************************************************************** + * DESCRIPTION + * VM_TS_DRV_UART_ID_CNT is the number of uart ports + *****************************************************************************/ +#define VM_TS_DRV_UART_ID_CNT 6 + + +/***************************************************************************** + * DESCRIPTION + * VM_TS_UART1_HISR_ID is UART1_HISR ID + *****************************************************************************/ +#define VM_TS_UART1_HISR_ID (VM_TS_DRV_UART_ID_START + 1) + +/***************************************************************************** + * DESCRIPTION + * VM_TS_UART1_HISR_RX_ID is UART1_HISR_RX ID + *****************************************************************************/ +#define VM_TS_UART1_HISR_RX_ID (VM_TS_DRV_UART_ID_START + 1) + +/***************************************************************************** + * DESCRIPTION + * VM_TS_UART1_HISR_TX_ID is UART1_HISR_TX ID + *****************************************************************************/ +#define VM_TS_UART1_HISR_TX_ID (VM_TS_DRV_UART_ID_START + 2) + +/***************************************************************************** + * DESCRIPTION + * VM_TS_UART2_HISR_ID is UART2_HISR ID + *****************************************************************************/ +#define VM_TS_UART2_HISR_ID (VM_TS_DRV_UART_ID_START + 3) + +/***************************************************************************** + * DESCRIPTION + * VM_TS_UART2_HISR_RX_ID is UART2_HISR_RX ID + *****************************************************************************/ +#define VM_TS_UART2_HISR_RX_ID (VM_TS_DRV_UART_ID_START + 3) + +/***************************************************************************** + * DESCRIPTION + * VM_TS_UART2_HISR_TX_ID is UART2_HISR_TX ID + *****************************************************************************/ +#define VM_TS_UART2_HISR_TX_ID (VM_TS_DRV_UART_ID_START + 4) + +/***************************************************************************** + * DESCRIPTION + * VM_TS_UART3_HISR_ID is UART3_HISR ID + *****************************************************************************/ +#define VM_TS_UART3_HISR_ID (VM_TS_DRV_UART_ID_START + 5) + +/***************************************************************************** + * DESCRIPTION + * VM_TS_UART3_HISR_RX_ID is UART3_HISR_RX ID + *****************************************************************************/ +#define VM_TS_UART3_HISR_RX_ID (VM_TS_DRV_UART_ID_START + 5) + +/***************************************************************************** + * DESCRIPTION + * VM_TS_UART3_HISR_TX_ID is UART3_HISR_TX ID + *****************************************************************************/ +#define VM_TS_UART3_HISR_TX_ID (VM_TS_DRV_UART_ID_START + 6) + +/************************************************************************************************************ + * DESCRIPTION + * VM_TS_UART_CTRL_CMD_T is the CMD type ENUM, user can use VM_TS_UART_CTRL_CMD_T + * command to control UART + * EXAMPLE + * + * VM_TS_DCL_HANDLE user_handler; + * VM_TS_UART_CTRL_GET_BYTES_T user_get_Data; + * user_get_Data.puBuffaddr = test_uart_Rx_buffer; + * user_get_Data.u2Length = ts_uart_total_get_num-ts_uart_have_get_num; + * user_handler = VM_TS_DCL_Open(VM_TS_UART_PORT1,0); + * VM_TS_DCL_Control(user_handler,VM_TS_UART_CMD_GET_BYTES,(void*)&user_get_Data); + * ts_uart_have_get_num += user_get_Data.u2RetSize; + * VM_TS_DCL_Close(user_handler); + * + **************************************************************************************************************/ +typedef enum +{ + VM_TS_UART_CMD_GET_BYTES, /*interrupt mode */ + VM_TS_UART_CMD_PUT_BYTES, /*interrupt mode */ + VM_TS_UART_CMD_GET_BYTE, /*polling mode */ + VM_TS_UART_CMD_PUT_BYTE /*polling mode */ +}VM_TS_UART_CTRL_CMD_T; + +/************************************************************************************************************ + * DESCRIPTION + * VM_TS_UART_CTRL_GET_BYTES_T is the cmd struct, user can use VM_TS_UART_CMD_GET_BYTES + * command to get data in interrupt mode + * EXAMPLE + * + * VM_TS_DCL_HANDLE user_handler; + * VM_TS_UART_CTRL_GET_BYTES_T user_get_Data; + * user_get_Data.puBuffaddr = test_uart_Rx_buffer; + * user_get_Data.u2Length = ts_uart_total_get_num-ts_uart_have_get_num; + * user_handler = VM_TS_DCL_Open(VM_TS_UART_PORT1,0); + * VM_TS_DCL_Control(user_handler,VM_TS_UART_CMD_GET_BYTES,(void*)&user_get_Data); + * ts_uart_have_get_num += user_get_Data.u2RetSize; + * VM_TS_DCL_Close(user_handler); + * + **************************************************************************************************************/ +typedef struct +{ + VMDCL_UINT16 u2Length; + VMDCL_UINT32 u4OwenrId; + VMDCL_UINT8* puBuffaddr; + VMDCL_UINT16 u2RetSize; +}VM_TS_UART_CTRL_GET_BYTES_T; + +/************************************************************************************************************ + * DESCRIPTION + * VM_TS_UART_CTRL_PUT_BYTES_T is the cmd struct, user can use VM_TS_UART_CTRL_PUT_BYTES_T + * command to put data in interrupt mode + * EXAMPLE + * + * VM_TS_DCL_HANDLE user_handler; + * VM_TS_UART_CTRL_PUT_BYTES_T user_put_Data; + * user_handler = VM_TS_DCL_Open(VM_TS_UART_PORT1,0); + * user_put_Data.puBuffaddr = test_uart_Tx_buffer; + * user_put_Data.u2Length = ts_uart_total_put_num-ts_uart_have_put_num; + * VM_TS_DCL_Control(user_handler,VM_TS_UART_CMD_PUT_BYTES,(void*)&user_put_Data); + * ts_uart_have_put_num += user_put_Data.u2RetSize; + * VM_TS_DCL_Close(user_handler); + * + **************************************************************************************************************/ +typedef struct +{ + VMDCL_UINT16 u2Length; + VMDCL_UINT32 u4OwenrId; + VMDCL_UINT8* puBuffaddr; + VMDCL_UINT16 u2RetSize; +}VM_TS_UART_CTRL_PUT_BYTES_T; + +/************************************************************************************************************ + * DESCRIPTION + * VM_TS_UART_CTRL_GET_BYTE_T is the cmd struct, user can use VM_TS_UART_CMD_GET_BYTE + * command to get data in polling mode + * EXAMPLE + * + * VM_TS_DCL_HANDLE user_handler; + * VM_TS_UART_CTRL_GET_BYTE_T user_get_Data; + * user_get_Data.puBuffaddr = &test_uart_Rx_one_data; + * user_handler = VM_TS_DCL_Open(TS_UART_PORT1,0); + * VM_TS_DCL_Control(user_handler,VM_TS_UART_CMD_GET_BYTE,(void*)&user_get_Data); + * if( user_get_Data.u1IsGetData ) + * { + * //get byte success + * } + * else + * { + * //there is no data + * } + * TS_DCL_Close(user_handler); + * + **************************************************************************************************************/ +typedef struct +{ + VMDCL_UINT32 u4OwenrId; + VMDCL_UINT8* puBuffaddr; + VMDCL_UINT8 u1IsGetData; +}VM_TS_UART_CTRL_GET_BYTE_T; + + +/************************************************************************************************************ + * DESCRIPTION + * VM_TS_UART_CTRL_PUT_BYTE_T is the cmd struct, user can use VM_TS_UART_CMD_PUT_BYTE + * command to put data in polling mode + * EXAMPLE + * + * VM_TS_DCL_HANDLE user_handler; + * VM_TS_UART_CTRL_PUT_BYTE_T user_put_Data; + * user_put_Data.puBuffaddr = &test_uart_Tx_one_data; + * user_handler = VM_TS_DCL_Open(TS_UART_PORT1,0); + * VM_TS_DCL_Control(user_handler,VM_TS_UART_CMD_PUT_BYTE,(void*)&user_get_Data); + * TS_DCL_Close(user_handler); + * + **************************************************************************************************************/ +typedef struct +{ + VMDCL_UINT32 u4OwenrId; + VMDCL_UINT8* puBuffaddr; +}VM_TS_UART_CTRL_PUT_BYTE_T; + + +extern VM_TS_DCL_STATUS VM_TS_Dcl_UART_Initialize(void); + +/************************************************************************* +* FUNCTION +* VM_TS_Dcl_UART_Open +* +* DESCRIPTION +* This function is to open the UART module and get a handle. Note that +* multiple opens are prohibited. +* +* PARAMETERS +* eDev - only valid for VM_TS_UART_PORT1, VM_TS_UART_PORT2, VM_TS_UART_PORT3(if exists) and +* DCL_UART_XXX. +* flags - user id (VM_TS_UART1_HISR_ID,VM_TS_UART2_HISR_ID.VM_TS_UART3_HISR_ID) +* +* RETURNS +* VM_TS_DCL_HANDLE_INVALID - The device is not valid. +* other value - a valid handle +* +*************************************************************************/ +extern VM_TS_DCL_HANDLE VM_TS_Dcl_UART_Open(TS_DCL_DEV dev, TS_DCL_FLAGS flags); + +/************************************************************************* +* FUNCTION +* VM_TS_Dcl_UART_Control +* +* DESCRIPTION +* This function is support UART module commands. +* +* CALLS +* It is called to send command to control the UART module. +* +* PARAMETERS +* handle - a valid handle return by VM_TS_Dcl_UART_Open() +* cmd - please refer to VM_TS_UART_CTRL_CMD_T STRUCT +* data - user's setting data +* +* RETURNS +* VM_TS_STATUS_OK: command is executed successfully. +* VM_TS_STATUS_INVALID_CMD: It's a invalid command. +* VM_TS_STATUS_INVALID_HANDLE: It's a invalid handle. +* +*************************************************************************/ +extern VM_TS_DCL_STATUS VM_TS_Dcl_UART_Control(TS_DCL_HANDLE handle, TS_DCL_CTRL_CMD cmd, void *data); + +/************************************************************************* +* FUNCTION +* VM_TS_Dcl_UART_Close +* +* DESCRIPTION +* This function is to close the UART module. +* +* PARAMETERS +* handle - hanlde previous got from VM_TS_Dcl_UART_Open() +* +* RETURNS +* VM_TS_STATUS_OK - successfully close the UART module. +* VM_TS_STATUS_INVALID_HANDLE - invalid handle + +*************************************************************************/ +extern VM_TS_DCL_STATUS VM_TS_Dcl_UART_Close(TS_DCL_HANDLE handle); + + +#endif + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmtsloader.h b/hardware/arduino/mtk/system/libmtk/include/vmtsloader.h new file mode 100644 index 00000000..2c5be56a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmtsloader.h @@ -0,0 +1,260 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ +/***************************************************************************** + * + * Filename: + * --------- + * vmtsloader.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * tiny system driver loader. + * + * Author: + * ------- + * + * + *============================================================================ + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ + * $Revision$ + * $Modtime$ + * $Log$ + * + * 05 28 2014 zhiwei.yang + * [MAUI_03492870] [Car Kit] GPS feature update + * . + * + * 05 26 2014 zhiwei.yang + * [MAUI_03492870] [Car Kit] GPS feature update + * . + * + * 05 20 2014 zhiwei.yang + * [MAUI_03492870] [Car Kit] GPS feature update + * . + * + * 04 21 2014 nan.zhao + * [MAUI_03493340] Check in LINKIT SDK + * . + * + * 04 18 2014 zhiwei.yang + * [MAUI_03488298] [MRE]tiny system check in + * . + * + *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================ + ****************************************************************************/ + +#ifndef _VM_TSLOADER_SDK_H +#define _VM_TSLOADER_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Definitions of tiny system driver loader return value */ +#define VM_TS_LOAD_ERR_UNKNOWN (-1) /* tiny system driver load failed */ +#define VM_TS_LOAD_ERR_FORMAT (-2) /* tiny system driver load file format error */ +#define VM_TS_LOAD_ERR_IO (-3) /* tiny system driver load file IO error */ +#define VM_TS_LOAD_ERR_MEMORY (-4) /* tiny system driver memory not enough */ +#define VM_TS_LOAD_ERR_MAXSIZE (-5) /* tiny system driver load driver too much */ + +/***************************************************************************** + * FUNCTION + * vm_ts_driver_load + * DESCRIPTION + * this interface used in AP mode, it allow the application load another appliction into memory, the loaded application will run on tiny mode. + * the first parameter is the file path to load, the second parameter is shared memory size, the memory can be accessed by both AP mode + * application(vm_ts_driver_get_mem) and tiny mode application(vm_ts_get_mem), so it can used by sharing data. this interface only load + * the application into memory, and the loaded application will auto run when system switch to tiny mode. + * You can load the tiny mode application in vm_main, or when you received VM_MSG_CREATE msg; and you also need unload the tiny mode + * application use vm_ts_driver_free when you want exit or not need tiny mode application anymore. + * PARAMETERS + * fileName : [IN] tiny system driver file without suffix or fullpath. + * size : size of shared memory + * RETURN VALUES + * >=0 : tiny driver handle. + * VM_TS_LOAD_ERR_UNKNOWN : If unsuccessful. + * VM_TS_LOAD_ERR_FORMAT : If unsuccessful. + * VM_TS_LOAD_ERR_IO : If unsuccessful. + * VM_TS_LOAD_ERR_MEMORY : If unsuccessful. + * VM_TS_LOAD_ERR_MAXSIZE : If unsuccessful. + * EXAMPLE + * + * // this interface allow application to load tiny mode driver into RAM, and the driver will auto launch when system + * // switch to tiny mode, + * VMINT hdl = -1; + * void handle_sysevt(VMINT message, VMINT param) { + * switch (message) { + * case VM_MSG_LOAD_TINY: + * hdl = vm_ts_driver_load(wszBuf,512); + * + * if (hdl < 0) + * { + * vm_log_fatal("failed to load tiny driver"); + * } + * break; + * case VM_MSG_QUIT: + * if(hdl>=0) + * { + * vm_ts_driver_free(hdl); + * hdl = -1; + * } + * break; + * } + * } + * + *****************************************************************************/ +VMINT vm_ts_driver_load(VMWSTR fileName, VMINT size); + +/***************************************************************************** + * FUNCTION + * vm_ts_driver_free + * DESCRIPTION + * this interface used in AP mode, unload tiny system driver, you need unload the tiny driver when you not used it or + * your application exit + * PARAMETERS + * handle : [IN] tiny system driver file handler, get from vm_ts_driver_load + * RETURN VALUES + * NULL + * SEE ALSO + * vm_ts_driver_load + * EXAMPLE + * + * void handle_sysevt(VMINT message, VMINT param) { + * switch (message) { + * case VM_MSG_CREATE: + * break; + * case VM_MSG_QUIT: + * if(hdl>=0) + * { + * vm_ts_driver_free(hdl); + * hdl = -1; + * } + * break; + * } + * } + * + *****************************************************************************/ +void vm_ts_driver_free(VMINT handle); + +/***************************************************************************** + * FUNCTION + * vm_ts_driver_get_mem + * DESCRIPTION + * this interface used in AP mode, get share memory pointer form tiny driver, when system switch tiny mode to ap mode, it will + * receive msg of VM_MSG_AP_MODE, you can use this interface to get memory address to get data. + * PARAMETERS + * handle : [IN] tiny driver file handler get from vm_ts_driver_load + * RETURN VALUES + * >0 : shared memory address + * NULL : no memory shared + * SEE ALSO + * vm_ts_driver_load + * EXAMPLE + * + * void* share_mem = NULL; + * void handle_sysevt(VMINT message, VMINT param) { + * switch (message) { + * case VM_MSG_CREATE: + * break; + * case VM_MSG_SUSPEND_TO_AP_MODE: + * if(hdl>=0) + * { + * share_mem = (VMCHAR *)vm_ts_driver_get_mem(hdl); + * // use the data in the memory + * } + * break; + * case VM_MSG_QUIT: + * if(hdl>=0) + * { + * vm_ts_driver_free(hdl); + * hdl = -1; + * } + * break; + * } + * } + * + *****************************************************************************/ +void* vm_ts_driver_get_mem(VMINT handle); + +/***************************************************************************** + * FUNCTION + * vm_ts_driver_get_handle + * DESCRIPTION + * get tiny app handle when return AP mode from Hibernation mode + * PARAMETERS + * void + * RETURN VALUES + * >=0 : handle + * <0 : not find the handle + * EXAMPLE + * + * void* share_mem = NULL; + * void handle_sysevt(VMINT message, VMINT param) { + * switch (message) { + * case VM_MSG_CREATE: + * break; + * case VM_MSG_HIBERNATION_TO_AP_MODE: + * hdl = vm_ts_driver_get_handle(); + * if(hdl>=0) + * { + * share_mem = (VMCHAR *)vm_ts_driver_get_mem(hdl); + * // use the data in the memory + * } + * break; + * case VM_MSG_QUIT: + * if(hdl>=0) + * { + * vm_ts_driver_free(hdl); + * hdl = -1; + * } + * break; + * } + * } + * + *****************************************************************************/ +VMINT vm_ts_driver_get_handle(void); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/hardware/arduino/mtk/system/libmtk/include/vmtssys.h b/hardware/arduino/mtk/system/libmtk/include/vmtssys.h new file mode 100644 index 00000000..be2eab19 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmtssys.h @@ -0,0 +1,503 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMTSSYS_SDK_H_ +#define VMTSSYS_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef NULL +#define NULL 0 +#endif + +typedef unsigned char VMUINT8; +typedef unsigned short VMUINT16; +typedef unsigned int VMUINT; +typedef unsigned long VMUINT32; + + +typedef unsigned long long VMUINT64 ; +typedef long long VMINT64 ; + + +typedef char VMINT8; +typedef short VMINT16; +typedef int VMINT; +typedef long VMINT32; + +typedef VMUINT8 VMUCHAR; +typedef VMUINT16 VMUWCHAR; +typedef VMUINT8 * VMUSTR; +typedef VMUINT16 * VMUWSTR; + +typedef VMINT8 VMCHAR; +typedef VMINT16 VMWCHAR; +typedef VMINT8 * VMSTR; +typedef VMINT16 * VMWSTR; + +typedef unsigned char VMBYTE; +typedef unsigned short VMUSHORT; +typedef short VMSHORT; + +typedef float VMFLOAT; + +typedef VMINT VMBOOL; + + +typedef struct +{ + VMUINT8 unused; +}*vm_ts_timerid; + +#ifndef BIT +#define BIT(i) (1U << i) +#endif + +#ifndef KHZ +#define KHZ(x) ((x) * 1000) +#endif + +#ifndef MHZ +#define MHZ(x) (KHZ(x) * 1000) +#endif + +typedef int VM_TS_BSSS_MODE; +#define VM_TS_BTSS_SUSPEND 0xcafebabe /* suspend mode */ +#define VM_TS_BTSS_HIBERNATION 0xfee1dead /* hibernation mode */ +#define VM_TS_BTSS_INVALID_MODE 0xDEADFA11 /* invalid mode */ + +/* For mode swith and blocker */ +typedef enum _VM_TS_BTSS_CLIENT{ + VM_TS_BTSS_CLIENT_MEMORY_DUMP = BIT(0), /* memdump */ + VM_TS_BTSS_CLIENT_TIMER = BIT(1), /* timer */ + VM_TS_BTSS_CLIENT_LOG = BIT(2), /* log */ + VM_TS_BTSS_CLIENT_KEYPAD = BIT(3), /* keypad */ + VM_TS_BTSS_CLIENT_DEF_INT = BIT(4), /* define INT */ + VM_TS_BTSS_CLIENT_CUST = BIT(30), /* cust */ +}VM_TS_BTSS_CLIENT; + + +/* DOM-NOT_FOR_SDK-BEGIN */ +void vm_ts_assert(VMSTR file, VMINT line); +void* vm_ts_csci_addr(char* key); +/* DOM-NOT_FOR_SDK-END */ + + +/* prototype of timer callback function */ +typedef void (*vm_ts_timer_func_ptr)(void *param_ptr); + +/* prototype of msg handler callback function */ +typedef void* (*vm_ts_service_hdlr_t)(VMINT func_id); + +typedef void (*vm_ts_swatch_pedometer_cb)(void* data); + +/***************************************************************************** + * FUNCTION + * vm_ts_irq_mask + * DESCRIPTION + * This interface used in tiny mode, Mask the I bit of the processor. Note this function must be used in pairs with vm_ts_irq_restore. + * And more, the I bit mask time should not exceed 5ms. + * PARAMETERS + * + * RETURN VALUES + * mask status of the current I bit, it should be an input parameter of vm_ts_irq_restore + * EXAMPLE + * + * VMUIN32 savedMask; + * savedMask = vm_ts_irq_mask(); + * ... // your code need to protect + * vm_ts_irq_restore(savedMask); + * + * + *****************************************************************************/ +VMUINT32 vm_ts_irq_mask(void); + +/***************************************************************************** + * FUNCTION + * vm_ts_irq_restore + * DESCRIPTION + * This interface used in tiny mode, restore the I bit of the processor. Note, this function must be used in pairs with vm_ts_irq_mask. + * PARAMETERS + * saved_mask:[in] the return value of vm_ts_irq_mask + * RETURN VALUES + * EXAMPLE + * + * VMUIN32 savedMask; + * savedMask = vm_ts_irq_mask(); + * ... // your code need to protect + * vm_ts_irq_restore(savedMask); + * + * + *****************************************************************************/ +void vm_ts_irq_restore(VMUINT32 saved_mask); + +/***************************************************************************** + * FUNCTION + * vm_ts_take_protect + * DESCRIPTION + * To get system thread protect. Note this function must be used in pairs with vm_ts_give_protect. + * PARAMETERS + * None + * RETURN VALUES + * protect status which should be a parameter of vm_ts_give_protect. + * EXAMPLE + * + * VMUIN32 ret; + * ret = vm_ts_take_protect (); + * ... // your code need to protect + * vm_ts_give_protect(ret); + * + * + *****************************************************************************/ +VMUINT32 vm_ts_take_protect(void); + +/***************************************************************************** + * FUNCTION + * vm_ts_give_protect + * DESCRIPTION + * To give the protect. Note, this function must be used in pairs with vm_ts_take_protect. + * PARAMETERS + * saved_mask :[in] the return value of vm_ts_take_protect + * RETURN VALUES + * none + * EXAMPLE + * + * VMUIN32 ret; + * ret = vm_ts_take_protect (); + * ... // your code need to protect + * vm_ts_give_protect(ret); + * + * + *****************************************************************************/ +void vm_ts_give_protect(VMUINT32 saved_mask); + +/***************************************************************************** +* FUNCTION +* vm_ts_create_timer +* DESCRIPTION +* This interface used in tiny mode, create a timer. +* PARAMETERS +* timer_name : [IN] timer name. It's used for debug only, and only the +* first 8 characters retain. +* RETURN VALUES +* Success: timer pointer. +* Error: system enter fatal error handling. +*****************************************************************************/ +vm_ts_timerid vm_ts_create_timer(VMINT8 *timer_name); + +/***************************************************************************** +* FUNCTION +* vm_ts_set_timer +* DESCRIPTION +* This interface used in tiny mode, start a timer. this will cancel previous set timeout event , and start a new one. +* PARAMETERS +* timer_ptr : [IN] timer pointer. +* handler_func_ptr: [IN] pointer of timeout handler, it will be called after +* timeout happens +* handler_param_ptr: [IN] user supply argument for handler_func_ptr +* delay: [IN] timeout duration in terms of time ticks, the maximum value is 0xFFFFFFFF +* reschedule_time: [IN] reset delay to reschedule_time after timeout happens. +* If it's zero, no reschedule happens and the timer is one-shot. +* Otherwise, it's a periodic timer. +* RETURN VALUES +* N/A +*****************************************************************************/ +void vm_ts_set_timer(vm_ts_timerid timer_ptr, vm_ts_timer_func_ptr handler_func_ptr,void *handler_param_ptr, VMUINT32 delay, VMUINT32 reshedule_time); + +/***************************************************************************** +* FUNCTION +* vm_ts_cancel_timer +* DESCRIPTION +* This interface used in tiny mode, cancel a timer. Please note that canceling timer inside HISR may cancel a timer which is +* in expired stage but the callback function not yet been serviced. +* PARAMETERS +* ext_timer : [IN] timer pointer. +* RETURN VALUES +* N/A +*****************************************************************************/ +void vm_ts_cancel_timer(vm_ts_timerid timer_ptr); + +/***************************************************************************** +* FUNCTION +* vm_ts_get_mem +* DESCRIPTION +* This interface used in tiny mode, get shared memory address +* RETURN VALUES +* pointer of shared memory, NULL means there is no shared memory +*****************************************************************************/ +void* vm_ts_get_mem(void); + +/***************************************************************************** +* FUNCTION +* vm_ts_get_mem_size +* DESCRIPTION +* This interface used in tiny mode, get shared memory size +* RETURN VALUES +* size of shared memory +*****************************************************************************/ +VMINT vm_ts_get_mem_size(void); + +/***************************************************************************** +* FUNCTION +* vm_ts_log_int +* DESCRIPTION +* This interface used in tiny mode, log function for application, for reducing code size, we not support formatted +* output of log, this function can output three integer and on string +* PARAMETERS +* str : [IN] string to output. +* i : [IN] integer to output +* j : [IN] integer to output +* k : [IN] integer to output +*****************************************************************************/ +void vm_ts_log_int(VMSTR str, VMINT i, VMINT j, VMINT k); + +/***************************************************************************** +* FUNCTION +* vm_ts_log_float +* DESCRIPTION +* This interface used in tiny mode, log function for application, for reducing code size, we not support formatted +* output of log, this function can output three float number and on string +* PARAMETERS +* str : [IN] string to output. +* i : [IN] float number to output +* j : [IN] float number to output +* k : [IN] float number to output +*****************************************************************************/ +void vm_ts_log_float(VMSTR str, VMFLOAT i, VMFLOAT j, VMFLOAT k); + +/***************************************************************************** +* FUNCTION +* vm_ts_log_hex +* DESCRIPTION +* This interface used in tiny mode, log function for application, for reducing code size, we not support formatted +* output of log, this function can output three unsigned integer and one string +* PARAMETERS +* str : [IN] string to output, the max size is 64 bytes, more then it will cut off. +* i : [IN] integer to output +* j : [IN] integer to output +* k : [IN] integer to output +*****************************************************************************/ +void vm_ts_log_hex(VMSTR str, VMUINT i, VMUINT j, VMUINT k); + +/***************************************************************************** +* FUNCTION +* vm_ts_get_mode +* DESCRIPTION +* This interface used in tiny mode, get current tiny mode +* AP system Tiny Suspend Tiny Hibernation +* PSRAM power down? No No Yes +* PSRAM can enter standby? Yes Yes N/A +* Access PSRAM Yes No No +* Switch mode latency N/A 40 ms 1 sec +* CPU performance FULL speed 26MHz 32KHz +* Power consumption High Low Lowest +* Scenario Run Second level sleep Minute level sleep +* +* PARAMETERS +* N/A +* RETURN VALUES +* VM_TS_BTSS_SUSPEND +* VM_TS_BTSS_HIBERNATION +* VM_TS_BTSS_INVALID_MODE +*****************************************************************************/ +VM_TS_BSSS_MODE vm_ts_get_mode(void); + +/***************************************************************************** +* FUNCTION +* vm_ts_mode_block +* DESCRIPTION +* This interface used in tiny mode, disable tiny system from entering AP system, use this when preparing shared information +* PARAMETERS +* client : [IN] please refer VM_TS_BTSS_CLIENT +*****************************************************************************/ +void vm_ts_mode_block(VM_TS_BTSS_CLIENT client); + +/***************************************************************************** +* FUNCTION +* vm_ts_mode_unblock +* DESCRIPTION +* This interface used in tiny mode, enable tiny system from entering AP system +* PARAMETERS +* client : [IN] please refer VM_TS_BTSS_CLIENT +*****************************************************************************/ +void vm_ts_mode_unblock(VM_TS_BTSS_CLIENT client); + +/***************************************************************************** +* FUNCTION +* vm_ts_switch_to_ap_mode +* DESCRIPTION +* This interface used in tiny mode, trigger entering AP system +* PARAMETERS +* client : [IN] please refer VM_TS_BTSS_CLIENT +*****************************************************************************/ +void vm_ts_switch_to_ap_mode(VM_TS_BTSS_CLIENT client); + +/***************************************************************************** +* FUNCTION +* vm_ts_requirement +* DESCRIPTION +* This interface used in tiny mode, request CPU frequency, scale down CPU frequency according to system requirement +* OR for power saving , set different voltage for different frequency +* PARAMETERS +* hz : [IN] only support 32KHz and 26MHz +* RETURN VALUES +* the number to set, unit is Hz + * EXAMPLE + * + * vm_ts_requirement(MHZ(100)) + * vm_ts_requirement(-1*MHZ(100)) +*****************************************************************************/ +void vm_ts_requirement(VMINT hz); + +/***************************************************************************** +* FUNCTION +* vm_ts_get_freq +* DESCRIPTION +* This interface used in tiny mode, to get current CPU speed +* RETURN VALUES +* current CPU's speed, the unit is Hz and maximum frequency is 26MHz +*****************************************************************************/ +VMINT vm_ts_get_freq(void); + +/***************************************************************************** +* FUNCTION +* VM_TS_ASSERT +* DESCRIPTION +* This interface used in tiny mode, debug for assert +* RETURN VALUES +* N/A +*****************************************************************************/ +#ifdef __MRE_DEBUG__ + #define VM_TS_ASSERT(expr) do {if(!(expr)) vm_ts_assert((VMSTR)__FILE__, __LINE__); } while (0) +#else + #define VM_TS_ASSERT(expr) do {if(!(expr)) {} } while (0) +#endif + +/***************************************************************************** +* FUNCTION +* vm_ts_reg_service +* DESCRIPTION +* This interface used in tiny mode, driver app can register service for other app use +* PARAMETERS +* name : [IN] server name, must less the 8 charactors +* hdlr : [IN] service handler +* RETURN VALUES +* TRUE : if register success +* FALSE : failed +*****************************************************************************/ +VMBOOL vm_ts_reg_service(char* name, vm_ts_service_hdlr_t hdlr); + +/***************************************************************************** +* FUNCTION +* vm_ts_get_service +* DESCRIPTION +* This interface used in tiny mode, app can get service form the app that had been +* register service to engine. +* PARAMETERS +* service_name : [IN] server name register to engine use vm_ts_reg_service +* func_id : [IN] function id that server provide +* RETURN VALUES +* function interface pointer +*****************************************************************************/ +void* vm_ts_get_service(char* service_name, VMINT func_id ); + +/***************************************************************************** +* FUNCTION +* vm_ts_get_systicks +* DESCRIPTION +* This interface used in tiny mode, return elapsed system ticks from boot up +* PARAMETERS +* N/A +* RETURN VALUES +* elapsed system ticks from boot up +*****************************************************************************/ +VMUINT32 vm_ts_get_systicks(void); + +/***************************************************************************** +* FUNCTION +* vm_ts_updata_screen +* DESCRIPTION +* This interface used in tiny mode, refresh the LCD screen, please use it after update the display buffer. +* PARAMETERS +* startx : [IN] update area left up point x +* starty : [IN] update area left up point y +* endx : [IN] update area right down point x +* endy : [IN] update area right down point y +* RETURN VALUES +* 0 success +*****************************************************************************/ +VMUINT8 vm_ts_updata_screen(VMUINT16 startx, VMUINT16 starty, VMUINT16 endx, VMUINT16 endy); + +/***************************************************************************** +* FUNCTION +* vm_ts_get_tiny_fb_size +* DESCRIPTION +* This interface used in tiny mode, get display buffer size. +* PARAMETERS +* N/A +* RETURN VALUES +* size of display buffer in byte +*****************************************************************************/ +VMUINT32 vm_ts_get_tiny_fb_size(); + +/***************************************************************************** +* FUNCTION +* vm_ts_get_display_buffer +* DESCRIPTION +* This interface used in tiny mode, get display buffer pointer +* PARAMETERS +* N/A +* RETURN VALUES +* display buffer pointer +*****************************************************************************/ +VMUINT8* vm_ts_get_display_buffer(); + +void vm_ts_swatch_pedometer_resgiter_callback(vm_ts_swatch_pedometer_cb cb); + +#ifdef __cplusplus +} +#endif + +#endif /* VMSYS_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmuart.h b/hardware/arduino/mtk/system/libmtk/include/vmuart.h new file mode 100644 index 00000000..22412bdb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmuart.h @@ -0,0 +1,146 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMUART_SDK_H_ +#define VMUART_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/* Enum values of uart port */ +typedef enum { + vm_uart_port1=0, + vm_uart_port2, + vm_uart_port3, + vm_uart_port_swdbg, + vm_uart_port_irda, + vm_uart_port_usb, + vm_uart_port_usb2, + vm_uart_port_usb3, + vm_uart_port_bluetooth, + vm_uart_max_port, + vm_uart_port_null = 99 +} vm_port; + + +/******************************************************************************* +* FUNCTION +* vm_uart_open +* DESCRIPTION +* open uart port +* PARAMETERS +* port: [IN] uart port +* RETURNS +* uart port handle +* GLOBALS AFFECTED +* +*******************************************************************************/ +VMINT32 vm_uart_open(vm_port port); + +/******************************************************************************* +* FUNCTION +* vm_read_from_uart +* DESCRIPTION +* read data from specific uart port handle +* PARAMETERS +* handle: [IN] return value of vm_uart_open +* buffer: [OUT] memory space of read data +* length: [IN] the expected length of read data +* RETURNS +* real length of read data +* GLOBALS AFFECTED +* +*******************************************************************************/ +VMUINT16 vm_read_from_uart(VMINT32 handle, VMUINT8 *buffer, VMUINT16 length); + +/******************************************************************************* +* FUNCTION +* vm_write_to_uart +* DESCRIPTION +* write data using uart port +* PARAMETERS +* handle: [IN] return value of vm_uart_open +* buffer: [IN] write data space +* length: [IN] the expected length of write data +* RETURNS +* real length of write data +* GLOBALS AFFECTED +* +*******************************************************************************/ +VMUINT16 vm_write_to_uart(VMINT32 handle, VMUINT8 *buffer, VMUINT16 length); + +/******************************************************************************* +* FUNCTION +* vm_uart_close +* DESCRIPTION +* close uart port +* PARAMETERS +* hanle: [IN] return value of vm_uart_open +* RETURNS +* VMINT32 0 is success, other fail +* GLOBALS AFFECTED +* +*******************************************************************************/ +VMINT32 vm_uart_close(VMINT32 handle); + + +/* +using sample code + +VMINT32 handle; +VMUINT16 length; +VMUINT8 buffer[7]; +handle = vm_uart_open(vm_uart_port1); +if(handle != 0) +{ + length = vm_write_to_uart(result, buffer, 7); + + (or length = vm_read_from_uart(result, buffer, 7);) +} +if(handle != 0) +{ + vm_uart_close(handle); +} +*/ + + +#ifdef __cplusplus +} +#endif + +#endif /* VMUART_SDK_H_ */ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmudp.h b/hardware/arduino/mtk/system/libmtk/include/vmudp.h new file mode 100644 index 00000000..68f9b909 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmudp.h @@ -0,0 +1,198 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMUDP_SDK_H +#define VMUDP_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + + + +/* write status */ +#define VM_UDP_EVT_WRITE 2 + +/* read status */ +#define VM_UDP_EVT_READ 3 + +/* broken status */ +#define VM_UDP_EVT_PIPE_BROKEN 4 + +/* udp pipe closed */ +#define VM_UDP_EVT_PIPE_CLOSED 6 + + +/***************************************************************************** + * FUNCTION + * vm_udp_create + * DESCRIPTION + * create udp socket. + * PARAMETERS + * port : [IN] port number for binding. + * apn : [IN] apn id. + * callback : [IN] callback function for udp notification. + * loopback : [IN] loopback flag, non-zero: loopback; zero: no loopback. + * RETURNS + * create udp success or not. + * RETURN VALUES + * udp handle, if value >= 0; failue if < 0 + * EXAMPLE + * + * static VMINT g_hdll; + * void hl_udp_create(void) + * { + * VMINT port = 0x1234; + * g_hdl1 = vm_udp_create(port, VM_TCP_APN_CMNET, udp_callback, 1); + * } + * +*****************************************************************************/ +VMINT vm_udp_create(VMINT port, VMINT apn, void (*callback)(VMINT hdl, VMINT event), VMINT loopback); +/***************************************************************************** + * FUNCTION + * vm_udp_sendto + * DESCRIPTION + * send data to the destination. + * PARAMETERS + * hdl : [IN] udp handle. + * buf : [IN] buf. + * len : [IN] buf len. + * addr : [IN] the address of destination. + * RETURNS + * size of sent data. + * RETURN VALUES + * udp handle, if value >= 0; failue if < 0 + * EXAMPLE + * + * static void udp_callback(VMINT hdl, VMINT evt) + * { + * vm_sockaddr_struct sendto = {0}; + * sendto.addr[0] = 192; + * sendto.addr[1] = 168; + * sendto.addr[2] = 1; + * sendto.addr[3] = 33; + * sendto.addr_len = 4; + * + * switch (evt) + * { + * case VM_UDP_EVT_WRITE: + * { + * VMINT ret = 0; + * sendto.port = 2500; + * sendto.addr[1], + * sendto.addr[2], + * sendto.addr[3], + * sendto.port, + * sendto.addr_len); + * ret = vm_udp_sendto(hdl, buf, 1024, &sendto); + * }break; + * default: + * { + * + * }break; + * } + * } + * +*****************************************************************************/ +VMINT vm_udp_sendto(VMINT hdl, const void * buf, VMINT32 len, const vm_sockaddr_struct * addr); +/***************************************************************************** + * FUNCTION + * vm_udp_recvfrom + * DESCRIPTION + * receive data from the destination. + * PARAMETERS + * hdl : [IN] udp handle. + * buf : [OUT] buf. + * len : [IN] buf len. + * addr : [OUT] the address of destination. + * RETURNS + * size of received data. + * RETURN VALUES + * udp handle, if value >= 0; failue if < 0 + * EXAMPLE + * + * static void udp_callback(VMINT hdl, VMINT evt) + * { + * VMCHAR buf[1024] = {0}; + * switch (evt) + * { + * case VM_UDP_EVT_READ: + * { + * VMINT ret = 0; + * vm_sockaddr_struct recvfrom = {0}; + * ret = vm_udp_recvfrom(hdl, buf, 1024, &recvfrom); + * }break; + * default: + * { + * + * }break; + * } + * } + * +*****************************************************************************/ +VMINT vm_udp_recvfrom(VMINT hdl, void * buf, VMINT32 len, vm_sockaddr_struct * addr); +/***************************************************************************** + * FUNCTION + * vm_udp_close + * DESCRIPTION + * close udp socket. + * PARAMETERS + * port : [IN] dest host port. + * apn : [IN] apn id. + * callback : [IN] callback function for udp notification. + * RETURNS + * create udp success or not. + * RETURN VALUES + * udp handle, if value >= 0; failue if < 0 + * EXAMPLE + * + * static VMINT g_hdll; + * void hl_udp_create(void) + * { + * VMINT port = 0x1234; + * g_hdl1 = vm_udp_create(port, VM_TCP_APN_CMNET, udp_callback, 1); + * vm_udp_close(g_hdll); + * } + * +*****************************************************************************/ +VMINT vm_udp_close(VMINT hdl); +#ifdef __cplusplus +} +#endif + +#endif /* VMUDP_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmuiapp.h b/hardware/arduino/mtk/system/libmtk/include/vmuiapp.h new file mode 100644 index 00000000..9ea31621 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmuiapp.h @@ -0,0 +1,283 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMUIAPP_SDK_H +#define VMUIAPP_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" +/* This enumeration defines the error code of dispatching URI request or registering URI request handler by scheme or by prefix. */ +typedef enum +{ + VM_SRV_URIAGENT_ERR_OK, /* Success to process this request. */ + VM_SRV_URIAGENT_ERR_SCHEME_IS_REGISTERED, /* Fail to process this registration because handler was already registered for this scheme; this error code is used for URI request handler registration only. */ + VM_SRV_URIAGENT_ERR_PREFIX_IS_REGISTERED, /* Fail to process this registration because handler was already registered for this prefix; this error code is used for URI request handler registration only. */ + VM_SRV_URIAGENT_ERR_PROCESSING, /* Fail to process this URI request because the previous request from the same URA is still in processing; this error code is used for URI request dispatch only. */ + VM_SRV_URIAGENT_ERR_UNSUPPORTED /* Fail to process this request. */ +}vm_srv_uriagent_err_enum; + + +/***************************************************************************** + * FUNCTION + * vm_uriagent_uri_request + * DESCRIPTION + * wtai + * PARAMETERS + * str [IN] string of wati + * confirm [IN] confirm + * RETURNS + * -1 : no authorization + * -2 : not be supported + * refer to vm_srv_uriagent_err_enum + *****************************************************************************/ +VMINT vm_uriagent_uri_request(const VMCHAR * str, VMINT confirm); + +/***************************************************************************** + * FUNCTION + * vm_start_native_browser + * DESCRIPTION + * query if specified key code is supported + * PARAMETERS + * url [IN] open native browser if there dose exist. + * RETURNS + * -1 : no authorization + * -2 : not be supported + * refer to return value of vm_open_wap_url + *****************************************************************************/ +VMINT vm_start_native_browser(const VMWSTR url); + + +/***************************************************************************** + * FUNCTION + * vm_startup_email + * DESCRIPTION + * startup email + * PARAMETERS + * to_addr : [IN] email address of receiver (UCS2) + * RETURN VALUES + * 0 : success + * non-zero : failure + * -2 : platform not support + * -3 : no email account + *****************************************************************************/ +VMINT vm_startup_email(const VMWSTR to_addr); + +typedef enum +{ + VM_CAM_ERR_BUSY = -4, + VM_CAM_ERR_EXCEPTION, + VM_CAM_ERR_NOT_SUPPORT, + VM_CAM_ERR_NOT_AUTHORIZED, + VM_CAM_ERR_SUCCESS = 0, +}vm_camera_startup_error_t; + + +/***************************************************************************** + * FUNCTION + * vm_camera_startup + * DESCRIPTION + * Run Camrea APP directly, In lowend project, APP maybe need to exit cause of Out of Memory. + * PARAMETERS + * Void + * RETURNS + * Run result + * RETURN VALUES + * 0 : success + * non-zero : failure + *****************************************************************************/ +VMINT vm_camera_startup(void); + +typedef enum +{ + VM_SELECTOR_ERR_NO_RES = -7, /* no avalible resource */ + VM_SELECTOR_ERR_PARAM, /* input invalid parameter */ + VM_SELECTOR_ERR_NO_MEMORY, /* no memmory */ + VM_SELECTOR_ERR_NO_DISK, /* driver path failure */ + VM_SELECTOR_ERR_EXCEPTION, /* exception */ + VM_SELECTOR_ERR_NOT_SUPPORT, /* platform dose not support */ + VM_SELECTOR_ERR_NOT_AUTHORIZED, /* no authrization */ + VM_SELECTOR_ERR_SUCCESS = 0 /* success */ +}vm_selector_error_t; + +typedef enum +{ + VM_SELECTOR_TYPE_ALL = 0, /* all file type */ + VM_SELECTOR_TYPE_IMAGE, /* image type */ + VM_SELECTOR_TYPE_TXT /* txt type */ +}vm_selector_type_t; + +/***************************************************************************** + * FUNCTION + * vm_selector_run + * DESCRIPTION + * Start Fmgr to select a file. + * PARAMETERS + * type : [IN] the browse type of file, define in vm_selector_type_t + * folder_path : [IN] witch path need to be browsed, NULL means root + * callback : [IN] the result callback of file selection. file_path is the path name of current selected file, + * it be set NULL if error. wlen is the length of path name in words. + * RETURNS + * 0 or error code define in vm_selector_error_t + * RETURN VALUES + * vm_selector_error_t +*****************************************************************************/ +VMINT vm_selector_run(VMINT type, const VMWCHAR * folder_path, VMINT (*callback)(VMWCHAR * file_path, VMINT wlen)); + +typedef enum +{ + VM_FOLDER_BROWSER_ERR_NO_RES = -7, /* no avalible resource */ + VM_FOLDER_BROWSER_ERR_PARAM, /* input invalid parameter */ + VM_FOLDER_BROWSER_ERR_NO_MEMORY, /* no memmory */ + VM_FOLDER_BROWSER_ERR_NO_DISK, /* driver path failure */ + VM_FOLDER_BROWSER_ERR_EXCEPTION, /* exception */ + VM_FOLDER_BROWSER_ERR_NOT_SUPPORT, /* platform dose not support */ + VM_FOLDER_BROWSER_ERR_NOT_AUTHORIZED, /* no authrization */ + VM_FOLDER_BROWSER_ERR_SUCCESS = 0 /* success */ +} vm_folder_browser_error_t; + +typedef enum +{ + VM_FOLDER_BROWSER_TYPE_ALL = 0, /* all file type */ + VM_FOLDER_BROWSER_TYPE_IMAGE, /* image type */ + VM_FOLDER_BROWSER_TYPE_TXT /* txt type */ +} vm_folder_browser_type_t; + +/******************************************************************************* + * FUNCTION + * vm_folder_browser_run + * DESCRIPTION + * launch folder browser CUI. + * PARAMETER + * type : [IN] which type of file should be shown in folder browser. + * the optional values are : + * VM_FOLDER_BROWSER_TYPE_ALL + * VM_FOLDER_BROWSER_TYPE_IMAGE + * VM_FOLDER_BROWSER_TYPE_TXT + * folder_path : [IN] the folder that you want to enter. + * NOTE: it can NOT be L"root" or only a Driver name + * such as L"D:\\". + * RETURNS + * if success, return VM_FOLDER_BROWSER_ERR_SUCCESS. + * otherwise, a value in type of vm_folder_browser_type_t will be returned. + ******************************************************************************/ +VMINT vm_folder_browser_run(VMINT type, const VMWCHAR *folder_path); + +typedef enum +{ + VM_FOLDER_SELECTOR_ERR_NO_RES = -7, /* no avalible resource */ + VM_FOLDER_SELECTOR_ERR_PARAM, /* input invalid parameter */ + VM_FOLDER_SELECTOR_ERR_NO_MEMORY, /* no memmory */ + VM_FOLDER_SELECTOR_ERR_NO_DISK, /* driver path failure */ + VM_FOLDER_SELECTOR_ERR_EXCEPTION, /* exception */ + VM_FOLDER_SELECTOR_ERR_NOT_SUPPORT, /* platform doesn't support */ + VM_FOLDER_SELECTOR_ERR_NOT_AUTHORIZED, /* no authrization */ + VM_FOLDER_SELECTOR_ERR_SUCCESS = 0 /* success */ +} vm_folder_selector_error_t; + +typedef enum +{ + VM_FOLDER_SELECTOR_STYLE_READ, /* CUI_FOLDER_SELECTOR_STYLE_READ */ + VM_FOLDER_SELECTOR_STYLE_WRITE, /* CUI_FOLDER_SELECTOR_STYLE_WRITE */ + VM_FOLDER_SELECTOR_STYLE_TOTAL /* CUI_FOLDER_SELECTOR_STYLE_TOTAL */ +} vm_folder_selector_style_t; + +/****************************************************************************** + * FUNCTION + * vm_folder_selector_run + * DESCRIPTION + * Start a file manager to select a folder. + * PARAMETERS + * start_folder_path : [IN] the path of start folder. when file manager + * is opened, it will enter this folder + * directly. + * folder_selector_style : [IN] if it's VM_FOLDER_SELECTOR_STYLE_READ, that + * means you can NOT create a folder, + * rename it or delete it. + * if it's VM_FOLDER_SELECTOR_STYLE_WRITE, that + * means you can create a folder, rename it + * , or delete it. + * callback : [IN] user provided callback function. when a + * folder is selected, this function will be + * called to handle the selection. + * selected_folder_path indicates which folder + * is selected. if it's NULL, that means + * an error occurs. + * wlen is the length of selected folder's path + * in words. + * RETURNS + * VM_FOLDER_SELECTOR_ERR_SUCCESS : the CUI runs successfully. + * other values means an error occurs, please refer to + * vm_folder_selector_error_t for detailed information. +******************************************************************************/ +VMINT vm_folder_selector_run( + const VMWCHAR *start_folder_path, + VMINT folder_selector_style, + VMINT (*callback)(VMWCHAR *selected_folder_path, VMINT wlen)); + +/***************************************************************************** + * FUNCTION + * vm_is_support_gsensor + * DESCRIPTION + * Check whether the phone support G-sensor or not. + * PARAMETERS + * void + * RETURN VALUES + * TRUE : Supports G-sensor. + * FALSE : Not support. + *****************************************************************************/ +VMINT vm_is_support_gsensor(void); + +/***************************************************************************** + * FUNCTION + * vm_is_support_camera_sensor + * DESCRIPTION + * Check whether the phone support camera sensor or not. + * PARAMETERS + * void + * RETURN VALUES + * TRUE : Supports camera sensor. + * FALSE : Not support. + *****************************************************************************/ +VMINT vm_is_support_camera_sensor(void); + +#ifdef __cplusplus +} +#endif + +#endif /* VMUIAPP_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmuimisc.h b/hardware/arduino/mtk/system/libmtk/include/vmuimisc.h new file mode 100644 index 00000000..ffe9f1eb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmuimisc.h @@ -0,0 +1,192 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmuimisc_sdk.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * ui misc + * + * Author: + * ------- + * + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ +* *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== +*******************************************************************************/ +#ifndef VM_UIMISC_SDK_H +#define VM_UIMISC_SDK_H +#ifdef __cplusplus +extern "C"{ +#endif/*__cplusplus*/ +#include "vmsys.h" +typedef enum +{ + VM_TOUCH_FEEDBACK_DOWN, + VM_TOUCH_FEEDBACK_DOWN_VIBRATE, + VM_TOUCH_FEEDBACK_DOWN_TONE, + VM_TOUCH_FEEDBACK_HOLD, + VM_TOUCH_FEEDBACK_SPECIAL, + VM_TOUCH_FEEDBACK_TOTAL +} vm_touch_feedback_enum; + +typedef enum +{ + VM_SCREEN_ROTATE_0, /* Normal screen */ + VM_SCREEN_ROTATE_90, /* Rotate 90 clockwise */ + VM_SCREEN_ROTATE_180, /* Rotate 180 */ + VM_SCREEN_ROTATE_270, /* Rotate 270 clockwise */ + + /*Add new enums above this*/ + VM_SCREEN_ROTATE_END = 0XFFFF +} vm_screen_rotate_enum; + +#define VM_PI 3.1415926f + +/* General color type methods */ +#define VM_COLOR32_MAKE(a, r, g, b) ((VMCOLOR32)((VMUINT32)(a) << 24 | (VMUINT32)(r) << 16 | (VMUINT32)(g) << 8 | (VMUINT32)(b))) +#define VM_COLOR32_GET_A(c) ((c) >> 24) +#define VM_COLOR32_GET_R(c) ((c) << 8 >> 24) +#define VM_COLOR32_GET_G(c) ((c) << 16 >> 24) +#define VM_COLOR32_GET_B(c) ((c) << 24 >> 24) + +/* default colors */ +#define VM_COLOR32_BLACK VM_COLOR32_MAKE(255, 0, 0, 0) +#define VM_COLOR32_WHITE VM_COLOR32_MAKE(255, 255, 255, 255) +#define VM_COLOR32_RED VM_COLOR32_MAKE(255, 255, 0, 0) +#define VM_COLOR32_GREEN VM_COLOR32_MAKE(255, 0, 255, 0) +#define VM_COLOR32_BLUE VM_COLOR32_MAKE(255, 0, 0, 255) +#define VM_COLOR32_AQUA VM_COLOR32_MAKE(255, 0, 255, 255) +#define VM_COLOR32_FUCHSIA VM_COLOR32_MAKE(255, 255, 0, 255) +#define VM_COLOR32_YELLOW VM_COLOR32_MAKE(255, 255, 255, 0) +#define VM_COLOR32_GREY VM_COLOR32_MAKE(255, 128, 128, 128) +#define VM_COLOR32_TEAL VM_COLOR32_MAKE(255, 0, 128, 128) +#define VM_COLOR32_PURPLE VM_COLOR32_MAKE(255, 128, 0, 128) +#define VM_COLOR32_OLIVE VM_COLOR32_MAKE(255, 128, 128, 0) +#define VM_COLOR32_SILVER VM_COLOR32_MAKE(255, 192, 192, 192) +#define VM_COLOR32_TRANSPARENT VM_COLOR32_MAKE(0, 0, 0, 255) + +/* Redian convert macros */ +#define VM_DEG_TO_RAD(x) ((VMFLOAT)((VMFLOAT)(x)) * VM_PI / 180.0f) +#define VM_RAD_TO_DEG(x) ((VMFLOAT)((VMFLOAT)(x)) * 180.0f / VM_PI) + +/* Float, Fixed conversion */ +#define VM_X_TO_F(x) ((VMFLOAT)x / 65536.0f) +#define VM_F_TO_X(x) (VMINT32)((x) * 65536.0f) + +/***************************************************************************** + * FUNCTION + * vm_get_sys_scene + * DESCRIPTION + * get system setting profile + * PARAMETERS + * void + * RETURNS + * 0 : standard mode + * 1: meeting mode + * 2: outside mode + * 3: indoor mode + * 4: earphone mode + * 5: silent mode + * 6: bluetooth mode + *****************************************************************************/ +VMINT vm_get_sys_scene(void); +/***************************************************************************** + * FUNCTION + * vm_clipboard_is_available + * DESCRIPTION + * Check whether the current project support clipboard + * PARAMETERS + * NULL + * RETURNS + * TRUE : Support clipboard + * FALSE: Not support clipboard + *****************************************************************************/ +VMBOOL vm_clipboard_is_available(void); + +/***************************************************************************** + * FUNCTION + * vm_clipboard_text_set_data + * DESCRIPTION + * Set text data to clipboard. + * The text encoded type should be unicode. + * Clipboard only could stores 2048 wchars at most. + * The memory is provided by system. + * PARAMETERS + * str : [IN] unicode string pointer + * str_len : [IN] string length (could be less than the total length, in other words, a part of string) + * RETURNS + * TRUE : 1. Operation success + * 2. str == NULL (clear the clipboard) + * FALSE: 1. memory not enough + * 2. memory overlapped + * 3. str_len <= 0 + *****************************************************************************/ +VMBOOL vm_clipboard_text_set_data(const VMWSTR str, VMUINT str_len); + + +/***************************************************************************** + * FUNCTION + * vm_clipboard_text_get_data + * DESCRIPTION + * Get text data from clipboard. + * This is a blobal string pointer saved in system memory. + * PARAMETERS + * void + * RETURNS + * Valid pointer: unicode string pointer + * NULL: clipboard is empty + *****************************************************************************/ +VMWSTR vm_clipboard_text_get_data(void); + +void vm_set_touch_feedback ( vm_touch_feedback_enum type); + +#ifdef __cplusplus +} +#endif/*__cplusplus*/ + +#endif/*VM_UIMISC_SDK_H*/ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmusb.h b/hardware/arduino/mtk/system/libmtk/include/vmusb.h new file mode 100644 index 00000000..15fb3b30 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmusb.h @@ -0,0 +1,85 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2006 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +/******************************************************************************* + * Filename: + * --------- + * vmusb_sdk.h + * + * Project: + * -------- + * MAUI + * + * Description: + * ------------ + * usb + * + * Author: + * ------- + * + * +*============================================================================== + * HISTORY + * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *------------------------------------------------------------------------------ +* *------------------------------------------------------------------------------ + * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! + *============================================================================== +*******************************************************************************/ + +#ifndef VM_USB_SDK_H +#define VM_USB_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" +/******************************************************************************* +* FUNCTION +* vm_usb_get_cable_status +* DESCRIPTION +* get usb cable plug in and plut out state +* PARAMETERS +* N/A +* RETURNS +* 0: usb is in plug in state; 1:usb is in plug out state +*******************************************************************************/ +VMINT vm_usb_get_cable_status(void); +#ifdef __cplusplus +} +#endif + +#endif /* VM_USB_SDK_H */ \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/include/vmvad.h b/hardware/arduino/mtk/system/libmtk/include/vmvad.h new file mode 100644 index 00000000..c6442699 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmvad.h @@ -0,0 +1,125 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMVAD_SDK_H +#define VMVAD_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + + + /***************************************************************************** + * + * + * FUNCTION + * vm_vad_msg_hdlr + * DESCRIPTION + * This function is used to handle msg data. + * PARAMETERS + * msg : [IN] message id. + * param : [IN] message parameter. + * RETURNS + * void + *****************************************************************************/ +typedef void (*vm_vad_msg_hdlr)(VMINT msg, VMINT param); + +/***************************************************************************** + * FUNCTION + * vm_vad_switch_on_off + * DESCRIPTION + * switch on/off VAD. + * PARAMETERS + * on : [IN] on/off VAD + * param : reserve, NULL is ok + * RETURN VALUES + * TRUE : if the operation is successful. + * FALSE : means error illegal + *****************************************************************************/ +VMBOOL vm_vad_switch_on_off(VMBOOL on, void* param); + +/***************************************************************************** + * FUNCTION + * vm_vad_set_level + * DESCRIPTION + * Set VAD Detect sensitivity + * PARAMETERS + * level : [IN] 0¨C255, 0 is the highest level sensitivity + * RETURN VALUES + * TRUE : if the operation is successful. + * FALSE : means error illegal + *****************************************************************************/ +VMBOOL vm_vad_set_level(VMUINT8 level); + +/***************************************************************************** + * FUNCTION + * vm_vad_is_on + * DESCRIPTION + * check VAD on/off + * RETURN VALUES + * TRUE : on. + * FALSE : off + *****************************************************************************/ +VMBOOL vm_vad_is_on(void); + +/***************************************************************************** + * FUNCTION + * vm_vad_get_level + * DESCRIPTION + * get current VAD sensitivity level + * RETURN VALUES + * 0-255 + *****************************************************************************/ +VMUINT8 vm_vad_get_level(void); + +/***************************************************************************** + * FUNCTION + * vm_vad_register_callback + * DESCRIPTION + * Register the callback function that deal with the detect result + * PARAMETERS + * callback : [IN] the function to deal with the detect result + *****************************************************************************/ +void vm_vad_register_callback(vm_vad_msg_hdlr callback); + + +#ifdef __cplusplus +} +#endif + +#endif /* VMVAD_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmvdorec.h b/hardware/arduino/mtk/system/libmtk/include/vmvdorec.h new file mode 100644 index 00000000..7163187f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmvdorec.h @@ -0,0 +1,334 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef _VM_VDOREC_SDK_H +#define _VM_VDOREC_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/* msg when record finish */ +#define VM_MSG_VDOREC_FINISH 1000 + +/* msg when file merge done */ +#define VM_MSG_VDOREC_FILE_MERGE_DONE 2000 + +/* video recorder result */ +#define VM_RES_VDOREC_SUCCESS 0 /* Success */ +#define VM_RES_VDOREC_FAILED (-1) /* Common failed */ +#define VM_RES_VDOREC_REACH_SIZE_LIMIT (-2) /* reach max size, mp4 file max size is 2G */ +#define VM_RES_VDOREC_REACH_TIME_LIMIT (-3) /* reach max time, LINKIT not support this parameter, so there is no limit */ +#define VM_RES_VDOREC_DISK_FULL (-4) /* disk space full */ +#define VM_RES_VDOREC_ERR_STORAGE_TOO_SLOW (-5) /* storage too slow */ +#define VM_RES_VDOREC_ERR_NO_FRAME_ENCODED (-6) /* frame encode error */ + +#ifndef MAX_APP_NAME_LEN +#define MAX_APP_NAME_LEN (260) +#endif + +/* Video recorder image format */ +typedef enum +{ + VM_VDOREC_FORMAT_MPEG4 = 0, /* MPEG4 */ + VM_VDOREC_FORMAT_H263 = 1, /* H263 */ + VM_VDOREC_FORMAT_H264 = 2, /* H264 */ + VM_VDOREC_FORMAT_MJPEG = 3, /* MJPEG */ + VM_VDOREC_FORMAT_MAX = 0x1FFF +} vm_vdorec_format_enum_t; + +/* Video recorder image quality */ +typedef enum +{ + VM_VDOREC_QUALITY_FINE = 0, /* FINE */ + VM_VDOREC_QUALITY_HIGH = 1, /* HIGH */ + VM_VDOREC_QUALITY_NORMAL = 2, /* NORMAL */ + VM_VDOREC_QUALITY_LOW = 3, /* LOW */ + VM_VDOREC_QUALITY_MAX = 0x1FFF +} vm_vdorec_quality_enum_t; + +/* Video record camera id */ +enum +{ + VM_VDOREC_MAIN_CAMERA, /* main camera */ + VM_VDOREC_SUB_CAMERA /* sub camera */ +}; + +/* Video recorder param */ +#define VM_VDOREC_CAMERA_CONTRAST (1) /* contrast */ +#define VM_VDOREC_CAMERA_SHARPNESS (2) /* sharpness */ +#define VM_VDOREC_CAMERA_WB (3) /* wb */ +#define VM_VDOREC_CAMERA_DIGITAL_ZOOM (4) /* digital zoom */ +#define VM_VDOREC_CAMERA_EV_VALUE (5) /* ev value */ + +/* Video recorder param contrast */ +typedef enum +{ + VM_VDOREC_CONTRAST_LOW=0, /* low */ + VM_VDOREC_CONTRAST_MEDIUM, /* medium */ + VM_VDOREC_CONTRAST_HIGH, /* high */ + VM_VDOREC_CONTRAST_MAX +} VM_VDOREC_CONTRAST_ENUM; + +/* Video recorder param sharpness */ +typedef enum +{ + VM_VDOREC_SHARPNESS_LOW=0, /* low */ + VM_VDOREC_SHARPNESS_MEDIUM, /* medium */ + VM_VDOREC_SHARPNESS_HIGH, /* high */ + VM_VDOREC_SHARPNESS_MAX +} VM_VDOREC_SHARPNESS_ENUM; + +/* Video recorder param wb */ +typedef enum +{ + VM_VDOREC_WB_AUTO = 0, /* auto */ + VM_VDOREC_WB_CLOUD, /* cloud */ + VM_VDOREC_WB_DAYLIGHT, /* daylight */ + VM_VDOREC_WB_INCANDESCENCE, /* incandescence */ + VM_VDOREC_WB_FLUORESCENT, /* fluorescent */ + VM_VDOREC_WB_TUNGSTEN, /* tungsten */ + VM_VDOREC_WB_MANUAL, /* manual */ + VM_VDOREC_NO_OF_WB /* no wb */ +} VM_VDOREC_WB_ENUM; + +/* Video recorder param zoom */ +typedef enum +{ + VM_VDOREC_DZ_TYPE_RANGE, /* ISP supported digital zoom . (for Raw/YUV sensors) */ + VM_VDOREC_DZ_TYPE_LIST, /* Sensor supported digial zoom. (for JPEG sensor) */ + VM_VDOREC_DZ_TYPE_MAX +} VM_VDOREC_DIGITAL_ZOOM_TYPE_ENUM; + +/* Video recorder param ev */ +typedef enum +{ + VM_VDOREC_EV_NEG_4_3 = 0, /* EV_NEG_4_3 */ + VM_VDOREC_EV_NEG_3_3, /* EV_NEG_3_3 */ + VM_VDOREC_EV_NEG_2_3, /* EV_NEG_2_3 */ + VM_VDOREC_EV_NEG_1_3, /* EV_NEG_1_3 */ + VM_VDOREC_EV_ZERO, /* EV_ZERO */ + VM_VDOREC_EV_POS_1_3, /* EV_POS_1_3 */ + VM_VDOREC_EV_POS_2_3, /* EV_POS_2_3 */ + VM_VDOREC_EV_POS_3_3, /* EV_POS_3_3 */ + VM_VDOREC_EV_POS_4_3, /* EV_POS_4_3 */ + VM_VDOREC_EV_NIGHT_SHOT, /* EV_NIGHT_SHOT */ + VM_VDOREC_NO_OF_EV +} VM_VDOREC_EV_ENUM; + +/* Video recorder preview setting structure */ +typedef struct +{ + VMUINT16 width; /* Width of the video */ + VMUINT16 height; /* Height of the video */ + VMUINT16 bit_stream_type; /* image type, refer vm_vdorec_format_enum_t */ + VMUINT16 encode_quality; /* image quality, refer vm_vdorec_quality_enum_t */ +}vm_vdorec_preview_struct; + +/* Video recorder record setting structure */ +typedef struct +{ + VMWCHAR fullFileName[MAX_APP_NAME_LEN + 1]; /* full file name to save */ +}vm_vdorec_record_struct; + + +/***************************************************************************** +* FUNCTION +* vm_vdorec_callback +* DESCRIPTION +* When record done or file merge done, application will receive this callback +* PARAMETERS +* msg : [IN] msg id , it should be VM_MSG_VDOREC_FINISH/VM_MSG_VIDEO_FILE_MERGE_DONE +* VMINT : [INT] please refer the video recorder result +* RETURNS +* void +*****************************************************************************/ +typedef void (*vm_vdorec_callback)(VMINT msg, VMINT ret); + + + /***************************************************************************** + * FUNCTION + * vm_vdorec_start + * DESCRIPTION + * video record start + * PARAMETERS + * camere_id : [IN] camear id, VM_VDOREC_MAIN_CAMERA/VM_VDOREC_SUB_CAMERA + * callback : [IN] callback function, please refer vm_vdorec_callback + * RETURN VALUES + * VM_RES_VDOREC_SUCCESS : Succeed to record. + * VM_RES_VDOREC_FAILED : Fail to record. + *****************************************************************************/ +VMINT vm_vdorec_power_up(VMUINT16 camere_id, vm_vdorec_callback callback); + +/***************************************************************************** + * FUNCTION + * vm_vdorec_preview + * DESCRIPTION + * video record preview start + * PARAMETERS + * para : [IN] video record setting, please refer vm_vdorec_preview_struct + * RETURN VALUES + * VM_RES_VDOREC_SUCCESS : Succeed to record. + * VM_RES_VDOREC_FAILED : Fail to record. + *****************************************************************************/ +VMINT vm_vdorec_preview(vm_vdorec_preview_struct* para); + +/***************************************************************************** + * FUNCTION + * vm_vdorec_set_param + * DESCRIPTION + * video record set parameters + * PARAMETERS + * param_id : [IN] video record setting, please refer the marco of Video recorder param + * value : [IN] value + * RETURN VALUES + * VM_RES_VDOREC_SUCCESS : Succeed to set. + * VM_RES_VDOREC_FAILED : Fail to set. + *****************************************************************************/ +VMINT vm_vdorec_set_param(VMUINT32 param_id, VMUINT16 value); + +/***************************************************************************** + * FUNCTION + * vm_vdorec_record + * DESCRIPTION + * video record start + * PARAMETERS + * para : [IN] video record setting, please refer vm_vdorec_record_struct + * RETURN VALUES + * VM_RES_VDOREC_SUCCESS : Succeed to record. + * VM_RES_VDOREC_FAILED : Fail to record. + *****************************************************************************/ +VMINT vm_vdorec_record(vm_vdorec_record_struct* para); + + /***************************************************************************** + * FUNCTION + * vm_video_close_file + * DESCRIPTION + * To stop video record. + * PARAMETERS + * void + * RETURN VALUES + * VM_RES_VDOREC_SUCCESS : Succeed to stop. + * VM_RES_VDOREC_FAILED : Fail to stop. + *****************************************************************************/ +VMINT vm_vdorec_stop(void); + + /***************************************************************************** + * FUNCTION + * vm_video_pause + * DESCRIPTION + * To pause video record. + * PARAMETERS + * void + * RETURN VALUES + * VM_RES_VDOREC_SUCCESS : Succeed to pause. + * VM_RES_VDOREC_FAILED : Fail to pause. + *****************************************************************************/ +VMINT vm_vdorec_pause(void); + + /***************************************************************************** + * FUNCTION + * vm_video_resume + * DESCRIPTION + * To resume video record. + * PARAMETERS + * void + * RETURN VALUES + * VM_RES_VDOREC_SUCCESS : Succeed to resume. + * VM_RES_VDOREC_FAILED : Fail to resume. + *****************************************************************************/ +VMINT vm_vdorec_resume(void); + +/***************************************************************************** + * FUNCTION + * vm_vdorec_power_down + * DESCRIPTION + * video record power down + * PARAMETERS + * void + * RETURN VALUES + * VM_RES_VDOREC_SUCCESS : Succeed to resume. + * VM_RES_VDOREC_FAILED : Fail to resume. + *****************************************************************************/ +VMINT vm_vdorec_power_down(void); + +/***************************************************************************** + * FUNCTION + * vm_vdorec_save_to_file + * DESCRIPTION + * Save record data to file + * PARAMETERS + * filepath : filepath to save + * callback : save result callback + * RETURN VALUES + * N/A +*****************************************************************************/ +void vm_vdorec_save_to_file(VMWSTR filepath, vm_vdorec_callback callback); + +/***************************************************************************** + * FUNCTION + * vm_vdorec_rtsp_local_save_start + * DESCRIPTION + * Save record data to local file + * PARAMETERS + * filepath : filepath to save + * callback : save result callback + * RETURN VALUES + * VM_RES_VDOREC_SUCCESS : Succeed to start. + * VM_RES_VDOREC_FAILED : Fail to start. +*****************************************************************************/ +VMINT vm_vdorec_rtsp_local_save_start(VMWSTR filepath, vm_vdorec_callback callback); + +/***************************************************************************** + * FUNCTION + * vm_vdorec_rtsp_local_save_stop + * DESCRIPTION + * Save record data to file + * PARAMETERS + * void + * RETURN VALUES + * VM_RES_VDOREC_SUCCESS : Succeed to stop. + * VM_RES_VDOREC_FAILED : Fail to stop. +*****************************************************************************/ +VMINT vm_vdorec_rtsp_local_save_stop(void); + +#ifdef __cplusplus +} +#endif + +#endif /*_VM_VDOREC_H*/ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmvibr.h b/hardware/arduino/mtk/system/libmtk/include/vmvibr.h new file mode 100644 index 00000000..2061da1e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmvibr.h @@ -0,0 +1,75 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMVIBR_SDK_H_ +#define VMVIBR_SDK_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/***************************************************************************** + * FUNCTION + * vm_vibrator_once + * DESCRIPTION + * vibrator once, vibrator on 1 second then off. +*****************************************************************************/ +void vm_vibrator_once(void); + + +/***************************************************************************** + * FUNCTION + * vm_vibrator_on + * DESCRIPTION + * vibrator on. +*****************************************************************************/ +void vm_vibrator_on(void); + + +/***************************************************************************** + * FUNCTION + * vm_vibrator_off + * DESCRIPTION + * vibrator off. +*****************************************************************************/ +void vm_vibrator_off(void); + +#ifdef __cplusplus +} +#endif + +#endif /* VMVIBR_SDK_H_ */ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmvideo.h b/hardware/arduino/mtk/system/libmtk/include/vmvideo.h new file mode 100644 index 00000000..9a29c2f9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmvideo.h @@ -0,0 +1,608 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef _VM_VIDEO_SDK_H +#define _VM_VIDEO_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" +#include "vmmm.h" + +/** + * operation succeed + */ +#define VM_VIDEO_SUCCESS (0) +/** + * operation fail + */ +#define VM_VIDEO_FAILED (-1) + + +/** + * data not enough + */ +#define VM_VIDEO_PROGRESSIVE_FILE_NOT_ENOUGH -101 + + + + +/** + * file open failed + */ +#define VM_VIDEO_ERR_OPEN_FILE_FAILED -103 + +/** + * file size too large + */ +#define VM_VIDEO_ERR_FILE_TOO_LARGE -104 + +/** + * snapshot failed + */ +#define VM_VIDEO_ERR_SNAPSHOT_FAILED -105 + +/** + * play failed + */ +#define VM_VIDEO_ERR_PLAY_FAILED -106 + + + +/** + * snapshot failed for disk full + */ +#define VM_VIDEO_ERR_SNAPSHOT_DISK_FULL -107 + +/** + * snapshot failed for disk read-only + */ +#define VM_VIDEO_ERR_SNAPSHOT_WRITE_PROTECTION -108 + +/** + * invalid resoulution + */ +#define VM_VIDEO_ERR_INVALID_RESOULTION -109 + +/** + * unsupported format + */ +#define VM_VIDEO_ERR_UNSUPPORTED_FORMAT -110 + +/** + * memory insufficient + */ +#define VM_VIDEO_ERR_MEMORY_INSUFFICIENT -111 + +/** + * DRM prohibited + */ +#define VM_VIDEO_ERR_DRM_PROHIBITED -112 + +/** + * DRM during usage + */ +#define VM_VIDEO_ERR_DRM_DURATION_USED -113 + +/** + * framerate too high + */ +#define VM_VIDEO_ERR_FRAMERATE_TOO_HIGH -114 + + + +/** + * one grade darker than N4 + */ +#define VM_VIDEO_BRIGHTNESS_N5 0 +/** + * one grade darker than N3 + */ +#define VM_VIDEO_BRIGHTNESS_N4 1 +/** + * one grade darker than N2 + */ +#define VM_VIDEO_BRIGHTNESS_N3 2 +/** + * one grade darker than N1 + */ +#define VM_VIDEO_BRIGHTNESS_N2 3 +/** + * one grade darker than 0 + */ +#define VM_VIDEO_BRIGHTNESS_N1 4 +/** + * default brightness + */ +#define VM_VIDEO_BRIGHTNESS_0 5 +/** + * one grade brighter than 0 + */ +#define VM_VIDEO_BRIGHTNESS_P1 6 +/** + * one grade brighter than P1 + */ +#define VM_VIDEO_BRIGHTNESS_P2 7 +/** + * one grade brighter than P2 + */ +#define VM_VIDEO_BRIGHTNESS_P3 8 +/** + * one grade brighter than P3 + */ +#define VM_VIDEO_BRIGHTNESS_P4 9 +/** + * one grade brighter than P4 + */ +#define VM_VIDEO_BRIGHTNESS_P5 10 + + +/** + * one grade lower than N4 + */ +#define VM_VIDEO_CONTRAST_N5 0 +/** + * one grade lower than N3 + */ +#define VM_VIDEO_CONTRAST_N4 1 +/** + * one grade lower than N2 + */ +#define VM_VIDEO_CONTRAST_N3 2 +/** + * one grade lower than N1 + */ +#define VM_VIDEO_CONTRAST_N2 3 +/** + * one grade lower than 0 + */ +#define VM_VIDEO_CONTRAST_N1 4 +/** + * default contrast + */ +#define VM_VIDEO_CONTRAST_0 5 +/** + * one grade higher than 0 + */ +#define VM_VIDEO_CONTRAST_P1 6 +/** + * one grade higher than P1 + */ +#define VM_VIDEO_CONTRAST_P2 7 +/** + * one grade higher than P2 + */ +#define VM_VIDEO_CONTRAST_P3 8 +/** + * one grade higher than P3 + */ +#define VM_VIDEO_CONTRAST_P4 9 +/** + * one grade higher than P4 + */ +#define VM_VIDEO_CONTRAST_P5 10 + + +/** + * rotate 0 degree + */ +#define VM_VIDEO_LCD_ROTATE_0 0 +/** + * rotate 90 degree + */ +#define VM_VIDEO_LCD_ROTATE_90 1 +/** + * rotate 180 degree + */ +#define VM_VIDEO_LCD_ROTATE_180 2 +/** + * rotate 270 degree + */ +#define VM_VIDEO_LCD_ROTATE_270 3 + +/* Video track type enum */ +typedef enum +{ + VM_VIDEO_TRACK_NONE, + VM_VIDEO_TRACK_AV, /* Video has both audio and video tracks */ + VM_VIDEO_TRACK_A_ONLY, /* Video has audio track only */ + VM_VIDEO_TRACK_V_ONLY /* Video has video track only */ +} vm_video_track_enum; + + +/* Max length of content info */ +#define VM_VIDEO_MAX_CONTENT_INFO_LEN 80 + + +/* Video information structure */ +typedef struct +{ + VMUINT16 width; /* Width of the video */ + VMUINT16 height; /* Height of the video */ + VMUINT32 total_frame_count; /* Total framecount of the video */ + VMUINT64 total_time_duration; /* Total time duration of the video */ + vm_video_track_enum track; + VMINT handle; /* Handle of the opened video file */ + VMINT is_seekable; /* Is this video seekable */ + VMUINT8 aud_channel_no; /* Audio channel count information */ + VMUINT16 aud_sample_rate; /* Audio sample rate information */ + + VMINT is_drm_streaming; /* Is this is a drm streaming file */ + VMUINT drm_handle; /* DRM handle of this video */ + + VMWCHAR title_desc[VM_VIDEO_MAX_CONTENT_INFO_LEN+1]; /* Title information */ + VMWCHAR artist_desc[VM_VIDEO_MAX_CONTENT_INFO_LEN+1]; /* Artist information */ + VMWCHAR album_desc[VM_VIDEO_MAX_CONTENT_INFO_LEN+1]; /* Album information */ + VMWCHAR author_desc[VM_VIDEO_MAX_CONTENT_INFO_LEN+1]; /* Author information */ + VMWCHAR copyright_desc[VM_VIDEO_MAX_CONTENT_INFO_LEN+1]; /* Copyright information */ + VMWCHAR date_desc[VM_VIDEO_MAX_CONTENT_INFO_LEN+1]; /* Date information */ +} vm_video_info_struct; + + + + + +/***************************************************************************** +* FUNCTION +* vm_video_open_result_callback +* DESCRIPTION +* When open a file in async mode, if there is any error or indication (open succeefully) from media-task, MDI-Video module will invoke this callback function and pass the result to MMI appliactions. +* MMI application should handle this kind of error. +* PARAMETERS +* ret : [IN] The result in MDI_RESULT enum type. +* video_info : [OUT] video information of this opened file, it will contain valid data if the open operation is succeeded. +* RETURNS +* void +*****************************************************************************/ +typedef void (*vm_video_open_result_callback)(VMINT ret, vm_video_info_struct *video_info); + + +/***************************************************************************** +* FUNCTION +* vm_video_finish_callback +* DESCRIPTION +* When playing a video, if there is any error or indication (finished playing) from media-task, MDI-Video module will invoke this callback function and pass the result to MMI applications. +* MMI application should handle this kind of error. +* PARAMETERS +* ret: [IN] The result in MDI_RESULT enum type. +* RETURNS +* void +*****************************************************************************/ +typedef void (*vm_video_finish_callback) (VMINT ret); + + + + /***************************************************************************** + * FUNCTION + * vm_video_open_file + * DESCRIPTION + * To open video file (non-blocking open). + * PARAMETERS + * filename : [IN] Videe clip's full file name + * open_result_callback : [IN] Open file result callback function + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to open video file, need to wait callback function when open operation is finished. + * VM_VIDEO_ERR_DRM_PROHIBITED : Fail to open video file due to drm is prohibited. + * VM_VIDEO_ERR_MEMORY_INSUFFICIENT : Fail to open video file due to memory is insufficient. + * VM_VIDEO_ERR_FRAMERATE_TOO_HIGH : Fail to open video file due to file is too large. + * VM_VIDEO_ERR_INVALID_RESOULTION : Fail to open video file due to framerate is too high. + * VM_VIDEO_ERR_OPEN_FILE_FAILED : Fail to open video file. + *****************************************************************************/ + VMINT vm_video_open_file( + const VMWSTR filename, + vm_video_open_result_callback open_result_callback); + + + /***************************************************************************** + * FUNCTION + * vm_video_close_file + * DESCRIPTION + * To close video file. + * PARAMETERS + * void + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to close video file. + * VM_VIDEO_FAILED : Fail to close video file. + *****************************************************************************/ + VMINT vm_video_close_file(void); + + + /***************************************************************************** + * FUNCTION + * vm_video_open_buffer + * DESCRIPTION + * To open video clip from buffer. + * PARAMETERS + * file_buffer : [IN] Video clip file buffer + * buffer_len : [IN] Video clip's buffer size + * info : [OUT] Video clip's info + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to open video buffer, need to wait callback function when open operation is finished. + * VM_VIDEO_ERR_MEMORY_INSUFFICIENT : Fail to open video buffer due to memory is insufficient. + * VM_VIDEO_ERR_FRAMERATE_TOO_HIGH : Fail to open video buffer due to framerate is too high. + * VM_VIDEO_ERR_OPEN_FILE_FAILED : Fail to open video file. + *****************************************************************************/ + VMINT vm_video_open_buffer( + const VMUSTR buffer, + const VMUINT buffer_len, + vm_video_info_struct *info); + + + /***************************************************************************** + * FUNCTION + * vm_video_close_buffer + * DESCRIPTION + * To close video clip from buffer + * PARAMETERS + * void + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to close video clip buffer. + * VM_VIDEO_FAILED : Fail to close video clip buffer. + *****************************************************************************/ + VMINT vm_video_close_buffer(void); + + +/***************************************************************************** +* FUNCTION +* mdi_video_ply_play +* DESCRIPTION +* To start play opened video. +* PARAMETERS +* player_layer_handle : [IN] Layer handle of playback layer. +* base_layer_handle : [IN] Layer handle of tool component layer. +* repeat_count : [IN] Repeat how many times. +* is_play_audio : [IN] To play audio or not. +* audio_path : [IN] Audio output path. +* play_finish_callback : [IN] Callback function. +* RETURN VALUES +* VM_VIDEO_SUCCESS : Succeed to start play. +* VM_VIDEO_ERR_DRM_PROHIBITED : Fail to start play due to drm check is prohibited. +* MDI_RES_VDOPLY_PROGRESSIVE_FILE_NOT_ENOUGH : Fail to start play due to the download data is not enough for progressive playback. +* VM_VIDEO_PROGRESSIVE_FILE_NOT_ENOUGH : Fail to start play due to it is stopped due to stop time is reached. +* VM_VIDEO_ERR_PLAY_FAILED : Fail to start play. +*****************************************************************************/ + VMINT vm_video_play( + VMUINT player_layer_handle, + VMUINT base_layer_handle, + VMUINT16 repeat_count, + VMINT is_play_audio, + VMINT audio_path, + vm_video_finish_callback play_finish_callback); + + +/***************************************************************************** + * FUNCTION + * vm_video_stop + * DESCRIPTION + * To stop video playing. + * PARAMETERS + * void + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to stop player. + * VM_VIDEO_FAILED : Fail to stop player due to it is already stopped. + *****************************************************************************/ + VMINT vm_video_stop(void); + + + /***************************************************************************** + * FUNCTION + * vm_video_pause + * DESCRIPTION + * To pause video playing. + * PARAMETERS + * void + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to pause. + * VM_VIDEO_FAILED : Fail to pause. + *****************************************************************************/ +VMINT vm_video_pause(void); + + + /***************************************************************************** + * FUNCTION + * vm_video_resume + * DESCRIPTION + * To resume video playing. + * PARAMETERS + * void + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to resume. + * VM_VIDEO_FAILED : Fail to resume. + *****************************************************************************/ +VMINT vm_video_resume(void); + + + /***************************************************************************** + * FUNCTION + * vm_video_seek_and_getframe + * DESCRIPTION + * To seek video and get seek frame. + * PARAMETERS + * time : [IN] Seek time stamp. + * player_layer_handle : [IN] Get frame on this layer. + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to seek. + * VM_VIDEO_FAILED : Fail to seek. + *****************************************************************************/ + VMINT vm_video_seek_and_getframe(VMUINT64 time, VMUINT player_layer_handle); + + + /***************************************************************************** + * FUNCTION + * vm_video_snapshot + * DESCRIPTION + * To snapshot video and save as jpeg file. + * PARAMETERS + * layer_handle : [IN] Video play layer. + * file_name : [IN] Filename for jpeg. + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to snapshot. + * VM_VIDEO_ERR_SNAPSHOT_DISK_FULL : Fail to snapshot due to disk is full. + * VM_VIDEO_ERR_SNAPSHOT_WRITE_PROTECTION : Fail to snapshot due to the disk is in write protection mode. + * VM_VIDEO_ERR_SNAPSHOT_FAILED : Fail to snapshot. + *****************************************************************************/ + VMINT vm_video_snapshot(VMUINT player_layer_handle, VMWSTR file_name); + + + + /***************************************************************************** + * FUNCTION + * vm_video_set_brightness + * DESCRIPTION + * To set brightness parameter for video player. + * PARAMETERS + * brightness : [IN] Brightness value + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to set brightness parameter to video player. + * VM_VIDEO_FAILED : Fail to set brightness parameter to video player. + *****************************************************************************/ + VMINT vm_video_set_brightness(VMUINT16 brightness); + + + /***************************************************************************** + * FUNCTION + * vm_video_set_contrast + * DESCRIPTION + * To set contrast parameter to video player. + * PARAMETERS + * contrast : [IN] Contrast value + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to set EV parameter to video player. + * VM_VIDEO_FAILED : Fail to set EV parameter to video player. + *****************************************************************************/ + VMINT vm_video_set_contrast(VMUINT16 contrast); + + + + /***************************************************************************** + * FUNCTION + * vm_video_get_cur_play_time + * DESCRIPTION + * To get current play time. + * PARAMETERS + * cur_play_time : [OUT] Current play time. + * RETURNS + * result of get play time + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to set EV parameter to video player. + * VM_VIDEO_FAILED : Fail to set EV parameter to video player. + *****************************************************************************/ + VMINT vm_video_get_cur_play_time(VMUINT64 *cur_play_time); + + + /***************************************************************************** + * FUNCTION + * vm_video_play_stream_from_rtsp_link + * DESCRIPTION + * launch native Video Player to play specified RTSP link + * PARAMETERS + * url : [IN] RTSP URL link encoding with UCS2 format. + * RETURNS + * result of launch video player applicaiton + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to launch video player application + * VM_VIDEO_FAILED : Fail to launch video player application. + *****************************************************************************/ +VMINT vm_video_play_stream_from_rtsp_link(VMWSTR url); + +/***************************************************************************** + * FUNCTION + * vm_video_play_stream_from_sdp_file + * DESCRIPTION + * launch native Video Player to play specified sdp file + * PARAMETERS + * filename : [IN] sdp file name encoding with UCS2 format. + * is_short : [IN] is 8.3 format file name or not. + * RETURNS + * result of launch video player applicaiton + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to launch video player application + * VM_VIDEO_FAILED : Fail to launch video player application. + *****************************************************************************/ +VMINT vm_video_play_stream_from_sdp_file(VMWSTR filename, VMUCHAR is_short); + + +/***************************************************************************** + * FUNCTION + * vm_video_play_by_filepath + * DESCRIPTION + * launch native Video Player to play specified file path + * PARAMETERS + * filename : [IN] file name encoding with UCS2 format. + * RETURNS + * result of launch video player applicaiton + * RETURN VALUES + * VM_VIDEO_SUCCESS : Succeed to launch video player application + * or else failure. + *****************************************************************************/ +VMINT vm_video_play_by_filepath(VMWSTR filename); + +/***************************************************************************** + * FUNCTION + * vm_video_is_support_rtsp_link_play + * DESCRIPTION + * support rstp play or not + * PARAMETERS + * + * RETURNS + * + * RETURN VALUES + * TRUE : support rtsp play + * FALSE : not support + *****************************************************************************/ +VMBOOL vm_video_is_support_rtsp_link_play(void); + +/***************************************************************************** + * FUNCTION + * vm_video_is_support_sdp_file_play + * DESCRIPTION + * support sdp file play or not + * PARAMETERS + * + * RETURNS + * + * RETURN VALUES + * TRUE : support sdp file play + * FALSE : not support + *****************************************************************************/ +VMBOOL vm_video_is_support_sdp_file_play(void); + +#ifdef __cplusplus +} +#endif + +#endif /*_VM_VIDEO_H*/ diff --git a/hardware/arduino/mtk/system/libmtk/include/vmwdt.h b/hardware/arduino/mtk/system/libmtk/include/vmwdt.h new file mode 100644 index 00000000..c3b40d65 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmwdt.h @@ -0,0 +1,138 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMWDT_SDK_H +#define VMWDT_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +void vm_assert(VMSTR file, VMINT line); + +/***************************************************************************** + * FUNCTION + * vm_wdt_start + * DESCRIPTION + * start a watch dog + * PARAMETERS + * millisec : [IN] watch dog reset time + * RETURN VALUES + * >=0 : the handle of watch dog + * <0 : error + * EXAMPLE + * + * VMINT handle = vm_wdt_start(1000); + * // do somting + * vm_wdt_feed(handle); + * // finish doing + * vm_wdt_stop(handle); + * + *****************************************************************************/ +VMINT vm_wdt_start(VMUINT tick); + +/***************************************************************************** + * FUNCTION + * vm_wdt_feed + * DESCRIPTION + * feed watch + * PARAMETERS + * handle : [IN] watch dog handle that vm_wdt_start returned. + * RETURN + * void + * EXAMPLE + * + * VMINT handle = vm_wdt_start(1000); + * // do somting + * vm_wdt_feed(handle); + * // finish doing + * vm_wdt_stop(handle); + *****************************************************************************/ +void vm_wdt_feed(VMINT handle); + +/***************************************************************************** + * FUNCTION + * vm_wdt_stop + * DESCRIPTION + * stop watch dog + * PARAMETERS + * handle : [IN] watch dog handle that vm_wdt_start returned. + * RETURN + * void + * EXAMPLE + * + * VMINT handle = vm_wdt_start(1000); + * // do somting + * vm_wdt_feed(handle); + * // finish doing + * vm_wdt_stop(handle); + *****************************************************************************/ +void vm_wdt_stop(VMINT handle); + + +/***************************************************************************** + * FUNCTION + * VM_ASSERT + * DESCRIPTION + * assert the phone if the expression is false + * PARAMETERS + * expr : [IN] expression to check + * RETURN VALUES + * N/A + *****************************************************************************/ +#ifdef __LINKIT_DEBUG__ +#ifdef WIN32 + #define VM_ASSERT(__expr__) \ + do { \ + if (!(__expr__)) \ + { \ + _asm {int 3} \ + } \ + } while (0) +#else + #define VM_ASSERT(expr) do {if(!(expr)) vm_assert((VMSTR)__FILE__, __LINE__); } while (0) +#endif +#else + #define VM_ASSERT(expr) do {if(!(expr)) {} } while (0) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* VMWDT_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/include/vmxml.h b/hardware/arduino/mtk/system/libmtk/include/vmxml.h new file mode 100644 index 00000000..f0c327fb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/include/vmxml.h @@ -0,0 +1,337 @@ +/***************************************************************************** +* Copyright Statement: +* -------------------- +* This software is protected by Copyright and the information contained +* herein is confidential. The software may not be copied and the information +* contained herein may not be used or disclosed except with the written +* permission of MediaTek Inc. (C) 2005 +* +* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES +* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") +* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON +* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. +* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE +* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR +* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH +* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO +* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S +* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. +* +* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE +* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, +* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, +* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO +* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. +* +* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE +* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF +* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND +* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER +* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). +* +*****************************************************************************/ + +#ifndef VMXML_SDK_H +#define VMXML_SDK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vmsys.h" + +/***************************************************************************** + * + * + * FUNCTION + * XML_start_doctype_hdlr + * DESCRIPTION + * This function is document type start handler. + * PARAMETERS + * data : [IN] Reserved. + * doctypeName : [IN] Document type name. + * sysid : [IN] System id. + * pubid : [IN] Public id. + * internal_subset : [IN] Internal subset. + * error : [IN] Error code. + * RETURNS + * void + *****************************************************************************/ +typedef void (*XML_start_doctype_hdlr) (void *data, + const VMCHAR *doctypeName, + const VMCHAR **sysid, + const VMCHAR **pubid, VMINT internal_subset, VMINT error); + + /***************************************************************************** + * + * + * FUNCTION + * XML_end_doctype_hdlr + * DESCRIPTION + * This function is document type end handler. + * PARAMETERS + * data : [IN] Reserved. + * error : [IN] Error code, refer to VM_XML_ERROR_ENUM. + * RETURNS + * void + *****************************************************************************/ +typedef void (*XML_end_doctype_hdlr) (void *data, VMINT error); + + /***************************************************************************** + * + * + * FUNCTION + * XML_start_elem_hdlr + * DESCRIPTION + * This function is element start handler. + * PARAMETERS + * data : [IN] Reserved. + * el : [IN] Element name. + * attr : [IN] Attribution list. + * error : [IN] Error code, refer to VM_XML_ERROR_ENUM. + * RETURNS + * void + *****************************************************************************/ +typedef void (*XML_start_elem_hdlr) (void *data, const VMCHAR *el, const VMCHAR **attr, VMINT error); + + /***************************************************************************** + * + * + * FUNCTION + * XML_end_elem_hdlr + * DESCRIPTION + * This function is element end handler. + * PARAMETERS + * data : [IN] Reserved. + * el : [IN] Element name. + * error : [IN] Error code, refer to VM_XML_ERROR_ENUM. + * RETURNS + * void + *****************************************************************************/ +typedef void (*XML_end_elem_hdlr) (void *data, const VMCHAR *el, VMINT error); + + /***************************************************************************** + * + * + * FUNCTION + * XML_data_hdlr + * DESCRIPTION + * This function is used to handle data. + * PARAMETERS + * resv : [IN] Reserved. + * el : [IN] Element name. + * data : [IN] Data. + * len : [IN] Length. + * error : [IN] Error code. + * RETURNS + * void + *****************************************************************************/ +typedef void (*XML_data_hdlr) (void *resv, const VMCHAR *el, const VMCHAR *data, VMINT len, VMINT error); + + /* Define the error code */ +typedef enum +{ + VM_XML_RESULT_FILE_NOT_FOUND = -4, /* The file isn't found */ + VM_XML_RESULT_OUT_OF_MEMORY = -3, /* The memory isn't enough */ + VM_XML_RESULT_ENCODING_ERROR = -2, /* The char encoding error */ + VM_XML_RESULT_FAIL = -1, /* Failed to parse xml */ + VM_XML_RESULT_OK = 0 /* Parsing xml successfully */ +} VM_XML_RESULT_ENUM; + +/* Define the error code */ +typedef enum +{ + VM_XML_NO_ERROR, /* No error */ + VM_XML_ERROR_MISMATCH_TAG, /* Error string: end tag name */ + VM_XML_ERROR_MISMATCH_DOCTYPENAME_ROOTNAME, /* Error string: root element name */ + VM_XML_ERROR_INVALID_ATTRIBUTE, /* Error string: attribute name */ + VM_XML_ERROR_DUPLICATE_ATTRIBUTE, /* Error string: attribute name */ + VM_XML_ERROR_ENTITY_DEFINITION, /* Error string: entity name */ + VM_XML_ERROR_UNDEFINED_ENTITY /* Error string: entity name */ +} VM_XML_ERROR_ENUM; + + /* XML parser struct with all the tag handler */ +typedef struct _VM_XML_PARSER_STRUCT +{ + XML_start_doctype_hdlr start_doctype_hdlr; /* Function pointer provided by app */ + XML_end_doctype_hdlr end_doctype_hdlr; /* Function pointer provided by app */ + XML_start_elem_hdlr start_elem_hdlr; /* Function pointer provided by app */ + XML_end_elem_hdlr end_elem_hdlr; /* Function pointer provided by app */ + XML_data_hdlr data_hdlr; /* Function pointer provided by app */ +} VM_XML_PARSER_STRUCT; + +/***************************************************************************** + * FUNCTION + * vm_xml_new_parser + * DESCRIPTION + * Initialize a new XML parser. The default handlers will be assigned. + * PARAMETERS + * parser : [IN] Pointer to a parser struct. + * RETURN VALUES + * VM_XML_RESULT_OK : If successful. + * VM_XML_RESULT_FAIL : If unsuccessful. + * EXAMPLE + * + * + * #define VMXML_TEST_FILE_RES "

Q's working space

Mediatek " + * + * static void vmxml_doctype_start(void *data, const VMCHAR *doctypeName, const VMCHAR **sysid, + * const VMCHAR **pubid, VMINT internal_subset, VMINT error) + * { + * vm_log_info("doctype_start: doctypeName: %s, %d", doctypeName, error); + * } + * + * static void vmxml_doctype_end(void *data, VMINT error) + * { + * vm_log_info("doctype_end: %d", error); + * } + * + * static void vmxml_elem_start(void *data, const VMCHAR *el, const VMCHAR **attr, VMINT error) + * { + * vm_log_info("elem_start: [%s] [res = %d]", el, error); + * } + * + * static void vmxml_elem_end(void *data, const VMCHAR *el, VMINT error) + * { + * if (VM_XML_NO_ERROR != error) + * { + * VMSTR err_str = vm_xml_get_error(); + * if (err_str != NULL) + * { + * vm_log_info("parse normally, error string %s", err_str); + * } + * } + * else + * { + * if (0 == strcmp(el, "html")) + * { + * vm_log_info("parse normally."); + * } + * } + * } + * + * static void vmxml_data(void *resv, const VMCHAR *el, const VMCHAR *data, VMINT len, VMINT error) + * { + * vm_log_info("Data: [%s][len = %d][res = %d]", el, len, error); + * + * if (0 == strcmp(el, "h1")) + * { + * if (0 == strcmp(data, "Q's working space")) + * { + * vm_log_info("get title text is correct"); + * } + * else + * { + * vm_log_info("get incorrect title"); + * } + * } + * } + * + * void xml_test(void) + * { + * VM_XML_RESULT_ENUM ret = VM_XML_RESULT_FAIL; + * VM_XML_PARSER_STRUCT parser; + * + * memset(&parser, 0, sizeof(VM_XML_PARSER_STRUCT)); + * ret = vm_xml_new_parser(&parser); + * + * if (ret == VM_XML_RESULT_OK) + * { + * vm_xml_set_data_handler(&parser, vmxml_data); + * vm_xml_set_doctype_handlers(&parser, vmxml_doctype_start, vmxml_doctype_end); + * vm_xml_set_element_handlers(&parser, vmxml_elem_start, vmxml_elem_end); + * ret = vm_xml_parse(&parser, VMXML_TEST_FILE_RES, strlen(VMXML_TEST_FILE_RES)); + * if (ret != VM_XML_RESULT_OK) + * { + * vm_log_info("vm_xml_parse() failed. error = %d", ret); + * } + * } + * } + * + *****************************************************************************/ +VMINT vm_xml_new_parser(VM_XML_PARSER_STRUCT *parser); + +/***************************************************************************** + * FUNCTION + * vm_xml_set_doctype_handlers + * DESCRIPTION + * Set document handlers. + * PARAMETERS + * parser : [IN] Pointer to a parser struct. + * start_hdlr : [IN] Function handler to handle start doc data. + * end_hdlr : [IN] Function handler to handle end doc data. + * SEE ALSO + * vm_xml_new_parser + *****************************************************************************/ +void vm_xml_set_doctype_handlers( + VM_XML_PARSER_STRUCT *parser, + XML_start_doctype_hdlr start_hdlr, + XML_end_doctype_hdlr end_hdlr); + +/***************************************************************************** + * FUNCTION + * vm_xml_set_element_handlers + * DESCRIPTION + * Set element handlers. + * PARAMETERS + * parser : [IN] Pointer to a parser struct. + * start_hdlr : [IN] Function handler to handle start element data. + * end_hdlr : [IN] Function handler to handle end element data. + * SEE ALSO + * vm_xml_new_parser + *****************************************************************************/ +void vm_xml_set_element_handlers( + VM_XML_PARSER_STRUCT *parser, + XML_start_elem_hdlr start_hdlr, + XML_end_elem_hdlr end_hdlr); + +/***************************************************************************** + * FUNCTION + * vm_xml_set_data_handler + * DESCRIPTION + * Set data handlers. + * PARAMETERS + * parser : [IN] Pointer to a parser struct. + * start_hdlr : [IN] Function handler to handle data. + * SEE ALSO + * vm_xml_new_parser + *****************************************************************************/ +void vm_xml_set_data_handler(VM_XML_PARSER_STRUCT *parser, XML_data_hdlr data_hdlr); + +/***************************************************************************** + * FUNCTION + * vm_xml_parse + * DESCRIPTION + * This function is called by application to start parsing if application pass. + * PARAMETERS + * parser : [IN] Pointer to a parser struct. + * xmlsource : [IN] Xml file name or XML string buffer. + * length : [IN] 0-from file; >0-from memory. + * RETURN VALUES + * VM_XML_RESULT_OK : If successful. + * VM_XML_RESULT_FAIL : If unsuccessful. + * SEE ALSO + * vm_xml_new_parser + *****************************************************************************/ +VMINT vm_xml_parse(VM_XML_PARSER_STRUCT *parser, const VMCHAR *xmlsource, VMINT length); + +/***************************************************************************** + * FUNCTION + * vm_xml_get_error + * DESCRIPTION + * Get the error string. + * RETURN + * Error string. + * SEE ALSO + * vm_xml_new_parser + *****************************************************************************/ +VMCHAR *vm_xml_get_error(void); + +#ifdef __cplusplus +} +#endif + +#endif /* VMXML_SDK_H */ + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/get_http_head.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/get_http_head.c new file mode 100644 index 00000000..d6b9d654 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/get_http_head.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_get_http_head_t)(http_session_t* session, const char* name, char* value); +_get_http_head_t _get_http_head = NULL; + +int get_http_head(http_session_t* session, const char* name, char* value) +{ + int ret = {-1}; + if (NULL == _get_http_head) + _get_http_head = (_get_http_head_t)vm_get_sym_entry("get_http_head"); + + if (NULL != _get_http_head) + return _get_http_head(session,name,value); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/get_http_head_by_index.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/get_http_head_by_index.c new file mode 100644 index 00000000..43eab96a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/get_http_head_by_index.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_get_http_head_by_index_t)(http_session_t* session, int index, char* name, char* value); +_get_http_head_by_index_t _get_http_head_by_index = NULL; + +int get_http_head_by_index(http_session_t* session, int index, char* name, char* value) +{ + int ret = {-1}; + if (NULL == _get_http_head_by_index) + _get_http_head_by_index = (_get_http_head_by_index_t)vm_get_sym_entry("get_http_head_by_index"); + + if (NULL != _get_http_head_by_index) + return _get_http_head_by_index(session,index,name,value); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/get_http_head_number.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/get_http_head_number.c new file mode 100644 index 00000000..82d513db --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/get_http_head_number.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_get_http_head_number_t)(http_session_t* session); +_get_http_head_number_t _get_http_head_number = NULL; + +int get_http_head_number(http_session_t* session) +{ + int ret = {-1}; + if (NULL == _get_http_head_number) + _get_http_head_number = (_get_http_head_number_t)vm_get_sym_entry("get_http_head_number"); + + if (NULL != _get_http_head_number) + return _get_http_head_number(session); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/get_today_from_2000.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/get_today_from_2000.c new file mode 100644 index 00000000..a065b5eb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/get_today_from_2000.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_get_today_from_2000_t)(void); +_get_today_from_2000_t _get_today_from_2000 = NULL; + +VMINT get_today_from_2000(void) +{ + if (NULL == _get_today_from_2000) + _get_today_from_2000 = (_get_today_from_2000_t)vm_get_sym_entry("get_today_from_2000"); + + if (NULL != _get_today_from_2000) + return _get_today_from_2000(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/rand.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/rand.c new file mode 100644 index 00000000..3f4a4856 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/rand.c @@ -0,0 +1,17 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int(*_rand_t)(void); + _rand_t _rand = NULL; +int rand(void) +{ + if (_rand == NULL) { + _rand = (_rand_t)vm_get_sym_entry("rand"); + } + if (_rand != NULL) { + return _rand(); + } + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/srand.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/srand.c new file mode 100644 index 00000000..19d1c354 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/srand.c @@ -0,0 +1,17 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int(*_srand_t)(unsigned int seed); + _srand_t _srand = NULL; +void srand(unsigned int seed) +{ + if (_srand == NULL) { + _srand = (_srand_t)vm_get_sym_entry("srand"); + } + if (_srand != NULL) { + _srand(seed); + } + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/strtoi.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/strtoi.c new file mode 100644 index 00000000..7ac6a2b0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/strtoi.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_strtoi_t)(char* s); +_strtoi_t _strtoi = NULL; + +int strtoi(char* s) +{ + int ret = {-1}; + if (NULL == _strtoi) + _strtoi = (_strtoi_t)vm_get_sym_entry("strtoi"); + + if (NULL != _strtoi) + return _strtoi(s); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm4res.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm4res.c new file mode 100644 index 00000000..4b68c51d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm4res.c @@ -0,0 +1,252 @@ +#include "vmsys.h" +#include "vm4res.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_res_init_t)(void); +_vm_res_init_t _vm_res_init = NULL; +VMINT32 vm_res_init(void) +{ + if (NULL == _vm_res_init) + _vm_res_init = (_vm_res_init_t)vm_get_sym_entry("vm_res_init"); + + if (NULL != _vm_res_init) + return _vm_res_init(); + + return (VMINT32 )-1; +} + +typedef VMINT32 (*_vm_res_init_with_language_t)(VMUINT32 language); +_vm_res_init_with_language_t _vm_res_init_with_language = NULL; +VMINT32 vm_res_init_with_language(VMUINT32 language) +{ + if (NULL == _vm_res_init_with_language) + _vm_res_init_with_language = (_vm_res_init_with_language_t)vm_get_sym_entry("vm_res_init_with_language"); + + if (NULL != _vm_res_init_with_language) + return _vm_res_init_with_language(language); + + return (VMINT32 )-1; +} + +typedef VMINT32 (*_vm_res_deinit_t)(void); +_vm_res_deinit_t _vm_res_deinit = NULL; +VMINT32 vm_res_deinit(void) +{ + if (NULL == _vm_res_deinit) + _vm_res_deinit = (_vm_res_deinit_t)vm_get_sym_entry("vm_res_deinit"); + + if (NULL != _vm_res_deinit) + return _vm_res_deinit(); + + return (VMINT32 )-1; +} + +typedef VMUINT8 * (*_vm_res_get_string_t)(VMUINT32 string_id); +_vm_res_get_string_t _vm_res_get_string = NULL; +VMUINT8 *vm_res_get_string(VMUINT32 string_id) +{ + if (NULL == _vm_res_get_string) + _vm_res_get_string = (_vm_res_get_string_t)vm_get_sym_entry("vm_res_get_string"); + + if (NULL != _vm_res_get_string) + return _vm_res_get_string(string_id); + + return NULL; +} + +typedef VMINT32 (*_vm_res_load_image_start_t)(void); +_vm_res_load_image_start_t _vm_res_load_image_start = NULL; +VMINT32 vm_res_load_image_start(void) +{ + if (NULL == _vm_res_load_image_start) + _vm_res_load_image_start = (_vm_res_load_image_start_t)vm_get_sym_entry("vm_res_load_image_start"); + + if (NULL != _vm_res_load_image_start) + return _vm_res_load_image_start(); + + return (VMINT32 )-1; +} + +typedef VMINT32 (*_vm_res_load_image_end_t)(void); +_vm_res_load_image_end_t _vm_res_load_image_end = NULL; +VMINT32 vm_res_load_image_end(void) +{ + if (NULL == _vm_res_load_image_end) + _vm_res_load_image_end = (_vm_res_load_image_end_t)vm_get_sym_entry("vm_res_load_image_end"); + + if (NULL != _vm_res_load_image_end) + return _vm_res_load_image_end(); + + return (VMINT32 )-1; +} + +typedef VMINT (*_vm_res_get_image_and_size_from_file_t)(VMWSTR filename, VMUINT32 image_id, void* buff, VMUINT32 *size); +_vm_res_get_image_and_size_from_file_t _vm_res_get_image_and_size_from_file = NULL; +VMINT vm_res_get_image_and_size_from_file(VMWSTR filename, VMUINT32 image_id, void* buff, VMUINT32 *size) +{ + if (NULL == _vm_res_get_image_and_size_from_file) + _vm_res_get_image_and_size_from_file = (_vm_res_get_image_and_size_from_file_t)vm_get_sym_entry("vm_res_get_image_and_size_from_file"); + + if (NULL != _vm_res_get_image_and_size_from_file) + return _vm_res_get_image_and_size_from_file(filename, image_id, buff, size); + + return (VMINT )-1; +} + +typedef VMINT (*_vm_res_get_audio_and_size_from_file_t)(VMWSTR filename, VMUINT32 audio_id, void* buff, VMUINT32 *size); +_vm_res_get_audio_and_size_from_file_t _vm_res_get_audio_and_size_from_file = NULL; +VMINT vm_res_get_audio_and_size_from_file(VMWSTR filename, VMUINT32 audio_id, void* buff, VMUINT32 *size) +{ + if (NULL == _vm_res_get_audio_and_size_from_file) + _vm_res_get_audio_and_size_from_file = (_vm_res_get_image_and_size_from_file_t)vm_get_sym_entry("vm_res_get_audio_and_size_from_file"); + + if (NULL != _vm_res_get_audio_and_size_from_file) + return _vm_res_get_audio_and_size_from_file(filename, audio_id, buff, size); + + return (VMINT )-1; +} + +typedef VMINT (*_vm_res_get_string_and_size_from_file_t)(VMWSTR filename, VMUINT32 string_id, void* buff, VMUINT32 *size); +_vm_res_get_string_and_size_from_file_t _vm_res_get_string_and_size_from_file = NULL; +VMINT vm_res_get_string_and_size_from_file(VMWSTR filename, VMUINT32 string_id, void* buff, VMUINT32 *size) +{ + if (NULL == _vm_res_get_string_and_size_from_file) + _vm_res_get_string_and_size_from_file = (_vm_res_get_string_and_size_from_file_t)vm_get_sym_entry("vm_res_get_string_and_size_from_file"); + + if (NULL != _vm_res_get_string_and_size_from_file) + return _vm_res_get_string_and_size_from_file(filename, string_id, buff, size); + + return (VMINT )-1; +} + +typedef VMINT (*_vm_res_get_image_and_size_from_rom_t)(VMWSTR filename, VMUINT32 image_id, void** buff, VMUINT32 *size); +_vm_res_get_image_and_size_from_rom_t _vm_res_get_image_and_size_from_rom = NULL; +VMINT vm_res_get_image_and_size_from_rom(VMWSTR filename, VMUINT32 image_id, void** buff, VMUINT32 *size) +{ + if (NULL == _vm_res_get_image_and_size_from_rom) + _vm_res_get_image_and_size_from_rom = (_vm_res_get_image_and_size_from_rom_t)vm_get_sym_entry("vm_res_get_image_and_size_from_rom"); + + if (NULL != _vm_res_get_image_and_size_from_rom) + return _vm_res_get_image_and_size_from_rom(filename, image_id, buff, size); + + return (VMINT )-1; +} + +typedef VMINT (*_vm_res_get_audio_and_size_from_rom_t)(VMWSTR filename, VMUINT32 audio_id, void** buff, VMUINT32 *size); +_vm_res_get_audio_and_size_from_rom_t _vm_res_get_audio_and_size_from_rom = NULL; +VMINT vm_res_get_audio_and_size_from_rom(VMWSTR filename, VMUINT32 audio_id, void** buff, VMUINT32 *size) +{ + if (NULL == _vm_res_get_audio_and_size_from_rom) + _vm_res_get_audio_and_size_from_rom = (_vm_res_get_audio_and_size_from_rom_t)vm_get_sym_entry("vm_res_get_audio_and_size_from_rom"); + + if (NULL != _vm_res_get_audio_and_size_from_rom) + return _vm_res_get_audio_and_size_from_rom(filename, audio_id, buff, size); + + return (VMINT )-1; +} + +typedef VMINT (*_vm_res_get_string_and_size_from_rom_t)(VMWSTR filename, VMUINT32 string_id, void** buff, VMUINT32 *size); +_vm_res_get_string_and_size_from_rom_t _vm_res_get_string_and_size_from_rom = NULL; +VMINT vm_res_get_string_and_size_from_rom(VMWSTR filename, VMUINT32 string_id, void** buff, VMUINT32 *size) +{ + if (NULL == _vm_res_get_string_and_size_from_rom) + _vm_res_get_string_and_size_from_rom = (_vm_res_get_string_and_size_from_rom_t)vm_get_sym_entry("vm_res_get_string_and_size_from_rom"); + + if (NULL != _vm_res_get_string_and_size_from_rom) + return _vm_res_get_string_and_size_from_rom(filename, string_id, buff, size); + + return (VMINT )-1; +} + +typedef VMUINT8 * (*_vm_res_get_image_and_size_t)(VMUINT32 image_id, VMUINT32 *size); +_vm_res_get_image_and_size_t _vm_res_get_image_and_size = NULL; +VMUINT8 *vm_res_get_image_and_size(VMUINT32 image_id, VMUINT32 *size) +{ + if (NULL == _vm_res_get_image_and_size) + _vm_res_get_image_and_size = (_vm_res_get_image_and_size_t)vm_get_sym_entry("vm_res_get_image_and_size"); + + if (NULL != _vm_res_get_image_and_size) + return _vm_res_get_image_and_size(image_id,size); + + return NULL; +} + +typedef VMUINT8 * (*_vm_res_get_image_t)(VMUINT32 image_id); +_vm_res_get_image_t _vm_res_get_image = NULL; +VMUINT8 *vm_res_get_image(VMUINT32 image_id) +{ + if (NULL == _vm_res_get_image) + _vm_res_get_image = (_vm_res_get_image_t)vm_get_sym_entry("vm_res_get_image"); + + if (NULL != _vm_res_get_image) + return _vm_res_get_image(image_id); + + return NULL; +} + +typedef VMUINT8 * (*_vm_res_get_image_with_header_t)(VMUINT32 image_id); +_vm_res_get_image_with_header_t _vm_res_get_image_with_header = NULL; +VMUINT8 *vm_res_get_image_with_header(VMUINT32 image_id) +{ + if (NULL == _vm_res_get_image_with_header) + _vm_res_get_image_with_header = (_vm_res_get_image_with_header_t)vm_get_sym_entry("vm_res_get_image_with_header"); + + if (NULL != _vm_res_get_image_with_header) + return _vm_res_get_image_with_header(image_id); + + return NULL; +} + +typedef VMUINT8 * (*_vm_res_get_image_and_size_with_header_t)(VMUINT32 image_id, VMUINT32 *size); +_vm_res_get_image_and_size_with_header_t _vm_res_get_image_and_size_with_header = NULL; +VMUINT8 *vm_res_get_image_and_size_with_header(VMUINT32 image_id, VMUINT32 *size) +{ + if (NULL == _vm_res_get_image_and_size_with_header) + _vm_res_get_image_and_size_with_header = (_vm_res_get_image_and_size_with_header_t)vm_get_sym_entry("vm_res_get_image_and_size_with_header"); + + if (NULL != _vm_res_get_image_and_size_with_header) + return _vm_res_get_image_and_size_with_header(image_id, size); + + return NULL; +} + +typedef VMUINT8 * (*_vm_res_get_audio_t)(VMUINT32 audio_id); +_vm_res_get_audio_t _vm_res_get_audio = NULL; +VMUINT8 *vm_res_get_audio(VMUINT32 audio_id) +{ + if (NULL == _vm_res_get_audio) + _vm_res_get_audio = (_vm_res_get_audio_t)vm_get_sym_entry("vm_res_get_audio"); + + if (NULL != _vm_res_get_audio) + return _vm_res_get_audio(audio_id); + + return NULL; +} + +typedef VMINT32 (*_vm_res_delete_t)(VMUINT32 id); +_vm_res_delete_t _vm_res_delete = NULL; +VMINT32 vm_res_delete(VMUINT32 id) +{ + if (NULL == _vm_res_delete) + _vm_res_delete = (_vm_res_delete_t)vm_get_sym_entry("vm_res_delete"); + + if (NULL != _vm_res_delete) + return _vm_res_delete(id); + + return (VMINT32 )-1; +} + +typedef VMUINT8 * (*_vm_res_get_virtual_image_t)(VMUINT32 image_id); +_vm_res_get_virtual_image_t _vm_res_get_virtual_image = NULL; +VMUINT8 *vm_res_get_virtual_image(VMUINT32 image_id) +{ + if (NULL == _vm_res_get_virtual_image) + _vm_res_get_virtual_image = (_vm_res_get_virtual_image_t)vm_get_sym_entry("vm_res_get_virtual_image"); + + if (NULL != _vm_res_get_virtual_image) + return _vm_res_get_virtual_image(image_id); + + return NULL; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_accept.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_accept.c new file mode 100644 index 00000000..058bdaae --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_accept.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_accept_t)(int sock, SOCKADDR *addr, int *addrlen); +_vm_accept_t _vm_accept = NULL; + +int vm_accept(int sock, SOCKADDR *addr, int *addrlen) +{ + if (NULL == _vm_accept) + _vm_accept = (_vm_accept_t)vm_get_sym_entry("vm_accept"); + if (NULL != _vm_accept) + return _vm_accept(sock,addr,addrlen); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_app_log.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_app_log.c new file mode 100644 index 00000000..06d05ba0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_app_log.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_app_log_t)(char* info); +_vm_app_log_t _vm_app_log = NULL; +void vm_app_log(char* info) +{ + if (_vm_app_log == NULL) + _vm_app_log = (_vm_app_log_t)vm_get_sym_entry("vm_app_log"); + + if (_vm_app_log != NULL) + _vm_app_log(info); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_dereg_msg_proc.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_dereg_msg_proc.c new file mode 100644 index 00000000..2d10c4d9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_dereg_msg_proc.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmappcomm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_appcomm_dereg_msg_proc_t)(VMINT handle, VM_MESSAGE_PROC proc); +_vm_appcomm_dereg_msg_proc_t _vm_appcomm_dereg_msg_proc = NULL; + +VMINT vm_appcomm_dereg_msg_proc(VMINT handle, VM_MESSAGE_PROC proc) +{ + if (NULL == _vm_appcomm_dereg_msg_proc) + _vm_appcomm_dereg_msg_proc = (_vm_appcomm_dereg_msg_proc_t)vm_get_sym_entry("vm_appcomm_dereg_msg_proc"); + + if (NULL != _vm_appcomm_dereg_msg_proc) + return _vm_appcomm_dereg_msg_proc(handle,proc); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_dispatch_msg.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_dispatch_msg.c new file mode 100644 index 00000000..6ebbbafd --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_dispatch_msg.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmappcomm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_appcomm_dispatch_msg_t)(void); +_vm_appcomm_dispatch_msg_t _vm_appcomm_dispatch_msg = NULL; + +void vm_appcomm_dispatch_msg(void) +{ + if (NULL == _vm_appcomm_dispatch_msg) + _vm_appcomm_dispatch_msg = (_vm_appcomm_dispatch_msg_t)vm_get_sym_entry("vm_appcomm_dispatch_msg"); + + if (NULL != _vm_appcomm_dispatch_msg) + _vm_appcomm_dispatch_msg(); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_init.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_init.c new file mode 100644 index 00000000..02c518eb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_init.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmappcomm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_appcomm_init_t)(void); +_vm_appcomm_init_t _vm_appcomm_init = NULL; + +void vm_appcomm_init(void) +{ + if (NULL == _vm_appcomm_init) + _vm_appcomm_init = (_vm_appcomm_init_t)vm_get_sym_entry("vm_appcomm_init"); + + if (NULL != _vm_appcomm_init) + _vm_appcomm_init(); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_post_msg.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_post_msg.c new file mode 100644 index 00000000..2f4dd172 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_post_msg.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmappcomm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_appcomm_post_msg_t)(VMINT handle, VMUINT msg_id, VMINT wparam, VMINT lparam); +_vm_appcomm_post_msg_t _vm_appcomm_post_msg = NULL; + +VMINT vm_appcomm_post_msg(VMINT handle, VMUINT msg_id, VMINT wparam, VMINT lparam) +{ + if (NULL == _vm_appcomm_post_msg) + _vm_appcomm_post_msg = (_vm_appcomm_post_msg_t)vm_get_sym_entry("vm_appcomm_post_msg"); + + if (NULL != _vm_appcomm_post_msg) + return _vm_appcomm_post_msg(handle,msg_id,wparam,lparam); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_reg_msg_proc.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_reg_msg_proc.c new file mode 100644 index 00000000..3c46e413 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_reg_msg_proc.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmappcomm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_appcomm_reg_msg_proc_t)(VMINT handle, VM_MESSAGE_PROC proc); +_vm_appcomm_reg_msg_proc_t _vm_appcomm_reg_msg_proc = NULL; + +VMINT vm_appcomm_reg_msg_proc(VMINT handle, VM_MESSAGE_PROC proc) +{ + if (NULL == _vm_appcomm_reg_msg_proc) + _vm_appcomm_reg_msg_proc = (_vm_appcomm_reg_msg_proc_t)vm_get_sym_entry("vm_appcomm_reg_msg_proc"); + + if (NULL != _vm_appcomm_reg_msg_proc) + return _vm_appcomm_reg_msg_proc(handle,proc); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_send_msg.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_send_msg.c new file mode 100644 index 00000000..cdac05eb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_appcomm_send_msg.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmappcomm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_appcomm_send_msg_t)(VMINT handle, VMUINT msg_id, VMINT wparam, VMINT lparam); +_vm_appcomm_send_msg_t _vm_appcomm_send_msg = NULL; + +VMINT vm_appcomm_send_msg(VMINT handle, VMUINT msg_id, VMINT wparam, VMINT lparam) +{ + if (NULL == _vm_appcomm_send_msg) + _vm_appcomm_send_msg = (_vm_appcomm_send_msg_t)vm_get_sym_entry("vm_appcomm_send_msg"); + + if (NULL != _vm_appcomm_send_msg) + return _vm_appcomm_send_msg(handle,msg_id,wparam,lparam); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ascii_to_ucs2.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ascii_to_ucs2.c new file mode 100644 index 00000000..b1abb802 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ascii_to_ucs2.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmchset.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ascii_to_ucs2_t)(VMWSTR dst, VMINT size, VMSTR src); +_vm_ascii_to_ucs2_t _vm_ascii_to_ucs2 = NULL; + +VMINT vm_ascii_to_ucs2(VMWSTR dst, VMINT size, VMSTR src) +{ + if (NULL == _vm_ascii_to_ucs2) + _vm_ascii_to_ucs2 = (_vm_ascii_to_ucs2_t)vm_get_sym_entry("vm_ascii_to_ucs2"); + + if (NULL != _vm_ascii_to_ucs2) + return _vm_ascii_to_ucs2(dst,size,src); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_assert.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_assert.c new file mode 100644 index 00000000..03b1270c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_assert.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmwdt.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_assert_t)(VMSTR file, VMINT line); +_vm_assert_t _vm_assert = NULL; + +void vm_assert(VMSTR file, VMINT line) +{ + if (NULL == _vm_assert) + _vm_assert = (_vm_assert_t)vm_get_sym_entry("vm_assert"); + + if (NULL != _vm_assert) + _vm_assert(file,line); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_asyn_http_req.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_asyn_http_req.c new file mode 100644 index 00000000..d51aa349 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_asyn_http_req.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_asyn_http_req_t)(asyn_http_req_t *request, void (*http_hook)(VMINT, void*), void (*http_state_notify)(VMINT state, VMINT param, void* session)); +_vm_asyn_http_req_t _vm_asyn_http_req = NULL; + +VMINT vm_asyn_http_req(asyn_http_req_t *request, void (*http_hook)(VMINT, void*), void (*http_state_notify)(VMINT state, VMINT param, void* session)) +{ + if (NULL == _vm_asyn_http_req) + _vm_asyn_http_req = (_vm_asyn_http_req_t)vm_get_sym_entry("vm_asyn_http_req"); + + if (NULL != _vm_asyn_http_req) + return _vm_asyn_http_req(request,http_hook,http_state_notify); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_atof.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_atof.c new file mode 100644 index 00000000..7426e065 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_atof.c @@ -0,0 +1,17 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef double(*_atof_t)(const char * nptr); + _atof_t _atof = NULL; +double vm_atof(const char * nptr) +{ + if (_atof == NULL) { + _atof = (_atof_t)vm_get_sym_entry("atof"); + } + if (_atof != NULL) { + return _atof(nptr); + } + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_bytes_duration.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_bytes_duration.c new file mode 100644 index 00000000..a5c1db90 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_bytes_duration.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_bytes_duration_t)(void *audio_data, VMUINT len, VMUINT8 format); +_vm_audio_bytes_duration_t _vm_audio_bytes_duration = NULL; + +VMINT vm_audio_bytes_duration(void *audio_data, VMUINT len, VMUINT8 format) +{ + if (NULL == _vm_audio_bytes_duration) + _vm_audio_bytes_duration = (_vm_audio_bytes_duration_t)vm_get_sym_entry("vm_audio_bytes_duration"); + + if (NULL != _vm_audio_bytes_duration) + return _vm_audio_bytes_duration(audio_data,len,format); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_clear_interrupt_callback.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_clear_interrupt_callback.c new file mode 100644 index 00000000..e5bd6454 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_clear_interrupt_callback.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_audio_clear_interrupt_callback_t)(VMINT handle); +_vm_audio_clear_interrupt_callback_t _vm_audio_clear_interrupt_callback = NULL; + +void vm_audio_clear_interrupt_callback(VMINT handle) +{ + if (NULL == _vm_audio_clear_interrupt_callback) + _vm_audio_clear_interrupt_callback = (_vm_audio_clear_interrupt_callback_t)vm_get_sym_entry("vm_audio_clear_interrupt_callback"); + + if (NULL != _vm_audio_clear_interrupt_callback) + _vm_audio_clear_interrupt_callback(handle); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_duration.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_duration.c new file mode 100644 index 00000000..86ee42c7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_duration.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_duration_t)(VMWSTR filename); +_vm_audio_duration_t _vm_audio_duration = NULL; + +VMINT vm_audio_duration(VMWSTR filename) +{ + if (NULL == _vm_audio_duration) + _vm_audio_duration = (_vm_audio_duration_t)vm_get_sym_entry("vm_audio_duration"); + + if (NULL != _vm_audio_duration) + return _vm_audio_duration(filename); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_get_time.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_get_time.c new file mode 100644 index 00000000..8945df4f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_get_time.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_get_time_t)(void); +_vm_audio_get_time_t _vm_audio_get_time = NULL; + +VMINT vm_audio_get_time(void) +{ + if (NULL == _vm_audio_get_time) + _vm_audio_get_time = (_vm_audio_get_time_t)vm_get_sym_entry("vm_audio_get_time"); + + if (NULL != _vm_audio_get_time) + return _vm_audio_get_time(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_is_app_playing.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_is_app_playing.c new file mode 100644 index 00000000..40e03cff --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_is_app_playing.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMBOOL (*_vm_audio_is_app_playing_t)(void); +_vm_audio_is_app_playing_t _vm_audio_is_app_playing = NULL; + +VMBOOL vm_audio_is_app_playing(void) +{ + if (NULL == _vm_audio_is_app_playing) + _vm_audio_is_app_playing = (_vm_audio_is_app_playing_t)vm_get_sym_entry("vm_audio_is_app_playing"); + + if (NULL != _vm_audio_is_app_playing) + return _vm_audio_is_app_playing(); + + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_is_calling.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_is_calling.c new file mode 100644 index 00000000..7f6d3a3d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_is_calling.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_is_calling_t)(void); +_vm_audio_is_calling_t _vm_audio_is_calling = NULL; + +VMINT vm_audio_is_calling(void) +{ + if (NULL == _vm_audio_is_calling) + _vm_audio_is_calling = (_vm_audio_is_calling_t)vm_get_sym_entry("vm_audio_is_calling"); + + if (NULL != _vm_audio_is_calling) + return _vm_audio_is_calling(); + + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_close.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_close.c new file mode 100644 index 00000000..7623a442 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_close.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_audio_mixed_close_t)(VMINT handle); +_vm_audio_mixed_close_t _vm_audio_mixed_close = NULL; + +void vm_audio_mixed_close(VMINT handle) +{ + if (NULL == _vm_audio_mixed_close) + _vm_audio_mixed_close = (_vm_audio_mixed_close_t)vm_get_sym_entry("vm_audio_mixed_close"); + + if (NULL != _vm_audio_mixed_close) + _vm_audio_mixed_close(handle); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_close_all.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_close_all.c new file mode 100644 index 00000000..5474f9fc --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_close_all.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_audio_mixed_close_all_t)(void); +_vm_audio_mixed_close_all_t _vm_audio_mixed_close_all = NULL; + +void vm_audio_mixed_close_all(void) +{ + if (NULL == _vm_audio_mixed_close_all) + _vm_audio_mixed_close_all = (_vm_audio_mixed_close_all_t)vm_get_sym_entry("vm_audio_mixed_close_all"); + + if (NULL != _vm_audio_mixed_close_all) + _vm_audio_mixed_close_all(); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_get_time.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_get_time.c new file mode 100644 index 00000000..6566fbda --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_get_time.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_mixed_get_time_t)(VMINT handle, VMUINT *current_time); +_vm_audio_mixed_get_time_t _vm_audio_mixed_get_time = NULL; + +VMINT vm_audio_mixed_get_time(VMINT handle, VMUINT *current_time) +{ + if (NULL == _vm_audio_mixed_get_time) + _vm_audio_mixed_get_time = (_vm_audio_mixed_get_time_t)vm_get_sym_entry("vm_audio_mixed_get_time"); + + if (NULL != _vm_audio_mixed_get_time) + return _vm_audio_mixed_get_time(handle,current_time); + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_open.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_open.c new file mode 100644 index 00000000..75aca2f8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_open.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_mixed_open_t)(vm_auido_mixed_open_struct* mixed_play); +_vm_audio_mixed_open_t _vm_audio_mixed_open = NULL; + +VMINT vm_audio_mixed_open(vm_auido_mixed_open_struct* mixed_open) +{ + if (NULL == _vm_audio_mixed_open) + _vm_audio_mixed_open = (_vm_audio_mixed_open_t)vm_get_sym_entry("vm_audio_mixed_open"); + + if (NULL != _vm_audio_mixed_open) + return _vm_audio_mixed_open(mixed_open); + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_pause.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_pause.c new file mode 100644 index 00000000..168dfb6e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_pause.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_mixed_pause_t)(VMINT handle); +_vm_audio_mixed_pause_t _vm_audio_mixed_pause = NULL; + +VMINT vm_audio_mixed_pause(VMINT handle) +{ + if (NULL == _vm_audio_mixed_pause) + _vm_audio_mixed_pause = (_vm_audio_mixed_pause_t)vm_get_sym_entry("vm_audio_mixed_pause"); + + if (NULL != _vm_audio_mixed_pause) + return _vm_audio_mixed_pause(handle); + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_play.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_play.c new file mode 100644 index 00000000..27e5cfb0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_play.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_mixed_play_t)(VMINT handle); +_vm_audio_mixed_play_t _vm_audio_mixed_play = NULL; + +VMINT vm_audio_mixed_play(VMINT handle) +{ + if (NULL == _vm_audio_mixed_play) + _vm_audio_mixed_play = (_vm_audio_mixed_play_t)vm_get_sym_entry("vm_audio_mixed_play"); + + if (NULL != _vm_audio_mixed_play) + return _vm_audio_mixed_play(handle); + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_resume.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_resume.c new file mode 100644 index 00000000..152516be --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_resume.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_mixed_resume_t)(VMINT handle); +_vm_audio_mixed_resume_t _vm_audio_mixed_resume = NULL; + +VMINT vm_audio_mixed_resume(VMINT handle) +{ + if (NULL == _vm_audio_mixed_resume) + _vm_audio_mixed_resume = (_vm_audio_mixed_resume_t)vm_get_sym_entry("vm_audio_mixed_resume"); + + if (NULL != _vm_audio_mixed_resume) + return _vm_audio_mixed_resume(handle); + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_set_speedup_mode.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_set_speedup_mode.c new file mode 100644 index 00000000..517e49b8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_set_speedup_mode.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_audio_mixed_set_speedup_mode_t)(VMBOOL mode); +_vm_audio_mixed_set_speedup_mode_t _vm_audio_mixed_set_speedup_mode = NULL; + +void vm_audio_mixed_set_speedup_mode(VMBOOL mode) +{ + if (NULL == _vm_audio_mixed_set_speedup_mode) + _vm_audio_mixed_set_speedup_mode = (_vm_audio_mixed_set_speedup_mode_t)vm_get_sym_entry("vm_audio_mixed_set_speedup_mode"); + + if (NULL != _vm_audio_mixed_set_speedup_mode) + _vm_audio_mixed_set_speedup_mode(mode); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_set_start_time.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_set_start_time.c new file mode 100644 index 00000000..903157c3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_set_start_time.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_mixed_set_start_time_t)(VMINT handle, VMUINT start_time); +_vm_audio_mixed_set_start_time_t _vm_audio_mixed_set_start_time = NULL; + +VMINT vm_audio_mixed_set_start_time(VMINT handle, VMUINT start_time) +{ + if (NULL == _vm_audio_mixed_set_start_time) + _vm_audio_mixed_set_start_time = (_vm_audio_mixed_set_start_time_t)vm_get_sym_entry("vm_audio_mixed_set_start_time"); + + if (NULL != _vm_audio_mixed_set_start_time) + return _vm_audio_mixed_set_start_time(handle,start_time); + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_stop.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_stop.c new file mode 100644 index 00000000..2235607a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_mixed_stop.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_audio_mixed_stop_t)(VMINT handle); +_vm_audio_mixed_stop_t _vm_audio_mixed_stop = NULL; + +void vm_audio_mixed_stop(VMINT handle) +{ + if (NULL == _vm_audio_mixed_stop) + _vm_audio_mixed_stop = (_vm_audio_mixed_stop_t)vm_get_sym_entry("vm_audio_mixed_stop"); + + if (NULL != _vm_audio_mixed_stop) + _vm_audio_mixed_stop(handle); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_pause.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_pause.c new file mode 100644 index 00000000..a3a0d8f3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_pause.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_pause_t)(void (*f)(VMINT result)); +_vm_audio_pause_t _vm_audio_pause = NULL; + +VMINT vm_audio_pause(void (*f)(VMINT result)) +{ + if (NULL == _vm_audio_pause) + _vm_audio_pause = (_vm_audio_pause_t)vm_get_sym_entry("vm_audio_pause"); + + if (NULL != _vm_audio_pause) + return _vm_audio_pause(f); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_pitch_shifting_set_level.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_pitch_shifting_set_level.c new file mode 100644 index 00000000..133caf23 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_pitch_shifting_set_level.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_pitch_shifting_set_level_t)(VMINT16 level); +_vm_audio_pitch_shifting_set_level_t _vm_audio_pitch_shifting_set_level = NULL; + +VMINT vm_audio_pitch_shifting_set_level(VMINT16 level) +{ + if (NULL == _vm_audio_pitch_shifting_set_level) + _vm_audio_pitch_shifting_set_level = (_vm_audio_pitch_shifting_set_level_t)vm_get_sym_entry("vm_audio_pitch_shifting_set_level"); + + if (NULL != _vm_audio_pitch_shifting_set_level) + return _vm_audio_pitch_shifting_set_level(level); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_pitch_shifting_turn_off.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_pitch_shifting_turn_off.c new file mode 100644 index 00000000..e4fcb926 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_pitch_shifting_turn_off.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_pitch_shifting_turn_off_t)(void); +_vm_audio_pitch_shifting_turn_off_t _vm_audio_pitch_shifting_turn_off = NULL; + +VMINT vm_audio_pitch_shifting_turn_off(void) +{ + if (NULL == _vm_audio_pitch_shifting_turn_off) + _vm_audio_pitch_shifting_turn_off = (_vm_audio_pitch_shifting_turn_off_t)vm_get_sym_entry("vm_audio_pitch_shifting_turn_off"); + + if (NULL != _vm_audio_pitch_shifting_turn_off) + return _vm_audio_pitch_shifting_turn_off(); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_pitch_shifting_turn_on.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_pitch_shifting_turn_on.c new file mode 100644 index 00000000..d908d096 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_pitch_shifting_turn_on.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_pitch_shifting_turn_on_t)(void); +_vm_audio_pitch_shifting_turn_on_t _vm_audio_pitch_shifting_turn_on = NULL; + +VMINT vm_audio_pitch_shifting_turn_on(void) +{ + if (NULL == _vm_audio_pitch_shifting_turn_on) + _vm_audio_pitch_shifting_turn_on = (_vm_audio_pitch_shifting_turn_on_t)vm_get_sym_entry("vm_audio_pitch_shifting_turn_on"); + + if (NULL != _vm_audio_pitch_shifting_turn_on) + return _vm_audio_pitch_shifting_turn_on(); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_beep.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_beep.c new file mode 100644 index 00000000..7dc81ef3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_beep.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_audio_play_beep_t)(void); +_vm_audio_play_beep_t _vm_audio_play_beep = NULL; + +void vm_audio_play_beep(void) +{ + if (NULL == _vm_audio_play_beep) + _vm_audio_play_beep = (_vm_audio_play_beep_t)vm_get_sym_entry("vm_audio_play_beep"); + + if (NULL != _vm_audio_play_beep) + _vm_audio_play_beep(); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_bytes.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_bytes.c new file mode 100644 index 00000000..73a4fc06 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_bytes.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_play_bytes_t)(void *audio_data, VMUINT len, VMUINT8 format, VMUINT start_time, VMUINT path, void (*f)(VMINT result)); +_vm_audio_play_bytes_t _vm_audio_play_bytes = NULL; + +VMINT vm_audio_play_bytes(void *audio_data, VMUINT len, VMUINT8 format, VMUINT start_time, VMUINT path, void (*f)(VMINT result)) +{ + if (NULL == _vm_audio_play_bytes) + _vm_audio_play_bytes = (_vm_audio_play_bytes_t)vm_get_sym_entry("vm_audio_play_bytes"); + + if (NULL != _vm_audio_play_bytes) + return _vm_audio_play_bytes(audio_data,len,format,start_time,path,f); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_bytes_no_block.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_bytes_no_block.c new file mode 100644 index 00000000..09dcba7b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_bytes_no_block.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_play_bytes_no_block_t)(void *audio_data, VMUINT len, VMUINT8 format, VMUINT path, void (*f)(VMINT result)); +_vm_audio_play_bytes_no_block_t _vm_audio_play_bytes_no_block = NULL; + +VMINT vm_audio_play_bytes_no_block(void *audio_data, VMUINT len, VMUINT8 format, VMUINT path, void (*f)(VMINT result)) +{ + if (NULL == _vm_audio_play_bytes_no_block) + _vm_audio_play_bytes_no_block = (_vm_audio_play_bytes_no_block_t)vm_get_sym_entry("vm_audio_play_bytes_no_block"); + + if (NULL != _vm_audio_play_bytes_no_block) + return _vm_audio_play_bytes_no_block(audio_data, len, format, path, f); + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_file.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_file.c new file mode 100644 index 00000000..3668cb6f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_file.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_play_file_t)(VMWSTR filename, void (*f)(VMINT result)); +_vm_audio_play_file_t _vm_audio_play_file = NULL; + +VMINT vm_audio_play_file(VMWSTR filename, void (*f)(VMINT result)) +{ + if (NULL == _vm_audio_play_file) + _vm_audio_play_file = (_vm_audio_play_file_t)vm_get_sym_entry("vm_audio_play_file"); + + if (NULL != _vm_audio_play_file) + return _vm_audio_play_file(filename,f); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_file_ex.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_file_ex.c new file mode 100644 index 00000000..a88e11fd --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_play_file_ex.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_play_file_ex_t)(VMWSTR filename, VMUINT start_time, VMUINT path, void (*f)(VMINT result)); +_vm_audio_play_file_ex_t _vm_audio_play_file_ex = NULL; + +VMINT vm_audio_play_file_ex(VMWSTR filename, VMUINT start_time, VMUINT path, void (*f)(VMINT result)) +{ + if (NULL == _vm_audio_play_file_ex) + _vm_audio_play_file_ex = (_vm_audio_play_file_ex_t)vm_get_sym_entry("vm_audio_play_file_ex"); + + if (NULL != _vm_audio_play_file_ex) + return _vm_audio_play_file_ex(filename,start_time,path,f); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_register_interrupt_callback.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_register_interrupt_callback.c new file mode 100644 index 00000000..bb673997 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_register_interrupt_callback.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_register_interrupt_callback_t)(vm_audio_result_callback callback); +_vm_audio_register_interrupt_callback_t _vm_audio_register_interrupt_callback = NULL; + +VMINT vm_audio_register_interrupt_callback(vm_audio_result_callback callback) +{ + if (NULL == _vm_audio_register_interrupt_callback) + _vm_audio_register_interrupt_callback = (_vm_audio_register_interrupt_callback_t)vm_get_sym_entry("vm_audio_register_interrupt_callback"); + + if (NULL != _vm_audio_register_interrupt_callback) + return _vm_audio_register_interrupt_callback(callback); + + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_resume.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_resume.c new file mode 100644 index 00000000..ec6d3aa4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_resume.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_resume_t)(void (*f)(VMINT result)); +_vm_audio_resume_t _vm_audio_resume = NULL; + +VMINT vm_audio_resume(void (*f)(VMINT result)) +{ + if (NULL == _vm_audio_resume) + _vm_audio_resume = (_vm_audio_resume_t)vm_get_sym_entry("vm_audio_resume"); + + if (NULL != _vm_audio_resume) + return _vm_audio_resume(f); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_resume_bg_play.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_resume_bg_play.c new file mode 100644 index 00000000..bfca2be4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_resume_bg_play.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_audio_resume_bg_play_t)(void); +_vm_audio_resume_bg_play_t _vm_audio_resume_bg_play = NULL; + +void vm_audio_resume_bg_play(void) +{ + if (NULL == _vm_audio_resume_bg_play) + _vm_audio_resume_bg_play = (_vm_audio_resume_bg_play_t)vm_get_sym_entry("vm_audio_resume_bg_play"); + + if (NULL != _vm_audio_resume_bg_play) + _vm_audio_resume_bg_play(); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_set_volume_type.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_set_volume_type.c new file mode 100644 index 00000000..c6d13fde --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_set_volume_type.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_set_volume_type_t)(VMINT type); +_vm_audio_set_volume_type_t _vm_audio_set_volume_type = NULL; + +VMINT vm_audio_set_volume_type(VMINT type) +{ + if (NULL == _vm_audio_set_volume_type) + _vm_audio_set_volume_type = (_vm_audio_set_volume_type_t)vm_get_sym_entry("vm_audio_set_volume_type"); + + if (NULL != _vm_audio_set_volume_type) + return _vm_audio_set_volume_type(type); + + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_stop.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_stop.c new file mode 100644 index 00000000..5a4592b8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_stop.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_stop_t)(void (*f)(VMINT result)); +_vm_audio_stop_t _vm_audio_stop = NULL; + +VMINT vm_audio_stop(void (*f)(VMINT result)) +{ + if (NULL == _vm_audio_stop) + _vm_audio_stop = (_vm_audio_stop_t)vm_get_sym_entry("vm_audio_stop"); + + if (NULL != _vm_audio_stop) + return _vm_audio_stop(f); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_stop_all.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_stop_all.c new file mode 100644 index 00000000..c75b0c37 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_stop_all.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_stop_all_t)(void); +_vm_audio_stop_all_t _vm_audio_stop_all = NULL; + +VMINT vm_audio_stop_all(void) +{ + if (NULL == _vm_audio_stop_all) + _vm_audio_stop_all = (_vm_audio_stop_all_t)vm_get_sym_entry("vm_audio_stop_all"); + + if (NULL != _vm_audio_stop_all) + return _vm_audio_stop_all(); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_suspend_bg_play.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_suspend_bg_play.c new file mode 100644 index 00000000..00a47156 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_suspend_bg_play.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_audio_suspend_bg_play_t)(void); +_vm_audio_suspend_bg_play_t _vm_audio_suspend_bg_play = NULL; + +void vm_audio_suspend_bg_play(void) +{ + if (NULL == _vm_audio_suspend_bg_play) + _vm_audio_suspend_bg_play = (_vm_audio_suspend_bg_play_t)vm_get_sym_entry("vm_audio_suspend_bg_play"); + + if (NULL != _vm_audio_suspend_bg_play) + _vm_audio_suspend_bg_play(); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_terminate_background_play.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_terminate_background_play.c new file mode 100644 index 00000000..f0bbe1b9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_terminate_background_play.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_audio_terminate_background_play_t)(void); +_vm_audio_terminate_background_play_t _vm_audio_terminate_background_play = NULL; + +void vm_audio_terminate_background_play(void) +{ + if (NULL == _vm_audio_terminate_background_play) + _vm_audio_terminate_background_play = (_vm_audio_terminate_background_play_t)vm_get_sym_entry("vm_audio_terminate_background_play"); + + if (NULL != _vm_audio_terminate_background_play) + _vm_audio_terminate_background_play(); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_vocal_removal_turn_off.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_vocal_removal_turn_off.c new file mode 100644 index 00000000..3cdca67b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_vocal_removal_turn_off.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_vocal_removal_turn_off_t)(void); +_vm_audio_vocal_removal_turn_off_t _vm_audio_vocal_removal_turn_off = NULL; + +VMINT vm_audio_vocal_removal_turn_off(void) +{ + if (NULL == _vm_audio_vocal_removal_turn_off) + _vm_audio_vocal_removal_turn_off = (_vm_audio_vocal_removal_turn_off_t)vm_get_sym_entry("vm_audio_vocal_removal_turn_off"); + + if (NULL != _vm_audio_vocal_removal_turn_off) + return _vm_audio_vocal_removal_turn_off(); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_vocal_removal_turn_on.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_vocal_removal_turn_on.c new file mode 100644 index 00000000..ab41165d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_audio_vocal_removal_turn_on.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_audio_vocal_removal_turn_on_t)(void); +_vm_audio_vocal_removal_turn_on_t _vm_audio_vocal_removal_turn_on = NULL; + +VMINT vm_audio_vocal_removal_turn_on(void) +{ + if (NULL == _vm_audio_vocal_removal_turn_on) + _vm_audio_vocal_removal_turn_on = (_vm_audio_vocal_removal_turn_on_t)vm_get_sym_entry("vm_audio_vocal_removal_turn_on"); + + if (NULL != _vm_audio_vocal_removal_turn_on) + return _vm_audio_vocal_removal_turn_on(); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_decode_basic.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_decode_basic.c new file mode 100644 index 00000000..a8e7f401 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_decode_basic.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmbase64.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_base64_decode_basic_t)(const VMCHAR *src, VMINT32 srcl,VMCHAR *dst,VMINT32 dstl); +_vm_base64_decode_basic_t _vm_base64_decode_basic = NULL; + +VMINT32 vm_base64_decode_basic(const VMCHAR *src, VMINT32 srcl,VMCHAR *dst,VMINT32 dstl) +{ + if (NULL == _vm_base64_decode_basic) + _vm_base64_decode_basic = (_vm_base64_decode_basic_t)vm_get_sym_entry("vm_base64_decode_basic"); + + if (NULL != _vm_base64_decode_basic) + return _vm_base64_decode_basic(src, srcl, dst, dstl); + else + return -255; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_encode_basic.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_encode_basic.c new file mode 100644 index 00000000..5e0e9bc5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_encode_basic.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmbase64.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_base64_encode_basic_t)(const VMCHAR *src, VMINT32 srcl, VMCHAR *dst,VMINT32 dstl,VMBOOL auto_line_wrap); +_vm_base64_encode_basic_t _vm_base64_encode_basic = NULL; + +VMINT32 vm_base64_encode_basic(const VMCHAR *src, VMINT32 srcl, VMCHAR *dst,VMINT32 dstl,VMBOOL auto_line_wrap) +{ + if (NULL == _vm_base64_encode_basic) + _vm_base64_encode_basic = (_vm_base64_encode_basic_t)vm_get_sym_entry("vm_base64_encode_basic"); + + if (NULL != _vm_base64_encode_basic) + return _vm_base64_encode_basic(src, srcl, dst, dstl, auto_line_wrap); + else + return -255; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_decode_append.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_decode_append.c new file mode 100644 index 00000000..97f8fe7d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_decode_append.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmbase64.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_base64_part_decode_append_t)(vm_base64_part_context* cntx,const VMCHAR *src, VMINT32 *srcl,VMCHAR *dst,VMINT32 dstl); +_vm_base64_part_decode_append_t _vm_base64_part_decode_append = NULL; + +VMINT32 vm_base64_part_decode_append(vm_base64_part_context* cntx,const VMCHAR *src, VMINT32 *srcl,VMCHAR *dst,VMINT32 dstl) +{ + if (NULL == _vm_base64_part_decode_append) + _vm_base64_part_decode_append = (_vm_base64_part_decode_append_t)vm_get_sym_entry("vm_base64_part_decode_append"); + + if (NULL != _vm_base64_part_decode_append) + return _vm_base64_part_decode_append(cntx, src, srcl, dst, dstl); + else + return -255; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_decode_finish.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_decode_finish.c new file mode 100644 index 00000000..f8fbf151 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_decode_finish.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmbase64.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_base64_part_decode_finish_t)(vm_base64_part_context* cntx,VMBOOL* illegal_format); +_vm_base64_part_decode_finish_t _vm_base64_part_decode_finish = NULL; + +VMINT32 vm_base64_part_decode_finish(vm_base64_part_context* cntx,VMBOOL* illegal_format) +{ + if (NULL == _vm_base64_part_decode_finish) + _vm_base64_part_decode_finish = (_vm_base64_part_decode_finish_t)vm_get_sym_entry("vm_base64_part_decode_finish"); + + if (NULL != _vm_base64_part_decode_finish) + return _vm_base64_part_decode_finish(cntx, illegal_format); + else + return -255; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_decode_init.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_decode_init.c new file mode 100644 index 00000000..70581b10 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_decode_init.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmbase64.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_base64_part_decode_init_t)(vm_base64_part_context *cntx, VMINT32 max_part_buf_size); +_vm_base64_part_decode_init_t _vm_base64_part_decode_init = NULL; + +VMINT32 vm_base64_part_decode_init( vm_base64_part_context *cntx, VMINT32 max_part_buf_size) +{ + if (NULL == _vm_base64_part_decode_init) + _vm_base64_part_decode_init = (_vm_base64_part_decode_init_t)vm_get_sym_entry("vm_base64_part_decode_init"); + + if (NULL != _vm_base64_part_decode_init) + return _vm_base64_part_decode_init(cntx, max_part_buf_size); + else + return -255; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_encode_append.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_encode_append.c new file mode 100644 index 00000000..b5f1db5e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_encode_append.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmbase64.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_base64_part_encode_append_t)(vm_base64_part_context *cntx,const VMCHAR *src,VMINT32 *srcl,VMCHAR *dst,VMINT32 dstl); +_vm_base64_part_encode_append_t _vm_base64_part_encode_append = NULL; + +VMINT32 vm_base64_part_encode_append(vm_base64_part_context *cntx,const VMCHAR *src,VMINT32 *srcl,VMCHAR *dst,VMINT32 dstl) +{ + if (NULL == _vm_base64_part_encode_append) + _vm_base64_part_encode_append = (_vm_base64_part_encode_append_t)vm_get_sym_entry("vm_base64_part_encode_append"); + + if (NULL != _vm_base64_part_encode_append) + return _vm_base64_part_encode_append(cntx, src, srcl, dst, dstl); + else + return -255; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_encode_finish.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_encode_finish.c new file mode 100644 index 00000000..ecc19685 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_encode_finish.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmbase64.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_base64_part_encode_finish_t)(vm_base64_part_context* cntx,VMCHAR *dst,VMINT32 dstl); +_vm_base64_part_encode_finish_t _vm_base64_part_encode_finish = NULL; + +VMINT32 vm_base64_part_encode_finish(vm_base64_part_context* cntx,VMCHAR *dst,VMINT32 dstl) +{ + if (NULL == _vm_base64_part_encode_finish) + _vm_base64_part_encode_finish = (_vm_base64_part_encode_finish_t)vm_get_sym_entry("vm_base64_part_encode_finish"); + + if (NULL != _vm_base64_part_encode_finish) + return _vm_base64_part_encode_finish(cntx, dst, dstl); + else + return -255; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_encode_init.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_encode_init.c new file mode 100644 index 00000000..89df0b45 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_base64_part_encode_init.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmbase64.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_base64_part_encode_init_t)(vm_base64_part_context *cntx,VMINT32 max_part_buf_size,VMBOOL auto_line_wrap); +_vm_base64_part_encode_init_t _vm_base64_part_encode_init = NULL; + +VMINT32 vm_base64_part_encode_init(vm_base64_part_context *cntx,VMINT32 max_part_buf_size,VMBOOL auto_line_wrap) +{ + if (NULL == _vm_base64_part_encode_init) + _vm_base64_part_encode_init = (_vm_base64_part_encode_init_t)vm_get_sym_entry("vm_base64_part_encode_init"); + + if (NULL != _vm_base64_part_encode_init) + return _vm_base64_part_encode_init(cntx, max_part_buf_size, auto_line_wrap); + else + return -255; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bearer_close.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bearer_close.c new file mode 100644 index 00000000..3c23913d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bearer_close.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_bearer_close_t)(VMINT hdl); +_vm_bearer_close_t _vm_bearer_close = NULL; + +VMINT vm_bearer_close(VMINT hdl) +{ + if (NULL == _vm_bearer_close) + _vm_bearer_close = (_vm_bearer_close_t)vm_get_sym_entry("vm_bearer_close"); + if (NULL != _vm_bearer_close) + return _vm_bearer_close(hdl); + return (VMINT)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bearer_open.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bearer_open.c new file mode 100644 index 00000000..dd46f441 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bearer_open.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_bearer_open_t)(VMINT apn, void *user_data, void (*callback)(VMINT handle, VMINT event, VMUINT param, void *user_data)); +_vm_bearer_open_t _vm_bearer_open = NULL; + +VMINT vm_bearer_open(VMINT apn, void *user_data, void (*callback)(VMINT handle, VMINT event, VMUINT param, void *user_data)) +{ + if (NULL == _vm_bearer_open) + _vm_bearer_open = (_vm_bearer_open_t)vm_get_sym_entry("vm_bearer_open"); + if (NULL != _vm_bearer_open) + return _vm_bearer_open(apn,user_data,callback); + return (VMINT)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bind.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bind.c new file mode 100644 index 00000000..68332503 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bind.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_bind_t)(int sock, const SOCKADDR *addr, int addrlen, int type); +_vm_bind_t _vm_bind = NULL; + +int vm_bind(int sock, const SOCKADDR *addr, int addrlen, int type) +{ + if (NULL == _vm_bind) + _vm_bind = (_vm_bind_t)vm_get_sym_entry("vm_bind"); + if (NULL != _vm_bind) + return _vm_bind(sock,addr,addrlen,type); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bridge_close.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bridge_close.c new file mode 100644 index 00000000..181995b5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bridge_close.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmbridge.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_bridge_close_t)(vm_bridge_info *firPeer, vm_bridge_info *secPeer); +_vm_bridge_close_t _vm_bridge_close = NULL; + +VMINT vm_bridge_close(vm_bridge_info *firPeer, vm_bridge_info *secPeer) +{ + if (NULL == _vm_bridge_close) + _vm_bridge_close = (_vm_bridge_close_t)vm_get_sym_entry("vm_bridge_close"); + + if (NULL != _vm_bridge_close) + return _vm_bridge_close(firPeer,secPeer); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bridge_create.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bridge_create.c new file mode 100644 index 00000000..ea144b5d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bridge_create.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmbridge.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_bridge_create_t)(vm_bridge_info *firPeer, vm_bridge_info *secPeer); +_vm_bridge_create_t _vm_bridge_create = NULL; + +VMINT vm_bridge_create(vm_bridge_info *firPeer, vm_bridge_info *secPeer) +{ + if (NULL == _vm_bridge_create) + _vm_bridge_create = (_vm_bridge_create_t)vm_get_sym_entry("vm_bridge_create"); + + if (NULL != _vm_bridge_create) + return _vm_bridge_create(firPeer,secPeer); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bt_cm_send_passkey.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bt_cm_send_passkey.c new file mode 100644 index 00000000..0e28275e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bt_cm_send_passkey.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_bt_cm_send_passkey_t)(vm_srv_bt_cm_bt_addr* dev_addr, VMUINT8* dev_passkey, VMBOOL result); +_vm_bt_cm_send_passkey_t _vm_bt_cm_send_passkey = NULL; + +VMINT vm_bt_cm_send_passkey(vm_srv_bt_cm_bt_addr* dev_addr, VMUINT8* dev_passkey, VMBOOL result) +{ + if (NULL == _vm_bt_cm_send_passkey) + _vm_bt_cm_send_passkey = (_vm_bt_cm_send_passkey_t)vm_get_sym_entry("vm_bt_cm_send_passkey"); + if (NULL != _vm_bt_cm_send_passkey) + return _vm_bt_cm_send_passkey(dev_addr,dev_passkey,result); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bt_noti_check_channel_valid.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bt_noti_check_channel_valid.c new file mode 100644 index 00000000..55c5ba89 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bt_noti_check_channel_valid.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmbtnotify.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_bt_noti_check_channel_valid_t)(VMINT cntx_chnl); +_vm_bt_noti_check_channel_valid_t _vm_bt_noti_check_channel_valid = NULL; + +VMINT vm_bt_noti_check_channel_valid(VMINT cntx_chnl) +{ + if (NULL == _vm_bt_noti_check_channel_valid) + _vm_bt_noti_check_channel_valid = (_vm_bt_noti_check_channel_valid_t)vm_get_sym_entry("vm_bt_noti_check_channel_valid"); + if (NULL != _vm_bt_noti_check_channel_valid) + return _vm_bt_noti_check_channel_valid(cntx_chnl); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bt_noti_get_bt_device_addr.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bt_noti_get_bt_device_addr.c new file mode 100644 index 00000000..aecdf4f1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_bt_noti_get_bt_device_addr.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmbtnotify.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_bt_noti_get_bt_device_addr_t)(VMINT cntx_chnl, vm_srv_bt_cm_bt_addr *bt_addr); +_vm_bt_noti_get_bt_device_addr_t _vm_bt_noti_get_bt_device_addr = NULL; + +VMINT vm_bt_noti_get_bt_device_addr(VMINT cntx_chnl, vm_srv_bt_cm_bt_addr *bt_addr) +{ + if (NULL == _vm_bt_noti_get_bt_device_addr) + _vm_bt_noti_get_bt_device_addr = (_vm_bt_noti_get_bt_device_addr_t)vm_get_sym_entry("vm_bt_noti_get_bt_device_addr"); + if (NULL != _vm_bt_noti_get_bt_device_addr) + return _vm_bt_noti_get_bt_device_addr(cntx_chnl,bt_addr); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_exit.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_exit.c new file mode 100644 index 00000000..475de421 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_exit.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btcm_exit_t)(VMINT res_hd); +_vm_btcm_exit_t _vm_btcm_exit = NULL; +VMINT vm_btcm_exit(VMINT res_hd) +{ + if (NULL == _vm_btcm_exit) + _vm_btcm_exit = (_vm_btcm_exit_t)vm_get_sym_entry("vm_btcm_exit"); + + if (NULL != _vm_btcm_exit) + return _vm_btcm_exit(res_hd); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_get_dev_info_by_index.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_get_dev_info_by_index.c new file mode 100644 index 00000000..c4531cbc --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_get_dev_info_by_index.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btcm_get_dev_info_by_index_t)(VMUINT idx, vm_srv_bt_cm_dev_type_enum dev_type, vm_srv_bt_cm_dev_struct * info); +_vm_btcm_get_dev_info_by_index_t _vm_btcm_get_dev_info_by_index = NULL; +VMINT vm_btcm_get_dev_info_by_index(VMUINT idx, vm_srv_bt_cm_dev_type_enum dev_type, vm_srv_bt_cm_dev_struct * info) +{ + if (NULL == _vm_btcm_get_dev_info_by_index) + _vm_btcm_get_dev_info_by_index = (_vm_btcm_get_dev_info_by_index_t)vm_get_sym_entry("vm_btcm_get_dev_info_by_index"); + + if (NULL != _vm_btcm_get_dev_info_by_index) + return _vm_btcm_get_dev_info_by_index(idx,dev_type,info); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_get_dev_num.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_get_dev_num.c new file mode 100644 index 00000000..2fa62cff --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_get_dev_num.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btcm_get_dev_num_t)(vm_srv_bt_cm_dev_type_enum dev_type); +_vm_btcm_get_dev_num_t _vm_btcm_get_dev_num = NULL; +VMINT vm_btcm_get_dev_num(vm_srv_bt_cm_dev_type_enum dev_type) +{ + if (NULL == _vm_btcm_get_dev_num) + _vm_btcm_get_dev_num = (_vm_btcm_get_dev_num_t)vm_get_sym_entry("vm_btcm_get_dev_num"); + + if (NULL != _vm_btcm_get_dev_num) + return _vm_btcm_get_dev_num(dev_type); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_get_host_dev_info.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_get_host_dev_info.c new file mode 100644 index 00000000..8fdb5895 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_get_host_dev_info.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btcm_get_host_dev_info_t)(vm_srv_bt_cm_dev_struct * info); +_vm_btcm_get_host_dev_info_t _vm_btcm_get_host_dev_info = NULL; +VMINT vm_btcm_get_host_dev_info(vm_srv_bt_cm_dev_struct * info) +{ + if (NULL == _vm_btcm_get_host_dev_info) + _vm_btcm_get_host_dev_info = (_vm_btcm_get_host_dev_info_t)vm_get_sym_entry("vm_btcm_get_host_dev_info"); + + if (NULL != _vm_btcm_get_host_dev_info) + return _vm_btcm_get_host_dev_info(info); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_get_power_status.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_get_power_status.c new file mode 100644 index 00000000..4a1b61cc --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_get_power_status.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btcm_get_power_status_t)(void); +_vm_btcm_get_power_status_t _vm_btcm_get_power_status = NULL; +VMINT vm_btcm_get_power_status(void) +{ + if (NULL == _vm_btcm_get_power_status) + _vm_btcm_get_power_status = (_vm_btcm_get_power_status_t)vm_get_sym_entry("vm_btcm_get_power_status"); + + if (NULL != _vm_btcm_get_power_status) + return _vm_btcm_get_power_status(); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_init.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_init.c new file mode 100644 index 00000000..fe2a047a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_init.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btcm_init_t)(void (*callback)(VMUINT evt, void * param, void * user_data), VMUINT evt_mask, void * user_data); +_vm_btcm_init_t _vm_btcm_init = NULL; +VMINT vm_btcm_init(void (*callback)(VMUINT evt, void * param, void * user_data), VMUINT evt_mask, void * user_data) +{ + if (NULL == _vm_btcm_init) + _vm_btcm_init = (_vm_btcm_init_t)vm_get_sym_entry("vm_btcm_init"); + + if (NULL != _vm_btcm_init) + return _vm_btcm_init(callback, evt_mask, user_data); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_search.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_search.c new file mode 100644 index 00000000..9cf84ff7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_search.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btcm_search_t)(VMUINT8 max_response, VMUINT16 time_out, VMUINT cod, VMBYTE is_name_discovery); +_vm_btcm_search_t _vm_btcm_search = NULL; +VMINT vm_btcm_search(VMUINT8 max_response, VMUINT16 time_out, VMUINT cod, VMBYTE is_name_discovery) +{ + if (NULL == _vm_btcm_search) + _vm_btcm_search = (_vm_btcm_search_t)vm_get_sym_entry("vm_btcm_search"); + + if (NULL != _vm_btcm_search) + return _vm_btcm_search(max_response,time_out,cod,is_name_discovery); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_search_abort.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_search_abort.c new file mode 100644 index 00000000..525604af --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_search_abort.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btcm_search_abort_t)(void); +_vm_btcm_search_abort_t _vm_btcm_search_abort = NULL; +VMINT vm_btcm_search_abort(void) +{ + if (NULL == _vm_btcm_search_abort) + _vm_btcm_search_abort = (_vm_btcm_search_abort_t)vm_get_sym_entry("vm_btcm_search_abort"); + + if (NULL != _vm_btcm_search_abort) + return _vm_btcm_search_abort(); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_set_host_name.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_set_host_name.c new file mode 100644 index 00000000..0402803a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_set_host_name.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btcm_set_host_name_t)(VMUINT8 * name); +_vm_btcm_set_host_name_t _vm_btcm_set_host_name = NULL; +VMINT vm_btcm_set_host_name(VMUINT8 * name) +{ + if (NULL == _vm_btcm_set_host_name) + _vm_btcm_set_host_name = (_vm_btcm_set_host_name_t)vm_get_sym_entry("vm_btcm_set_host_name"); + + if (NULL != _vm_btcm_set_host_name) + return _vm_btcm_set_host_name(name); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_srv_get_visibility.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_srv_get_visibility.c new file mode 100644 index 00000000..d25047f9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_srv_get_visibility.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btcm_srv_get_visibility_t)(void); +_vm_btcm_srv_get_visibility_t _vm_btcm_srv_get_visibility = NULL; +VMINT vm_btcm_srv_get_visibility(void) +{ + if (NULL == _vm_btcm_srv_get_visibility) + _vm_btcm_srv_get_visibility = (_vm_btcm_srv_get_visibility_t)vm_get_sym_entry("vm_btcm_srv_get_visibility"); + + if (NULL != _vm_btcm_srv_get_visibility) + return _vm_btcm_srv_get_visibility(); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_srv_set_visibility.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_srv_set_visibility.c new file mode 100644 index 00000000..bc33d364 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_srv_set_visibility.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btcm_srv_set_visibility_t)(vm_srv_bt_cm_visibility_type type); +_vm_btcm_srv_set_visibility_t _vm_btcm_srv_set_visibility = NULL; +VMINT vm_btcm_srv_set_visibility(vm_srv_bt_cm_visibility_type type) +{ + if (NULL == _vm_btcm_srv_set_visibility) + _vm_btcm_srv_set_visibility = (_vm_btcm_srv_set_visibility_t)vm_get_sym_entry("vm_btcm_srv_set_visibility"); + + if (NULL != _vm_btcm_srv_set_visibility) + return _vm_btcm_srv_set_visibility(type); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_switch_off.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_switch_off.c new file mode 100644 index 00000000..d9263e3d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_switch_off.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btcm_switch_off_t)(void); +_vm_btcm_switch_off_t _vm_btcm_switch_off = NULL; +VMINT vm_btcm_switch_off(void) +{ + if (NULL == _vm_btcm_switch_off) + _vm_btcm_switch_off = (_vm_btcm_switch_off_t)vm_get_sym_entry("vm_btcm_switch_off"); + + if (NULL != _vm_btcm_switch_off) + return _vm_btcm_switch_off(); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_switch_on.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_switch_on.c new file mode 100644 index 00000000..e55b44bd --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btcm_switch_on.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btcm_switch_on_t)(void); +_vm_btcm_switch_on_t _vm_btcm_switch_on = NULL; +VMINT vm_btcm_switch_on(void) +{ + if (NULL == _vm_btcm_switch_on) + _vm_btcm_switch_on = (_vm_btcm_switch_on_t)vm_get_sym_entry("vm_btcm_switch_on"); + + if (NULL != _vm_btcm_switch_on) + return _vm_btcm_switch_on(); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_accept.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_accept.c new file mode 100644 index 00000000..eeb8f7c2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_accept.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtspp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btspp_accept_t)(VMINT conn_id, void * buf, VMUINT tx_size, VMUINT rx_size ); +_vm_btspp_accept_t _vm_btspp_accept = NULL; +VMINT vm_btspp_accept(VMINT conn_id, void * buf, VMUINT tx_size, VMUINT rx_size ) +{ + if (NULL == _vm_btspp_accept) + _vm_btspp_accept = (_vm_btspp_accept_t)vm_get_sym_entry("vm_btspp_accept"); + + if (NULL != _vm_btspp_accept) + return _vm_btspp_accept(conn_id,buf,tx_size,rx_size); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_bind.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_bind.c new file mode 100644 index 00000000..f2005563 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_bind.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtspp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btspp_bind_t)(VMINT res_hd, VMUINT16 uuid); +_vm_btspp_bind_t _vm_btspp_bind = NULL; +VMINT vm_btspp_bind(VMINT res_hd, VMUINT16 uuid) +{ + if (NULL == _vm_btspp_bind) + _vm_btspp_bind = (_vm_btspp_bind_t)vm_get_sym_entry("vm_btspp_bind"); + + if (NULL != _vm_btspp_bind) + return _vm_btspp_bind(res_hd, uuid); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_close.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_close.c new file mode 100644 index 00000000..d92018f3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_close.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtspp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btspp_close_t)(VMINT res_hd); +_vm_btspp_close_t _vm_btspp_close = NULL; +VMINT vm_btspp_close(VMINT res_hd) +{ + if (NULL == _vm_btspp_close) + _vm_btspp_close = (_vm_btspp_close_t)vm_get_sym_entry("vm_btspp_close"); + + if (NULL != _vm_btspp_close) + return _vm_btspp_close(res_hd); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_connect.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_connect.c new file mode 100644 index 00000000..23e20f3c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_connect.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtspp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btspp_connect_t)(VMINT res_hd, const vm_srv_bt_cm_bt_addr * bt_addr, void * buf, VMUINT tx_size, VMUINT rx_size, VMUINT16 uuid ); +_vm_btspp_connect_t _vm_btspp_connect = NULL; +VMINT vm_btspp_connect(VMINT res_hd, const vm_srv_bt_cm_bt_addr * bt_addr, void * buf, VMUINT tx_size, VMUINT rx_size, VMUINT16 uuid ) +{ + if (NULL == _vm_btspp_connect) + _vm_btspp_connect = (_vm_btspp_connect_t)vm_get_sym_entry("vm_btspp_connect"); + + if (NULL != _vm_btspp_connect) + return _vm_btspp_connect(res_hd,bt_addr,buf,tx_size,rx_size, uuid); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_connect_ex.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_connect_ex.c new file mode 100644 index 00000000..350f0889 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_connect_ex.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtspp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btspp_connect_ex_t)(VMINT res_hd, const vm_srv_bt_cm_bt_addr * bt_addr, void * buf, VMUINT tx_size, VMUINT rx_size, vm_srv_spp_connect_type conn_type, VMUINT16 uuid ); +_vm_btspp_connect_ex_t _vm_btspp_connect_ex = NULL; +VMINT vm_btspp_connect_ex(VMINT res_hd, const vm_srv_bt_cm_bt_addr * bt_addr, void * buf, VMUINT tx_size, VMUINT rx_size, vm_srv_spp_connect_type conn_type, VMUINT16 uuid ) +{ + if (NULL == _vm_btspp_connect_ex) + _vm_btspp_connect_ex = (_vm_btspp_connect_ex_t)vm_get_sym_entry("vm_btspp_connect_ex"); + + if (NULL != _vm_btspp_connect_ex) + return _vm_btspp_connect_ex(res_hd,bt_addr,buf,tx_size,rx_size,conn_type, uuid); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_disconnect.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_disconnect.c new file mode 100644 index 00000000..47136ed2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_disconnect.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtspp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btspp_disconnect_t)(VMINT conn_id); +_vm_btspp_disconnect_t _vm_btspp_disconnect = NULL; +VMINT vm_btspp_disconnect(VMINT conn_id) +{ + if (NULL == _vm_btspp_disconnect) + _vm_btspp_disconnect = (_vm_btspp_disconnect_t)vm_get_sym_entry("vm_btspp_disconnect"); + + if (NULL != _vm_btspp_disconnect) + return _vm_btspp_disconnect(conn_id); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_get_dev_addr.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_get_dev_addr.c new file mode 100644 index 00000000..6f70ad57 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_get_dev_addr.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtspp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btspp_get_dev_addr_t)(VMINT conn_id, vm_srv_bt_cm_bt_addr * bt_addr); +_vm_btspp_get_dev_addr_t _vm_btspp_get_dev_addr = NULL; +VMINT vm_btspp_get_dev_addr(VMINT conn_id, vm_srv_bt_cm_bt_addr * bt_addr) +{ + if (NULL == _vm_btspp_get_dev_addr) + _vm_btspp_get_dev_addr = (_vm_btspp_get_dev_addr_t)vm_get_sym_entry("vm_btspp_get_dev_addr"); + + if (NULL != _vm_btspp_get_dev_addr) + return _vm_btspp_get_dev_addr(conn_id,bt_addr); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_get_min_buf_size.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_get_min_buf_size.c new file mode 100644 index 00000000..c4018f32 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_get_min_buf_size.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtspp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btspp_get_min_buf_size_t)(void); +_vm_btspp_get_min_buf_size_t _vm_btspp_get_min_buf_size = NULL; +VMINT vm_btspp_get_min_buf_size(void) +{ + if (NULL == _vm_btspp_get_min_buf_size) + _vm_btspp_get_min_buf_size = (_vm_btspp_get_min_buf_size_t)vm_get_sym_entry("vm_btspp_get_min_buf_size"); + + if (NULL != _vm_btspp_get_min_buf_size) + return _vm_btspp_get_min_buf_size(); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_open.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_open.c new file mode 100644 index 00000000..3d39beb9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_open.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtspp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btspp_open_t)(VMUINT evt_mask, void (*callback)(VMUINT evt, void * param, void * user_data), void * user_data); +_vm_btspp_open_t _vm_btspp_open = NULL; +VMINT vm_btspp_open(VMUINT evt_mask, void (*callback)(VMUINT evt, void * param, void * user_data), void * user_data) +{ + if (NULL == _vm_btspp_open) + _vm_btspp_open = (_vm_btspp_open_t)vm_get_sym_entry("vm_btspp_open"); + + if (NULL != _vm_btspp_open) + return _vm_btspp_open(evt_mask,callback,user_data); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_read.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_read.c new file mode 100644 index 00000000..60ae74ae --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_read.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtspp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btspp_read_t)(VMUINT conn_id, void * buf, VMUINT size); +_vm_btspp_read_t _vm_btspp_read = NULL; +VMINT vm_btspp_read(VMUINT conn_id, void * buf, VMUINT size) +{ + if (NULL == _vm_btspp_read) + _vm_btspp_read = (_vm_btspp_read_t)vm_get_sym_entry("vm_btspp_read"); + + if (NULL != _vm_btspp_read) + return _vm_btspp_read(conn_id,buf,size); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_reject.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_reject.c new file mode 100644 index 00000000..2da225c8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_reject.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtspp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btspp_reject_t)(VMINT conn_id); +_vm_btspp_reject_t _vm_btspp_reject = NULL; +VMINT vm_btspp_reject(VMINT conn_id) +{ + if (NULL == _vm_btspp_reject) + _vm_btspp_reject = (_vm_btspp_reject_t)vm_get_sym_entry("vm_btspp_reject"); + + if (NULL != _vm_btspp_reject) + return _vm_btspp_reject(conn_id); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_set_security_level.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_set_security_level.c new file mode 100644 index 00000000..2c5fb2f1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_set_security_level.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtspp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btspp_set_security_level_t)(VMINT res_hd, VMINT level); +_vm_btspp_set_security_level_t _vm_btspp_set_security_level = NULL; +VMINT vm_btspp_set_security_level(VMINT res_hd, VMINT level) +{ + if (NULL == _vm_btspp_set_security_level) + _vm_btspp_set_security_level = (_vm_btspp_set_security_level_t)vm_get_sym_entry("vm_btspp_set_security_level"); + + if (NULL != _vm_btspp_set_security_level) + return _vm_btspp_set_security_level(res_hd,level); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_set_service_name.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_set_service_name.c new file mode 100644 index 00000000..866998ca --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_set_service_name.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtspp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btspp_set_service_name_t)(VMINT res_hd, VMWCHAR * name); +_vm_btspp_set_service_name_t _vm_btspp_set_service_name = NULL; +VMINT vm_btspp_set_service_name(VMINT res_hd, VMWCHAR * name) +{ + if (NULL == _vm_btspp_set_service_name) + _vm_btspp_set_service_name = (_vm_btspp_set_service_name_t)vm_get_sym_entry("vm_btspp_set_service_name"); + + if (NULL != _vm_btspp_set_service_name) + return _vm_btspp_set_service_name(res_hd,name); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_write.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_write.c new file mode 100644 index 00000000..d524ca02 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_btspp_write.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmbtspp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_btspp_write_t)(VMUINT conn_id, void * buf, VMUINT size); +_vm_btspp_write_t _vm_btspp_write = NULL; +VMINT vm_btspp_write(VMUINT conn_id, void * buf, VMUINT size) +{ + if (NULL == _vm_btspp_write) + _vm_btspp_write = (_vm_btspp_write_t)vm_get_sym_entry("vm_btspp_write"); + + if (NULL != _vm_btspp_write) + return _vm_btspp_write(conn_id,buf,size); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cache_read_char.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cache_read_char.c new file mode 100644 index 00000000..5aab1f8e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cache_read_char.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_cache_read_char_t)(vm_cache_t *cache, char *ch); +_vm_cache_read_char_t _vm_cache_read_char = NULL; + +VMINT vm_cache_read_char(vm_cache_t *cache, char *ch) +{ + if (NULL == _vm_cache_read_char) + _vm_cache_read_char = (_vm_cache_read_char_t)vm_get_sym_entry("vm_cache_read_char"); + + if (NULL != _vm_cache_read_char) + return _vm_cache_read_char(cache,ch); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_call_actions.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_call_actions.c new file mode 100644 index 00000000..70ad501c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_call_actions.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmtel.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_call_actions_t)(const vm_call_actions_data* data); +_vm_call_actions_t _vm_call_actions = NULL; + +VMINT vm_call_actions(const vm_call_actions_data* data) +{ + if (NULL == _vm_call_actions) + _vm_call_actions = (_vm_call_actions_t)vm_get_sym_entry("vm_call_actions"); + + if (NULL != _vm_call_actions) + return _vm_call_actions(data); + + return -1; + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_call_reg_listener.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_call_reg_listener.c new file mode 100644 index 00000000..bb7dd311 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_call_reg_listener.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmtel.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_call_reg_listener_t)(vm_call_listener_func func); +_vm_call_reg_listener_t _vm_call_reg_listener = NULL; + +VMINT vm_call_reg_listener(vm_call_listener_func func) +{ + if (NULL == _vm_call_reg_listener) + _vm_call_reg_listener = (_vm_call_reg_listener_t)vm_get_sym_entry("vm_call_reg_listener"); + + if (NULL != _vm_call_reg_listener) + return _vm_call_reg_listener(func); + + return -1; + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_calloc.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_calloc.c new file mode 100644 index 00000000..05b024b3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_calloc.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void *(*_vm_calloc_t)(int size); +_vm_calloc_t _vm_calloc = NULL; + +void *vm_calloc(int size) +{ + if (NULL == _vm_calloc) + _vm_calloc = (_vm_calloc_t)vm_get_sym_entry("vm_calloc"); + + if (NULL != _vm_calloc) + return _vm_calloc(size); + return NULL; + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_callout.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_callout.c new file mode 100644 index 00000000..8f67a1e1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_callout.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtel.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_callout_t)(VMWSTR phnum); +_vm_callout_t _vm_callout = NULL; + +void vm_callout(VMWSTR phnum) +{ + if (NULL == _vm_callout) + _vm_callout = (_vm_callout_t)vm_get_sym_entry("vm_callout"); + + if (NULL != _vm_callout) + _vm_callout(phnum); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_callout_ex.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_callout_ex.c new file mode 100644 index 00000000..dbfd378c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_callout_ex.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtel.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_callout_ex_t)(VMWSTR phnum, VM_CALLOUT_RESPONSE_T callback); +_vm_callout_ex_t _vm_callout_ex = NULL; + +VMINT vm_callout_ex(VMWSTR phnum, VM_CALLOUT_RESPONSE_T callback) +{ + if (NULL == _vm_callout_ex) + _vm_callout_ex = (_vm_callout_ex_t)vm_get_sym_entry("vm_callout_ex"); + + if (NULL != _vm_callout_ex) + return _vm_callout_ex(phnum,callback); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_camera_startup.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_camera_startup.c new file mode 100644 index 00000000..a54beb82 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_camera_startup.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_vm_camera_startup_t)(void); +_vm_vm_camera_startup_t _vm_camera_startup = NULL; +VMINT vm_camera_startup(void) +{ + if (NULL == _vm_camera_startup) + _vm_camera_startup = (_vm_vm_camera_startup_t)vm_get_sym_entry("vm_camera_startup"); + + if (NULL != _vm_camera_startup) + return _vm_camera_startup(); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cancel_all_http_sessions.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cancel_all_http_sessions.c new file mode 100644 index 00000000..04f9078f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cancel_all_http_sessions.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_cancel_all_http_sessions_t)(void); +_vm_cancel_all_http_sessions_t _vm_cancel_all_http_sessions = NULL; + +void vm_cancel_all_http_sessions(void) +{ + if (NULL == _vm_cancel_all_http_sessions) + _vm_cancel_all_http_sessions = (_vm_cancel_all_http_sessions_t)vm_get_sym_entry("vm_cancel_all_http_sessions"); + + if (NULL != _vm_cancel_all_http_sessions) + _vm_cancel_all_http_sessions(); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cancel_asyn_http_req.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cancel_asyn_http_req.c new file mode 100644 index 00000000..e2c3f2df --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cancel_asyn_http_req.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_cancel_asyn_http_req_t)(VMINT handle); +_vm_cancel_asyn_http_req_t _vm_cancel_asyn_http_req = NULL; + +VMINT vm_cancel_asyn_http_req(VMINT handle) +{ + if (NULL == _vm_cancel_asyn_http_req) + _vm_cancel_asyn_http_req = (_vm_cancel_asyn_http_req_t)vm_get_sym_entry("vm_cancel_asyn_http_req"); + + if (NULL != _vm_cancel_asyn_http_req) + return _vm_cancel_asyn_http_req(handle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cancel_kal_timer.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cancel_kal_timer.c new file mode 100644 index 00000000..e977cd50 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cancel_kal_timer.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmtimer.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_cancel_kal_timer_t)(vm_kal_timerid timer_ptr); +_vm_cancel_kal_timer_t _vm_cancel_kal_timer = NULL; +void vm_cancel_kal_timer(vm_kal_timerid timer_ptr) + +{ + if (NULL == _vm_cancel_kal_timer) + _vm_cancel_kal_timer = (_vm_cancel_kal_timer_t)vm_get_sym_entry("vm_cancel_kal_timer"); + if (NULL != _vm_cancel_kal_timer) + _vm_cancel_kal_timer(timer_ptr); +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cancel_send_sms.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cancel_send_sms.c new file mode 100644 index 00000000..f68f5da4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cancel_send_sms.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtel.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_cancel_send_sms_t)(void); +_vm_cancel_send_sms_t _vm_cancel_send_sms = NULL; + +void vm_cancel_send_sms(void) +{ + if (NULL == _vm_cancel_send_sms) + _vm_cancel_send_sms = (_vm_cancel_send_sms_t)vm_get_sym_entry("vm_cancel_send_sms"); + + if (NULL != _vm_cancel_send_sms) + _vm_cancel_send_sms(); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cbm_hold_bearer.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cbm_hold_bearer.c new file mode 100644 index 00000000..7cf26460 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cbm_hold_bearer.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_cbm_hold_bearer_t)(vm_res_type_t type, VMINT hdl); +_vm_cbm_hold_bearer_t _vm_cbm_hold_bearer = NULL; + +VMINT vm_cbm_hold_bearer(vm_res_type_t type, VMINT hdl) +{ + if (NULL == _vm_cbm_hold_bearer) + _vm_cbm_hold_bearer = (_vm_cbm_hold_bearer_t)vm_get_sym_entry("vm_cbm_hold_bearer"); + + if (NULL != _vm_cbm_hold_bearer) + return _vm_cbm_hold_bearer(type,hdl); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cbm_release_bearer.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cbm_release_bearer.c new file mode 100644 index 00000000..2b0c5bff --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cbm_release_bearer.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_cbm_release_bearer_t)(void); +_vm_cbm_release_bearer_t _vm_cbm_release_bearer = NULL; + +VMINT vm_cbm_release_bearer(void) +{ + if (NULL == _vm_cbm_release_bearer) + _vm_cbm_release_bearer = (_vm_cbm_release_bearer_t)vm_get_sym_entry("vm_cbm_release_bearer"); + + if (NULL != _vm_cbm_release_bearer) + return _vm_cbm_release_bearer(); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ce_auth_app_ex.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ce_auth_app_ex.c new file mode 100644 index 00000000..1bddfa65 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ce_auth_app_ex.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmcert.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ce_auth_app_ex_t)(VMWSTR filename, VMUCHAR * cache_buf, VMINT cache_len, VMINT mode ); +_vm_ce_auth_app_ex_t _vm_ce_auth_app_ex = NULL; + +VMINT vm_ce_auth_app_ex( VMWSTR filename, VMUCHAR * cache_buf, VMINT cache_len, VMINT mode ) +{ + if (NULL == _vm_ce_auth_app_ex) + _vm_ce_auth_app_ex = (_vm_ce_auth_app_ex_t)vm_get_sym_entry("vm_ce_auth_app_ex"); + + if (NULL != _vm_ce_auth_app_ex) + return _vm_ce_auth_app_ex(filename,cache_buf,cache_len, mode); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_close.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_close.c new file mode 100644 index 00000000..f16cf97b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_close.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmcell.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_cell_close_t)(void); +_vm_cell_close_t _vm_cell_close = NULL; + +void vm_cell_close(void) +{ + if (NULL == _vm_cell_close) + _vm_cell_close = (_vm_cell_close_t)vm_get_sym_entry("vm_cell_close"); + + if (NULL != _vm_cell_close) + _vm_cell_close(); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_get_cur_cell_info.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_get_cur_cell_info.c new file mode 100644 index 00000000..9faf66bb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_get_cur_cell_info.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmcell.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_cell_info_struct* (*_vm_cell_get_cur_cell_info_t)(void); +_vm_cell_get_cur_cell_info_t _vm_cell_get_cur_cell_info = NULL; + +vm_cell_info_struct* vm_cell_get_cur_cell_info(void) +{ + if (NULL == _vm_cell_get_cur_cell_info) + _vm_cell_get_cur_cell_info = (_vm_cell_get_cur_cell_info_t)vm_get_sym_entry("vm_cell_get_cur_cell_info"); + + if (NULL != _vm_cell_get_cur_cell_info) + return _vm_cell_get_cur_cell_info(); + + return (vm_cell_info_struct* )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_get_nbr_cell_info.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_get_nbr_cell_info.c new file mode 100644 index 00000000..a4161793 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_get_nbr_cell_info.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmcell.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_cell_info_struct** (*_vm_cell_get_nbr_cell_info_t)(void); +_vm_cell_get_nbr_cell_info_t _vm_cell_get_nbr_cell_info = NULL; + +vm_cell_info_struct** vm_cell_get_nbr_cell_info(void) +{ + if (NULL == _vm_cell_get_nbr_cell_info) + _vm_cell_get_nbr_cell_info = (_vm_cell_get_nbr_cell_info_t)vm_get_sym_entry("vm_cell_get_nbr_cell_info"); + + if (NULL != _vm_cell_get_nbr_cell_info) + return _vm_cell_get_nbr_cell_info(); + + return (vm_cell_info_struct** )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_get_nbr_num.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_get_nbr_num.c new file mode 100644 index 00000000..7a86f095 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_get_nbr_num.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmcell.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT* (*_vm_cell_get_nbr_num_t)(void); +_vm_cell_get_nbr_num_t _vm_cell_get_nbr_num = NULL; + +VMINT* vm_cell_get_nbr_num(void) +{ + if (NULL == _vm_cell_get_nbr_num) + _vm_cell_get_nbr_num = (_vm_cell_get_nbr_num_t)vm_get_sym_entry("vm_cell_get_nbr_num"); + + if (NULL != _vm_cell_get_nbr_num) + return _vm_cell_get_nbr_num(); + + return (VMINT* )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_open.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_open.c new file mode 100644 index 00000000..87e40340 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_cell_open.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmcell.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_cell_open_t)(void); +_vm_cell_open_t _vm_cell_open = NULL; + +VMINT vm_cell_open(void) +{ + if (NULL == _vm_cell_open) + _vm_cell_open = (_vm_cell_open_t)vm_get_sym_entry("vm_cell_open"); + + if (NULL != _vm_cell_open) + return _vm_cell_open(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_charbat_is_charging.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_charbat_is_charging.c new file mode 100644 index 00000000..a4abecbb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_charbat_is_charging.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMBOOL (*_vm_charbat_is_charging_t)(void) ; +_vm_charbat_is_charging_t _vm_charbat_is_charging = NULL; + +VMBOOL vm_charbat_is_charging(void) +{ + if (NULL == _vm_charbat_is_charging) + _vm_charbat_is_charging = (_vm_charbat_is_charging_t)vm_get_sym_entry("vm_charbat_is_charging"); + + if (NULL != _vm_charbat_is_charging) + return _vm_charbat_is_charging(); + + return VM_FALSE; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_deinit.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_deinit.c new file mode 100644 index 00000000..70e0aee9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_deinit.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmche.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_che_deinit_t)(vm_stche *che_context_p ); +_vm_che_deinit_t _vm_che_deinit = NULL; + +void vm_che_deinit(vm_stche *che_context_p) +{ + if (NULL == _vm_che_deinit) + _vm_che_deinit = (_vm_che_deinit_t)vm_get_sym_entry("vm_che_deinit"); + + if (NULL != _vm_che_deinit) + _vm_che_deinit(che_context_p); + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_init.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_init.c new file mode 100644 index 00000000..498fc7fd --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_init.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmche.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_che_init_t)(vm_stche *che_context_p, VMUINT type); +_vm_che_init_t _vm_che_init = NULL; + +void vm_che_init(vm_stche *che_context_p, VMUINT type) +{ + if (NULL == _vm_che_init) + _vm_che_init = (_vm_che_init_t)vm_get_sym_entry("vm_che_init"); + + if (NULL != _vm_che_init) + _vm_che_init(che_context_p,type); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_key_action.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_key_action.c new file mode 100644 index 00000000..4aeef36b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_key_action.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmche.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_che_key_action_t)(vm_stche *che_context_p, vm_che_key_action_type type, VMUINT8 *key, VMINT key_len); +_vm_che_key_action_t _vm_che_key_action = NULL; + +void vm_che_key_action(vm_stche *che_context_p, vm_che_key_action_type type, VMUINT8 *key, VMINT key_len) +{ + if (NULL == _vm_che_key_action) + _vm_che_key_action = (_vm_che_key_action_t)vm_get_sym_entry("vm_che_key_action"); + + if (NULL != _vm_che_key_action) + _vm_che_key_action(che_context_p,type,key,key_len); + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_process.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_process.c new file mode 100644 index 00000000..b1d291ef --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_process.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmche.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT8 (*_vm_che_process_t)(vm_stche *che_context_p,vm_che_type type,vm_che_operation_mode mode, + vm_che_action act, VMUINT8 *source,VMUINT8 *dest,VMUINT source_length,VMUINT8 last_block); +_vm_che_process_t _vm_che_process = NULL; + +VMUINT8 vm_che_process(vm_stche *che_context_p,vm_che_type type,vm_che_operation_mode mode, + vm_che_action act, VMUINT8 *source,VMUINT8 *dest,VMUINT source_length,VMUINT8 last_block) +{ + if (NULL == _vm_che_process) + _vm_che_process = (_vm_che_process_t)vm_get_sym_entry("vm_che_process"); + + if (NULL != _vm_che_process) + return _vm_che_process(che_context_p,type,mode,act,source,dest,source_length,last_block); + + return (VMUINT8 )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_rsa_private_decrypt.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_rsa_private_decrypt.c new file mode 100644 index 00000000..6d688ef1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_rsa_private_decrypt.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmche.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_che_rsa_private_decrypt_t)(vm_stche *ctx, VMUINT8 *src, VMUINT src_len, VMUINT8 *dst, + VMUINT *dst_len, vm_che_rsa_padding_mode_enum padding); +_vm_che_rsa_private_decrypt_t _vm_che_rsa_private_decrypt = NULL; + +VMINT vm_che_rsa_private_decrypt(vm_stche *ctx, VMUINT8 *src, VMUINT src_len, VMUINT8 *dst, + VMUINT *dst_len, vm_che_rsa_padding_mode_enum padding) +{ + if (NULL == _vm_che_rsa_private_decrypt) + _vm_che_rsa_private_decrypt = (_vm_che_rsa_private_decrypt_t)vm_get_sym_entry("vm_che_rsa_private_decrypt"); + + if (NULL != _vm_che_rsa_private_decrypt) + return _vm_che_rsa_private_decrypt(ctx,src,src_len,dst,dst_len,padding); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_rsa_private_encrypt.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_rsa_private_encrypt.c new file mode 100644 index 00000000..c958b6ad --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_rsa_private_encrypt.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmche.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_che_rsa_private_encrypt_t)( vm_stche *ctx, VMUINT8 *src, VMUINT src_len, VMUINT8 *dst, + VMUINT *dst_len, vm_che_rsa_padding_mode_enum padding); +_vm_che_rsa_private_encrypt_t _vm_che_rsa_private_encrypt = NULL; + +VMINT vm_che_rsa_private_encrypt(vm_stche *ctx, VMUINT8 *src, VMUINT src_len, VMUINT8 *dst, + VMUINT *dst_len, vm_che_rsa_padding_mode_enum padding) +{ + if (NULL == _vm_che_rsa_private_encrypt) + _vm_che_rsa_private_encrypt = (_vm_che_rsa_private_encrypt_t)vm_get_sym_entry("vm_che_rsa_private_encrypt"); + + if (NULL != _vm_che_rsa_private_encrypt) + return _vm_che_rsa_private_encrypt(ctx,src,src_len,dst,dst_len,padding); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_rsa_public_decrypt.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_rsa_public_decrypt.c new file mode 100644 index 00000000..84af926c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_rsa_public_decrypt.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmche.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_che_rsa_public_decrypt_t)( vm_stche *ctx, VMUINT8 *src, VMUINT src_len, VMUINT8 *dst, + VMUINT *dst_len, vm_che_rsa_padding_mode_enum padding); +_vm_che_rsa_public_decrypt_t _vm_che_rsa_public_decrypt = NULL; + +VMINT vm_che_rsa_public_decrypt(vm_stche *ctx, VMUINT8 *src, VMUINT src_len, VMUINT8 *dst, + VMUINT *dst_len, vm_che_rsa_padding_mode_enum padding) +{ + if (NULL == _vm_che_rsa_public_decrypt) + _vm_che_rsa_public_decrypt = (_vm_che_rsa_public_decrypt_t)vm_get_sym_entry("vm_che_rsa_public_decrypt"); + + if (NULL != _vm_che_rsa_public_decrypt) + return _vm_che_rsa_public_decrypt(ctx,src,src_len,dst,dst_len,padding); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_rsa_public_encrypt.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_rsa_public_encrypt.c new file mode 100644 index 00000000..e28cd918 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_rsa_public_encrypt.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmche.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_che_rsa_public_encrypt_t)( vm_stche *ctx, VMUINT8 *src, VMUINT src_len, VMUINT8 *dst, + VMUINT *dst_len, vm_che_rsa_padding_mode_enum padding); +_vm_che_rsa_public_encrypt_t _vm_che_rsa_public_encrypt = NULL; + +VMINT vm_che_rsa_public_encrypt(vm_stche *ctx, VMUINT8 *src, VMUINT src_len, VMUINT8 *dst, + VMUINT *dst_len, vm_che_rsa_padding_mode_enum padding) +{ + if (NULL == _vm_che_rsa_public_encrypt) + _vm_che_rsa_public_encrypt = (_vm_che_rsa_public_encrypt_t)vm_get_sym_entry("vm_che_rsa_public_encrypt"); + + if (NULL != _vm_che_rsa_public_encrypt) + return _vm_che_rsa_public_encrypt(ctx,src,src_len,dst,dst_len,padding); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_set_iv.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_set_iv.c new file mode 100644 index 00000000..fb606d23 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_che_set_iv.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmche.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_che_set_iv_t)(vm_stche *che_context_p, VMUINT8 *iv, VMUINT iv_len); +_vm_che_set_iv_t _vm_che_set_iv = NULL; + +void vm_che_set_iv(vm_stche *che_context_p, VMUINT8 *iv, VMUINT iv_len) +{ + if (NULL == _vm_che_set_iv) + _vm_che_set_iv = (_vm_che_set_iv_t)vm_get_sym_entry("vm_che_set_iv"); + + if (NULL != _vm_che_set_iv) + _vm_che_set_iv(che_context_p,iv,iv_len); + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_chset_convert.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_chset_convert.c new file mode 100644 index 00000000..049ae598 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_chset_convert.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmchset.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_chset_convert_t)(vm_chset_enum src_type, vm_chset_enum dest_type, VMCHAR *src, VMCHAR *dest, VMINT dest_size); +_vm_chset_convert_t _vm_chset_convert = NULL; + +VMINT vm_chset_convert(vm_chset_enum src_type, vm_chset_enum dest_type, VMCHAR *src, VMCHAR *dest, VMINT dest_size) +{ + if (NULL == _vm_chset_convert) + _vm_chset_convert = (_vm_chset_convert_t)vm_get_sym_entry("vm_chset_convert"); + + if (NULL != _vm_chset_convert) + return _vm_chset_convert(src_type,dest_type,src,dest,dest_size); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_closesocket.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_closesocket.c new file mode 100644 index 00000000..eeb9e6f4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_closesocket.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_closesocket_t)(int sock); +_vm_closesocket_t _vm_closesocket = NULL; + +int vm_closesocket(int sock) +{ + if (NULL == _vm_closesocket) + _vm_closesocket = (_vm_closesocket_t)vm_get_sym_entry("vm_closesocket"); + if (NULL != _vm_closesocket) + return _vm_closesocket(sock); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_command_close_port.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_command_close_port.c new file mode 100644 index 00000000..07145a9a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_command_close_port.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmatcmd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_command_close_port_t)(VMUINT16 port); +_vm_command_close_port_t _vm_command_close_port = NULL; + +void vm_command_close_port(VMUINT16 port) +{ + if (NULL == _vm_command_close_port) + _vm_command_close_port = (_vm_command_close_port_t)vm_get_sym_entry("vm_command_close_port"); + if (NULL != _vm_command_close_port) + _vm_command_close_port(port); +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_command_open_port.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_command_open_port.c new file mode 100644 index 00000000..680bc70c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_command_open_port.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmatcmd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT16 (*_vm_command_open_port_t)(VMUINT16 port, vm_command_callback call_back, void *user_data); +_vm_command_open_port_t _vm_command_open_port = NULL; + +VMUINT16 vm_command_open_port(VMUINT16 port, vm_command_callback call_back, void *user_data) +{ + if (NULL == _vm_command_open_port) + _vm_command_open_port = (_vm_command_open_port_t)vm_get_sym_entry("vm_command_open_port"); + if (NULL != _vm_command_open_port) + return _vm_command_open_port(port,call_back,user_data); + return 0; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_command_reply.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_command_reply.c new file mode 100644 index 00000000..64888632 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_command_reply.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmatcmd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_command_reply_t)(char* reply_buf, VMUINT32 buf_size, VMUINT32 reply_type); +_vm_command_reply_t _vm_command_reply = NULL; +void vm_command_reply(char* reply_buf, VMUINT32 buf_size, VMUINT32 reply_type) +{ + if (NULL == _vm_command_reply) + _vm_command_reply = (_vm_command_reply_t)vm_get_sym_entry("vm_command_reply"); + + if (NULL != _vm_command_reply) + _vm_command_reply(reply_buf, buf_size, reply_type); +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_connect.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_connect.c new file mode 100644 index 00000000..ab24b73b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_connect.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_connect_t)(int sock, SOCKADDR *addr, int addrlen); +_vm_connect_t _vm_connect = NULL; + +int vm_connect(int sock, SOCKADDR *addr, int addrlen) +{ + if (NULL == _vm_connect) + _vm_connect = (_vm_connect_t)vm_get_sym_entry("vm_connect"); + if (NULL != _vm_connect) + return _vm_connect(sock,addr,addrlen); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_array_stack.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_array_stack.c new file mode 100644 index 00000000..abfc88ce --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_array_stack.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_create_array_stack_t)(VMINT capability, VMINT* handle); +_vm_create_array_stack_t _vm_create_array_stack = NULL; + +VMINT vm_create_array_stack(VMINT capability, VMINT* handle) +{ + if (NULL == _vm_create_array_stack) + _vm_create_array_stack = (_vm_create_array_stack_t)vm_get_sym_entry("vm_create_array_stack"); + + if (NULL != _vm_create_array_stack) + return _vm_create_array_stack(capability,handle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_dyn_array.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_dyn_array.c new file mode 100644 index 00000000..00c31005 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_dyn_array.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_dyn_array_t* (*_vm_create_dyn_array_t)(VMINT init_size, VMINT inc_size, VMINT block_size); +_vm_create_dyn_array_t _vm_create_dyn_array = NULL; + +vm_dyn_array_t* vm_create_dyn_array(VMINT init_size, VMINT inc_size, VMINT block_size) +{ + if (NULL == _vm_create_dyn_array) + _vm_create_dyn_array = (_vm_create_dyn_array_t)vm_get_sym_entry("vm_create_dyn_array"); + + if (NULL != _vm_create_dyn_array) + return _vm_create_dyn_array(init_size,inc_size,block_size); + + return (vm_dyn_array_t* )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_kal_timer.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_kal_timer.c new file mode 100644 index 00000000..1b9f6b27 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_kal_timer.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmtimer.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_kal_timerid (*_vm_create_kal_timer_t)(VMINT8 *timer_name); +_vm_create_kal_timer_t _vm_create_kal_timer = NULL; + +vm_kal_timerid vm_create_kal_timer(VMINT8 *timer_name) +{ + if (NULL == _vm_create_kal_timer) + _vm_create_kal_timer = (_vm_create_kal_timer_t)vm_get_sym_entry("vm_create_kal_timer"); + if (NULL != _vm_create_kal_timer) + return _vm_create_kal_timer(timer_name); + return (vm_kal_timerid)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_linked_stack.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_linked_stack.c new file mode 100644 index 00000000..4bc3bdc9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_linked_stack.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_create_linked_stack_t)(VMINT capability, VMINT* handle); +_vm_create_linked_stack_t _vm_create_linked_stack = NULL; + +VMINT vm_create_linked_stack(VMINT capability, VMINT* handle) +{ + if (NULL == _vm_create_linked_stack) + _vm_create_linked_stack = (_vm_create_linked_stack_t)vm_get_sym_entry("vm_create_linked_stack"); + + if (NULL != _vm_create_linked_stack) + return _vm_create_linked_stack(capability,handle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_timer.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_timer.c new file mode 100644 index 00000000..ce666db8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_timer.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtimer.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_create_timer_t)(VMUINT32 millisec, VM_TIMERPROC_T timerproc); +_vm_create_timer_t _vm_create_timer = NULL; + +VMINT vm_create_timer(VMUINT32 millisec, VM_TIMERPROC_T timerproc) +{ + if (NULL == _vm_create_timer) + _vm_create_timer = (_vm_create_timer_t)vm_get_sym_entry("vm_create_timer"); + + if (NULL != _vm_create_timer) + return _vm_create_timer(millisec,timerproc); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_timer_ex.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_timer_ex.c new file mode 100644 index 00000000..847b5cf0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_create_timer_ex.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtimer.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_create_timer_ex_t)(VMUINT32 millisec, VM_TIMERPROC_T timerproc); +_vm_create_timer_ex_t _vm_create_timer_ex = NULL; + +VMINT vm_create_timer_ex(VMUINT32 millisec, VM_TIMERPROC_T timerproc) +{ + if (NULL == _vm_create_timer_ex) + _vm_create_timer_ex = (_vm_create_timer_ex_t)vm_get_sym_entry("vm_create_timer_ex"); + + if (NULL != _vm_create_timer_ex) + return _vm_create_timer_ex(millisec,timerproc); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_custom_set_bt_pairing_method.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_custom_set_bt_pairing_method.c new file mode 100644 index 00000000..bea7f5bb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_custom_set_bt_pairing_method.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmbtcm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_custom_set_bt_pairing_method_t)(vm_bt_pairing_Type config_type); +_vm_custom_set_bt_pairing_method_t _vm_custom_set_bt_pairing_method = NULL; +void vm_custom_set_bt_pairing_method(vm_bt_pairing_Type config_type) + +{ + if (NULL == _vm_custom_set_bt_pairing_method) + _vm_custom_set_bt_pairing_method = (_vm_custom_set_bt_pairing_method_t)vm_get_sym_entry("vm_custom_set_bt_pairing_method"); + if (NULL != _vm_custom_set_bt_pairing_method) + _vm_custom_set_bt_pairing_method(config_type); +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_da_display_download_list.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_da_display_download_list.c new file mode 100644 index 00000000..5a56cc67 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_da_display_download_list.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmda.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_da_display_download_list_t)(void); +_vm_da_display_download_list_t _vm_da_display_download_list = NULL; + +VMINT vm_da_display_download_list(void) +{ + if (NULL == _vm_da_display_download_list) + _vm_da_display_download_list = (_vm_da_display_download_list_t)vm_get_sym_entry("vm_da_display_download_list"); + + if (NULL != _vm_da_display_download_list) + return _vm_da_display_download_list(); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_da_http_dl_operation.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_da_http_dl_operation.c new file mode 100644 index 00000000..443c0d11 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_da_http_dl_operation.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmda.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_da_http_dl_operation_t)(VMINT hdl, vm_srv_da_download_cause_enum cause); +_vm_da_http_dl_operation_t _vm_da_http_dl_operation = NULL; + +VMINT vm_da_http_dl_operation(VMINT hdl, vm_srv_da_download_cause_enum cause) +{ + if (NULL == _vm_da_http_dl_operation) + _vm_da_http_dl_operation = (_vm_da_http_dl_operation_t)vm_get_sym_entry("vm_da_http_dl_operation"); + + if (NULL != _vm_da_http_dl_operation) + return _vm_da_http_dl_operation(hdl,cause); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_da_http_start_download.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_da_http_start_download.c new file mode 100644 index 00000000..c45eb2c6 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_da_http_start_download.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmda.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_da_http_start_download_t)(vm_srv_da_start_download_struct * arg); +_vm_da_http_start_download_t _vm_da_http_start_download = NULL; + +VMINT vm_da_http_start_download(vm_srv_da_start_download_struct * arg) +{ + if (NULL == _vm_da_http_start_download) + _vm_da_http_start_download = (_vm_da_http_start_download_t)vm_get_sym_entry("vm_da_http_start_download"); + + if (NULL != _vm_da_http_start_download) + return _vm_da_http_start_download(arg); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_delete_timer.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_delete_timer.c new file mode 100644 index 00000000..7eb08df5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_delete_timer.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtimer.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_delete_timer_t)(VMINT timerid); +_vm_delete_timer_t _vm_delete_timer = NULL; + +VMINT vm_delete_timer(VMINT timerid) +{ + if (NULL == _vm_delete_timer) + _vm_delete_timer = (_vm_delete_timer_t)vm_get_sym_entry("vm_delete_timer"); + + if (NULL != _vm_delete_timer) + return _vm_delete_timer(timerid); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_delete_timer_ex.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_delete_timer_ex.c new file mode 100644 index 00000000..10158fc0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_delete_timer_ex.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtimer.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_delete_timer_ex_t)(VMINT timerid); +_vm_delete_timer_ex_t _vm_delete_timer_ex = NULL; + +VMINT vm_delete_timer_ex(VMINT timerid) +{ + if (NULL == _vm_delete_timer_ex) + _vm_delete_timer_ex = (_vm_delete_timer_ex_t)vm_get_sym_entry("vm_delete_timer_ex"); + + if (NULL != _vm_delete_timer_ex) + return _vm_delete_timer_ex(timerid); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_des_decrypt.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_des_decrypt.c new file mode 100644 index 00000000..a9ed68da --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_des_decrypt.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmdes.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT8 * (*_vm_des_decrypt_t)( VMDESHANDLE handle, VMUINT8 * input, VMINT input_len, VMINT * output_len ); +_vm_des_decrypt_t _vm_des_decrypt = NULL; + +VMUINT8 * vm_des_decrypt( VMDESHANDLE handle, VMUINT8 * input, VMINT input_len, VMINT * output_len ) +{ + if (NULL == _vm_des_decrypt) + _vm_des_decrypt = (_vm_des_decrypt_t)vm_get_sym_entry("vm_des_decrypt"); + + if (NULL != _vm_des_decrypt) + return _vm_des_decrypt(handle,input,input_len,output_len); + + return (VMUINT8 * )0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_des_encrypt.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_des_encrypt.c new file mode 100644 index 00000000..44a13ff9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_des_encrypt.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmdes.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT8 * (*_vm_des_encrypt_t)( VMDESHANDLE handle, VMUINT8 * input, VMINT input_len, VMINT * output_len ); +_vm_des_encrypt_t _vm_des_encrypt = NULL; + +VMUINT8 * vm_des_encrypt( VMDESHANDLE handle, VMUINT8 * input, VMINT input_len, VMINT * output_len ) +{ + if (NULL == _vm_des_encrypt) + _vm_des_encrypt = (_vm_des_encrypt_t)vm_get_sym_entry("vm_des_encrypt"); + + if (NULL != _vm_des_encrypt) + return _vm_des_encrypt(handle,input,input_len,output_len); + + return (VMUINT8 * )0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_des_reset_key.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_des_reset_key.c new file mode 100644 index 00000000..9683cc56 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_des_reset_key.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmdes.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_des_reset_key_t)( VMDESHANDLE handle ); +_vm_des_reset_key_t _vm_des_reset_key = NULL; + +VMINT vm_des_reset_key( VMDESHANDLE handle ) +{ + if (NULL == _vm_des_reset_key) + _vm_des_reset_key = (_vm_des_reset_key_t)vm_get_sym_entry("vm_des_reset_key"); + + if (NULL != _vm_des_reset_key) + return _vm_des_reset_key(handle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_des_set_key.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_des_set_key.c new file mode 100644 index 00000000..2828801f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_des_set_key.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmdes.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMDESHANDLE (*_vm_des_set_key_t)( VMUINT8 key[8] ); +_vm_des_set_key_t _vm_des_set_key = NULL; + +VMDESHANDLE vm_des_set_key( VMUINT8 key[8] ) +{ + VMDESHANDLE ret = {-1}; + if (NULL == _vm_des_set_key) + _vm_des_set_key = (_vm_des_set_key_t)vm_get_sym_entry("vm_des_set_key"); + + if (NULL != _vm_des_set_key) + return _vm_des_set_key(key); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_destroy_stack.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_destroy_stack.c new file mode 100644 index 00000000..de4303ed --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_destroy_stack.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_destroy_stack_t)(VMINT stackHandle); +_vm_destroy_stack_t _vm_destroy_stack = NULL; + +VMINT vm_destroy_stack(VMINT stackHandle) +{ + if (NULL == _vm_destroy_stack) + _vm_destroy_stack = (_vm_destroy_stack_t)vm_get_sym_entry("vm_destroy_stack"); + + if (NULL != _vm_destroy_stack) + return _vm_destroy_stack(stackHandle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_client_get_mode.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_client_get_mode.c new file mode 100644 index 00000000..8ec8cc7d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_client_get_mode.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmdhcp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_dhcp_client_get_mode_t)(void); +_vm_dhcp_client_get_mode_t _vm_dhcp_client_get_mode = NULL; +VMINT vm_dhcp_client_get_mode(void) +{ + if (NULL == _vm_dhcp_client_get_mode) + _vm_dhcp_client_get_mode = (_vm_dhcp_client_get_mode_t)vm_get_sym_entry("vm_dhcp_client_get_mode"); + + if (NULL != _vm_dhcp_client_get_mode) + return _vm_dhcp_client_get_mode(); + + return -1; + +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_client_set_mode.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_client_set_mode.c new file mode 100644 index 00000000..be980512 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_client_set_mode.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmdhcp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_dhcp_client_set_mode_t)(VMUINT32 mode); +_vm_dhcp_client_set_mode_t _vm_dhcp_client_set_mode = NULL; +VMINT vm_dhcp_client_set_mode(VMUINT32 mode) +{ + if (NULL == _vm_dhcp_client_set_mode) + _vm_dhcp_client_set_mode = (_vm_dhcp_client_set_mode_t)vm_get_sym_entry("vm_dhcp_client_set_mode"); + + if (NULL != _vm_dhcp_client_set_mode) + return _vm_dhcp_client_set_mode(mode); + + return -1; + +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_server_get_mode.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_server_get_mode.c new file mode 100644 index 00000000..2eb0dc4d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_server_get_mode.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmdhcp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_dhcp_server_get_mode_t)(void); +_vm_dhcp_server_get_mode_t _vm_dhcp_server_get_mode = NULL; +VMINT vm_dhcp_server_get_mode(void) +{ + if (NULL == _vm_dhcp_server_get_mode) + _vm_dhcp_server_get_mode = (_vm_dhcp_server_get_mode_t)vm_get_sym_entry("vm_dhcp_server_get_mode"); + + if (NULL != _vm_dhcp_server_get_mode) + return _vm_dhcp_server_get_mode(); + + return -1; + +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_server_get_param.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_server_get_param.c new file mode 100644 index 00000000..4c70a54c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_server_get_param.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmdhcp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_dhcp_server_get_param_t)(vm_dhcp_server_config_struct *param); +_vm_dhcp_server_get_param_t _vm_dhcp_server_get_param = NULL; +VMINT vm_dhcp_server_get_param(vm_dhcp_server_config_struct *param) +{ + if (NULL == _vm_dhcp_server_get_param) + _vm_dhcp_server_get_param = (_vm_dhcp_server_get_param_t)vm_get_sym_entry("vm_dhcp_server_get_param"); + + if (NULL != _vm_dhcp_server_get_param) + return _vm_dhcp_server_get_param(param); + + return -1; + +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_server_set_mode.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_server_set_mode.c new file mode 100644 index 00000000..cace0f64 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_server_set_mode.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmdhcp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_dhcp_server_set_mode_t)(VMUINT32 mode); +_vm_dhcp_server_set_mode_t _vm_dhcp_server_set_mode = NULL; +VMINT vm_dhcp_server_set_mode(VMUINT32 mode) +{ + if (NULL == _vm_dhcp_server_set_mode) + _vm_dhcp_server_set_mode = (_vm_dhcp_server_set_mode_t)vm_get_sym_entry("vm_dhcp_server_set_mode"); + + if (NULL != _vm_dhcp_server_set_mode) + return _vm_dhcp_server_set_mode(mode); + + return -1; + +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_server_set_param.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_server_set_param.c new file mode 100644 index 00000000..48782a68 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dhcp_server_set_param.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmdhcp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_dhcp_server_set_param_t)(vm_dhcp_server_config_struct *param); +_vm_dhcp_server_set_param_t _vm_dhcp_server_set_param = NULL; +VMINT vm_dhcp_server_set_param(vm_dhcp_server_config_struct *param) +{ + if (NULL == _vm_dhcp_server_set_param) + _vm_dhcp_server_set_param = (_vm_dhcp_server_set_param_t)vm_get_sym_entry("vm_dhcp_server_set_param"); + + if (NULL != _vm_dhcp_server_set_param) + return _vm_dhcp_server_set_param(param); + + return -1; + +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dialer_launch.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dialer_launch.c new file mode 100644 index 00000000..aa7c646e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dialer_launch.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtel.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_dialer_launch_t)(VMWSTR phone_num); +_vm_dialer_launch_t _vm_dialer_launch = NULL; + +VMINT vm_dialer_launch(VMWSTR phone_num) +{ + if (NULL == _vm_dialer_launch) + _vm_dialer_launch = (_vm_dialer_launch_t)vm_get_sym_entry("vm_dialer_launch"); + + if (NULL != _vm_dialer_launch) + return _vm_dialer_launch(phone_num); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dns_get_state.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dns_get_state.c new file mode 100644 index 00000000..fae9db23 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dns_get_state.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmdns.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_dns_get_state_t)(void); +_vm_dns_get_state_t _vm_dns_get_state = NULL; +VMINT vm_dns_get_state(void) +{ + if (NULL == _vm_dns_get_state) + _vm_dns_get_state = (_vm_dns_get_state_t)vm_get_sym_entry("vm_dns_get_state"); + + if (NULL != _vm_dns_get_state) + return _vm_dns_get_state(); + + return -1; + +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dns_start.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dns_start.c new file mode 100644 index 00000000..a091fda3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dns_start.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmdns.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_dns_start_t)(VMUINT32 port, VMCHAR *config_path, VMCHAR *domain_path); +_vm_dns_start_t _vm_dns_start = NULL; +VMINT vm_dns_start(VMUINT32 port, VMCHAR *config_path, VMCHAR *domain_path) +{ + if (NULL == _vm_dns_start) + _vm_dns_start = (_vm_dns_start_t)vm_get_sym_entry("vm_dns_start"); + + if (NULL != _vm_dns_start) + return _vm_dns_start(port, config_path, domain_path); + + return -1; + +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dns_stop.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dns_stop.c new file mode 100644 index 00000000..801c3ea2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dns_stop.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmdns.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_dns_stop_t)(void); +_vm_dns_stop_t _vm_dns_stop = NULL; +VMINT vm_dns_stop(void) +{ + if (NULL == _vm_dns_stop) + _vm_dns_stop = (_vm_dns_stop_t)vm_get_sym_entry("vm_dns_stop"); + + if (NULL != _vm_dns_stop) + return _vm_dns_stop(); + + return -1; + +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dtacct_select.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dtacct_select.c new file mode 100644 index 00000000..461b0cf1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dtacct_select.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_dtacct_select_t)(VMINT sim_id, VMINT (*callback)(VMUINT32 dtacct)); +_vm_dtacct_select_t _vm_dtacct_select = NULL; +VMINT vm_dtacct_select(VMINT sim_id, VMINT (*callback)(VMUINT32 dtacct)) +{ + if (NULL == _vm_dtacct_select) + _vm_dtacct_select = (_vm_dtacct_select_t)vm_get_sym_entry("vm_dtacct_select"); + + if (NULL != _vm_dtacct_select) + return _vm_dtacct_select(sim_id, callback); + + return -1; +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dtacct_set.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dtacct_set.c new file mode 100644 index 00000000..8c1c7517 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dtacct_set.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + + +typedef VMINT (*_vm_dtacct_set_t)(VMINT sim_id, VMUINT32 dtacct); +_vm_dtacct_set_t _vm_dtacct_set = NULL; +VMINT vm_dtacct_set(VMINT sim_id, VMUINT32 dtacct) +{ + if (NULL == _vm_dtacct_set) + _vm_dtacct_set = (_vm_dtacct_set_t)vm_get_sym_entry("vm_dtacct_set"); + + if (NULL != _vm_dtacct_set) + return _vm_dtacct_set(sim_id, dtacct); + + return -1; +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dyn_array_add.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dyn_array_add.c new file mode 100644 index 00000000..8b2185f3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dyn_array_add.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_dyn_array_add_t)(vm_dyn_array_t *array, void* data); +_vm_dyn_array_add_t _vm_dyn_array_add = NULL; + +VMINT vm_dyn_array_add(vm_dyn_array_t *array, void* data) +{ + if (NULL == _vm_dyn_array_add) + _vm_dyn_array_add = (_vm_dyn_array_add_t)vm_get_sym_entry("vm_dyn_array_add"); + + if (NULL != _vm_dyn_array_add) + return _vm_dyn_array_add(array,data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dyn_array_del.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dyn_array_del.c new file mode 100644 index 00000000..905efc31 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dyn_array_del.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_dyn_array_del_t)(vm_dyn_array_t *array, VMINT idx); +_vm_dyn_array_del_t _vm_dyn_array_del = NULL; + +VMINT vm_dyn_array_del(vm_dyn_array_t *array, VMINT idx) +{ + if (NULL == _vm_dyn_array_del) + _vm_dyn_array_del = (_vm_dyn_array_del_t)vm_get_sym_entry("vm_dyn_array_del"); + + if (NULL != _vm_dyn_array_del) + return _vm_dyn_array_del(array,idx); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dyn_array_del_all.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dyn_array_del_all.c new file mode 100644 index 00000000..24154c56 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_dyn_array_del_all.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_dyn_array_del_all_t)(vm_dyn_array_t *array); +_vm_dyn_array_del_all_t _vm_dyn_array_del_all = NULL; + +VMINT vm_dyn_array_del_all(vm_dyn_array_t *array) +{ + if (NULL == _vm_dyn_array_del_all) + _vm_dyn_array_del_all = (_vm_dyn_array_del_all_t)vm_get_sym_entry("vm_dyn_array_del_all"); + + if (NULL != _vm_dyn_array_del_all) + return _vm_dyn_array_del_all(array); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_em_send_command.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_em_send_command.c new file mode 100644 index 00000000..48f30282 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_em_send_command.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmemcmd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_emcmd_enum (*_vm_em_send_command_t)(VMCHAR *atCmdStr, VM_EM_CMD_CB atcmd_cb); +_vm_em_send_command_t _vm_em_send_command = NULL; + +vm_emcmd_enum vm_em_send_command(VMCHAR *atCmdStr, VM_EM_CMD_CB atcmd_cb) +{ + if (NULL == _vm_em_send_command) + _vm_em_send_command = (_vm_em_send_command_t)vm_get_sym_entry("vm_em_send_command"); + + if (NULL != _vm_em_send_command) + return _vm_em_send_command(atCmdStr, atcmd_cb); + + return (vm_emcmd_enum)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_enable_proxy.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_enable_proxy.c new file mode 100644 index 00000000..b077ec09 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_enable_proxy.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_enable_proxy_t)(VMINT use_proxy); +_vm_enable_proxy_t _vm_enable_proxy = NULL; + +void vm_enable_proxy(VMINT use_proxy) +{ + if (NULL == _vm_enable_proxy) + _vm_enable_proxy = (_vm_enable_proxy_t)vm_get_sym_entry("vm_enable_proxy"); + + if (NULL != _vm_enable_proxy) + _vm_enable_proxy(use_proxy); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ends_with.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ends_with.c new file mode 100644 index 00000000..4a01eba4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ends_with.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ends_with_t)(const char *s1, const char *s2); +_vm_ends_with_t _vm_ends_with = NULL; + +VMINT vm_ends_with(const char *s1, const char *s2) +{ + if (NULL == _vm_ends_with) + _vm_ends_with = (_vm_ends_with_t)vm_get_sym_entry("vm_ends_with"); + + if (NULL != _vm_ends_with) + return _vm_ends_with(s1,s2); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_exit_app.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_exit_app.c new file mode 100644 index 00000000..96b647f7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_exit_app.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_exit_app_t)(void); +_vm_exit_app_t _vm_exit_app = NULL; + +void vm_exit_app(void) +{ + if (NULL == _vm_exit_app) + _vm_exit_app = (_vm_exit_app_t)vm_get_sym_entry("vm_exit_app"); + + if (NULL != _vm_exit_app) + _vm_exit_app(); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_close.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_close.c new file mode 100644 index 00000000..35d011e5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_close.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_file_close_t)(VMFILE handle); +_vm_file_close_t _vm_file_close = NULL; + +void vm_file_close(VMFILE handle) +{ + if (NULL == _vm_file_close) + _vm_file_close = (_vm_file_close_t)vm_get_sym_entry("vm_file_close"); + + if (NULL != _vm_file_close) + _vm_file_close(handle); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_commit.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_commit.c new file mode 100644 index 00000000..3c7a695c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_commit.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_commit_t)(VMFILE handle); +_vm_file_commit_t _vm_file_commit = NULL; + +VMINT vm_file_commit(VMFILE handle) +{ + if (NULL == _vm_file_commit) + _vm_file_commit = (_vm_file_commit_t)vm_get_sym_entry("vm_file_commit"); + + if (NULL != _vm_file_commit) + return _vm_file_commit(handle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_copy.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_copy.c new file mode 100644 index 00000000..4c9859de --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_copy.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_copy_t)(const VMWSTR dst, const VMWSTR src, vm_file_copy_cb cb); +_vm_file_copy_t _vm_file_copy = NULL; + +VMINT vm_file_copy(const VMWSTR dst, const VMWSTR src, vm_file_copy_cb cb) +{ + if (NULL == _vm_file_copy) + _vm_file_copy = (_vm_file_copy_t)vm_get_sym_entry("vm_file_copy"); + + if (NULL != _vm_file_copy) + return _vm_file_copy(dst, src, cb); + + return (VMINT )0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_copy_abort.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_copy_abort.c new file mode 100644 index 00000000..54fcea95 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_copy_abort.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_copy_abort_t)(VMINT hdl); +_vm_file_copy_abort_t _vm_file_copy_abort = NULL; + +VMINT vm_file_copy_abort(VMINT hdl) +{ + if (NULL == _vm_file_copy_abort) + _vm_file_copy_abort = (_vm_file_copy_abort_t)vm_get_sym_entry("vm_file_copy_abort"); + + if (NULL != _vm_file_copy_abort) + return _vm_file_copy_abort(hdl); + + return (VMINT )0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_delete.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_delete.c new file mode 100644 index 00000000..df4bd34e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_delete.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_delete_t)(const VMWSTR filename); +_vm_file_delete_t _vm_file_delete = NULL; + +VMINT vm_file_delete(const VMWSTR filename) +{ + if (NULL == _vm_file_delete) + _vm_file_delete = (_vm_file_delete_t)vm_get_sym_entry("vm_file_delete"); + + if (NULL != _vm_file_delete) + return _vm_file_delete(filename); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_get_attributes.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_get_attributes.c new file mode 100644 index 00000000..98286286 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_get_attributes.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_get_attributes_t)(const VMWSTR filename); +_vm_file_get_attributes_t _vm_file_get_attributes = NULL; + +VMINT vm_file_get_attributes(const VMWSTR filename) +{ + if (NULL == _vm_file_get_attributes) + _vm_file_get_attributes = (_vm_file_get_attributes_t)vm_get_sym_entry("vm_file_get_attributes"); + + if (NULL != _vm_file_get_attributes) + return _vm_file_get_attributes(filename); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_get_modify_time.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_get_modify_time.c new file mode 100644 index 00000000..04329fac --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_get_modify_time.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_get_modify_time_t)(const VMWSTR filename, vm_time_t * modify_time); +_vm_file_get_modify_time_t _vm_file_get_modify_time = NULL; + +VMINT vm_file_get_modify_time(const VMWSTR filename, vm_time_t * modify_time) +{ + if (NULL == _vm_file_get_modify_time) + _vm_file_get_modify_time = (_vm_file_get_modify_time_t)vm_get_sym_entry("vm_file_get_modify_time"); + + if (NULL != _vm_file_get_modify_time) + return _vm_file_get_modify_time(filename,modify_time); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_getfilesize.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_getfilesize.c new file mode 100644 index 00000000..cee8b8e1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_getfilesize.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_getfilesize_t)(VMFILE handle, VMUINT *file_size); +_vm_file_getfilesize_t _vm_file_getfilesize = NULL; + +VMINT vm_file_getfilesize(VMFILE handle, VMUINT *file_size) +{ + if (NULL == _vm_file_getfilesize) + _vm_file_getfilesize = (_vm_file_getfilesize_t)vm_get_sym_entry("vm_file_getfilesize"); + + if (NULL != _vm_file_getfilesize) + return _vm_file_getfilesize(handle,file_size); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_is_eof.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_is_eof.c new file mode 100644 index 00000000..4d5eec35 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_is_eof.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_is_eof_t)(VMFILE handle); +_vm_file_is_eof_t _vm_file_is_eof = NULL; + +VMINT vm_file_is_eof(VMFILE handle) +{ + if (NULL == _vm_file_is_eof) + _vm_file_is_eof = (_vm_file_is_eof_t)vm_get_sym_entry("vm_file_is_eof"); + + if (NULL != _vm_file_is_eof) + return _vm_file_is_eof(handle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_mkdir.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_mkdir.c new file mode 100644 index 00000000..edf56986 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_mkdir.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_mkdir_t)(const VMWSTR dirname); +_vm_file_mkdir_t _vm_file_mkdir = NULL; + +VMINT vm_file_mkdir(const VMWSTR dirname) +{ + if (NULL == _vm_file_mkdir) + _vm_file_mkdir = (_vm_file_mkdir_t)vm_get_sym_entry("vm_file_mkdir"); + + if (NULL != _vm_file_mkdir) + return _vm_file_mkdir(dirname); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_open.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_open.c new file mode 100644 index 00000000..0f03e3ac --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_open.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMFILE (*_vm_file_open_t)(const VMWSTR filename, VMUINT mode, VMUINT binary); +_vm_file_open_t _vm_file_open = NULL; + +VMFILE vm_file_open(const VMWSTR filename, VMUINT mode, VMUINT binary) +{ + if (NULL == _vm_file_open) + _vm_file_open = (_vm_file_open_t)vm_get_sym_entry("vm_file_open"); + + if (NULL != _vm_file_open) + return _vm_file_open(filename,mode,binary); + + return (VMFILE )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_read.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_read.c new file mode 100644 index 00000000..5646e770 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_read.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_read_t)(VMFILE handle, void * data, VMUINT length, VMUINT *nread); +_vm_file_read_t _vm_file_read = NULL; + +VMINT vm_file_read(VMFILE handle, void * data, VMUINT length, VMUINT *nread) +{ + if (NULL == _vm_file_read) + _vm_file_read = (_vm_file_read_t)vm_get_sym_entry("vm_file_read"); + + if (NULL != _vm_file_read) + return _vm_file_read(handle,data,length,nread); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_rename.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_rename.c new file mode 100644 index 00000000..0f5a41e1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_rename.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_rename_t)(const VMWSTR filename, const VMWSTR newname); +_vm_file_rename_t _vm_file_rename = NULL; + +VMINT vm_file_rename(const VMWSTR filename, const VMWSTR newname) +{ + if (NULL == _vm_file_rename) + _vm_file_rename = (_vm_file_rename_t)vm_get_sym_entry("vm_file_rename"); + + if (NULL != _vm_file_rename) + return _vm_file_rename(filename,newname); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_rmdir.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_rmdir.c new file mode 100644 index 00000000..19384861 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_rmdir.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_rmdir_t)(const VMWSTR dirname); +_vm_file_rmdir_t _vm_file_rmdir = NULL; + +VMINT vm_file_rmdir(const VMWSTR dirname) +{ + if (NULL == _vm_file_rmdir) + _vm_file_rmdir = (_vm_file_rmdir_t)vm_get_sym_entry("vm_file_rmdir"); + + if (NULL != _vm_file_rmdir) + return _vm_file_rmdir(dirname); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_seek.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_seek.c new file mode 100644 index 00000000..2111ebac --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_seek.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_seek_t)(VMFILE handle, VMINT offset, VMINT base); +_vm_file_seek_t _vm_file_seek = NULL; + +VMINT vm_file_seek(VMFILE handle, VMINT offset, VMINT base) +{ + if (NULL == _vm_file_seek) + _vm_file_seek = (_vm_file_seek_t)vm_get_sym_entry("vm_file_seek"); + + if (NULL != _vm_file_seek) + return _vm_file_seek(handle,offset,base); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_set_attributes.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_set_attributes.c new file mode 100644 index 00000000..3129f2f7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_set_attributes.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_set_attributes_t)(const VMWSTR filename, VMBYTE attributes); +_vm_file_set_attributes_t _vm_file_set_attributes = NULL; + +VMINT vm_file_set_attributes(const VMWSTR filename, VMBYTE attributes) +{ + if (NULL == _vm_file_set_attributes) + _vm_file_set_attributes = (_vm_file_set_attributes_t)vm_get_sym_entry("vm_file_set_attributes"); + + if (NULL != _vm_file_set_attributes) + return _vm_file_set_attributes(filename,attributes); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_tell.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_tell.c new file mode 100644 index 00000000..3da23422 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_tell.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_tell_t)(VMFILE handle); +_vm_file_tell_t _vm_file_tell = NULL; + +VMINT vm_file_tell(VMFILE handle) +{ + if (NULL == _vm_file_tell) + _vm_file_tell = (_vm_file_tell_t)vm_get_sym_entry("vm_file_tell"); + + if (NULL != _vm_file_tell) + return _vm_file_tell(handle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_write.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_write.c new file mode 100644 index 00000000..a92fa996 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_file_write.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_file_write_t)(VMFILE handle, void * data, VMUINT length, VMUINT * written); +_vm_file_write_t _vm_file_write = NULL; + +VMINT vm_file_write(VMFILE handle, void * data, VMUINT length, VMUINT * written) +{ + if (NULL == _vm_file_write) + _vm_file_write = (_vm_file_write_t)vm_get_sym_entry("vm_file_write"); + + if (NULL != _vm_file_write) + return _vm_file_write(handle,data,length,written); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_close.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_close.c new file mode 100644 index 00000000..95d449fa --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_close.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_find_close_t)(VMINT handle); +_vm_find_close_t _vm_find_close = NULL; + +void vm_find_close(VMINT handle) +{ + if (NULL == _vm_find_close) + _vm_find_close = (_vm_find_close_t)vm_get_sym_entry("vm_find_close"); + + if (NULL != _vm_find_close) + _vm_find_close(handle); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_close_ext.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_close_ext.c new file mode 100644 index 00000000..19d26f66 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_close_ext.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_find_close_ext_t)(VMINT handle); +_vm_find_close_ext_t _vm_find_close_ext = NULL; + +void vm_find_close_ext(VMINT handle) +{ + if (NULL == _vm_find_close_ext) + _vm_find_close_ext = (_vm_find_close_ext_t)vm_get_sym_entry("vm_find_close_ext"); + + if (NULL != _vm_find_close_ext) + _vm_find_close_ext(handle); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_first.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_first.c new file mode 100644 index 00000000..11616226 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_first.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_find_first_t)(VMWSTR pathname, struct vm_fileinfo_t* info); +_vm_find_first_t _vm_find_first = NULL; + +VMINT vm_find_first(VMWSTR pathname, struct vm_fileinfo_t* info) +{ + if (NULL == _vm_find_first) + _vm_find_first = (_vm_find_first_t)vm_get_sym_entry("vm_find_first"); + + if (NULL != _vm_find_first) + return _vm_find_first(pathname,info); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_first_ext.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_first_ext.c new file mode 100644 index 00000000..f8c031c6 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_first_ext.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_find_first_ext_t)(VMWSTR pathname, vm_fileinfo_ext * direntry); +_vm_find_first_ext_t _vm_find_first_ext = NULL; + +VMINT vm_find_first_ext(VMWSTR pathname, vm_fileinfo_ext * direntry) +{ + if (NULL == _vm_find_first_ext) + _vm_find_first_ext = (_vm_find_first_ext_t)vm_get_sym_entry("vm_find_first_ext"); + + if (NULL != _vm_find_first_ext) + return _vm_find_first_ext(pathname,direntry); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_next.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_next.c new file mode 100644 index 00000000..e40b8d0c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_next.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_find_next_t)(VMINT handle, struct vm_fileinfo_t* info); +_vm_find_next_t _vm_find_next = NULL; + +VMINT vm_find_next(VMINT handle, struct vm_fileinfo_t* info) +{ + if (NULL == _vm_find_next) + _vm_find_next = (_vm_find_next_t)vm_get_sym_entry("vm_find_next"); + + if (NULL != _vm_find_next) + return _vm_find_next(handle,info); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_next_ext.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_next_ext.c new file mode 100644 index 00000000..cfce886e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_find_next_ext.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_find_next_ext_t)(VMINT handle, vm_fileinfo_ext * direntry); +_vm_find_next_ext_t _vm_find_next_ext = NULL; + +VMINT vm_find_next_ext(VMINT handle, vm_fileinfo_ext * direntry) +{ + if (NULL == _vm_find_next_ext) + _vm_find_next_ext = (_vm_find_next_ext_t)vm_get_sym_entry("vm_find_next_ext"); + + if (NULL != _vm_find_next_ext) + return _vm_find_next_ext(handle,direntry); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fly_mode_is_network_service_available.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fly_mode_is_network_service_available.c new file mode 100644 index 00000000..9047e5ad --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fly_mode_is_network_service_available.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpwr.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMBOOL (*_vm_fly_mode_is_network_service_available_t)(void); +_vm_fly_mode_is_network_service_available_t _vm_fly_mode_is_network_service_available = NULL; + +VMBOOL vm_fly_mode_is_network_service_available(void) +{ + if (NULL == _vm_fly_mode_is_network_service_available) + _vm_fly_mode_is_network_service_available = (_vm_fly_mode_is_network_service_available_t)vm_get_sym_entry("vm_fly_mode_is_network_service_available"); + + if (NULL != _vm_fly_mode_is_network_service_available) + return _vm_fly_mode_is_network_service_available(); + + return (VMBOOL)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fly_mode_is_switching.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fly_mode_is_switching.c new file mode 100644 index 00000000..c577677e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fly_mode_is_switching.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpwr.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMBOOL (*_vm_fly_mode_is_switching_t)(void); +_vm_fly_mode_is_switching_t _vm_fly_mode_is_switching = NULL; + +VMBOOL vm_fly_mode_is_switching(void) +{ + if (NULL == _vm_fly_mode_is_switching) + _vm_fly_mode_is_switching = (_vm_fly_mode_is_switching_t)vm_get_sym_entry("vm_fly_mode_is_switching"); + + if (NULL != _vm_fly_mode_is_switching) + return _vm_fly_mode_is_switching(); + + return (VMBOOL)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fly_mode_switch.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fly_mode_switch.c new file mode 100644 index 00000000..a139db3f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fly_mode_switch.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpwr.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMBOOL (*_vm_fly_mode_switch_t)(VMBOOL flight_mode_on, VMBOOL check_sim, vm_fly_mode_cb cb, void *user_data); +_vm_fly_mode_switch_t _vm_fly_mode_switch = NULL; + +VMBOOL vm_fly_mode_switch(VMBOOL flight_mode_on, VMBOOL check_sim, vm_fly_mode_cb cb, void *user_data) +{ + if (NULL == _vm_fly_mode_switch) + _vm_fly_mode_switch = (_vm_fly_mode_switch_t)vm_get_sym_entry("vm_fly_mode_switch"); + + if (NULL != _vm_fly_mode_switch) + return _vm_fly_mode_switch(flight_mode_on, check_sim, cb, user_data); + + return (VMBOOL)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_free.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_free.c new file mode 100644 index 00000000..da5b4d8d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_free.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_free_t)(void* ptr); +_vm_free_t _vm_free = NULL; + +void vm_free(void* ptr) +{ + if (NULL == _vm_free) + _vm_free = (_vm_free_t)vm_get_sym_entry("vm_free"); + + if (NULL != _vm_free) + _vm_free(ptr); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_free_dyn_array.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_free_dyn_array.c new file mode 100644 index 00000000..c17947e7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_free_dyn_array.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_free_dyn_array_t)(vm_dyn_array_t *array); +_vm_free_dyn_array_t _vm_free_dyn_array = NULL; + +void vm_free_dyn_array(vm_dyn_array_t *array) +{ + if (NULL == _vm_free_dyn_array) + _vm_free_dyn_array = (_vm_free_dyn_array_t)vm_get_sym_entry("vm_free_dyn_array"); + + if (NULL != _vm_free_dyn_array) + _vm_free_dyn_array(array); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_abort.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_abort.c new file mode 100644 index 00000000..7cae9f64 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_abort.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_fs_async_abort_t)(vm_fs_job_id jid); +_vm_fs_async_abort_t _vm_fs_async_abort = NULL; + +VMINT vm_fs_async_abort(vm_fs_job_id jid) +{ + if (NULL == _vm_fs_async_abort) + _vm_fs_async_abort = (_vm_fs_async_abort_t)vm_get_sym_entry("vm_fs_async_abort"); + + if (NULL != _vm_fs_async_abort) + return _vm_fs_async_abort(jid); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_close.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_close.c new file mode 100644 index 00000000..e0e3f512 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_close.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_fs_async_close_t)(VM_FS_HANDLE fs_hdl); +_vm_fs_async_close_t _vm_fs_async_close = NULL; + +VMINT vm_fs_async_close(VM_FS_HANDLE fs_hdl) +{ + if (NULL == _vm_fs_async_close) + _vm_fs_async_close = (_vm_fs_async_close_t)vm_get_sym_entry("vm_fs_async_close"); + + if (NULL != _vm_fs_async_close) + return _vm_fs_async_close(fs_hdl); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_commit.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_commit.c new file mode 100644 index 00000000..9eb3f88a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_commit.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_fs_async_commit_t)(VM_FS_HANDLE fs_hdl); +_vm_fs_async_commit_t _vm_fs_async_commit = NULL; + +VMINT vm_fs_async_commit(VM_FS_HANDLE fs_hdl) +{ + if (NULL == _vm_fs_async_commit) + _vm_fs_async_commit = (_vm_fs_async_commit_t)vm_get_sym_entry("vm_fs_async_commit"); + + if (NULL != _vm_fs_async_commit) + return _vm_fs_async_commit(fs_hdl); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_delete.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_delete.c new file mode 100644 index 00000000..781266b2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_delete.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_fs_async_delete_t)(const VMWSTR filename, vm_fs_overlapped_struct *overlapped); +_vm_fs_async_delete_t _vm_fs_async_delete = NULL; + +VMINT vm_fs_async_delete(const VMWSTR filename, vm_fs_overlapped_struct *overlapped) +{ + if (NULL == _vm_fs_async_delete) + _vm_fs_async_delete = (_vm_fs_async_delete_t)vm_get_sym_entry("vm_fs_async_delete"); + + if (NULL != _vm_fs_async_delete) + return _vm_fs_async_delete(filename,overlapped); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_get_working_buf_size.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_get_working_buf_size.c new file mode 100644 index 00000000..1cfeaa96 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_get_working_buf_size.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_fs_async_get_working_buf_size_t)(void); +_vm_fs_async_get_working_buf_size_t _vm_fs_async_get_working_buf_size = NULL; + +VMINT vm_fs_async_get_working_buf_size(void) +{ + if (NULL == _vm_fs_async_get_working_buf_size) + _vm_fs_async_get_working_buf_size = (_vm_fs_async_get_working_buf_size_t)vm_get_sym_entry("vm_fs_async_get_working_buf_size"); + + if (NULL != _vm_fs_async_get_working_buf_size) + return _vm_fs_async_get_working_buf_size(); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_open.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_open.c new file mode 100644 index 00000000..03115928 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_open.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_fs_async_open_t)(const VMWSTR file_name, VMINT flag, vm_fs_overlapped_struct *overlapped); +_vm_fs_async_open_t _vm_fs_async_open = NULL; + +VMINT vm_fs_async_open(const VMWSTR file_name, VMINT flag, vm_fs_overlapped_struct *overlapped) +{ + if (NULL == _vm_fs_async_open) + _vm_fs_async_open = (_vm_fs_async_open_t)vm_get_sym_entry("vm_fs_async_open"); + + if (NULL != _vm_fs_async_open) + return _vm_fs_async_open(file_name,flag,overlapped); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_read.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_read.c new file mode 100644 index 00000000..8ea7e8a2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_read.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_fs_async_read_t)(VM_FS_HANDLE fs_hdl, void *data, VMUINT length, VMUINT *read, vm_fs_overlapped_struct *overlapped); +_vm_fs_async_read_t _vm_fs_async_read = NULL; + +VMINT vm_fs_async_read(VM_FS_HANDLE fs_hdl, void *data, VMUINT length, VMUINT *read, vm_fs_overlapped_struct *overlapped) +{ + if (NULL == _vm_fs_async_read) + _vm_fs_async_read = (_vm_fs_async_read_t)vm_get_sym_entry("vm_fs_async_read"); + + if (NULL != _vm_fs_async_read) + return _vm_fs_async_read(fs_hdl,data,length,read,overlapped); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_seek.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_seek.c new file mode 100644 index 00000000..72fba570 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_seek.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_fs_async_seek_t)(VM_FS_HANDLE fs_hdl, VMINT64 * offset, VMINT whence, vm_fs_overlapped_struct *overlapped); +_vm_fs_async_seek_t _vm_fs_async_seek = NULL; + +VMINT vm_fs_async_seek(VM_FS_HANDLE fs_hdl, VMINT64 * offset, VMINT whence, vm_fs_overlapped_struct *overlapped) +{ + if (NULL == _vm_fs_async_seek) + _vm_fs_async_seek = (_vm_fs_async_seek_t)vm_get_sym_entry("vm_fs_async_seek"); + + if (NULL != _vm_fs_async_seek) + return _vm_fs_async_seek(fs_hdl,offset,whence,overlapped); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_write.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_write.c new file mode 100644 index 00000000..d1e3629a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_fs_async_write.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_fs_async_write_t)(VM_FS_HANDLE fs_hdl, void *data, VMUINT length, VMUINT *written, vm_fs_overlapped_struct *overlapped); +_vm_fs_async_write_t _vm_fs_async_write = NULL; + +VMINT vm_fs_async_write(VM_FS_HANDLE fs_hdl, void *data, VMUINT length, VMUINT *written, vm_fs_overlapped_struct *overlapped) +{ + if (NULL == _vm_fs_async_write) + _vm_fs_async_write = (_vm_fs_async_write_t)vm_get_sym_entry("vm_fs_async_write"); + + if (NULL != _vm_fs_async_write) + return _vm_fs_async_write(fs_hdl,data,length,written,overlapped); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gb2312_string.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gb2312_string.c new file mode 100644 index 00000000..e618dd25 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gb2312_string.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmchset.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef char *(*_vm_gb2312_string_t)(VMWSTR s); +_vm_gb2312_string_t _vm_gb2312_string = NULL; + +char *vm_gb2312_string(VMWSTR s) +{ + if (NULL == _vm_gb2312_string) + _vm_gb2312_string = (_vm_gb2312_string_t)vm_get_sym_entry("vm_gb2312_string"); + + if (NULL != _vm_gb2312_string) + return _vm_gb2312_string(s); + + return (char *)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gb2312_to_ucs2.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gb2312_to_ucs2.c new file mode 100644 index 00000000..3c031145 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gb2312_to_ucs2.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmchset.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_gb2312_to_ucs2_t)(VMWSTR dst, VMINT size, VMSTR src); +_vm_gb2312_to_ucs2_t _vm_gb2312_to_ucs2 = NULL; + +VMINT vm_gb2312_to_ucs2(VMWSTR dst, VMINT size, VMSTR src) +{ + if (NULL == _vm_gb2312_to_ucs2) + _vm_gb2312_to_ucs2 = (_vm_gb2312_to_ucs2_t)vm_get_sym_entry("vm_gb2312_to_ucs2"); + + if (NULL != _vm_gb2312_to_ucs2) + return _vm_gb2312_to_ucs2(dst,size,src); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_apn_info.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_apn_info.c new file mode 100644 index 00000000..e7b0f8fe --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_apn_info.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_apn_info_t)(vm_apn_info_ext *current_apn_info); +_vm_get_apn_info_t _vm_get_apn_info = NULL; + +VMINT vm_get_apn_info(vm_apn_info_ext *current_apn_info) +{ + if (NULL == _vm_get_apn_info) + _vm_get_apn_info = (_vm_get_apn_info_t)vm_get_sym_entry("vm_get_apn_info"); + + if (NULL != _vm_get_apn_info) + return _vm_get_apn_info(current_apn_info); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_asyn_http_req_handle.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_asyn_http_req_handle.c new file mode 100644 index 00000000..2b6cadd1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_asyn_http_req_handle.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_asyn_http_req_handle_t)(asyn_http_req_t* request, VMINT* handle); +_vm_get_asyn_http_req_handle_t _vm_get_asyn_http_req_handle = NULL; + +VMINT vm_get_asyn_http_req_handle(asyn_http_req_t* request, VMINT* handle) +{ + if (NULL == _vm_get_asyn_http_req_handle) + _vm_get_asyn_http_req_handle = (_vm_get_asyn_http_req_handle_t)vm_get_sym_entry("vm_get_asyn_http_req_handle"); + + if (NULL != _vm_get_asyn_http_req_handle) + return _vm_get_asyn_http_req_handle(request,handle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_battery_level.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_battery_level.c new file mode 100644 index 00000000..f30ef1d9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_battery_level.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_battery_level_t)(void) ; +_vm_get_battery_level_t _vm_get_battery_level = NULL; + +VMINT vm_get_battery_level(void) +{ + if (NULL == _vm_get_battery_level) + _vm_get_battery_level = (_vm_get_battery_level_t)vm_get_sym_entry("vm_get_battery_level"); + + if (NULL != _vm_get_battery_level) + return _vm_get_battery_level(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_cache_free_space.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_cache_free_space.c new file mode 100644 index 00000000..c7f25367 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_cache_free_space.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_cache_free_space_t)(vm_cache_t *cache); +_vm_get_cache_free_space_t _vm_get_cache_free_space = NULL; + +VMINT vm_get_cache_free_space(vm_cache_t *cache) +{ + if (NULL == _vm_get_cache_free_space) + _vm_get_cache_free_space = (_vm_get_cache_free_space_t)vm_get_sym_entry("vm_get_cache_free_space"); + + if (NULL != _vm_get_cache_free_space) + return _vm_get_cache_free_space(cache); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_curr_utc.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_curr_utc.c new file mode 100644 index 00000000..53568ea0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_curr_utc.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_curr_utc_t)(VMUINT * utc); +_vm_get_curr_utc_t _vm_get_curr_utc = NULL; +VMINT vm_get_curr_utc(VMUINT * utc) +{ + if (_vm_get_curr_utc == NULL) + _vm_get_curr_utc = (_vm_get_curr_utc_t)vm_get_sym_entry("vm_get_curr_utc"); + + if (_vm_get_curr_utc != NULL) + return _vm_get_curr_utc(utc); + + return -1; + +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_current_lang_country_code.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_current_lang_country_code.c new file mode 100644 index 00000000..752462a5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_current_lang_country_code.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmchset.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUSTR (*_vm_get_current_lang_country_code_t)(void); +_vm_get_current_lang_country_code_t _vm_get_current_lang_country_code = NULL; + +VMUSTR vm_get_current_lang_country_code(void) +{ + if (NULL == _vm_get_current_lang_country_code) + _vm_get_current_lang_country_code = (_vm_get_current_lang_country_code_t)vm_get_sym_entry("vm_get_current_lang_country_code"); + + if (NULL != _vm_get_current_lang_country_code) + return _vm_get_current_lang_country_code(); + + return (VMUSTR)NULL; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_cust_apn_info.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_cust_apn_info.c new file mode 100644 index 00000000..6d690449 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_cust_apn_info.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_cust_apn_info_t)(vm_dtcnt_info_t * info); +_vm_get_cust_apn_info_t _vm_get_cust_apn_info = NULL; + +VMINT vm_get_cust_apn_info(vm_dtcnt_info_t * info) +{ + if (NULL == _vm_get_cust_apn_info) + _vm_get_cust_apn_info = (_vm_get_cust_apn_info_t)vm_get_sym_entry("vm_get_cust_apn_info"); + + if (NULL != _vm_get_cust_apn_info) + return _vm_get_cust_apn_info(info); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_customer_name.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_customer_name.c new file mode 100644 index 00000000..e6a763a3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_customer_name.c @@ -0,0 +1,22 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_get_customer_name_t)(VMCHAR *value, VMUINT len); +_vm_get_customer_name_t _vm_get_customer_name = NULL; + +VMUINT vm_get_customer_name(VMCHAR *value, VMUINT len) +{ + if (_vm_get_customer_name == NULL) + { + _vm_get_customer_name = (_vm_get_customer_name_t) vm_get_sym_entry("vm_get_customer_name"); + } + + if (_vm_get_customer_name != NULL) + { + return _vm_get_customer_name(value, len); + } + + return (VMUINT) 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_default_apn_info.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_default_apn_info.c new file mode 100644 index 00000000..32c554ae --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_default_apn_info.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_default_apn_info_t)(vm_apn_info_ext *apn_info); +_vm_get_default_apn_info_t _vm_get_default_apn_info = NULL; + +VMINT vm_get_default_apn_info( vm_apn_info_ext *apn_info) +{ + if (NULL == _vm_get_default_apn_info) + _vm_get_default_apn_info = (_vm_get_default_apn_info_t)vm_get_sym_entry("vm_get_default_apn_info"); + + if (NULL != _vm_get_default_apn_info) + return _vm_get_default_apn_info(apn_info); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_default_folder_path.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_default_folder_path.c new file mode 100644 index 00000000..2c8cdf2f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_default_folder_path.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef const VMWCHAR * (*_vm_get_default_folder_path_t)(vm_fmgr_default_folder_enum type); +_vm_get_default_folder_path_t _vm_get_default_folder_path = NULL; + +const VMWCHAR * vm_get_default_folder_path(vm_fmgr_default_folder_enum type) +{ + if (NULL == _vm_get_default_folder_path) + _vm_get_default_folder_path = (_vm_get_default_folder_path_t)vm_get_sym_entry("vm_get_default_folder_path"); + + if (NULL != _vm_get_default_folder_path) + return _vm_get_default_folder_path(type); + return NULL; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_disk_free_space.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_disk_free_space.c new file mode 100644 index 00000000..f1272f9b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_disk_free_space.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_get_disk_free_space_t)(VMWSTR drv_name); +_vm_get_disk_free_space_t _vm_get_disk_free_space = NULL; + +VMUINT vm_get_disk_free_space(VMWSTR drv_name) +{ + if (NULL == _vm_get_disk_free_space) + _vm_get_disk_free_space = (_vm_get_disk_free_space_t)vm_get_sym_entry("vm_get_disk_free_space"); + + if (NULL != _vm_get_disk_free_space) + return _vm_get_disk_free_space(drv_name); + + return (VMUINT )0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_disk_info.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_disk_info.c new file mode 100644 index 00000000..6ff53939 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_disk_info.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_disk_info_t)(const VMCHAR * drv_name, vm_fs_disk_info * fs_disk, vm_fs_di_enum e_di); +_vm_get_disk_info_t _vm_get_disk_info = NULL; + +VMINT vm_get_disk_info(const VMCHAR * drv_name, vm_fs_disk_info * fs_disk, vm_fs_di_enum e_di) +{ + if (NULL == _vm_get_disk_info) + _vm_get_disk_info = (_vm_get_disk_info_t)vm_get_sym_entry("vm_get_disk_info"); + + if (NULL != _vm_get_disk_info) + return _vm_get_disk_info(drv_name,fs_disk,e_di); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_encoded_dtacct_id.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_encoded_dtacct_id.c new file mode 100644 index 00000000..336e2d6d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_encoded_dtacct_id.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_encoded_dtacct_id_t)(VMINT apn, VMUINT * dtacct_id); +_vm_get_encoded_dtacct_id_t _vm_get_encoded_dtacct_id = NULL; + +VMINT vm_get_encoded_dtacct_id(VMINT apn, VMUINT * dtacct_id) +{ + if (NULL == _vm_get_encoded_dtacct_id) + _vm_get_encoded_dtacct_id = (_vm_get_encoded_dtacct_id_t)vm_get_sym_entry("vm_get_encoded_dtacct_id"); + + if (NULL != _vm_get_encoded_dtacct_id) + return _vm_get_encoded_dtacct_id(apn,dtacct_id); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_exec_filename.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_exec_filename.c new file mode 100644 index 00000000..4fcc2f62 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_exec_filename.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_exec_filename_t)(VMWSTR filename); +_vm_get_exec_filename_t _vm_get_exec_filename = NULL; + +VMINT vm_get_exec_filename(VMWSTR filename) +{ + if (NULL == _vm_get_exec_filename) + _vm_get_exec_filename = (_vm_get_exec_filename_t)vm_get_sym_entry("vm_get_exec_filename"); + + if (NULL != _vm_get_exec_filename) + return _vm_get_exec_filename(filename); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_filename.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_filename.c new file mode 100644 index 00000000..a937f920 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_filename.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_get_filename_t)(VMWSTR path, VMWSTR filename); +_vm_get_filename_t _vm_get_filename = NULL; + +void vm_get_filename(VMWSTR path, VMWSTR filename) +{ + if (NULL == _vm_get_filename) + _vm_get_filename = (_vm_get_filename_t)vm_get_sym_entry("vm_get_filename"); + + if (NULL != _vm_get_filename) + _vm_get_filename(path,filename); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_full_path_by_short_name.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_full_path_by_short_name.c new file mode 100644 index 00000000..d2e66a50 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_full_path_by_short_name.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_full_path_by_short_name_t)(VMWSTR short_name, VMWSTR full_path); +_vm_get_full_path_by_short_name_t _vm_get_full_path_by_short_name = NULL; +VMINT vm_get_full_path_by_short_name(VMWSTR short_name, VMWSTR full_path) +{ + if (_vm_get_full_path_by_short_name == NULL) + _vm_get_full_path_by_short_name = (_vm_get_full_path_by_short_name_t)vm_get_sym_entry("vm_get_full_path_by_short_name"); + if (_vm_get_full_path_by_short_name != NULL) + return _vm_get_full_path_by_short_name(short_name, full_path); + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_imei.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_imei.c new file mode 100644 index 00000000..d74bee55 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_imei.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMSTR (*_vm_get_imei_t)(void); +_vm_get_imei_t _vm_get_imei = NULL; + +VMSTR vm_get_imei(void) +{ + if (NULL == _vm_get_imei) + _vm_get_imei = (_vm_get_imei_t)vm_get_sym_entry("vm_get_imei"); + + if (NULL != _vm_get_imei) + return _vm_get_imei(); + + return (VMSTR )NULL; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_imei_ext.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_imei_ext.c new file mode 100644 index 00000000..e1fab049 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_imei_ext.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMSTR (*_vm_get_imei_ext_t)(VMINT sim); +_vm_get_imei_ext_t _vm_get_imei_ext = NULL; + +VMSTR vm_get_imei_ext(VMINT sim) +{ + if (NULL == _vm_get_imei_ext) + _vm_get_imei_ext = (_vm_get_imei_ext_t)vm_get_sym_entry("vm_get_imei_ext"); + + if (NULL != _vm_get_imei_ext) + return _vm_get_imei_ext(sim); + + return (VMSTR )NULL; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_imsi.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_imsi.c new file mode 100644 index 00000000..b2fbdd7a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_imsi.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMSTR (*_vm_get_imsi_t)(void); +_vm_get_imsi_t _vm_get_imsi = NULL; + +VMSTR vm_get_imsi(void) +{ + if (NULL == _vm_get_imsi) + _vm_get_imsi = (_vm_get_imsi_t)vm_get_sym_entry("vm_get_imsi"); + + if (NULL != _vm_get_imsi) + return _vm_get_imsi(); + + return (VMSTR )NULL; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_language.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_language.c new file mode 100644 index 00000000..b214356e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_language.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmchset.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_language_t (*_vm_get_language_t)(void); +_vm_get_language_t _vm_get_language = NULL; + +vm_language_t vm_get_language(void) +{ + vm_language_t ret = {-1}; + if (NULL == _vm_get_language) + _vm_get_language = (_vm_get_language_t)vm_get_sym_entry("vm_get_language"); + + if (NULL != _vm_get_language) + return _vm_get_language(); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_language_ssc.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_language_ssc.c new file mode 100644 index 00000000..c943cdac --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_language_ssc.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmchset.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_get_language_ssc_t)(VMINT8 *ssc); +_vm_get_language_ssc_t _vm_get_language_ssc = NULL; + +VMINT32 vm_get_language_ssc(VMINT8 *ssc) +{ + if (NULL == _vm_get_language_ssc) + _vm_get_language_ssc = (_vm_get_language_ssc_t)vm_get_sym_entry("vm_get_language_ssc"); + + if (NULL != _vm_get_language_ssc) + return _vm_get_language_ssc(ssc); + + return (VMINT32 )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_malloc_stat.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_malloc_stat.c new file mode 100644 index 00000000..ed7f8c1b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_malloc_stat.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef malloc_stat_t* (*_vm_get_malloc_stat_t)(void); +_vm_get_malloc_stat_t _vm_get_malloc_stat = NULL; + +malloc_stat_t* vm_get_malloc_stat(void) +{ + if (NULL == _vm_get_malloc_stat) + _vm_get_malloc_stat = (_vm_get_malloc_stat_t)vm_get_sym_entry("vm_get_malloc_stat"); + + if (NULL != _vm_get_malloc_stat) + return _vm_get_malloc_stat(); + + return (malloc_stat_t* )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_modules.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_modules.c new file mode 100644 index 00000000..ca80bd4e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_modules.c @@ -0,0 +1,18 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_modules_t)(vm_module_struct *modules, VMUINT size); +_vm_get_modules_t _vm_get_modules = NULL; + +VMINT vm_get_modules(vm_module_struct *modules, VMUINT size) +{ + if (NULL == _vm_get_modules) + _vm_get_modules = (_vm_get_modules_t)vm_get_sym_entry("vm_get_modules"); + + if (NULL != _vm_get_modules) + return _vm_get_modules(modules,size); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_mre_modules.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_mre_modules.c new file mode 100644 index 00000000..7bd5e5dc --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_mre_modules.c @@ -0,0 +1,18 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_mre_modules_t)(vm_module_struct *modules, VMUINT size); +_vm_get_mre_modules_t _vm_get_mre_modules = NULL; + +VMINT vm_get_mre_modules(vm_module_struct *modules, VMUINT size) +{ + if (NULL == _vm_get_mre_modules) + _vm_get_mre_modules = (_vm_get_mre_modules_t)vm_get_sym_entry("vm_get_mre_modules"); + + if (NULL != _vm_get_mre_modules) + return _vm_get_mre_modules(modules,size); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_mre_total_mem_size.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_mre_total_mem_size.c new file mode 100644 index 00000000..86581665 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_mre_total_mem_size.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_get_mre_total_mem_size_t)(void); +_vm_get_mre_total_mem_size_t _vm_get_mre_total_mem_size = NULL; + +VMUINT vm_get_mre_total_mem_size(void) +{ + if (NULL == _vm_get_mre_total_mem_size) + _vm_get_mre_total_mem_size = (_vm_get_mre_total_mem_size_t)vm_get_sym_entry("vm_get_mre_total_mem_size"); + + if (NULL != _vm_get_mre_total_mem_size) + return _vm_get_mre_total_mem_size(); + + return (VMUINT )0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_mre_version.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_mre_version.c new file mode 100644 index 00000000..5a723e07 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_mre_version.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_get_mre_version_t)(void); +_vm_get_mre_version_t _vm_get_mre_version = NULL; + +VMUINT vm_get_mre_version(void) +{ + if (NULL == _vm_get_mre_version) + _vm_get_mre_version = (_vm_get_mre_version_t)vm_get_sym_entry("vm_get_mre_version"); + + if (NULL != _vm_get_mre_version) + return _vm_get_mre_version(); + + return (VMUINT )0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_multi_tags.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_multi_tags.c new file mode 100644 index 00000000..01fa02ff --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_multi_tags.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmgettag.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_multi_tags_t)( short* filename, MULTI_TAG * tag_req); +_vm_get_multi_tags_t _vm_get_multi_tags = NULL; + +VMINT vm_get_multi_tags( short* filename, MULTI_TAG * tag_req) +{ + if (NULL == _vm_get_multi_tags) + _vm_get_multi_tags = (_vm_get_multi_tags_t)vm_get_sym_entry("vm_get_multi_tags"); + + if (NULL != _vm_get_multi_tags) + return _vm_get_multi_tags(filename,tag_req); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_multi_tags_by_lang_id.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_multi_tags_by_lang_id.c new file mode 100644 index 00000000..afa5e691 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_multi_tags_by_lang_id.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmgettag.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_multi_tags_by_lang_id_t)( short* filename, MULTI_TAG * tag_req, int lang_id ); +_vm_get_multi_tags_by_lang_id_t _vm_get_multi_tags_by_lang_id = NULL; + +VMINT vm_get_multi_tags_by_lang_id( short* filename, MULTI_TAG * tag_req, int lang_id ) +{ + if (NULL == _vm_get_multi_tags_by_lang_id) + _vm_get_multi_tags_by_lang_id = (_vm_get_multi_tags_by_lang_id_t)vm_get_sym_entry("vm_get_multi_tags_by_lang_id"); + + if (NULL != _vm_get_multi_tags_by_lang_id) + return _vm_get_multi_tags_by_lang_id(filename,tag_req,lang_id); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_operator.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_operator.c new file mode 100644 index 00000000..ffc5d18b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_operator.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef operator_t (*_vm_get_operator_t)(void); +_vm_get_operator_t _vm_get_operator = NULL; + +operator_t vm_get_operator(void) +{ + operator_t ret = {-1}; + if (NULL == _vm_get_operator) + _vm_get_operator = (_vm_get_operator_t)vm_get_sym_entry("vm_get_operator"); + + if (NULL != _vm_get_operator) + return _vm_get_operator(); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_origin_release_verno.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_origin_release_verno.c new file mode 100644 index 00000000..76c1eed3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_origin_release_verno.c @@ -0,0 +1,22 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_get_origin_release_verno_t)(VMCHAR *value, VMUINT len); +_vm_get_origin_release_verno_t _vm_get_origin_release_verno = NULL; + +VMUINT vm_get_origin_release_verno(VMCHAR *value, VMUINT len) +{ + if (_vm_get_origin_release_verno == NULL) + { + _vm_get_origin_release_verno = (_vm_get_origin_release_verno_t) vm_get_sym_entry("vm_get_origin_release_verno"); + } + + if (_vm_get_origin_release_verno != NULL) + { + return _vm_get_origin_release_verno(value, len); + } + + return (VMUINT) 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_path.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_path.c new file mode 100644 index 00000000..133d9741 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_path.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_path_t)(VMWSTR fullpath, VMWSTR path); +_vm_get_path_t _vm_get_path = NULL; + +VMINT vm_get_path(VMWSTR fullpath, VMWSTR path) +{ + if (NULL == _vm_get_path) + _vm_get_path = (_vm_get_path_t)vm_get_sym_entry("vm_get_path"); + + if (NULL != _vm_get_path) + return _vm_get_path(fullpath,path); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_removable_driver.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_removable_driver.c new file mode 100644 index 00000000..4cee9fce --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_removable_driver.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_removeable_driver_t)(void); +_vm_get_removeable_driver_t _vm_get_removeable_driver = NULL; + + +VMINT vm_get_removeable_driver(void) { + if (_vm_get_removeable_driver == NULL) + _vm_get_removeable_driver = (_vm_get_removeable_driver_t)vm_get_sym_entry("vm_get_removeable_driver"); + + if (_vm_get_removeable_driver != NULL) + return _vm_get_removeable_driver(); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_res_header.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_res_header.c new file mode 100644 index 00000000..8f507284 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_res_header.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmres.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_res_header_t)(void); +_vm_get_res_header_t _vm_get_res_header = NULL; + +VMINT vm_get_res_header(void) +{ + if (NULL == _vm_get_res_header) + _vm_get_res_header = (_vm_get_res_header_t)vm_get_sym_entry("vm_get_res_header"); + + if (NULL != _vm_get_res_header) + return _vm_get_res_header(); + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_resource_offset.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_resource_offset.c new file mode 100644 index 00000000..5ec9e4c0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_resource_offset.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmres.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_get_resource_offset_t)(char* res_name); +_vm_get_resource_offset_t _vm_get_resource_offset = NULL; + +VMUINT vm_get_resource_offset(char *res_name) +{ + if (NULL == _vm_get_resource_offset) + _vm_get_resource_offset = (_vm_get_resource_offset_t)vm_get_sym_entry("vm_get_resource_offset"); + + if (NULL != _vm_get_resource_offset) + return _vm_get_resource_offset(res_name); + + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_resource_offset_from_file.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_resource_offset_from_file.c new file mode 100644 index 00000000..37a368ab --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_resource_offset_from_file.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmres.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_get_resource_offset_from_file_t)(VMWSTR filename, char *res_name); +_vm_get_resource_offset_from_file_t _vm_get_resource_offset_from_file = NULL; + +VMUINT vm_get_resource_offset_from_file(VMWSTR filename, char *res_name) +{ + if (NULL == _vm_get_resource_offset_from_file) + _vm_get_resource_offset_from_file = (_vm_get_resource_offset_from_file_t)vm_get_sym_entry("vm_get_resource_offset_from_file"); + + if (NULL != _vm_get_resource_offset_from_file) + return _vm_get_resource_offset_from_file(filename, res_name); + + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_rtc.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_rtc.c new file mode 100644 index 00000000..ea371755 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_rtc.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_rtc_t)(VMUINT * rtc); +_vm_get_rtc_t _vm_get_rtc = NULL; +VMINT vm_get_rtc(VMUINT * rtc) +{ + if (_vm_get_rtc == NULL) + _vm_get_rtc = (_vm_get_rtc_t)vm_get_sym_entry("vm_get_rtc"); + + if (_vm_get_rtc != NULL) + return _vm_get_rtc(rtc); + + return -1; + +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_sim_card_status.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_sim_card_status.c new file mode 100644 index 00000000..71ebae39 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_sim_card_status.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_sim_state_t (*_vm_get_sim_card_status_t)(VMINT card_id); +_vm_get_sim_card_status_t _vm_get_sim_card_status = NULL; + +vm_sim_state_t vm_get_sim_card_status(VMINT card_id) +{ + vm_sim_state_t ret = {-1}; + if (NULL == _vm_get_sim_card_status) + _vm_get_sim_card_status = (_vm_get_sim_card_status_t)vm_get_sym_entry("vm_get_sim_card_status"); + + if (NULL != _vm_get_sim_card_status) + return _vm_get_sim_card_status(card_id); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_sys_property.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_sys_property.c new file mode 100644 index 00000000..6c5a5bef --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_sys_property.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_get_sys_property_t)(const VMINT key, VMCHAR* value, VMUINT len); +_vm_get_sys_property_t _vm_get_sys_property = NULL; + +VMUINT vm_get_sys_property(const VMINT key, VMCHAR* value, VMUINT len) +{ + if (NULL == _vm_get_sys_property) + _vm_get_sys_property = (_vm_get_sys_property_t)vm_get_sym_entry("vm_get_sys_property"); + + if (NULL != _vm_get_sys_property) + return _vm_get_sys_property(key,value,len); + + return (VMUINT )0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_sys_scene.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_sys_scene.c new file mode 100644 index 00000000..a625eea1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_sys_scene.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_sys_scene_t)(void); +_vm_get_sys_scene_t _vm_get_sys_scene = NULL; + +VMINT vm_get_sys_scene(void) +{ + if (NULL == _vm_get_sys_scene) + _vm_get_sys_scene = (_vm_get_sys_scene_t)vm_get_sym_entry("vm_get_sys_scene"); + + if (NULL != _vm_get_sys_scene) + return _vm_get_sys_scene(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_sys_time_zone.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_sys_time_zone.c new file mode 100644 index 00000000..aff8bb0f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_sys_time_zone.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef float (*_vm_get_sys_time_zone_t)(void); +_vm_get_sys_time_zone_t _vm_get_sys_time_zone = NULL; + +float vm_get_sys_time_zone(void) +{ + float ret = {-1}; + if (NULL == _vm_get_sys_time_zone) + _vm_get_sys_time_zone = (_vm_get_sys_time_zone_t)vm_get_sym_entry("vm_get_sys_time_zone"); + + if (NULL != _vm_get_sys_time_zone) + return _vm_get_sys_time_zone(); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_system_driver.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_system_driver.c new file mode 100644 index 00000000..e8ce550e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_system_driver.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_system_driver_t)(void); +_vm_get_system_driver_t _vm_get_system_driver = NULL; + +VMINT vm_get_system_driver(void) +{ + if (NULL == _vm_get_system_driver) + _vm_get_system_driver = (_vm_get_system_driver_t)vm_get_sym_entry("vm_get_system_driver"); + + if (NULL != _vm_get_system_driver) + return _vm_get_system_driver(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_tag_by_lang_id.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_tag_by_lang_id.c new file mode 100644 index 00000000..0f02d198 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_tag_by_lang_id.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmgettag.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_tag_by_lang_id_t)( short* filename, int tag_num, void* buf, int* buf_size, int lang_id ); +_vm_get_tag_by_lang_id_t _vm_get_tag_by_lang_id = NULL; + +VMINT vm_get_tag_by_lang_id( short* filename, int tag_num, void* buf, int* buf_size, int lang_id ) +{ + if (NULL == _vm_get_tag_by_lang_id) + _vm_get_tag_by_lang_id = (_vm_get_tag_by_lang_id_t)vm_get_sym_entry("vm_get_tag_by_lang_id"); + + if (NULL != _vm_get_tag_by_lang_id) + return _vm_get_tag_by_lang_id(filename,tag_num,buf,buf_size,lang_id); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_tick_count.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_tick_count.c new file mode 100644 index 00000000..7eb5ad58 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_tick_count.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_tick_count_t)(void); +_vm_get_tick_count_t _vm_get_tick_count = NULL; + +VMINT vm_get_tick_count(void) +{ + if (NULL == _vm_get_tick_count) + _vm_get_tick_count = (_vm_get_tick_count_t)vm_get_sym_entry("vm_get_tick_count"); + + if (NULL != _vm_get_tick_count) + return _vm_get_tick_count(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_time.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_time.c new file mode 100644 index 00000000..555865e2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_time.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_time_t)(vm_time_t* time); +_vm_get_time_t _vm_get_time = NULL; + +VMINT vm_get_time(vm_time_t* time) +{ + if (NULL == _vm_get_time) + _vm_get_time = (_vm_get_time_t)vm_get_sym_entry("vm_get_time"); + + if (NULL != _vm_get_time) + return _vm_get_time(time); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_total_mem_size.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_total_mem_size.c new file mode 100644 index 00000000..cb19d505 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_total_mem_size.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_get_total_mem_size_t)(void); +_vm_get_total_mem_size_t _vm_get_total_mem_size = NULL; + +VMUINT vm_get_total_mem_size(void) +{ + if (NULL == _vm_get_total_mem_size) + _vm_get_total_mem_size = (_vm_get_total_mem_size_t)vm_get_sym_entry("vm_get_total_mem_size"); + + if (NULL != _vm_get_total_mem_size) + return _vm_get_total_mem_size(); + + return (VMUINT )0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_version.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_version.c new file mode 100644 index 00000000..e4751f8a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_version.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_get_version_t)(void); +_vm_get_version_t _vm_get_version = NULL; + +VMUINT vm_get_version(void) +{ + if (NULL == _vm_get_version) + _vm_get_version = (_vm_get_version_t)vm_get_sym_entry("vm_get_version"); + + if (NULL != _vm_get_version) + return _vm_get_version(); + + return (VMUINT )0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_vm_tag.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_vm_tag.c new file mode 100644 index 00000000..ca2bd4d8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_vm_tag.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmgettag.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_vm_tag_t)(short* filename,int tag_num, void* buf ,int* buf_size); +_vm_get_vm_tag_t _vm_get_vm_tag = NULL; + +VMINT vm_get_vm_tag(short* filename,int tag_num, void* buf ,int* buf_size) +{ + if (NULL == _vm_get_vm_tag) + _vm_get_vm_tag = (_vm_get_vm_tag_t)vm_get_sym_entry("vm_get_vm_tag"); + + if (NULL != _vm_get_vm_tag) + return _vm_get_vm_tag(filename,tag_num,buf ,buf_size); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_volume.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_volume.c new file mode 100644 index 00000000..253255dd --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_get_volume.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_get_volume_t)(void); +_vm_get_volume_t _vm_get_volume = NULL; + +VMINT vm_get_volume(void) +{ + if (NULL == _vm_get_volume) + _vm_get_volume = (_vm_get_volume_t)vm_get_sym_entry("vm_get_volume"); + + if (NULL != _vm_get_volume) + return _vm_get_volume(); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_getpeername.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_getpeername.c new file mode 100644 index 00000000..55434b1c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_getpeername.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_getpeername_t)(int s, SOCKADDR *addr, int *len); +_vm_getpeername_t _vm_getpeername = NULL; + +int vm_getpeername(int s, SOCKADDR *addr, int *len) +{ + if (NULL == _vm_getpeername) + _vm_getpeername = (_vm_getpeername_t)vm_get_sym_entry("vm_getpeername"); + if (NULL != _vm_getpeername) + return _vm_getpeername(s,addr,len); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_getsockname.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_getsockname.c new file mode 100644 index 00000000..1625f166 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_getsockname.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_getsockname_t)(int s, SOCKADDR *addr, int *len); +_vm_getsockname_t _vm_getsockname = NULL; + +int vm_getsockname(int s, SOCKADDR *addr, int *len) +{ + if (NULL == _vm_getsockname) + _vm_getsockname = (_vm_getsockname_t)vm_get_sym_entry("vm_getsockname"); + if (NULL != _vm_getsockname) + return _vm_getsockname(s,addr,len); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_getsockopt.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_getsockopt.c new file mode 100644 index 00000000..0e5097bc --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_getsockopt.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_getsockopt_t)(int sock, VMUINT32 option, void *val, VMUINT8 val_size); +_vm_getsockopt_t _vm_getsockopt = NULL; + +int vm_getsockopt(int sock, VMUINT32 option, void *val, VMUINT8 val_size) +{ + if (NULL == _vm_getsockopt) + _vm_getsockopt = (_vm_getsockopt_t)vm_get_sym_entry("vm_getsockopt"); + if (NULL != _vm_getsockopt) + return _vm_getsockopt(sock,option,val,val_size); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_global_free.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_global_free.c new file mode 100644 index 00000000..9c46d4d2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_global_free.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_global_free_t)(void* ptr); +_vm_global_free_t _vm_global_free = NULL; + +void vm_global_free(void* ptr) +{ + if (NULL == _vm_global_free) + _vm_global_free = (_vm_global_free_t)vm_get_sym_entry("vm_global_free"); + + if (NULL != _vm_global_free) + _vm_global_free(ptr); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_global_get_max_alloc_size.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_global_get_max_alloc_size.c new file mode 100644 index 00000000..a2390764 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_global_get_max_alloc_size.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_global_get_max_alloc_size_t)(void); +_vm_global_get_max_alloc_size_t _vm_global_get_max_alloc_size = NULL; + +VMINT vm_global_get_max_alloc_size(void) +{ + if (NULL == _vm_global_get_max_alloc_size) + _vm_global_get_max_alloc_size = (_vm_global_get_max_alloc_size_t)vm_get_sym_entry("vm_global_get_max_alloc_size"); + + if (NULL != _vm_global_get_max_alloc_size) + return _vm_global_get_max_alloc_size(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_global_malloc.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_global_malloc.c new file mode 100644 index 00000000..ca68aba5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_global_malloc.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void *(*_vm_global_malloc_t)(unsigned int size); +_vm_global_malloc_t _vm_global_malloc = NULL; + +void *vm_global_malloc(unsigned int size) +{ + if (NULL == _vm_global_malloc) + _vm_global_malloc = (_vm_global_malloc_t)vm_get_sym_entry("vm_global_malloc"); + + if (NULL != _vm_global_malloc) + return _vm_global_malloc(size); + + return NULL; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gps_close.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gps_close.c new file mode 100644 index 00000000..f1110233 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gps_close.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmgps.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_gps_close_t)(void); +_vm_gps_close_t _vm_gps_close = NULL; + +VMINT vm_gps_close(void) +{ + if (NULL == _vm_gps_close) + _vm_gps_close = (_vm_gps_close_t)vm_get_sym_entry("vm_gps_close"); + + if (NULL != _vm_gps_close) + return _vm_gps_close(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gps_open.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gps_open.c new file mode 100644 index 00000000..60854f6f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gps_open.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmgps.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_gps_open_t)(VMUINT period, vm_gps_type_enum type, VM_GPS_CAlLBACK_FUNC callback); +_vm_gps_open_t _vm_gps_open = NULL; + +VMINT vm_gps_open(VMUINT period, vm_gps_type_enum type, VM_GPS_CAlLBACK_FUNC callback) +{ + if (NULL == _vm_gps_open) + _vm_gps_open = (_vm_gps_open_t)vm_get_sym_entry("vm_gps_open"); + + if (NULL != _vm_gps_open) + return _vm_gps_open(period, type, callback); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gps_set_mode.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gps_set_mode.c new file mode 100644 index 00000000..71f3c822 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_gps_set_mode.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmgps.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_gps_set_mode_t)(vm_gps_mode_enum mode); +_vm_gps_set_mode_t _vm_gps_set_mode = NULL; + +VMINT vm_gps_set_mode(vm_gps_mode_enum mode) +{ + if (NULL == _vm_gps_set_mode) + _vm_gps_set_mode = (_vm_gps_set_mode_t)vm_get_sym_entry("vm_gps_set_mode"); + + if (NULL != _vm_gps_set_mode) + return _vm_gps_set_mode(mode); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_has_sim_card.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_has_sim_card.c new file mode 100644 index 00000000..48aa1910 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_has_sim_card.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_has_sim_card_t)(void); +_vm_has_sim_card_t _vm_has_sim_card = NULL; + +VMINT vm_has_sim_card(void) +{ + if (NULL == _vm_has_sim_card) + _vm_has_sim_card = (_vm_has_sim_card_t)vm_get_sym_entry("vm_has_sim_card"); + + if (NULL != _vm_has_sim_card) + return _vm_has_sim_card(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_htonl.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_htonl.c new file mode 100644 index 00000000..c4f42f2a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_htonl.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT32 (*_vm_htonl_t)(VMUINT32 a); +_vm_htonl_t _vm_htonl = NULL; + +VMUINT32 vm_htonl(VMUINT32 a) +{ + if (NULL == _vm_htonl) + _vm_htonl = (_vm_htonl_t)vm_get_sym_entry("vm_htonl"); + if (NULL != _vm_htonl) + return _vm_htonl(a); + return (VMUINT32)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_htons.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_htons.c new file mode 100644 index 00000000..8df484d0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_htons.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT16 (*_vm_htons_t)(VMUINT16 a); +_vm_htons_t _vm_htons = NULL; + +VMUINT16 vm_htons(VMUINT16 a) +{ + if (NULL == _vm_htons) + _vm_htons = (_vm_htons_t)vm_get_sym_entry("vm_htons"); + if (NULL != _vm_htons) + return _vm_htons(a); + return (VMUINT16)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_add_header.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_add_header.c new file mode 100644 index 00000000..3271fee5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_add_header.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_http_add_header_t)(VMINT handle, VMCHAR* name, VMCHAR* value); +_vm_http_add_header_t _vm_http_add_header = NULL; + +VMINT vm_http_add_header(VMINT handle, VMCHAR* name, VMCHAR* value) +{ + if (NULL == _vm_http_add_header) + _vm_http_add_header = (_vm_http_add_header_t)vm_get_sym_entry("vm_http_add_header"); + + if (NULL != _vm_http_add_header) + return _vm_http_add_header(handle,name,value); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_fetch_handle.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_fetch_handle.c new file mode 100644 index 00000000..4efde0c0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_fetch_handle.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_http_fetch_handle_t)(VMINT type, void* p); +_vm_http_fetch_handle_t _vm_http_fetch_handle = NULL; + +VMINT vm_http_fetch_handle(VMINT type, void* p) +{ + if (NULL == _vm_http_fetch_handle) + _vm_http_fetch_handle = (_vm_http_fetch_handle_t)vm_get_sym_entry("vm_http_fetch_handle"); + + if (NULL != _vm_http_fetch_handle) + return _vm_http_fetch_handle(type,p); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_free_handle.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_free_handle.c new file mode 100644 index 00000000..d95c14de --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_free_handle.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_http_free_handle_t)(VMINT handle); +_vm_http_free_handle_t _vm_http_free_handle = NULL; + +void vm_http_free_handle(VMINT handle) +{ + if (NULL == _vm_http_free_handle) + _vm_http_free_handle = (_vm_http_free_handle_t)vm_get_sym_entry("vm_http_free_handle"); + + if (NULL != _vm_http_free_handle) + _vm_http_free_handle(handle); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_get_current_handle.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_get_current_handle.c new file mode 100644 index 00000000..9e98aae3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_get_current_handle.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_http_get_current_handle_t)(void); +_vm_http_get_current_handle_t _vm_http_get_current_handle = NULL; + +VMINT vm_http_get_current_handle(void) +{ + if (NULL == _vm_http_get_current_handle) + _vm_http_get_current_handle = (_vm_http_get_current_handle_t)vm_get_sym_entry("vm_http_get_current_handle"); + + if (NULL != _vm_http_get_current_handle) + return _vm_http_get_current_handle(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_recv_data.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_recv_data.c new file mode 100644 index 00000000..d69e2d0d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_recv_data.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_http_recv_data_t)(VMINT handle, VMUINT8* data, VMINT len); +_vm_http_recv_data_t _vm_http_recv_data = NULL; + +VMINT vm_http_recv_data(VMINT handle, VMUINT8* data, VMINT len) +{ + if (NULL == _vm_http_recv_data) + _vm_http_recv_data = (_vm_http_recv_data_t)vm_get_sym_entry("vm_http_recv_data"); + + if (NULL != _vm_http_recv_data) + return _vm_http_recv_data(handle,data,len); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_reg_receiver.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_reg_receiver.c new file mode 100644 index 00000000..2bce0adb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_reg_receiver.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_http_reg_receiver_t)(VMINT handle, http_data_receiver reciever); +_vm_http_reg_receiver_t _vm_http_reg_receiver = NULL; + +VMINT vm_http_reg_receiver(VMINT handle, http_data_receiver reciever) +{ + if (NULL == _vm_http_reg_receiver) + _vm_http_reg_receiver = (_vm_http_reg_receiver_t)vm_get_sym_entry("vm_http_reg_receiver"); + + if (NULL != _vm_http_reg_receiver) + return _vm_http_reg_receiver(handle,reciever); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_reg_sender.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_reg_sender.c new file mode 100644 index 00000000..abfe95bd --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_reg_sender.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_http_reg_sender_t)(VMINT handle, http_data_sender sender); +_vm_http_reg_sender_t _vm_http_reg_sender = NULL; + +VMINT vm_http_reg_sender(VMINT handle, http_data_sender sender) +{ + if (NULL == _vm_http_reg_sender) + _vm_http_reg_sender = (_vm_http_reg_sender_t)vm_get_sym_entry("vm_http_reg_sender"); + + if (NULL != _vm_http_reg_sender) + return _vm_http_reg_sender(handle,sender); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_request.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_request.c new file mode 100644 index 00000000..1fcec6b9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_request.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_http_request_t)(http_request_t *request, http_session_t *session); +_vm_http_request_t _vm_http_request = NULL; + +int vm_http_request(http_request_t *request, http_session_t *session) +{ + int ret = {-1}; + if (NULL == _vm_http_request) + _vm_http_request = (_vm_http_request_t)vm_get_sym_entry("vm_http_request"); + + if (NULL != _vm_http_request) + return _vm_http_request(request,session); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_send_data.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_send_data.c new file mode 100644 index 00000000..71e981b2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_send_data.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_http_send_data_t)(VMINT handle, VMUINT8* data, VMINT len); +_vm_http_send_data_t _vm_http_send_data = NULL; + +VMINT vm_http_send_data(VMINT handle, VMUINT8* data, VMINT len) +{ + if (NULL == _vm_http_send_data) + _vm_http_send_data = (_vm_http_send_data_t)vm_get_sym_entry("vm_http_send_data"); + + if (NULL != _vm_http_send_data) + return _vm_http_send_data(handle,data,len); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_set_body.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_set_body.c new file mode 100644 index 00000000..8f86f83b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_set_body.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_http_set_body_t)(VMINT handle, VMUINT8* data, VMINT len); +_vm_http_set_body_t _vm_http_set_body = NULL; + +VMINT vm_http_set_body(VMINT handle, VMUINT8* data, VMINT len) +{ + if (NULL == _vm_http_set_body) + _vm_http_set_body = (_vm_http_set_body_t)vm_get_sym_entry("vm_http_set_body"); + + if (NULL != _vm_http_set_body) + return _vm_http_set_body(handle,data,len); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_set_current_handle.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_set_current_handle.c new file mode 100644 index 00000000..356eaa68 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_set_current_handle.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_http_set_current_handle_t)(VMINT handle); +_vm_http_set_current_handle_t _vm_http_set_current_handle = NULL; + +VMINT vm_http_set_current_handle(VMINT handle) +{ + if (NULL == _vm_http_set_current_handle) + _vm_http_set_current_handle = (_vm_http_set_current_handle_t)vm_get_sym_entry("vm_http_set_current_handle"); + + if (NULL != _vm_http_set_current_handle) + return _vm_http_set_current_handle(handle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_set_url.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_set_url.c new file mode 100644 index 00000000..7d1fbe64 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_http_set_url.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_http_set_url_t)(VMINT handle, VMCHAR* url, VMINT len); +_vm_http_set_url_t _vm_http_set_url = NULL; + +VMINT vm_http_set_url(VMINT handle, VMCHAR* url, VMINT len) +{ + if (NULL == _vm_http_set_url) + _vm_http_set_url = (_vm_http_set_url_t)vm_get_sym_entry("vm_http_set_url"); + + if (NULL != _vm_http_set_url) + return _vm_http_set_url(handle,url,len); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_register_wps_cntxt_and_callback.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_register_wps_cntxt_and_callback.c new file mode 100644 index 00000000..36695126 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_register_wps_cntxt_and_callback.c @@ -0,0 +1,44 @@ +#include "vmsys.h" +#include "vmhttps.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; +typedef VMUINT8 (*_vm_https_register_wps_cntxt_and_callback_t)( + VMINT apn, + wps_send_set_channel_rsp_cb set_channel_rsp_cb, + wps_unset_channel_rsp_cb unset_channel_cb, + wps_send_release_all_req_rsp_cb release_all_req_cb, + wps_send_wps_termination_ind_cb terminal_ind_cb, + wps_send_http_rsp_cb http_rsp_cb, + wps_send_read_content_rsp_cb read_content_rsp_cb, + wps_send_cancel_rsp_cb cancel_rsp_cb, + wps_send_status_query_rsp_cb status_query_rsp_cb); +_vm_https_register_wps_cntxt_and_callback_t _vm_https_register_wps_cntxt_and_callback = NULL; +VMUINT8 vm_https_register_wps_cntxt_and_callback( + VMINT apn, + wps_send_set_channel_rsp_cb set_channel_rsp_cb, + wps_unset_channel_rsp_cb unset_channel_cb, + wps_send_release_all_req_rsp_cb release_all_req_cb, + wps_send_wps_termination_ind_cb terminal_ind_cb, + wps_send_http_rsp_cb http_rsp_cb, + wps_send_read_content_rsp_cb read_content_rsp_cb, + wps_send_cancel_rsp_cb cancel_rsp_cb, + wps_send_status_query_rsp_cb status_query_rsp_cb) +{ + if (_vm_https_register_wps_cntxt_and_callback == NULL) { + _vm_https_register_wps_cntxt_and_callback = (_vm_https_register_wps_cntxt_and_callback_t)vm_get_sym_entry("vm_https_register_wps_cntxt_and_callback"); + } + if (_vm_https_register_wps_cntxt_and_callback != NULL) { + return _vm_https_register_wps_cntxt_and_callback( + apn, + set_channel_rsp_cb, + unset_channel_cb, + release_all_req_cb, + terminal_ind_cb, + http_rsp_cb, + read_content_rsp_cb, + cancel_rsp_cb, + status_query_rsp_cb); + } + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_cancel_req.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_cancel_req.c new file mode 100644 index 00000000..501e74bc --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_cancel_req.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmhttps.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT8 (*_vm_https_send_cancel_req_t)(VMUINT16 request_id); + _vm_https_send_cancel_req_t _vm_https_send_cancel_req = NULL; +VMUINT8 vm_https_send_cancel_req(VMUINT16 request_id) +{ + if (_vm_https_send_cancel_req == NULL) { + _vm_https_send_cancel_req = (_vm_https_send_cancel_req_t)vm_get_sym_entry("vm_https_send_cancel_req"); + } + if (_vm_https_send_cancel_req != NULL) { + return _vm_https_send_cancel_req(request_id); + } + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_post_content_res.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_post_content_res.c new file mode 100644 index 00000000..813fa3ee --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_post_content_res.c @@ -0,0 +1,30 @@ +#include "vmsys.h" +#include "vmhttps.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT8 (*_vm_https_send_post_content_res_t)(VMUINT16 request_id, + VMUINT8 seq_num, + VMBYTE more, + VMUINT32 post_segment_len, + VMUINT8* post_segment); +_vm_https_send_post_content_res_t _vm_https_send_post_content_res = NULL; +VMINT vm_https_send_post_content_res(VMUINT16 request_id, + VMUINT8 seq_num, + VMBYTE more, + VMUINT32 post_segment_len, + VMUINT8* post_segment) +{ + if (_vm_https_send_post_content_res == NULL) { + _vm_https_send_post_content_res = (_vm_https_send_post_content_res_t)vm_get_sym_entry("vm_https_send_post_content_res"); + } + if (_vm_https_send_post_content_res != NULL) { + return _vm_https_send_post_content_res(request_id, + seq_num, + more, + post_segment_len, + post_segment); + } + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_read_content_req.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_read_content_req.c new file mode 100644 index 00000000..b81535c9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_read_content_req.c @@ -0,0 +1,29 @@ +#include "vmsys.h" +#include "vmhttps.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + + +typedef VMUINT8 (*_vm_https_send_read_content_req_t)( + VMUINT16 request_id, + VMUINT8 seq_num, + VMUINT32 read_segnemtn_len); +_vm_https_send_read_content_req_t _vm_https_send_read_content_req = NULL; + +VMUINT8 vm_https_send_read_content_req( + VMUINT16 request_id, + VMUINT8 seq_num, + VMUINT32 read_segnemtn_len) +{ + if (_vm_https_send_read_content_req == NULL) { + _vm_https_send_read_content_req = (_vm_https_send_read_content_req_t)vm_get_sym_entry("vm_https_send_read_content_req"); + } + if (_vm_https_send_read_content_req != NULL) { + return _vm_https_send_read_content_req( + request_id, + seq_num, + read_segnemtn_len); + } + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_req.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_req.c new file mode 100644 index 00000000..6982565c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_req.c @@ -0,0 +1,52 @@ +#include "vmsys.h" +#include "vmhttps.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT8(*_vm_https_send_req_t)( + VMUINT16 request_id, + VMUINT8 method, + VMUINT32 option, + VMUINT8 reply_type, + VMUINT32 reply_segment_len, + VMUINT32 request_url_len, + VMUINT8 *request_url, + VMUINT32 request_header_len, + VMUINT8 *request_header, + VMUINT32 post_segment_len, + VMUINT8 *post_segment); +_vm_https_send_req_t _vm_https_send_req = NULL; + +VMUINT8 vm_https_send_req( + VMUINT16 request_id, + VMUINT8 method, + VMUINT32 option, + VMUINT8 reply_type, + VMUINT32 reply_segment_len, + VMUINT32 request_url_len, + VMUINT8 *request_url, + VMUINT32 request_header_len, + VMUINT8 *request_header, + VMUINT32 post_segment_len, + VMUINT8 *post_segment) +{ + if (_vm_https_send_req == NULL) { + _vm_https_send_req = (_vm_https_send_req_t)vm_get_sym_entry("vm_https_send_req"); + } + if (_vm_https_send_req != NULL) { + return _vm_https_send_req( + request_id, + method, + option, + reply_type, + reply_segment_len, + request_url_len, + request_url, + request_header_len, + request_header, + post_segment_len, + post_segment); + } + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_req_ext.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_req_ext.c new file mode 100644 index 00000000..1ec58070 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_req_ext.c @@ -0,0 +1,44 @@ +#include "vmsys.h" +#include "vmhttps.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_https_send_req_ext_t)(VMUINT16 request_id, + VMUINT8 method, + VMUINT32 option, + VMUINT8 reply_type, + VMUINT32 reply_segment_len, + VMBYTE more_post, + VMUINT8 post_type, + const vm_wps_http_req_var_struct * req, + wps_post_ind_cb cb); +_vm_https_send_req_ext_t _vm_https_send_req_ext = NULL; +VMINT vm_https_send_req_ext(VMUINT16 request_id, + VMUINT8 method, + VMUINT32 option, + VMUINT8 reply_type, + VMUINT32 reply_segment_len, + VMBYTE more_post, + VMUINT8 post_type, + const vm_wps_http_req_var_struct * req, + wps_post_ind_cb cb) +{ + if (_vm_https_send_req_ext == NULL) { + _vm_https_send_req_ext = (_vm_https_send_req_ext_t)vm_get_sym_entry("vm_https_send_req_ext"); + } + if (_vm_https_send_req_ext != NULL) { + return _vm_https_send_req_ext(request_id, + method, + option, + reply_type, + reply_segment_len, + more_post, + post_type, + req, + cb); + } + return -1; +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_set_channel_req.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_set_channel_req.c new file mode 100644 index 00000000..4ce83f3d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_set_channel_req.c @@ -0,0 +1,60 @@ +#include "vmsys.h" +#include "vmhttps.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT8 (*_vm_https_send_set_channel_req_t)( + VMUINT16 req_id, + VMUINT8 use_proxy, + VMUINT8 prx_ip[4], + VMUINT16 prx_port, + VMUINT8 *username, + VMUINT8 username_len, + VMUINT8 *password, + VMUINT8 password_len, + VMUINT8 *server_auth_username, + VMUINT8 server_auth_username_len, + VMUINT8 *server_auth_password, + VMUINT8 server_auth_password_len, + VMUINT32 static_header_len, + VMUINT8 *static_header ); +_vm_https_send_set_channel_req_t _vm_https_send_set_channel_req = NULL; + +VMUINT8 vm_https_send_set_channel_req(VMUINT16 req_id, + VMUINT8 use_proxy, + VMUINT8 prx_ip[4], + VMUINT16 prx_port, + VMUINT8 *username, + VMUINT8 username_len, + VMUINT8 *password, + VMUINT8 password_len, + VMUINT8 *server_auth_username, + VMUINT8 server_auth_username_len, + VMUINT8 *server_auth_password, + VMUINT8 server_auth_password_len, + VMUINT32 static_header_len, + VMUINT8 *static_header) +{ + if (_vm_https_send_set_channel_req == NULL) { + _vm_https_send_set_channel_req = (_vm_https_send_set_channel_req_t)vm_get_sym_entry("vm_https_send_set_channel_req"); + } + if (_vm_https_send_set_channel_req != NULL) { + return _vm_https_send_set_channel_req( + req_id, + use_proxy, + prx_ip, + prx_port, + username, + username_len, + password, + password_len, + server_auth_username, + server_auth_username_len, + server_auth_password, + server_auth_password_len, + static_header_len, + static_header); + } + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_unset_channel_req.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_unset_channel_req.c new file mode 100644 index 00000000..7ea5d9be --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_https_send_unset_channel_req.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttps.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT8(*_vm_https_send_unset_channel_req_t)(VMUINT8 channel_id); +_vm_https_send_unset_channel_req_t _vm_https_send_unset_channel_req = NULL; + +VMUINT8 vm_https_send_unset_channel_req(VMUINT8 channel_id) +{ + if (_vm_https_send_unset_channel_req == NULL) { + _vm_https_send_unset_channel_req = (_vm_https_send_unset_channel_req_t)vm_get_sym_entry("vm_https_send_unset_channel_req"); + } + if (_vm_https_send_unset_channel_req != NULL) { + return _vm_https_send_unset_channel_req(channel_id); + } + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_idle_swatch_pedometer_register_callback.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_idle_swatch_pedometer_register_callback.c new file mode 100644 index 00000000..674a3755 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_idle_swatch_pedometer_register_callback.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmsettings.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_idle_swatch_pedometer_register_callback_t)(vm_idle_swatch_pedometer_cb event_hdlr); +_vm_idle_swatch_pedometer_register_callback_t _vm_idle_swatch_pedometer_register_callback = NULL; +void vm_idle_swatch_pedometer_register_callback(vm_idle_swatch_pedometer_cb event_hdlr) + +{ + if (NULL == _vm_idle_swatch_pedometer_register_callback) + _vm_idle_swatch_pedometer_register_callback = (_vm_idle_swatch_pedometer_register_callback_t)vm_get_sym_entry("vm_idle_swatch_pedometer_register_callback"); + if (NULL != _vm_idle_swatch_pedometer_register_callback) + _vm_idle_swatch_pedometer_register_callback(event_hdlr); +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_addr.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_addr.c new file mode 100644 index 00000000..69998b42 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_addr.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_inet_addr_t)(const char* addr); +_vm_inet_addr_t _vm_inet_addr = NULL; + +VMUINT vm_inet_addr(const char* addr) +{ + if (NULL == _vm_inet_addr) + _vm_inet_addr = (_vm_inet_addr_t)vm_get_sym_entry("vm_inet_addr"); + if (NULL != _vm_inet_addr) + return _vm_inet_addr(addr); + return (VMUINT)0; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_ftpd_restart.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_ftpd_restart.c new file mode 100644 index 00000000..65d1ddda --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_ftpd_restart.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmftpd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_ftpsrv_error_enum (*_vm_inet_ftpd_restart_t)(VMUINT32 port, VMCHAR* root_dir); +_vm_inet_ftpd_restart_t _vm_inet_ftpd_restart = NULL; + +vm_ftpsrv_error_enum vm_inet_ftpd_restart(VMUINT32 port, VMCHAR* root_dir) +{ + if (NULL == _vm_inet_ftpd_restart) + _vm_inet_ftpd_restart = (_vm_inet_ftpd_restart_t)vm_get_sym_entry("vm_inet_ftpd_restart"); + + if (NULL != _vm_inet_ftpd_restart) + return _vm_inet_ftpd_restart(port, root_dir); + + return (vm_ftpsrv_error_enum)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_ftpd_start.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_ftpd_start.c new file mode 100644 index 00000000..b9000cf2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_ftpd_start.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmftpd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_ftpsrv_error_enum (*_vm_inet_ftpd_start_t)(VMUINT32 port, VMCHAR* root_dir); +_vm_inet_ftpd_start_t _vm_inet_ftpd_start = NULL; + +vm_ftpsrv_error_enum vm_inet_ftpd_start(VMUINT32 port, VMCHAR* root_dir) +{ + if (NULL == _vm_inet_ftpd_start) + _vm_inet_ftpd_start = (_vm_inet_ftpd_start_t)vm_get_sym_entry("vm_inet_ftpd_start"); + + if (NULL != _vm_inet_ftpd_start) + return _vm_inet_ftpd_start(port, root_dir); + + return (vm_ftpsrv_error_enum)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_ftpd_stop.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_ftpd_stop.c new file mode 100644 index 00000000..89631f18 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_ftpd_stop.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmftpd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_ftpsrv_error_enum (*_vm_inet_ftpd_stop_t)(void); +_vm_inet_ftpd_stop_t _vm_inet_ftpd_stop = NULL; + +vm_ftpsrv_error_enum vm_inet_ftpd_stop(void) +{ + if (NULL == _vm_inet_ftpd_stop) + _vm_inet_ftpd_stop = (_vm_inet_ftpd_stop_t)vm_get_sym_entry("vm_inet_ftpd_stop"); + + if (NULL != _vm_inet_ftpd_stop) + return _vm_inet_ftpd_stop(); + + return (vm_ftpsrv_error_enum)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_cgi_job_finish.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_cgi_job_finish.c new file mode 100644 index 00000000..83522a11 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_cgi_job_finish.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmhttpd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_inet_httpd_cgi_job_finish_t)(VMUINT32 hc_handle); +_vm_inet_httpd_cgi_job_finish_t _vm_inet_httpd_cgi_job_finish = NULL; + +void vm_inet_httpd_cgi_job_finish(VMUINT32 hc_handle) +{ + if (NULL == _vm_inet_httpd_cgi_job_finish) + _vm_inet_httpd_cgi_job_finish = (_vm_inet_httpd_cgi_job_finish_t)vm_get_sym_entry("vm_inet_httpd_cgi_job_finish"); + + if (NULL != _vm_inet_httpd_cgi_job_finish) + _vm_inet_httpd_cgi_job_finish(hc_handle); + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_disable_ssl.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_disable_ssl.c new file mode 100644 index 00000000..c2370153 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_disable_ssl.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmhttpd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_inet_httpd_disable_ssl_t)(); +_vm_inet_httpd_disable_ssl_t _vm_inet_httpd_disable_ssl = NULL; + +void vm_inet_httpd_disable_ssl() +{ + if (NULL == _vm_inet_httpd_disable_ssl) + _vm_inet_httpd_disable_ssl = (_vm_inet_httpd_disable_ssl_t)vm_get_sym_entry("vm_inet_httpd_disable_ssl"); + + if (NULL != _vm_inet_httpd_disable_ssl) + _vm_inet_httpd_disable_ssl(); + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_enable_ssl.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_enable_ssl.c new file mode 100644 index 00000000..b9b9b941 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_enable_ssl.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmhttpd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_inet_httpd_enable_ssl_t)(VMUINT32 port, VMINT8* cer_dir, VMINT8* peer_cn, VMINT8* server_key_passwd); +_vm_inet_httpd_enable_ssl_t _vm_inet_httpd_enable_ssl = NULL; + +void vm_inet_httpd_enable_ssl(VMUINT32 port, VMINT8* cer_dir, VMINT8* peer_cn, VMINT8* server_key_passwd) +{ + if (NULL == _vm_inet_httpd_enable_ssl) + _vm_inet_httpd_enable_ssl = (_vm_inet_httpd_enable_ssl_t)vm_get_sym_entry("vm_inet_httpd_enable_ssl"); + + if (NULL != _vm_inet_httpd_enable_ssl) + _vm_inet_httpd_enable_ssl(port,cer_dir,peer_cn,server_key_passwd); + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_getenv.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_getenv.c new file mode 100644 index 00000000..107c2de2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_getenv.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttpd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT8* (*_vm_inet_httpd_getenv_t)(VMUINT32 hc_handle, VMINT8* name); +_vm_inet_httpd_getenv_t _vm_inet_httpd_getenv = NULL; + +VMINT8* vm_inet_httpd_getenv(VMUINT32 hc_handle, VMINT8* name) +{ + if (NULL == _vm_inet_httpd_getenv) + _vm_inet_httpd_getenv = (_vm_inet_httpd_getenv_t)vm_get_sym_entry("vm_inet_httpd_getenv"); + + if (NULL != _vm_inet_httpd_getenv) + return _vm_inet_httpd_getenv(hc_handle,name); + + return (VMINT8* )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_read.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_read.c new file mode 100644 index 00000000..5aeb2c5f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_read.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttpd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_inet_httpd_read_t)(VMUINT32 hc_handle, VMINT8* buf, VMINT32 buf_size); +_vm_inet_httpd_read_t _vm_inet_httpd_read = NULL; + +VMINT32 vm_inet_httpd_read(VMUINT32 hc_handle, VMINT8* buf, VMINT32 buf_size) +{ + if (NULL == _vm_inet_httpd_read) + _vm_inet_httpd_read = (_vm_inet_httpd_read_t)vm_get_sym_entry("vm_inet_httpd_read"); + + if (NULL != _vm_inet_httpd_read) + return _vm_inet_httpd_read(hc_handle,buf,buf_size); + + return (VMINT32 )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_restart.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_restart.c new file mode 100644 index 00000000..e46b8ba5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_restart.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttpd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_httpsrv_error_enum (*_vm_inet_httpd_restart_t)(VMUINT32 port, VMINT8* root_dir, VMINT8* cgi_pattern); +_vm_inet_httpd_restart_t _vm_inet_httpd_restart = NULL; + +vm_httpsrv_error_enum vm_inet_httpd_restart(VMUINT32 port, VMINT8* root_dir, VMINT8* cgi_pattern) +{ + if (NULL == _vm_inet_httpd_restart) + _vm_inet_httpd_restart = (_vm_inet_httpd_restart_t)vm_get_sym_entry("vm_inet_httpd_restart"); + + if (NULL != _vm_inet_httpd_restart) + return _vm_inet_httpd_restart(port,root_dir,cgi_pattern); + + return (vm_httpsrv_error_enum )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_start.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_start.c new file mode 100644 index 00000000..9f1559c1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_start.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttpd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_httpsrv_error_enum (*_vm_inet_httpd_start_t)(VMUINT32 port, VMINT8* root_dir, VMINT8* cgi_pattern); +_vm_inet_httpd_start_t _vm_inet_httpd_start = NULL; + +vm_httpsrv_error_enum vm_inet_httpd_start(VMUINT32 port, VMINT8* root_dir, VMINT8* cgi_pattern) +{ + if (NULL == _vm_inet_httpd_start) + _vm_inet_httpd_start = (_vm_inet_httpd_start_t)vm_get_sym_entry("vm_inet_httpd_start"); + + if (NULL != _vm_inet_httpd_start) + return _vm_inet_httpd_start(port, root_dir, cgi_pattern); + + return (vm_httpsrv_error_enum )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_stop.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_stop.c new file mode 100644 index 00000000..65507060 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_stop.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttpd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_httpsrv_error_enum (*_vm_inet_httpd_stop_t)(void); +_vm_inet_httpd_stop_t _vm_inet_httpd_stop = NULL; + +vm_httpsrv_error_enum vm_inet_httpd_stop(void) +{ + if (NULL == _vm_inet_httpd_stop) + _vm_inet_httpd_stop = (_vm_inet_httpd_stop_t)vm_get_sym_entry("vm_inet_httpd_stop"); + + if (NULL != _vm_inet_httpd_stop) + return _vm_inet_httpd_stop(); + + return (vm_httpsrv_error_enum )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_write.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_write.c new file mode 100644 index 00000000..89d398a7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_httpd_write.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttpd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_inet_httpd_write_t)(VMUINT32 hc_handle, VMINT8* buf, VMINT32 content_size); +_vm_inet_httpd_write_t _vm_inet_httpd_write = NULL; + +VMINT32 vm_inet_httpd_write(VMUINT32 hc_handle, VMINT8* buf, VMINT32 content_size) +{ + if (NULL == _vm_inet_httpd_write) + _vm_inet_httpd_write = (_vm_inet_httpd_write_t)vm_get_sym_entry("vm_inet_httpd_write"); + + if (NULL != _vm_inet_httpd_write) + return _vm_inet_httpd_write(hc_handle,buf,content_size); + + return (VMINT32 )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_ntoa.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_ntoa.c new file mode 100644 index 00000000..30af8084 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_ntoa.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef char* (*_vm_inet_ntoa_t)(IN_ADDR in); +_vm_inet_ntoa_t _vm_inet_ntoa = NULL; + +char* vm_inet_ntoa(IN_ADDR in) +{ + if (NULL == _vm_inet_ntoa) + _vm_inet_ntoa = (_vm_inet_ntoa_t)vm_get_sym_entry("vm_inet_ntoa"); + if (NULL != _vm_inet_ntoa) + return _vm_inet_ntoa(in); + return (char*)NULL; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_register_cb.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_register_cb.c new file mode 100644 index 00000000..79cd2bb2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_register_cb.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmrtspd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_rtspd_error_enum (*_vm_inet_rtspd_register_cb_t)(VM_RTSPD_CB callback); +_vm_inet_rtspd_register_cb_t _vm_inet_rtspd_register_cb = NULL; + +vm_rtspd_error_enum vm_inet_rtspd_register_cb(VM_RTSPD_CB callback) +{ + if (NULL == _vm_inet_rtspd_register_cb) + _vm_inet_rtspd_register_cb = (_vm_inet_rtspd_register_cb_t)vm_get_sym_entry("vm_inet_rtspd_register_cb"); + + if (NULL != _vm_inet_rtspd_register_cb) + return _vm_inet_rtspd_register_cb(callback); + + return (vm_rtspd_error_enum)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_restart.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_restart.c new file mode 100644 index 00000000..4f21649e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_restart.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmrtspd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_rtspd_error_enum (*_vm_inet_rtspd_restart_t)(VMUINT32 port, VMCHAR* root_dir); +_vm_inet_rtspd_restart_t _vm_inet_rtspd_restart = NULL; + +vm_rtspd_error_enum vm_inet_rtspd_restart(VMUINT32 port, VMCHAR* root_dir) +{ + if (NULL == _vm_inet_rtspd_restart) + _vm_inet_rtspd_restart = (_vm_inet_rtspd_restart_t)vm_get_sym_entry("vm_inet_rtspd_restart"); + + if (NULL != _vm_inet_rtspd_restart) + return _vm_inet_rtspd_restart(port,root_dir); + + return (vm_rtspd_error_enum)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_set_stream_identify.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_set_stream_identify.c new file mode 100644 index 00000000..e31c2421 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_set_stream_identify.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmrtspd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_inet_rtspd_set_stream_identify_t)(VMCHAR* stream_name); +_vm_inet_rtspd_set_stream_identify_t _vm_inet_rtspd_set_stream_identify = NULL; + +void vm_inet_rtspd_set_stream_identify(VMCHAR* stream_name) +{ + if (NULL == _vm_inet_rtspd_set_stream_identify) + _vm_inet_rtspd_set_stream_identify = (_vm_inet_rtspd_set_stream_identify_t)vm_get_sym_entry("vm_inet_rtspd_set_stream_identify"); + + if (NULL != _vm_inet_rtspd_set_stream_identify) + _vm_inet_rtspd_set_stream_identify(stream_name); + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_start.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_start.c new file mode 100644 index 00000000..c0b9e610 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_start.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmrtspd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_rtspd_error_enum (*_vm_inet_rtspd_start_t)(VMUINT32 port, VMCHAR* root_dir); +_vm_inet_rtspd_start_t _vm_inet_rtspd_start = NULL; + +vm_rtspd_error_enum vm_inet_rtspd_start(VMUINT32 port, VMCHAR* root_dir) +{ + if (NULL == _vm_inet_rtspd_start) + _vm_inet_rtspd_start = (_vm_inet_rtspd_start_t)vm_get_sym_entry("vm_inet_rtspd_start"); + + if (NULL != _vm_inet_rtspd_start) + return _vm_inet_rtspd_start(port,root_dir); + + return (vm_rtspd_error_enum)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_stop.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_stop.c new file mode 100644 index 00000000..d36c66c3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_inet_rtspd_stop.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmrtspd.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_rtspd_error_enum (*_vm_inet_rtspd_stop_t)(void); +_vm_inet_rtspd_stop_t _vm_inet_rtspd_stop = NULL; + +vm_rtspd_error_enum vm_inet_rtspd_stop(void) +{ + if (NULL == _vm_inet_rtspd_stop) + _vm_inet_rtspd_stop = (_vm_inet_rtspd_stop_t)vm_get_sym_entry("vm_inet_rtspd_stop"); + + if (NULL != _vm_inet_rtspd_stop) + return _vm_inet_rtspd_stop(); + + return (vm_rtspd_error_enum)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_empty_stack.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_empty_stack.c new file mode 100644 index 00000000..cc54789c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_empty_stack.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_is_empty_stack_t)(VMINT stackHandle); +_vm_is_empty_stack_t _vm_is_empty_stack = NULL; + +VMINT vm_is_empty_stack(VMINT stackHandle) +{ + if (NULL == _vm_is_empty_stack) + _vm_is_empty_stack = (_vm_is_empty_stack_t)vm_get_sym_entry("vm_is_empty_stack"); + + if (NULL != _vm_is_empty_stack) + return _vm_is_empty_stack(stackHandle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_exist_stack.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_exist_stack.c new file mode 100644 index 00000000..e122a93b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_exist_stack.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_is_exist_stack_t)(VMINT stackHandle, void* ptr); +_vm_is_exist_stack_t _vm_is_exist_stack = NULL; + +VMINT vm_is_exist_stack(VMINT stackHandle, void* ptr) +{ + if (NULL == _vm_is_exist_stack) + _vm_is_exist_stack = (_vm_is_exist_stack_t)vm_get_sym_entry("vm_is_exist_stack"); + + if (NULL != _vm_is_exist_stack) + return _vm_is_exist_stack(stackHandle,ptr); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_support_camera_sensor.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_support_camera_sensor.c new file mode 100644 index 00000000..51c60827 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_support_camera_sensor.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_is_support_camera_sensor_t)(void); +_vm_is_support_camera_sensor_t _vm_is_support_camera_sensor = NULL; + +VMINT vm_is_support_camera_sensor(void) +{ + if (NULL == _vm_is_support_camera_sensor) + _vm_is_support_camera_sensor = (_vm_is_support_camera_sensor_t)vm_get_sym_entry("vm_is_support_camera_sensor"); + + if (NULL != _vm_is_support_camera_sensor) + return _vm_is_support_camera_sensor(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_support_gsensor.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_support_gsensor.c new file mode 100644 index 00000000..c961934b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_support_gsensor.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_is_support_gsensor_t)(void); +_vm_is_support_gsensor_t _vm_is_support_gsensor = NULL; + +VMINT vm_is_support_gsensor(void) +{ + if (NULL == _vm_is_support_gsensor) + _vm_is_support_gsensor = (_vm_is_support_gsensor_t)vm_get_sym_entry("vm_is_support_gsensor"); + + if (NULL != _vm_is_support_gsensor) + return _vm_is_support_gsensor(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_support_wifi.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_support_wifi.c new file mode 100644 index 00000000..b3959edc --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_is_support_wifi.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_is_support_wifi_t)(void); +_vm_is_support_wifi_t _vm_is_support_wifi = NULL; + +VMINT vm_is_support_wifi(void) +{ + if (NULL == _vm_is_support_wifi) + _vm_is_support_wifi = (_vm_is_support_wifi_t)vm_get_sym_entry("vm_is_support_wifi"); + + if (NULL != _vm_is_support_wifi) + return _vm_is_support_wifi(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ivr_call.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ivr_call.c new file mode 100644 index 00000000..cbe1efbf --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ivr_call.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtel.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ivr_call_t)(vm_ivr_call_data* data); +_vm_ivr_call_t _vm_ivr_call = NULL; + +VMINT vm_ivr_call(vm_ivr_call_data* data) +{ + if (NULL == _vm_ivr_call) + _vm_ivr_call = (_vm_ivr_call_t)vm_get_sym_entry("vm_ivr_call"); + + if (NULL != _vm_ivr_call) + return _vm_ivr_call(data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ivr_dial_number.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ivr_dial_number.c new file mode 100644 index 00000000..4706415c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ivr_dial_number.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtel.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ivr_dial_number_t)(VMCHAR number); +_vm_ivr_dial_number_t _vm_ivr_dial_number = NULL; + +VMINT vm_ivr_dial_number(VMCHAR number) +{ + if (NULL == _vm_ivr_dial_number) + _vm_ivr_dial_number = (_vm_ivr_dial_number_t)vm_get_sym_entry("vm_ivr_dial_number"); + + if (NULL != _vm_ivr_dial_number) + return _vm_ivr_dial_number(number); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ivr_end.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ivr_end.c new file mode 100644 index 00000000..cfeb84bc --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ivr_end.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtel.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ivr_end_t)(void); +_vm_ivr_end_t _vm_ivr_end = NULL; + +VMINT vm_ivr_end(void) +{ + if (NULL == _vm_ivr_end) + _vm_ivr_end = (_vm_ivr_end_t)vm_get_sym_entry("vm_ivr_end"); + + if (NULL != _vm_ivr_end) + return _vm_ivr_end(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_listen.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_listen.c new file mode 100644 index 00000000..f46249ee --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_listen.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_listen_t)(int sock, int backlog); +_vm_listen_t _vm_listen = NULL; + +int vm_listen(int sock, int backlog) +{ + if (NULL == _vm_listen) + _vm_listen = (_vm_listen_t)vm_get_sym_entry("vm_listen"); + if (NULL != _vm_listen) + return _vm_listen(sock,backlog); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_load_resource.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_load_resource.c new file mode 100644 index 00000000..6a6a3794 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_load_resource.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmres.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT8* (*_vm_load_resource_t)(char* res_name, VMINT* res_size); +_vm_load_resource_t _vm_load_resource = NULL; + +VMUINT8* vm_load_resource(char* res_name, VMINT* res_size) +{ + if (NULL == _vm_load_resource) + _vm_load_resource = (_vm_load_resource_t)vm_get_sym_entry("vm_load_resource"); + + if (NULL != _vm_load_resource) + return _vm_load_resource(res_name,res_size); + + return (VMUINT8* )0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_load_resource_from_file.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_load_resource_from_file.c new file mode 100644 index 00000000..a56ed4ec --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_load_resource_from_file.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmres.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT8* (*_vm_load_resource_from_file_t)(VMWSTR filename, char *res_name, VMINT *res_size); +_vm_load_resource_from_file_t _vm_load_resource_from_file = NULL; + +VMUINT8* vm_load_resource_from_file(VMWSTR filename, char *res_name, VMINT *res_size) +{ + if (NULL == _vm_load_resource_from_file) + _vm_load_resource_from_file = (_vm_load_resource_from_file_t)vm_get_sym_entry("vm_load_resource_from_file"); + + if (NULL != _vm_load_resource_from_file) + return _vm_load_resource_from_file(filename,res_name,res_size); + + return (VMUINT8* )0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_load_resource_use_outside_memory.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_load_resource_use_outside_memory.c new file mode 100644 index 00000000..a8c9d1ad --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_load_resource_use_outside_memory.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmres.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMBOOL (*_vm_load_resource_use_outside_memory_t)(VMWSTR filename, char *res_name, void* buffer, VMINT buffer_size, vm_res_read_hint_struct* hint); +_vm_load_resource_use_outside_memory_t _vm_load_resource_use_outside_memory = NULL; + +VMBOOL vm_load_resource_use_outside_memory(VMWSTR filename, char *res_name, void* buffer, VMINT buffer_size, vm_res_read_hint_struct* hint) +{ + if (NULL == _vm_load_resource_use_outside_memory) + _vm_load_resource_use_outside_memory = (_vm_load_resource_use_outside_memory_t)vm_get_sym_entry("vm_load_resource_use_outside_memory"); + + if (NULL != _vm_load_resource_use_outside_memory) + return _vm_load_resource_use_outside_memory(filename,res_name,buffer,buffer_size,hint); + + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_lower_case.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_lower_case.c new file mode 100644 index 00000000..67205b5b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_lower_case.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_lower_case_t)(char* dst, char* src); +_vm_lower_case_t _vm_lower_case = NULL; + +void vm_lower_case(char* dst, char* src) +{ + if (NULL == _vm_lower_case) + _vm_lower_case = (_vm_lower_case_t)vm_get_sym_entry("vm_lower_case"); + + if (NULL != _vm_lower_case) + _vm_lower_case(dst,src); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_magic_wrapper_for_customer.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_magic_wrapper_for_customer.c new file mode 100644 index 00000000..a12db9b7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_magic_wrapper_for_customer.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmmagic.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_magic_wrapper_for_customer_t)(VMINT index, void* param, void* reserve); +_vm_magic_wrapper_for_customer_t _vm_magic_wrapper_for_customer = NULL; + +VMINT vm_magic_wrapper_for_customer(VMINT index, void* param, void* reserve) +{ + if (NULL == _vm_magic_wrapper_for_customer) + _vm_magic_wrapper_for_customer = (_vm_magic_wrapper_for_customer_t)vm_get_sym_entry("vm_magic_wrapper_for_customer"); + if (NULL != _vm_magic_wrapper_for_customer) + return _vm_magic_wrapper_for_customer(index,param,reserve); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_malloc.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_malloc.c new file mode 100644 index 00000000..41a308ac --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_malloc.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void *(*_vm_malloc_t)(int size); +_vm_malloc_t _vm_malloc = NULL; + +void *vm_malloc(int size) +{ + if (NULL == _vm_malloc) + _vm_malloc = (_vm_malloc_t)vm_get_sym_entry("vm_malloc"); + + if (NULL != _vm_malloc) + return _vm_malloc(size); + return NULL; + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_malloc_nc.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_malloc_nc.c new file mode 100644 index 00000000..71792379 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_malloc_nc.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void *(*_vm_malloc_nc_t)(int size); +_vm_malloc_nc_t _vm_malloc_nc = NULL; + +void *vm_malloc_nc(int size) +{ + if (NULL == _vm_malloc_nc) + _vm_malloc_nc = (_vm_malloc_nc_t)vm_get_sym_entry("vm_malloc_nc"); + + if (NULL != _vm_malloc_nc) + return _vm_malloc_nc(size); + else + return NULL; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_malloc_nc_topmost.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_malloc_nc_topmost.c new file mode 100644 index 00000000..cf7e31c7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_malloc_nc_topmost.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void *(*_vm_malloc_nc_topmost_t)(int size); +_vm_malloc_nc_topmost_t _vm_malloc_nc_topmost = NULL; + +void *vm_malloc_nc_topmost(int size) +{ + if (NULL == _vm_malloc_nc_topmost) + _vm_malloc_nc_topmost = (_vm_malloc_nc_topmost_t)vm_get_sym_entry("vm_malloc_nc_topmost"); + + if (NULL != _vm_malloc_nc_topmost) + return _vm_malloc_nc_topmost(size); + else + return NULL; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_malloc_topmost.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_malloc_topmost.c new file mode 100644 index 00000000..6cd0a3f8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_malloc_topmost.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void *(*_vm_malloc_topmost_t)(int size); +_vm_malloc_topmost_t _vm_malloc_topmost = NULL; + +void *vm_malloc_topmost(int size) +{ + if (NULL == _vm_malloc_topmost) + _vm_malloc_topmost = (_vm_malloc_topmost_t)vm_get_sym_entry("vm_malloc_topmost"); + + if (NULL != _vm_malloc_topmost) + return _vm_malloc_topmost(size); + return NULL; + + +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_memcpy.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_memcpy.c new file mode 100644 index 00000000..fe00188d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_memcpy.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_memcpy_t)(void* dst, void* src, VMINT count); +_vm_memcpy_t _vm_memcpy = NULL; + +void vm_memcpy(void* dst, void* src, VMINT count) +{ + if (NULL == _vm_memcpy) + _vm_memcpy = (_vm_memcpy_t)vm_get_sym_entry("vm_memcpy"); + + if (NULL != _vm_memcpy) + _vm_memcpy(dst,src,count); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_get_time.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_get_time.c new file mode 100644 index 00000000..829d2a25 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_get_time.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_midi_get_time_t)(VMINT handle, VMUINT *current_time); +_vm_midi_get_time_t _vm_midi_get_time = NULL; + +VMINT vm_midi_get_time(VMINT handle, VMUINT *current_time) +{ + if (NULL == _vm_midi_get_time) + _vm_midi_get_time = (_vm_midi_get_time_t)vm_get_sym_entry("vm_midi_get_time"); + + if (NULL != _vm_midi_get_time) + return _vm_midi_get_time(handle,current_time); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_pause.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_pause.c new file mode 100644 index 00000000..75ba4619 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_pause.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_midi_pause_t)(VMINT handle); +_vm_midi_pause_t _vm_midi_pause = NULL; + +VMINT vm_midi_pause(VMINT handle) +{ + if (NULL == _vm_midi_pause) + _vm_midi_pause = (_vm_midi_pause_t)vm_get_sym_entry("vm_midi_pause"); + + if (NULL != _vm_midi_pause) + return _vm_midi_pause(handle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_play.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_play.c new file mode 100644 index 00000000..1cdf6a07 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_play.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_midi_play_t)(VMINT resid, VMINT repeat, void (*f)(VMINT handle, VMINT event)); +_vm_midi_play_t _vm_midi_play = NULL; + +VMINT vm_midi_play(VMINT resid, VMINT repeat, void (*f)(VMINT handle, VMINT event)) +{ + if (NULL == _vm_midi_play) + _vm_midi_play = (_vm_midi_play_t)vm_get_sym_entry("vm_midi_play"); + + if (NULL != _vm_midi_play) + return _vm_midi_play(resid,repeat,f); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_play_by_bytes.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_play_by_bytes.c new file mode 100644 index 00000000..15bb6a02 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_play_by_bytes.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_midi_play_by_bytes_t)( VMUINT8 * midibuf, VMINT len, VMINT repeat, void (*f)(VMINT handle, VMINT event) ); +_vm_midi_play_by_bytes_t _vm_midi_play_by_bytes = NULL; + +VMINT vm_midi_play_by_bytes( VMUINT8 * midibuf, VMINT len, VMINT repeat, void (*f)(VMINT handle, VMINT event) ) +{ + if (NULL == _vm_midi_play_by_bytes) + _vm_midi_play_by_bytes = (_vm_midi_play_by_bytes_t)vm_get_sym_entry("vm_midi_play_by_bytes"); + + if (NULL != _vm_midi_play_by_bytes) + return _vm_midi_play_by_bytes(midibuf,len,repeat,f); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_play_by_bytes_ex.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_play_by_bytes_ex.c new file mode 100644 index 00000000..30753e46 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_play_by_bytes_ex.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_midi_play_by_bytes_ex_t)( VMUINT8 * midibuf, VMINT len, VMUINT start_time, VMINT repeat, VMUINT path, void (*f)(VMINT handle, VMINT event) ); +_vm_midi_play_by_bytes_ex_t _vm_midi_play_by_bytes_ex = NULL; + +VMINT vm_midi_play_by_bytes_ex( VMUINT8 * midibuf, VMINT len, VMUINT start_time, VMINT repeat, VMUINT path, void (*f)(VMINT handle, VMINT event) ) +{ + if (NULL == _vm_midi_play_by_bytes_ex) + _vm_midi_play_by_bytes_ex = (_vm_midi_play_by_bytes_ex_t)vm_get_sym_entry("vm_midi_play_by_bytes_ex"); + + if (NULL != _vm_midi_play_by_bytes_ex) + return _vm_midi_play_by_bytes_ex(midibuf,len,start_time,repeat,path,f); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_play_ex.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_play_ex.c new file mode 100644 index 00000000..123dbbec --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_play_ex.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_midi_play_ex_t)(VMINT resid, VMUINT start_time, VMINT repeat, VMUINT path, void (*f)(VMINT handle, VMINT event)); +_vm_midi_play_ex_t _vm_midi_play_ex = NULL; + +VMINT vm_midi_play_ex(VMINT resid, VMUINT start_time, VMINT repeat, VMUINT path, void (*f)(VMINT handle, VMINT event)) +{ + if (NULL == _vm_midi_play_ex) + _vm_midi_play_ex = (_vm_midi_play_ex_t)vm_get_sym_entry("vm_midi_play_ex"); + + if (NULL != _vm_midi_play_ex) + return _vm_midi_play_ex(resid,start_time,repeat,path,f); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_resume.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_resume.c new file mode 100644 index 00000000..6baf3bc2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_resume.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_midi_resume_t)(VMINT handle); +_vm_midi_resume_t _vm_midi_resume = NULL; + +VMINT vm_midi_resume(VMINT handle) +{ + if (NULL == _vm_midi_resume) + _vm_midi_resume = (_vm_midi_resume_t)vm_get_sym_entry("vm_midi_resume"); + + if (NULL != _vm_midi_resume) + return _vm_midi_resume(handle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_set_type.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_set_type.c new file mode 100644 index 00000000..a74b2da9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_set_type.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_midi_set_type_t)(VMINT type); +_vm_midi_set_type_t _vm_midi_set_type = NULL; + +void vm_midi_set_type(VMINT type) +{ + if (NULL == _vm_midi_set_type) + _vm_midi_set_type = (_vm_midi_set_type_t)vm_get_sym_entry("vm_midi_set_type"); + + if (NULL != _vm_midi_set_type) + _vm_midi_set_type(type); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_stop.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_stop.c new file mode 100644 index 00000000..fd80b842 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_stop.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_midi_stop_t)(VMINT handle); +_vm_midi_stop_t _vm_midi_stop = NULL; + +void vm_midi_stop(VMINT handle) +{ + if (NULL == _vm_midi_stop) + _vm_midi_stop = (_vm_midi_stop_t)vm_get_sym_entry("vm_midi_stop"); + + if (NULL != _vm_midi_stop) + _vm_midi_stop(handle); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_stop_all.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_stop_all.c new file mode 100644 index 00000000..00316385 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_midi_stop_all.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_midi_stop_all_t)(void); +_vm_midi_stop_all_t _vm_midi_stop_all = NULL; + +void vm_midi_stop_all(void) +{ + if (NULL == _vm_midi_stop_all) + _vm_midi_stop_all = (_vm_midi_stop_all_t)vm_get_sym_entry("vm_midi_stop_all"); + + if (NULL != _vm_midi_stop_all) + _vm_midi_stop_all(); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_cancel_download.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_cancel_download.c new file mode 100644 index 00000000..e8696247 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_cancel_download.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmmms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_mms_cancel_download_t)(VMINT msg_id); +_vm_mms_cancel_download_t _vm_mms_cancel_download = NULL; + +void vm_mms_cancel_download(VMINT msg_id) +{ + if (NULL == _vm_mms_cancel_download) + _vm_mms_cancel_download = (_vm_mms_cancel_download_t)vm_get_sym_entry("vm_mms_cancel_download"); + + if (NULL != _vm_mms_cancel_download) + _vm_mms_cancel_download(msg_id); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_cancel_send_mms.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_cancel_send_mms.c new file mode 100644 index 00000000..e3d2fcdf --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_cancel_send_mms.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_mms_cancel_send_mms_t)(void); +_vm_mms_cancel_send_mms_t _vm_mms_cancel_send_mms = NULL; + +void vm_mms_cancel_send_mms(void) +{ + if (NULL == _vm_mms_cancel_send_mms) + _vm_mms_cancel_send_mms = (_vm_mms_cancel_send_mms_t)vm_get_sym_entry("vm_mms_cancel_send_mms"); + + if (NULL != _vm_mms_cancel_send_mms) + _vm_mms_cancel_send_mms(); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_clear_interrupt_event_handler.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_clear_interrupt_event_handler.c new file mode 100644 index 00000000..3cd1f929 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_clear_interrupt_event_handler.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_mms_clear_interrupt_event_handler_t)(vm_mms_event_enum event); +_vm_mms_clear_interrupt_event_handler_t _vm_mms_clear_interrupt_event_handler = NULL; + +VMINT vm_mms_clear_interrupt_event_handler(vm_mms_event_enum event) +{ + if (NULL == _vm_mms_clear_interrupt_event_handler) + _vm_mms_clear_interrupt_event_handler = (_vm_mms_clear_interrupt_event_handler_t)vm_get_sym_entry("vm_mms_clear_interrupt_event_handler"); + + if (NULL != _vm_mms_clear_interrupt_event_handler) + return _vm_mms_clear_interrupt_event_handler(event); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_delete.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_delete.c new file mode 100644 index 00000000..1cf25582 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_delete.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmmms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_mms_delete_t)(VMUINT* msg_id_list, VMUINT msg_num, vm_mms_folder_enum folder, vm_mms_delete_callback callback,void* user_data); +_vm_mms_delete_t _vm_mms_delete = NULL; + +VMINT vm_mms_delete(VMUINT* msg_id_list, VMUINT msg_num, vm_mms_folder_enum folder, vm_mms_delete_callback callback,void* user_data) +{ + if (NULL == _vm_mms_delete) + _vm_mms_delete = (_vm_mms_delete_t)vm_get_sym_entry("vm_mms_delete"); + + if (NULL != _vm_mms_delete) + return _vm_mms_delete(msg_id_list,msg_num,folder,callback,user_data); + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_download.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_download.c new file mode 100644 index 00000000..18ca76a6 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_download.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_mms_download_t)(VMUINT msg_id, vm_mms_sim_id_enum sim, vm_mms_msg_storage_type_enum storage_type); +_vm_mms_download_t _vm_mms_download = NULL; + +VMINT vm_mms_download(VMUINT msg_id, vm_mms_sim_id_enum sim, vm_mms_msg_storage_type_enum storage_type) +{ + if (NULL == _vm_mms_download) + _vm_mms_download = (_vm_mms_download_t)vm_get_sym_entry("vm_mms_download"); + + if (NULL != _vm_mms_download) + return _vm_mms_download(msg_id,sim,storage_type ); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_get_content.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_get_content.c new file mode 100644 index 00000000..594b2fde --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_get_content.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmmms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_mms_get_content_t)(vm_mms_get_content_req_struct *req_data); +_vm_mms_get_content_t _vm_mms_get_content = NULL; + +VMINT vm_mms_get_content(vm_mms_get_content_req_struct *req_data) +{ + if (NULL == _vm_mms_get_content) + _vm_mms_get_content = (_vm_mms_get_content_t)vm_get_sym_entry("vm_mms_get_content"); + + if (NULL != _vm_mms_get_content) + return _vm_mms_get_content(req_data); + + return (VMINT)-1; +} + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_get_msg_id_list.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_get_msg_id_list.c new file mode 100644 index 00000000..e59cfaab --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_get_msg_id_list.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmmms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_mms_get_msg_id_list_t)(vm_mms_folder_enum folder, vm_mms_get_msg_id_list_callback_type callback, void* user_data); +_vm_mms_get_msg_id_list_t _vm_mms_get_msg_id_list = NULL; + +VMINT vm_mms_get_msg_id_list(vm_mms_folder_enum folder, vm_mms_get_msg_id_list_callback_type callback, void* user_data) +{ + if (NULL == _vm_mms_get_msg_id_list) + _vm_mms_get_msg_id_list = (_vm_mms_get_msg_id_list_t)vm_get_sym_entry("vm_mms_get_msg_id_list"); + + if (NULL != _vm_mms_get_msg_id_list) + return _vm_mms_get_msg_id_list(folder,callback, user_data); + + return (VMINT)-1; +} + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_launch.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_launch.c new file mode 100644 index 00000000..827e0d15 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_launch.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_mms_launch_t)(vm_mms_launch_data* data, VMINT data_size); +_vm_mms_launch_t _vm_mms_launch = NULL; + +VMINT vm_mms_launch(vm_mms_launch_data* data, VMINT data_size) +{ + if (NULL == _vm_mms_launch) + _vm_mms_launch = (_vm_mms_launch_t)vm_get_sym_entry("vm_mms_launch"); + + if (NULL != _vm_mms_launch) + return _vm_mms_launch(data,data_size); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_send_mms.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_send_mms.c new file mode 100644 index 00000000..54a222e2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_send_mms.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_mms_send_mms_t)(vm_send_mms_req_t * req_ptr, vm_mms_callback_type callback); +_vm_mms_send_mms_t _vm_mms_send_mms = NULL; + +VMINT vm_mms_send_mms(vm_send_mms_req_t * req_ptr, vm_mms_callback_type callback) +{ + if (NULL == _vm_mms_send_mms) + _vm_mms_send_mms = (_vm_mms_send_mms_t)vm_get_sym_entry("vm_mms_send_mms"); + + if (NULL != _vm_mms_send_mms) + return _vm_mms_send_mms(req_ptr,callback); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_set_interrupt_event_handler.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_set_interrupt_event_handler.c new file mode 100644 index 00000000..27dea822 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mms_set_interrupt_event_handler.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_mms_set_interrupt_event_handler_t)(vm_mms_event_enum event, vm_mms_interrupt_callback callback, void* user_data); +_vm_mms_set_interrupt_event_handler_t _vm_mms_set_interrupt_event_handler = NULL; + +VMINT vm_mms_set_interrupt_event_handler(vm_mms_event_enum event, vm_mms_interrupt_callback callback, void* user_data) +{ + if (NULL == _vm_mms_set_interrupt_event_handler) + _vm_mms_set_interrupt_event_handler = (_vm_mms_set_interrupt_event_handler_t)vm_get_sym_entry("vm_mms_set_interrupt_event_handler"); + + if (NULL != _vm_mms_set_interrupt_event_handler) + return _vm_mms_set_interrupt_event_handler(event,callback,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mode_block.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mode_block.c new file mode 100644 index 00000000..afbb612c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mode_block.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmpwr.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_mode_block_t)(void); +_vm_mode_block_t _vm_mode_block = NULL; +void vm_mode_block(void) +{ + if (NULL == _vm_mode_block) + _vm_mode_block = (_vm_mode_block_t)vm_get_sym_entry("vm_mode_block"); + + if (NULL != _vm_mode_block) + _vm_mode_block(); +} + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mode_unblock.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mode_unblock.c new file mode 100644 index 00000000..da4e6d0c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_mode_unblock.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmpwr.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_mode_unblock_t)(void); +_vm_mode_unblock_t _vm_mode_unblock = NULL; +void vm_mode_unblock(void) +{ + if (NULL == _vm_mode_unblock) + _vm_mode_unblock = (_vm_mode_unblock_t)vm_get_sym_entry("vm_mode_unblock"); + + if (NULL != _vm_mode_unblock) + _vm_mode_unblock(); +} + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_nvram_get_data.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_nvram_get_data.c new file mode 100644 index 00000000..cd72f40f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_nvram_get_data.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmnvram.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_nvram_get_data_t)(vm_nvram_sensor_lid id, void* buff, VMUINT size); +_vm_nvram_get_data_t _vm_nvram_get_data = NULL; +VMINT vm_nvram_get_data(vm_nvram_sensor_lid id, void* buff, VMUINT size) +{ + if (NULL == _vm_nvram_get_data) + _vm_nvram_get_data = (_vm_nvram_get_data_t)vm_get_sym_entry("vm_nvram_get_data"); + + if (NULL != _vm_nvram_get_data) + return _vm_nvram_get_data(id, buff, size); + + return -1; +} + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_nvram_set_data.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_nvram_set_data.c new file mode 100644 index 00000000..a903738c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_nvram_set_data.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmnvram.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_nvram_set_data_t)(vm_nvram_sensor_lid id, void* buff, VMUINT size); +_vm_nvram_set_data_t _vm_nvram_set_data = NULL; +VMINT vm_nvram_set_data(vm_nvram_sensor_lid id, void* buff, VMUINT size) +{ + if (NULL == _vm_nvram_set_data) + _vm_nvram_set_data = (_vm_nvram_set_data_t)vm_get_sym_entry("vm_nvram_set_data"); + + if (NULL != _vm_nvram_set_data) + return _vm_nvram_set_data(id, buff, size); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_peek_stack.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_peek_stack.c new file mode 100644 index 00000000..33397d1f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_peek_stack.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_peek_stack_t)(VMINT stackHandle, void** ptr); +_vm_peek_stack_t _vm_peek_stack = NULL; + +VMINT vm_peek_stack(VMINT stackHandle, void** ptr) +{ + if (NULL == _vm_peek_stack) + _vm_peek_stack = (_vm_peek_stack_t)vm_get_sym_entry("vm_peek_stack"); + + if (NULL != _vm_peek_stack) + return _vm_peek_stack(stackHandle,ptr); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_add_contact.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_add_contact.c new file mode 100644 index 00000000..6abbef87 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_add_contact.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmcontact.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_phb_req_error_enum (*_vm_phb_add_contact_t)(vm_phb_add_req_struct *req_info, vm_phb_callback_type cb); +_vm_phb_add_contact_t _vm_phb_add_contact = NULL; + +vm_phb_req_error_enum vm_phb_add_contact(vm_phb_add_req_struct *req_info, vm_phb_callback_type cb) +{ + vm_phb_req_error_enum ret = {-1}; + if (NULL == _vm_phb_add_contact) + _vm_phb_add_contact = (_vm_phb_add_contact_t)vm_get_sym_entry("vm_phb_add_contact"); + + if (NULL != _vm_phb_add_contact) + return _vm_phb_add_contact(req_info,cb); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_delete_contact.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_delete_contact.c new file mode 100644 index 00000000..2a6f77c7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_delete_contact.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmcontact.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_phb_req_error_enum (*_vm_phb_delete_contact_t)(vm_phb_delete_req_struct *req_info, vm_phb_callback_type cb); +_vm_phb_delete_contact_t _vm_phb_delete_contact = NULL; + +vm_phb_req_error_enum vm_phb_delete_contact(vm_phb_delete_req_struct *req_info, vm_phb_callback_type cb) +{ + vm_phb_req_error_enum ret = {-1}; + if (NULL == _vm_phb_delete_contact) + _vm_phb_delete_contact = (_vm_phb_delete_contact_t)vm_get_sym_entry("vm_phb_delete_contact"); + + if (NULL != _vm_phb_delete_contact) + return _vm_phb_delete_contact(req_info,cb); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_contact.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_contact.c new file mode 100644 index 00000000..5e3850ec --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_contact.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmcontact.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_phb_req_error_enum (*_vm_phb_get_contact_t)(vm_phb_get_req_struct *req_info, vm_phb_callback_type cb); +_vm_phb_get_contact_t _vm_phb_get_contact = NULL; + +vm_phb_req_error_enum vm_phb_get_contact(vm_phb_get_req_struct *req_info, vm_phb_callback_type cb) +{ + vm_phb_req_error_enum ret = {-1}; + if (NULL == _vm_phb_get_contact) + _vm_phb_get_contact = (_vm_phb_get_contact_t)vm_get_sym_entry("vm_phb_get_contact"); + + if (NULL != _vm_phb_get_contact) + return _vm_phb_get_contact(req_info,cb); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_contact_syn.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_contact_syn.c new file mode 100644 index 00000000..14dcfc7f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_contact_syn.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmcontact.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_phb_req_error_enum (*_vm_phb_get_contact_syn_t)(vm_phb_get_req_struct *req_info); +_vm_phb_get_contact_syn_t _vm_phb_get_contact_syn = NULL; + +vm_phb_req_error_enum vm_phb_get_contact_syn(vm_phb_get_req_struct *req_info) +{ + vm_phb_req_error_enum ret = {-1}; + if (NULL == _vm_phb_get_contact_syn) + _vm_phb_get_contact_syn = (_vm_phb_get_contact_syn_t)vm_get_sym_entry("vm_phb_get_contact_syn"); + + if (NULL != _vm_phb_get_contact_syn) + return _vm_phb_get_contact_syn(req_info); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_group_list.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_group_list.c new file mode 100644 index 00000000..5c3f2ac9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_group_list.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmcontact.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_phb_get_group_list_t)(vm_phb_group_struct *group_array, VMINT group_array_len); +_vm_phb_get_group_list_t _vm_phb_get_group_list = NULL; + +VMINT vm_phb_get_group_list(vm_phb_group_struct *group_array, VMINT group_array_len) +{ + if (NULL == _vm_phb_get_group_list) + _vm_phb_get_group_list = (_vm_phb_get_group_list_t)vm_get_sym_entry("vm_phb_get_group_list"); + + if (NULL != _vm_phb_get_group_list) + return _vm_phb_get_group_list(group_array,group_array_len); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_group_list_count.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_group_list_count.c new file mode 100644 index 00000000..ced51de3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_group_list_count.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmcontact.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_phb_get_group_list_count_t)(void); +_vm_phb_get_group_list_count_t _vm_phb_get_group_list_count = NULL; + +VMINT vm_phb_get_group_list_count(void) +{ + if (NULL == _vm_phb_get_group_list_count) + _vm_phb_get_group_list_count = (_vm_phb_get_group_list_count_t)vm_get_sym_entry("vm_phb_get_group_list_count"); + + if (NULL != _vm_phb_get_group_list_count) + return _vm_phb_get_group_list_count(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_group_name_by_id.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_group_name_by_id.c new file mode 100644 index 00000000..726fa310 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_group_name_by_id.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmcontact.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_phb_get_group_name_by_id_t)(VMUINT group_id, VMWCHAR *group_name, VMINT len); +_vm_phb_get_group_name_by_id_t _vm_phb_get_group_name_by_id = NULL; + +VMINT vm_phb_get_group_name_by_id(VMUINT group_id, VMWCHAR *group_name, VMINT len) +{ + if (NULL == _vm_phb_get_group_name_by_id) + _vm_phb_get_group_name_by_id = (_vm_phb_get_group_name_by_id_t)vm_get_sym_entry("vm_phb_get_group_name_by_id"); + + if (NULL != _vm_phb_get_group_name_by_id) + return _vm_phb_get_group_name_by_id(group_id,group_name,len); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_total_contacts.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_total_contacts.c new file mode 100644 index 00000000..688c3508 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_total_contacts.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmcontact.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_phb_get_total_contacts_t)(vm_phb_storage_loc_enum storage); +_vm_phb_get_total_contacts_t _vm_phb_get_total_contacts = NULL; + +VMINT vm_phb_get_total_contacts(vm_phb_storage_loc_enum storage) +{ + if (NULL == _vm_phb_get_total_contacts) + _vm_phb_get_total_contacts = (_vm_phb_get_total_contacts_t)vm_get_sym_entry("vm_phb_get_total_contacts"); + + if (NULL != _vm_phb_get_total_contacts) + return _vm_phb_get_total_contacts(storage); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_used_contacts.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_used_contacts.c new file mode 100644 index 00000000..5a221e15 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_used_contacts.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmcontact.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_phb_get_used_contacts_t)(vm_phb_contact_pos_struct *pos_array, vm_phb_storage_loc_enum storage); +_vm_phb_get_used_contacts_t _vm_phb_get_used_contacts = NULL; + +VMINT vm_phb_get_used_contacts(vm_phb_contact_pos_struct *pos_array, vm_phb_storage_loc_enum storage) +{ + if (NULL == _vm_phb_get_used_contacts) + _vm_phb_get_used_contacts = (_vm_phb_get_used_contacts_t)vm_get_sym_entry("vm_phb_get_used_contacts"); + + if (NULL != _vm_phb_get_used_contacts) + return _vm_phb_get_used_contacts(pos_array,storage); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_used_contacts_count.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_used_contacts_count.c new file mode 100644 index 00000000..163d53a4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_get_used_contacts_count.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmcontact.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_phb_get_used_contacts_count_t)(vm_phb_storage_loc_enum storage); +_vm_phb_get_used_contacts_count_t _vm_phb_get_used_contacts_count = NULL; + +VMINT vm_phb_get_used_contacts_count(vm_phb_storage_loc_enum storage) +{ + if (NULL == _vm_phb_get_used_contacts_count) + _vm_phb_get_used_contacts_count = (_vm_phb_get_used_contacts_count_t)vm_get_sym_entry("vm_phb_get_used_contacts_count"); + + if (NULL != _vm_phb_get_used_contacts_count) + return _vm_phb_get_used_contacts_count(storage); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_search_contact.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_search_contact.c new file mode 100644 index 00000000..31bc8220 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_search_contact.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmcontact.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_phb_req_error_enum (*_vm_phb_search_contact_t)(vm_phb_search_req_struct *req_info, vm_phb_callback_type cb); +_vm_phb_search_contact_t _vm_phb_search_contact = NULL; + +vm_phb_req_error_enum vm_phb_search_contact(vm_phb_search_req_struct *req_info, vm_phb_callback_type cb) +{ + vm_phb_req_error_enum ret = {-1}; + if (NULL == _vm_phb_search_contact) + _vm_phb_search_contact = (_vm_phb_search_contact_t)vm_get_sym_entry("vm_phb_search_contact"); + + if (NULL != _vm_phb_search_contact) + return _vm_phb_search_contact(req_info,cb); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_search_contact_list.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_search_contact_list.c new file mode 100644 index 00000000..8a3b26f1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_search_contact_list.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmcontact.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_phb_search_contact_list_t)( vm_phb_search_list_req_struct *req_info, vm_phb_contact_pos_struct *pos_array, VMINT post_array_len); +_vm_phb_search_contact_list_t _vm_phb_search_contact_list = NULL; + +VMINT vm_phb_search_contact_list( vm_phb_search_list_req_struct *req_info, vm_phb_contact_pos_struct *pos_array, VMINT post_array_len) +{ + if (NULL == _vm_phb_search_contact_list) + _vm_phb_search_contact_list = (_vm_phb_search_contact_list_t)vm_get_sym_entry("vm_phb_search_contact_list"); + + if (NULL != _vm_phb_search_contact_list) + return _vm_phb_search_contact_list(req_info,pos_array,post_array_len); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_search_contact_syn.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_search_contact_syn.c new file mode 100644 index 00000000..534fad6a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_search_contact_syn.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmcontact.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_phb_req_error_enum (*_vm_phb_search_contact_syn_t)(vm_phb_search_req_struct *req_info); +_vm_phb_search_contact_syn_t _vm_phb_search_contact_syn = NULL; + +vm_phb_req_error_enum vm_phb_search_contact_syn(vm_phb_search_req_struct *req_info) +{ + vm_phb_req_error_enum ret = {-1}; + if (NULL == _vm_phb_search_contact_syn) + _vm_phb_search_contact_syn = (_vm_phb_search_contact_syn_t)vm_get_sym_entry("vm_phb_search_contact_syn"); + + if (NULL != _vm_phb_search_contact_syn) + return _vm_phb_search_contact_syn(req_info); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_update_contact.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_update_contact.c new file mode 100644 index 00000000..88e4e1f8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_phb_update_contact.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmcontact.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_phb_req_error_enum (*_vm_phb_update_contact_t)(vm_phb_update_req_struct *req_info, vm_phb_callback_type cb); +_vm_phb_update_contact_t _vm_phb_update_contact = NULL; + +vm_phb_req_error_enum vm_phb_update_contact(vm_phb_update_req_struct *req_info, vm_phb_callback_type cb) +{ + vm_phb_req_error_enum ret = {-1}; + if (NULL == _vm_phb_update_contact) + _vm_phb_update_contact = (_vm_phb_update_contact_t)vm_get_sym_entry("vm_phb_update_contact"); + + if (NULL != _vm_phb_update_contact) + return _vm_phb_update_contact(req_info,cb); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_delete_process.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_delete_process.c new file mode 100644 index 00000000..809621d5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_delete_process.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pmng_delete_process_t)(VM_P_HANDLE p_handle); +_vm_pmng_delete_process_t _vm_pmng_delete_process = NULL; +VMINT vm_pmng_delete_process(VM_P_HANDLE p_handle) +{ + if (_vm_pmng_delete_process == NULL) + _vm_pmng_delete_process = (_vm_pmng_delete_process_t)vm_get_sym_entry("vm_pmng_delete_process"); + if (_vm_pmng_delete_process != NULL) + return _vm_pmng_delete_process(p_handle); + return -1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_get_app_handle.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_get_app_handle.c new file mode 100644 index 00000000..9839f638 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_get_app_handle.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pmng_get_app_handle_t)(void); +_vm_pmng_get_app_handle_t _vm_pmng_get_app_handle = NULL; + +VMINT vm_pmng_get_app_handle(void) +{ + if (NULL == _vm_pmng_get_app_handle) + _vm_pmng_get_app_handle = (_vm_pmng_get_app_handle_t)vm_get_sym_entry("vm_pmng_get_app_handle"); + + if (NULL != _vm_pmng_get_app_handle) + return _vm_pmng_get_app_handle(); + + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_get_current_handle.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_get_current_handle.c new file mode 100644 index 00000000..c809ae51 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_get_current_handle.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VM_P_HANDLE (*_vm_pmng_get_current_handle_t)(void); +_vm_pmng_get_current_handle_t _vm_pmng_get_current_handle = NULL; + +VM_P_HANDLE vm_pmng_get_current_handle(void) +{ + VM_P_HANDLE ret = {-1}; + if (NULL == _vm_pmng_get_current_handle) + _vm_pmng_get_current_handle = (_vm_pmng_get_current_handle_t)vm_get_sym_entry("vm_pmng_get_current_handle"); + + if (NULL != _vm_pmng_get_current_handle) + return _vm_pmng_get_current_handle(); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_get_handle.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_get_handle.c new file mode 100644 index 00000000..014304c2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_get_handle.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VM_P_HANDLE (*_vm_pmng_get_handle_t)(VMWSTR file_name); +_vm_pmng_get_handle_t _vm_pmng_get_handle = NULL; + +VM_P_HANDLE vm_pmng_get_handle(VMWSTR file_name) +{ + VM_P_HANDLE ret = {-1}; + if (NULL == _vm_pmng_get_handle) + _vm_pmng_get_handle = (_vm_pmng_get_handle_t)vm_get_sym_entry("vm_pmng_get_handle"); + + if (NULL != _vm_pmng_get_handle) + return _vm_pmng_get_handle(file_name); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_reset_ctx.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_reset_ctx.c new file mode 100644 index 00000000..8d263dfd --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_reset_ctx.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pmng_reset_ctx_t)(void); +_vm_pmng_reset_ctx_t _vm_pmng_reset_ctx = NULL; + +VMINT vm_pmng_reset_ctx(void) +{ + if (NULL == _vm_pmng_reset_ctx) + _vm_pmng_reset_ctx = (_vm_pmng_reset_ctx_t)vm_get_sym_entry("vm_pmng_reset_ctx"); + + if (NULL != _vm_pmng_reset_ctx) + return _vm_pmng_reset_ctx(); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_restore_default_event_filter.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_restore_default_event_filter.c new file mode 100644 index 00000000..087a1543 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_restore_default_event_filter.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pmng_restore_default_event_filter_t)(void); +_vm_pmng_restore_default_event_filter_t _vm_pmng_restore_default_event_filter = NULL; + +VMINT vm_pmng_restore_default_event_filter(void) +{ + if (NULL == _vm_pmng_restore_default_event_filter) + _vm_pmng_restore_default_event_filter = (_vm_pmng_restore_default_event_filter_t)vm_get_sym_entry("vm_pmng_restore_default_event_filter"); + + if (NULL != _vm_pmng_restore_default_event_filter) + return _vm_pmng_restore_default_event_filter(); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_send_app_sys_event.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_send_app_sys_event.c new file mode 100644 index 00000000..e46d8e77 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_send_app_sys_event.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pmng_send_app_sys_event_t)(VM_PROCESS_STATUS pmng_status); +_vm_pmng_send_app_sys_event_t _vm_pmng_send_app_sys_event = NULL; + +VMINT vm_pmng_send_app_sys_event(VM_PROCESS_STATUS pmng_status) +{ + if (NULL == _vm_pmng_send_app_sys_event) + _vm_pmng_send_app_sys_event = (_vm_pmng_send_app_sys_event_t)vm_get_sym_entry("vm_pmng_send_app_sys_event"); + + if (NULL != _vm_pmng_send_app_sys_event) + return _vm_pmng_send_app_sys_event(pmng_status); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_set_bg.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_set_bg.c new file mode 100644 index 00000000..f2880e7e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_set_bg.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pmng_set_bg_t)(void); +_vm_pmng_set_bg_t _vm_pmng_set_bg = NULL; + +VMINT vm_pmng_set_bg(void) +{ + if (NULL == _vm_pmng_set_bg) + _vm_pmng_set_bg = (_vm_pmng_set_bg_t)vm_get_sym_entry("vm_pmng_set_bg"); + + if (NULL != _vm_pmng_set_bg) + return _vm_pmng_set_bg(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_set_ctx.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_set_ctx.c new file mode 100644 index 00000000..930aef2a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_set_ctx.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pmng_set_ctx_t)(VM_P_HANDLE p_handle); +_vm_pmng_set_ctx_t _vm_pmng_set_ctx = NULL; + +VMINT vm_pmng_set_ctx(VM_P_HANDLE p_handle) +{ + if (NULL == _vm_pmng_set_ctx) + _vm_pmng_set_ctx = (_vm_pmng_set_ctx_t)vm_get_sym_entry("vm_pmng_set_ctx"); + + if (NULL != _vm_pmng_set_ctx) + return _vm_pmng_set_ctx(p_handle); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_set_event_filter.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_set_event_filter.c new file mode 100644 index 00000000..e8ca705a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_set_event_filter.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pmng_set_event_filter_t)(_event_filter_t* be_filter); +_vm_pmng_set_event_filter_t _vm_pmng_set_event_filter = NULL; + +VMINT vm_pmng_set_event_filter(_event_filter_t* be_filter) +{ + if (NULL == _vm_pmng_set_event_filter) + _vm_pmng_set_event_filter = (_vm_pmng_set_event_filter_t)vm_get_sym_entry("vm_pmng_set_event_filter"); + + if (NULL != _vm_pmng_set_event_filter) + return _vm_pmng_set_event_filter(be_filter); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_set_fg.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_set_fg.c new file mode 100644 index 00000000..04cce5c3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_set_fg.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VM_P_HANDLE (*_vm_pmng_set_fg_t)(VMWSTR fileName); +_vm_pmng_set_fg_t _vm_pmng_set_fg = NULL; + +VM_P_HANDLE vm_pmng_set_fg(VMWSTR fileName) +{ + if (NULL == _vm_pmng_set_fg) + _vm_pmng_set_fg = (_vm_pmng_set_fg_t)vm_get_sym_entry("vm_pmng_set_fg"); + + if (NULL != _vm_pmng_set_fg) + return _vm_pmng_set_fg(fileName); + else + return (VM_P_HANDLE)VM_PMNG_NO_SCHEDULE; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_state.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_state.c new file mode 100644 index 00000000..e5fa11e7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pmng_state.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VM_PROCESS_STATUS (*_vm_pmng_state_t)(VM_P_HANDLE p_handle); +_vm_pmng_state_t _vm_pmng_state = NULL; +VM_PROCESS_STATUS vm_pmng_state(VM_P_HANDLE p_handle) +{ + if (_vm_pmng_state == NULL) + _vm_pmng_state = (_vm_pmng_state_t)vm_get_sym_entry("vm_pmng_state"); + if (_vm_pmng_state != NULL) + return _vm_pmng_state(p_handle); + return VM_PMNG_UNLOAD; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_dereg.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_dereg.c new file mode 100644 index 00000000..370ca12a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_dereg.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpn.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pn_dereg_t)(); +_vm_pn_dereg_t _vm_pn_dereg = NULL; + +VMINT vm_pn_dereg() +{ + if (NULL == _vm_pn_dereg) + _vm_pn_dereg = (_vm_pn_dereg_t)vm_get_sym_entry("vm_pn_dereg"); + + if (NULL != _vm_pn_dereg) + return _vm_pn_dereg(); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_get_global_setting.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_get_global_setting.c new file mode 100644 index 00000000..895134b6 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_get_global_setting.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpn.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pn_get_global_setting_t)(void); +_vm_pn_get_global_setting_t _vm_pn_get_global_setting = NULL; + +VMINT vm_pn_get_global_setting(void) +{ + if (NULL == _vm_pn_get_global_setting) + _vm_pn_get_global_setting = (_vm_pn_get_global_setting_t)vm_get_sym_entry("vm_pn_get_global_setting"); + + if (NULL != _vm_pn_get_global_setting) + return _vm_pn_get_global_setting(); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_get_mps_info.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_get_mps_info.c new file mode 100644 index 00000000..bcc6c11d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_get_mps_info.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpn.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pn_get_mps_info_t)(const VMCHAR * msgBody, vm_srv_pns_msg_mps_struct * mpsPtr); +_vm_pn_get_mps_info_t _vm_pn_get_mps_info = NULL; + +VMINT vm_pn_get_mps_info(const VMCHAR * msgBody, vm_srv_pns_msg_mps_struct * mpsPtr) +{ + if (NULL == _vm_pn_get_mps_info) + _vm_pn_get_mps_info = (_vm_pn_get_mps_info_t)vm_get_sym_entry("vm_pn_get_mps_info"); + + if (NULL != _vm_pn_get_mps_info) + return _vm_pn_get_mps_info(msgBody,mpsPtr); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_get_mps_info_ex.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_get_mps_info_ex.c new file mode 100644 index 00000000..6047d34f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_get_mps_info_ex.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpn.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pn_get_mps_info_ex_t)(const VMCHAR * msgBody, vm_srv_pns_msg_mps_struct_ex* mpsPtr); +_vm_pn_get_mps_info_ex_t _vm_pn_get_mps_info_ex = NULL; + +VMINT vm_pn_get_mps_info_ex(const VMCHAR * msgBody, vm_srv_pns_msg_mps_struct_ex * mpsPtr) +{ + if (NULL == _vm_pn_get_mps_info_ex) + _vm_pn_get_mps_info_ex = (_vm_pn_get_mps_info_ex_t)vm_get_sym_entry("vm_pn_get_mps_info_ex"); + + if (NULL != _vm_pn_get_mps_info_ex) + return _vm_pn_get_mps_info_ex(msgBody,mpsPtr); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_get_object.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_get_object.c new file mode 100644 index 00000000..9b30f0cb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_get_object.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpn.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pn_get_object_t)(const VMCHAR * msgBody, const VMCHAR * key, vm_srv_pns_msg_value_struct * value); +_vm_pn_get_object_t _vm_pn_get_object = NULL; + +VMINT vm_pn_get_object(const VMCHAR * msgBody, const VMCHAR * key, vm_srv_pns_msg_value_struct * value) +{ + if (NULL == _vm_pn_get_object) + _vm_pn_get_object = (_vm_pn_get_object_t)vm_get_sym_entry("vm_pn_get_object"); + + if (NULL != _vm_pn_get_object) + return _vm_pn_get_object(msgBody,key,value); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_is_support.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_is_support.c new file mode 100644 index 00000000..3136cc15 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_is_support.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpn.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pn_is_support_t)(void); +_vm_pn_is_support_t _vm_pn_is_support = NULL; + +VMINT vm_pn_is_support(void) +{ + if (NULL == _vm_pn_is_support) + _vm_pn_is_support = (_vm_pn_is_support_t)vm_get_sym_entry("vm_pn_is_support"); + + if (NULL != _vm_pn_is_support) + return _vm_pn_is_support(); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_query.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_query.c new file mode 100644 index 00000000..a2fdd1b3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_query.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpn.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pn_query_t)(vm_srv_pns_query_event query_id, void * user_data); +_vm_pn_query_t _vm_pn_query = NULL; + +VMINT vm_pn_query(vm_srv_pns_query_event query_id, void * user_data) +{ + if (NULL == _vm_pn_query) + _vm_pn_query = (_vm_pn_query_t)vm_get_sym_entry("vm_pn_query"); + + if (NULL != _vm_pn_query) + return _vm_pn_query(query_id,user_data); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_reg.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_reg.c new file mode 100644 index 00000000..8a2689e8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_reg.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpn.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pn_reg_t)(vm_pn_cb cb, void* user_data); +_vm_pn_reg_t _vm_pn_reg = NULL; + +VMINT vm_pn_reg(vm_pn_cb cb, void* user_data) +{ + if (NULL == _vm_pn_reg) + _vm_pn_reg = (_vm_pn_reg_t)vm_get_sym_entry("vm_pn_reg"); + + if (NULL != _vm_pn_reg) + return _vm_pn_reg(cb,user_data); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_set_badge.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_set_badge.c new file mode 100644 index 00000000..e4f8de5a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_set_badge.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpn.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pn_set_badge_t)(VMINT32 badege_number); +_vm_pn_set_badge_t _vm_pn_set_badge = NULL; + +VMINT vm_pn_set_badge(VMINT32 badege_number) +{ + if (NULL == _vm_pn_set_badge) + _vm_pn_set_badge = (_vm_pn_set_badge_t)vm_get_sym_entry("vm_pn_set_badge"); + + if (NULL != _vm_pn_set_badge) + return _vm_pn_set_badge(badege_number); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_set_notify_style.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_set_notify_style.c new file mode 100644 index 00000000..54eae6e5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_pn_set_notify_style.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpn.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_pn_set_notify_style_t)(vm_srv_pns_notify_switch OnOff, vm_srv_pns_notify_style style); +_vm_pn_set_notify_style_t _vm_pn_set_notify_style = NULL; + +VMINT vm_pn_set_notify_style(vm_srv_pns_notify_switch OnOff, vm_srv_pns_notify_style style) +{ + if (NULL == _vm_pn_set_notify_style) + _vm_pn_set_notify_style = (_vm_pn_set_notify_style_t)vm_get_sym_entry("vm_pn_set_notify_style"); + + if (NULL != _vm_pn_set_notify_style) + return _vm_pn_set_notify_style(OnOff,style); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_popup_stack.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_popup_stack.c new file mode 100644 index 00000000..efe93bc1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_popup_stack.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_popup_stack_t)(VMINT stackHandle, void** ptr); +_vm_popup_stack_t _vm_popup_stack = NULL; + +VMINT vm_popup_stack(VMINT stackHandle, void** ptr) +{ + if (NULL == _vm_popup_stack) + _vm_popup_stack = (_vm_popup_stack_t)vm_get_sym_entry("vm_popup_stack"); + + if (NULL != _vm_popup_stack) + return _vm_popup_stack(stackHandle,ptr); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_post_msg.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_post_msg.c new file mode 100644 index 00000000..286963c7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_post_msg.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_post_msg_t)(VM_P_HANDLE phandle, VMUINT msg_id, VMINT wparam, VMINT lparam); +_vm_post_msg_t _vm_post_msg = NULL; + +VMINT vm_post_msg(VM_P_HANDLE phandle, VMUINT msg_id, VMINT wparam, VMINT lparam) +{ + if (NULL == _vm_post_msg) + _vm_post_msg = (_vm_post_msg_t)vm_get_sym_entry("vm_post_msg"); + + if (NULL != _vm_post_msg) + return _vm_post_msg(phandle,msg_id,wparam,lparam); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_push_stack.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_push_stack.c new file mode 100644 index 00000000..623af049 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_push_stack.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_push_stack_t)(VMINT stackHandle, void* ptr); +_vm_push_stack_t _vm_push_stack = NULL; + +VMINT vm_push_stack(VMINT stackHandle, void* ptr) +{ + if (NULL == _vm_push_stack) + _vm_push_stack = (_vm_push_stack_t)vm_get_sym_entry("vm_push_stack"); + + if (NULL != _vm_push_stack) + return _vm_push_stack(stackHandle,ptr); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_query_operator_code.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_query_operator_code.c new file mode 100644 index 00000000..8509fe7b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_query_operator_code.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_query_operator_code_t)(VMCHAR *buffer, VMUINT buffer_size); +_vm_query_operator_code_t _vm_query_operator_code = NULL; + +VMINT vm_query_operator_code(VMCHAR *buffer, VMUINT buffer_size) +{ + if (NULL == _vm_query_operator_code) + _vm_query_operator_code = (_vm_query_operator_code_t)vm_get_sym_entry("vm_query_operator_code"); + + if (NULL != _vm_query_operator_code) + return _vm_query_operator_code(buffer,buffer_size); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_read_cache.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_read_cache.c new file mode 100644 index 00000000..463c38e3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_read_cache.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_read_cache_t)(vm_cache_t *cache, void *buf, VMINT buf_size, VMINT len); +_vm_read_cache_t _vm_read_cache = NULL; + +VMINT vm_read_cache(vm_cache_t *cache, void *buf, VMINT buf_size, VMINT len) +{ + if (NULL == _vm_read_cache) + _vm_read_cache = (_vm_read_cache_t)vm_get_sym_entry("vm_read_cache"); + + if (NULL != _vm_read_cache) + return _vm_read_cache(cache,buf,buf_size,len); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_read_from_uart.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_read_from_uart.c new file mode 100644 index 00000000..a414d583 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_read_from_uart.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmuart.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT16 (*_vm_read_from_uart_t)(VMINT32 handle, VMUINT8 *buffer, VMUINT16 length); + _vm_read_from_uart_t _vm_read_from_uart = NULL; + +VMUINT16 vm_read_from_uart(VMINT32 handle, VMUINT8 *buffer, VMUINT16 length) +{ + if (NULL == _vm_read_from_uart) + _vm_read_from_uart = (_vm_read_from_uart_t)vm_get_sym_entry("vm_read_from_uart"); + + if (NULL != _vm_read_from_uart) + _vm_read_from_uart(handle, buffer, length); +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_read_line.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_read_line.c new file mode 100644 index 00000000..fb4041b9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_read_line.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_read_line_t)(char* line, VMINT size, vm_cache_t* cache); +_vm_read_line_t _vm_read_line = NULL; + +VMINT vm_read_line(char* line, VMINT size, vm_cache_t* cache) +{ + if (NULL == _vm_read_line) + _vm_read_line = (_vm_read_line_t)vm_get_sym_entry("vm_read_line"); + + if (NULL != _vm_read_line) + return _vm_read_line(line,size,cache); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_realloc.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_realloc.c new file mode 100644 index 00000000..d9a6214e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_realloc.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void *(*_vm_realloc_t)(void* p, int size); +_vm_realloc_t _vm_realloc = NULL; + +void *vm_realloc(void* p, int size) +{ + if (NULL == _vm_realloc) + _vm_realloc = (_vm_realloc_t)vm_get_sym_entry("vm_realloc"); + + if (NULL != _vm_realloc) + return _vm_realloc(p,size); + return NULL; + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_realloc_topmost.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_realloc_topmost.c new file mode 100644 index 00000000..021791f3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_realloc_topmost.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void *(*_vm_realloc_topmost_t)(void* p, int size); +_vm_realloc_topmost_t _vm_realloc_topmost = NULL; + +void *vm_realloc_topmost(void* p, int size) +{ + if (NULL == _vm_realloc_topmost) + _vm_realloc_topmost = (_vm_realloc_topmost_t)vm_get_sym_entry("vm_realloc_topmost"); + + if (NULL != _vm_realloc_topmost) + return _vm_realloc_topmost(p,size); + return NULL; + + +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reboot_normal_start.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reboot_normal_start.c new file mode 100644 index 00000000..ef999857 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reboot_normal_start.c @@ -0,0 +1,16 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT8 (*_vm_reboot_normal_start_t)(void); +_vm_reboot_normal_start_t _vm_reboot_normal_start = NULL; + +void vm_reboot_normal_start(void) +{ + if (NULL == _vm_reboot_normal_start) + _vm_reboot_normal_start = (_vm_reboot_normal_start_t)vm_get_sym_entry("vm_reboot_normal_start"); + + if (NULL != _vm_reboot_normal_start) + _vm_reboot_normal_start(); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_record_pause.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_record_pause.c new file mode 100644 index 00000000..018f306e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_record_pause.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_record_pause_t)(void); +_vm_record_pause_t _vm_record_pause = NULL; + +VMINT vm_record_pause(void) +{ + if (NULL == _vm_record_pause) + _vm_record_pause = (_vm_record_pause_t)vm_get_sym_entry("vm_record_pause"); + + if (NULL != _vm_record_pause) + return _vm_record_pause(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_record_resume.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_record_resume.c new file mode 100644 index 00000000..4731dfc3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_record_resume.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_record_resume_t)(void); +_vm_record_resume_t _vm_record_resume = NULL; + +VMINT vm_record_resume(void) +{ + if (NULL == _vm_record_resume) + _vm_record_resume = (_vm_record_resume_t)vm_get_sym_entry("vm_record_resume"); + + if (NULL != _vm_record_resume) + return _vm_record_resume(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_record_start.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_record_start.c new file mode 100644 index 00000000..c02e02a0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_record_start.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_record_start_t)(VMSTR drv_name, VMSTR dir_name, VMSTR rec_name, VMUINT8 format, VMWSTR full_rec_file_wname, vm_recorder_callback vm_record_cb); +_vm_record_start_t _vm_record_start = NULL; + +VMINT vm_record_start(VMSTR drv_name, VMSTR dir_name, VMSTR rec_name, VMUINT8 format, VMWSTR full_rec_file_wname, vm_recorder_callback vm_record_cb) +{ + if (NULL == _vm_record_start) + _vm_record_start = (_vm_record_start_t)vm_get_sym_entry("vm_record_start"); + + if (NULL != _vm_record_start) + return _vm_record_start(drv_name,dir_name,rec_name,format,full_rec_file_wname,vm_record_cb); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_record_stop.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_record_stop.c new file mode 100644 index 00000000..c0839ea8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_record_stop.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_record_stop_t)(void); +_vm_record_stop_t _vm_record_stop = NULL; + +VMINT vm_record_stop(void) +{ + if (NULL == _vm_record_stop) + _vm_record_stop = (_vm_record_stop_t)vm_get_sym_entry("vm_record_stop"); + + if (NULL != _vm_record_stop) + return _vm_record_stop(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_recv.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_recv.c new file mode 100644 index 00000000..943f56ff --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_recv.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_recv_t)(int sock, char *buf, int len, int flags); +_vm_recv_t _vm_recv = NULL; + +int vm_recv(int sock, char *buf, int len, int flags) +{ + if (NULL == _vm_recv) + _vm_recv = (_vm_recv_t)vm_get_sym_entry("vm_recv"); + if (NULL != _vm_recv) + return _vm_recv(sock,buf,len,flags); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_recvfrom.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_recvfrom.c new file mode 100644 index 00000000..7f8d4f4e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_recvfrom.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_recvfrom_t)(int sock, char *buf, int len, int flags, SOCKADDR *from, int *fromlen); +_vm_recvfrom_t _vm_recvfrom = NULL; + +int vm_recvfrom(int sock, char *buf, int len, int flags, SOCKADDR *from, int *fromlen) +{ + if (NULL == _vm_recvfrom) + _vm_recvfrom = (_vm_recvfrom_t)vm_get_sym_entry("vm_recvfrom"); + if (NULL != _vm_recvfrom) + return _vm_recvfrom(sock,buf,len,flags,from,fromlen); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reg_func_callback.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reg_func_callback.c new file mode 100644 index 00000000..bbc8a018 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reg_func_callback.c @@ -0,0 +1,17 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void(*_vm_reg_func_callback_t)(VMINT (*f)(VMSTR symbol)); +_vm_reg_func_callback_t _vm_reg_func_callback = NULL; + +void vm_reg_func_callback(VMINT (*f)(VMSTR symbol)) +{ + if (_vm_reg_func_callback == NULL) { + _vm_reg_func_callback = (_vm_reg_func_callback_t)vm_get_sym_entry("vm_reg_func_callback"); + } + if (_vm_reg_func_callback != NULL) { + _vm_reg_func_callback(f); + } +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reg_http_notification.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reg_http_notification.c new file mode 100644 index 00000000..f7e79528 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reg_http_notification.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmhttp.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_reg_http_notification_t)(void (*f)(VMINT state, VMINT param)); +_vm_reg_http_notification_t _vm_reg_http_notification = NULL; + +void vm_reg_http_notification(void (*f)(VMINT state, VMINT param)) +{ + if (NULL == _vm_reg_http_notification) + _vm_reg_http_notification = (_vm_reg_http_notification_t)vm_get_sym_entry("vm_reg_http_notification"); + + if (NULL != _vm_reg_http_notification) + _vm_reg_http_notification(f); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reg_msg_proc.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reg_msg_proc.c new file mode 100644 index 00000000..89e86380 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reg_msg_proc.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_reg_msg_proc_t)(VM_MESSAGE_PROC proc); +_vm_reg_msg_proc_t _vm_reg_msg_proc = NULL; + +void vm_reg_msg_proc(VM_MESSAGE_PROC proc) +{ + if (NULL == _vm_reg_msg_proc) + _vm_reg_msg_proc = (_vm_reg_msg_proc_t)vm_get_sym_entry("vm_reg_msg_proc"); + + if (NULL != _vm_reg_msg_proc) + _vm_reg_msg_proc(proc); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reg_sysevt_callback.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reg_sysevt_callback.c new file mode 100644 index 00000000..d195b60e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reg_sysevt_callback.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_reg_sysevt_callback_t)(void (*f)(VMINT message, VMINT param)); +_vm_reg_sysevt_callback_t _vm_reg_sysevt_callback = NULL; + +void vm_reg_sysevt_callback(void (*f)(VMINT message, VMINT param)) +{ + if (NULL == _vm_reg_sysevt_callback) + _vm_reg_sysevt_callback = (_vm_reg_sysevt_callback_t)vm_get_sym_entry("vm_reg_sysevt_callback"); + + if (NULL != _vm_reg_sysevt_callback) + _vm_reg_sysevt_callback(f); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reset_stack.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reset_stack.c new file mode 100644 index 00000000..3f9c5041 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_reset_stack.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_reset_stack_t)(VMINT stackHandle); +_vm_reset_stack_t _vm_reset_stack = NULL; + +VMINT vm_reset_stack(VMINT stackHandle) +{ + if (NULL == _vm_reset_stack) + _vm_reset_stack = (_vm_reset_stack_t)vm_get_sym_entry("vm_reset_stack"); + + if (NULL != _vm_reset_stack) + return _vm_reset_stack(stackHandle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_resource_get_data.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_resource_get_data.c new file mode 100644 index 00000000..81e7b247 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_resource_get_data.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmres.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_resource_get_data_t)(VMUINT8 *data, VMUINT32 offset, VMUINT32 size); +_vm_resource_get_data_t _vm_resource_get_data = NULL; + +VMINT32 vm_resource_get_data(VMUINT8 *data, VMUINT32 offset, VMUINT32 size) +{ + if (NULL == _vm_resource_get_data) + _vm_resource_get_data = (_vm_resource_get_data_t)vm_get_sym_entry("vm_resource_get_data"); + + if (NULL != _vm_resource_get_data) + return _vm_resource_get_data(data,offset,size); + + return (VMINT32 )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_resource_get_data_from_file.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_resource_get_data_from_file.c new file mode 100644 index 00000000..dec94c50 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_resource_get_data_from_file.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmres.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_resource_get_data_from_file_t)(VMWSTR filename, VMUINT8 *data, VMUINT32 offset, VMUINT32 size); +_vm_resource_get_data_from_file_t _vm_resource_get_data_from_file = NULL; + +VMINT32 vm_resource_get_data_from_file(VMWSTR filename, VMUINT8 *data, VMUINT32 offset, VMUINT32 size) +{ + if (NULL == _vm_resource_get_data_from_file) + _vm_resource_get_data_from_file = (_vm_resource_get_data_from_file_t)vm_get_sym_entry("vm_resource_get_data_from_file"); + + if (NULL != _vm_resource_get_data_from_file) + return _vm_resource_get_data_from_file(filename, data,offset,size); + + return (VMINT32 )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_restore_irq_mask.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_restore_irq_mask.c new file mode 100644 index 00000000..6004c9a9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_restore_irq_mask.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmdcl.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_restore_irq_mask_t)(VMUINT32 mask); +_vm_restore_irq_mask_t _vm_restore_irq_mask = NULL; +void vm_restore_irq_mask(VMUINT32 mask) +{ + if (NULL == _vm_restore_irq_mask) + _vm_restore_irq_mask = (_vm_restore_irq_mask_t)vm_get_sym_entry("vm_restore_irq_mask"); + + if (NULL != _vm_restore_irq_mask) + _vm_restore_irq_mask(mask); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_safe_wstrcpy.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_safe_wstrcpy.c new file mode 100644 index 00000000..37945ff0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_safe_wstrcpy.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_safe_wstrcpy_t)(VMWSTR dest, VMINT size, VMWSTR src); +_vm_safe_wstrcpy_t _vm_safe_wstrcpy = NULL; + +VMINT vm_safe_wstrcpy(VMWSTR dest, VMINT size, VMWSTR src) +{ + if (NULL == _vm_safe_wstrcpy) + _vm_safe_wstrcpy = (_vm_safe_wstrcpy_t)vm_get_sym_entry("vm_safe_wstrcpy"); + + if (NULL != _vm_safe_wstrcpy) + return _vm_safe_wstrcpy(dest,size,src); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_save_irq_mask.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_save_irq_mask.c new file mode 100644 index 00000000..698a1480 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_save_irq_mask.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmdcl.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + + +typedef VMUINT32 (*_vm_save_irq_mask_t)(void); +_vm_save_irq_mask_t _vm_save_irq_mask = NULL; +VMUINT32 vm_save_irq_mask(void) +{ + if (NULL == _vm_save_irq_mask) + _vm_save_irq_mask = (_vm_save_irq_mask_t)vm_get_sym_entry("vm_save_irq_mask"); + + if (NULL != _vm_save_irq_mask) + return _vm_save_irq_mask(); + + return (VMUINT32)0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_select.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_select.c new file mode 100644 index 00000000..0eae2e5b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_select.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_select_t)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const timeval *timeout); +_vm_select_t _vm_select = NULL; + +int vm_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const timeval *timeout) +{ + if (NULL == _vm_select) + _vm_select = (_vm_select_t)vm_get_sym_entry("vm_select"); + if (NULL != _vm_select) + return _vm_select(nfds,readfds,writefds,exceptfds,timeout); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_send.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_send.c new file mode 100644 index 00000000..34ce3dab --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_send.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_send_t)(int sock, const char *buf, int len, int flags); +_vm_send_t _vm_send = NULL; + +int vm_send(int sock, const char *buf, int len, int flags) +{ + if (NULL == _vm_send) + _vm_send = (_vm_send_t)vm_get_sym_entry("vm_send"); + if (NULL != _vm_send) + return _vm_send(sock,buf,len,flags); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_send_msg.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_send_msg.c new file mode 100644 index 00000000..3dfca8ef --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_send_msg.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_send_msg_t)(VM_P_HANDLE phandle, VMUINT msg_id, VMINT wparam, VMINT lparam); +_vm_send_msg_t _vm_send_msg = NULL; + +VMINT vm_send_msg(VM_P_HANDLE phandle, VMUINT msg_id, VMINT wparam, VMINT lparam) +{ + if (NULL == _vm_send_msg) + _vm_send_msg = (_vm_send_msg_t)vm_get_sym_entry("vm_send_msg"); + + if (NULL != _vm_send_msg) + return _vm_send_msg(phandle,msg_id,wparam,lparam); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_send_sms.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_send_sms.c new file mode 100644 index 00000000..e085c19f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_send_sms.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtel.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_send_sms_t)(VMWSTR phone_number, VMWSTR content, void (*callback)(VMINT result)); +_vm_send_sms_t _vm_send_sms = NULL; + +VMINT vm_send_sms(VMWSTR phone_number, VMWSTR content, void (*callback)(VMINT result)) +{ + if (NULL == _vm_send_sms) + _vm_send_sms = (_vm_send_sms_t)vm_get_sym_entry("vm_send_sms"); + + if (NULL != _vm_send_sms) + return _vm_send_sms(phone_number,content,callback); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sendto.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sendto.c new file mode 100644 index 00000000..cf4cc4f8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sendto.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_sendto_t)(int sock, const char *buf, int len, int flags, const SOCKADDR *to, int tolen); +_vm_sendto_t _vm_sendto = NULL; + +int vm_sendto(int sock, const char *buf, int len, int flags, const SOCKADDR *to, int tolen) +{ + if (NULL == _vm_sendto) + _vm_sendto = (_vm_sendto_t)vm_get_sym_entry("vm_sendto"); + if (NULL != _vm_sendto) + return _vm_sendto(sock,buf,len,flags,to,tolen); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_active_sim_card.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_active_sim_card.c new file mode 100644 index 00000000..200d24ac --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_active_sim_card.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_set_active_sim_card_t)(VMINT card_id); +_vm_set_active_sim_card_t _vm_set_active_sim_card = NULL; + +VMINT vm_set_active_sim_card(VMINT card_id) +{ + if (NULL == _vm_set_active_sim_card) + _vm_set_active_sim_card = (_vm_set_active_sim_card_t)vm_get_sym_entry("vm_set_active_sim_card"); + + if (NULL != _vm_set_active_sim_card) + return _vm_set_active_sim_card(card_id); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_app_desired_input_mode.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_app_desired_input_mode.c new file mode 100644 index 00000000..75689757 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_app_desired_input_mode.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmio.h" +#include "vminput.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_set_app_desired_input_mode_t)(vm_input_mode_enum desired_input_mode); +_vm_set_app_desired_input_mode_t _vm_set_app_desired_input_mode = NULL; + +void vm_set_app_desired_input_mode(vm_input_mode_enum desired_input_mode) +{ + if (NULL == _vm_set_app_desired_input_mode) + _vm_set_app_desired_input_mode = (_vm_set_app_desired_input_mode_t)vm_get_sym_entry("vm_set_app_desired_input_mode"); + + if (NULL != _vm_set_app_desired_input_mode) + _vm_set_app_desired_input_mode(desired_input_mode); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_cust_apn_info.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_cust_apn_info.c new file mode 100644 index 00000000..3cefb775 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_cust_apn_info.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_set_cust_apn_info_t)(const vm_dtcnt_info_t * info, VMUINT32 * dtacct); +_vm_set_cust_apn_info_t _vm_set_cust_apn_info = NULL; + +VMINT vm_set_cust_apn_info(const vm_dtcnt_info_t * info, VMUINT32 * dtacct) +{ + if (NULL == _vm_set_cust_apn_info) + _vm_set_cust_apn_info = (_vm_set_cust_apn_info_t)vm_get_sym_entry("vm_set_cust_apn_info"); + + if (NULL != _vm_set_cust_apn_info) + return _vm_set_cust_apn_info(info, dtacct); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_kal_timer.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_kal_timer.c new file mode 100644 index 00000000..158eaad3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_kal_timer.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmtimer.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_set_kal_timer_t)(vm_kal_timerid timer_ptr, vm_kal_timer_func_ptr handler_func_ptr,void *handler_param_ptr, VMUINT32 delay, VMUINT32 reshedule_time); +_vm_set_kal_timer_t _vm_set_kal_timer = NULL; +void vm_set_kal_timer(vm_kal_timerid timer_ptr, vm_kal_timer_func_ptr handler_func_ptr,void *handler_param_ptr, VMUINT32 delay, VMUINT32 reshedule_time) + +{ + if (NULL == _vm_set_kal_timer) + _vm_set_kal_timer = (_vm_set_kal_timer_t)vm_get_sym_entry("vm_set_kal_timer"); + if (NULL != _vm_set_kal_timer) + _vm_set_kal_timer(timer_ptr,handler_func_ptr,handler_param_ptr,delay,reshedule_time); +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_ringtone.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_ringtone.c new file mode 100644 index 00000000..e78a9c86 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_ringtone.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_set_ringtone_t)(VMWSTR filepath); +_vm_set_ringtone_t _vm_set_ringtone = NULL; + +VMINT vm_set_ringtone(VMWSTR filepath) +{ + if (NULL == _vm_set_ringtone) + _vm_set_ringtone = (_vm_set_ringtone_t)vm_get_sym_entry("vm_set_ringtone"); + + if (NULL != _vm_set_ringtone) + return _vm_set_ringtone(filepath); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_volume.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_volume.c new file mode 100644 index 00000000..a2f6dd6d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_set_volume.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_set_volume_t)(VMINT volume); +_vm_set_volume_t _vm_set_volume = NULL; + +void vm_set_volume(VMINT volume) +{ + if (NULL == _vm_set_volume) + _vm_set_volume = (_vm_set_volume_t)vm_get_sym_entry("vm_set_volume"); + + if (NULL != _vm_set_volume) + _vm_set_volume(volume); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setsockopt.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setsockopt.c new file mode 100644 index 00000000..bda553fc --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setsockopt.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_setsockopt_t)(int sock, VMUINT32 option, void *val, VMUINT8 val_size); +_vm_setsockopt_t _vm_setsockopt = NULL; + +int vm_setsockopt(int sock, VMUINT32 option, void *val, VMUINT8 val_size) +{ + if (NULL == _vm_setsockopt) + _vm_setsockopt = (_vm_setsockopt_t)vm_get_sym_entry("vm_setsockopt"); + if (NULL != _vm_setsockopt) + return _vm_setsockopt(sock,option,val,val_size); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setting_get_date_format.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setting_get_date_format.c new file mode 100644 index 00000000..7e753631 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setting_get_date_format.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsettings.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_setting_get_date_format_t)(void); +_vm_setting_get_date_format_t _vm_setting_get_date_format = NULL; + +VMINT vm_setting_get_date_format(void) +{ + if (NULL == _vm_setting_get_date_format) + _vm_setting_get_date_format = (_vm_setting_get_date_format_t)vm_get_sym_entry("vm_setting_get_date_format"); + + if (NULL != _vm_setting_get_date_format) + return _vm_setting_get_date_format(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setting_get_date_seperator.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setting_get_date_seperator.c new file mode 100644 index 00000000..31571952 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setting_get_date_seperator.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsettings.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_setting_get_date_seperator_t)(void); +_vm_setting_get_date_seperator_t _vm_setting_get_date_seperator = NULL; + +VMINT vm_setting_get_date_seperator(void) +{ + if (NULL == _vm_setting_get_date_seperator) + _vm_setting_get_date_seperator = (_vm_setting_get_date_seperator_t)vm_get_sym_entry("vm_setting_get_date_seperator"); + + if (NULL != _vm_setting_get_date_seperator) + return _vm_setting_get_date_seperator(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setting_get_time_format.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setting_get_time_format.c new file mode 100644 index 00000000..006943f8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setting_get_time_format.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsettings.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_setting_get_time_format_t)(void); +_vm_setting_get_time_format_t _vm_setting_get_time_format = NULL; + +VMINT vm_setting_get_time_format(void) +{ + if (NULL == _vm_setting_get_time_format) + _vm_setting_get_time_format = (_vm_setting_get_time_format_t)vm_get_sym_entry("vm_setting_get_time_format"); + + if (NULL != _vm_setting_get_time_format) + return _vm_setting_get_time_format(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setting_srv_command.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setting_srv_command.c new file mode 100644 index 00000000..e42c8be2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_setting_srv_command.c @@ -0,0 +1,29 @@ +#include "vmsys.h" +#include "vmsettings.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT32 (*_vm_setting_srv_command_t)(VMUINT16 type, + VMUINT16 operation, + void *in, + void *out, + vm_setting_srv_result_callback cb, + void *user_data); +_vm_setting_srv_command_t _vm_setting_srv_command = NULL; + +VMINT32 vm_setting_srv_command(VMUINT16 type, + VMUINT16 operation, + void *in, + void *out, + vm_setting_srv_result_callback cb, + void *user_data) +{ + if (NULL == _vm_setting_srv_command) + _vm_setting_srv_command = (_vm_setting_srv_command_t)vm_get_sym_entry("vm_setting_srv_command"); + + if (NULL != _vm_setting_srv_command) + return _vm_setting_srv_command(type, operation, in, out, cb, user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_settings_set_tone.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_settings_set_tone.c new file mode 100644 index 00000000..b1471ac2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_settings_set_tone.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsettings.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_settings_set_tone_t)(vm_settings_tone_enum type, VMWCHAR* path); +_vm_settings_set_tone_t _vm_settings_set_tone = NULL; + +VMINT vm_settings_set_tone(vm_settings_tone_enum type, VMWCHAR* path) +{ + if (NULL == _vm_settings_set_tone) + _vm_settings_set_tone = (_vm_settings_set_tone_t)vm_get_sym_entry("vm_settings_set_tone"); + + if (NULL != _vm_settings_set_tone) + return _vm_settings_set_tone(type,path); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_settings_set_wallpaper.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_settings_set_wallpaper.c new file mode 100644 index 00000000..d23f301c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_settings_set_wallpaper.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsettings.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_settings_set_wallpaper_t)(vm_setttings_wallpaper_enum type, VMWCHAR* path,vm_settings_set_wallpaper_callback callback, void* user_data); +_vm_settings_set_wallpaper_t _vm_settings_set_wallpaper = NULL; + +VMINT vm_settings_set_wallpaper(vm_setttings_wallpaper_enum type, VMWCHAR* path,vm_settings_set_wallpaper_callback callback, void* user_data) +{ + if (NULL == _vm_settings_set_wallpaper) + _vm_settings_set_wallpaper = (_vm_settings_set_wallpaper_t)vm_get_sym_entry("vm_settings_set_wallpaper"); + + if (NULL != _vm_settings_set_wallpaper) + return _vm_settings_set_wallpaper(type,path,callback,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_shutdown.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_shutdown.c new file mode 100644 index 00000000..83aa4684 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_shutdown.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_shutdown_t)(int sock, int how); +_vm_shutdown_t _vm_shutdown = NULL; + +int vm_shutdown(int sock, int how) +{ + if (NULL == _vm_shutdown) + _vm_shutdown = (_vm_shutdown_t)vm_get_sym_entry("vm_shutdown"); + if (NULL != _vm_shutdown) + return _vm_shutdown(sock,how); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_shutdown_normal_start.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_shutdown_normal_start.c new file mode 100644 index 00000000..e925db93 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_shutdown_normal_start.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmpwr.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_shutdown_normal_start_t)(VMUINT16 trigger_man_app_id); +_vm_shutdown_normal_start_t _vm_shutdown_normal_start = NULL; + +void vm_shutdown_normal_start(VMUINT16 trigger_man_app_id) +{ + if (NULL == _vm_shutdown_normal_start) + _vm_shutdown_normal_start = (_vm_shutdown_normal_start_t)vm_get_sym_entry("vm_shutdown_normal_start"); + + if (NULL != _vm_shutdown_normal_start) + _vm_shutdown_normal_start(trigger_man_app_id); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_card_count.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_card_count.c new file mode 100644 index 00000000..6fc0c1b7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_card_count.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sim_card_count_t)(void); +_vm_sim_card_count_t _vm_sim_card_count = NULL; + +VMINT vm_sim_card_count(void) +{ + if (NULL == _vm_sim_card_count) + _vm_sim_card_count = (_vm_sim_card_count_t)vm_get_sym_entry("vm_sim_card_count"); + + if (NULL != _vm_sim_card_count) + return _vm_sim_card_count(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_active_sim_card.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_active_sim_card.c new file mode 100644 index 00000000..24f29b47 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_active_sim_card.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sim_get_active_sim_card_t)(void); +_vm_sim_get_active_sim_card_t _vm_sim_get_active_sim_card = NULL; + +VMINT vm_sim_get_active_sim_card(void) +{ + if (NULL == _vm_sim_get_active_sim_card) + _vm_sim_get_active_sim_card = (_vm_sim_get_active_sim_card_t)vm_get_sym_entry("vm_sim_get_active_sim_card"); + + if (NULL != _vm_sim_get_active_sim_card) + return _vm_sim_get_active_sim_card(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_card_status.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_card_status.c new file mode 100644 index 00000000..7bec59b2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_card_status.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_sim_state_t (*_vm_sim_get_card_status_t)(VMINT sim); +_vm_sim_get_card_status_t _vm_sim_get_card_status = NULL; + +vm_sim_state_t vm_sim_get_card_status(VMINT sim) +{ + if (NULL == _vm_sim_get_card_status) + _vm_sim_get_card_status = (_vm_sim_get_card_status_t)vm_get_sym_entry("vm_sim_get_card_status"); + if (NULL != _vm_sim_get_card_status) + return _vm_sim_get_card_status(sim); + return (vm_sim_state_t)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_iccid.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_iccid.c new file mode 100644 index 00000000..76ce5e18 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_iccid.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sim_get_iccid_t)(VMINT sim, vm_sim_get_iccid_cb callback, VMCHAR* iccid, VMINT buff_len, void* user_data); +_vm_sim_get_iccid_t _vm_sim_get_iccid = NULL; + +VMINT vm_sim_get_iccid(VMINT sim, vm_sim_get_iccid_cb callback, VMCHAR* iccid, VMINT buff_len, void* user_data) +{ + if (NULL == _vm_sim_get_iccid) + _vm_sim_get_iccid = (_vm_sim_get_iccid_t)vm_get_sym_entry("vm_sim_get_iccid"); + + if (NULL != _vm_sim_get_iccid) + return _vm_sim_get_iccid(sim,callback,iccid,buff_len,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_imei.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_imei.c new file mode 100644 index 00000000..477ea739 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_imei.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMSTR (*_vm_sim_get_imei_t)(void); +_vm_sim_get_imei_t _vm_sim_get_imei = NULL; + +VMSTR vm_sim_get_imei(void) +{ + if (NULL == _vm_sim_get_imei) + _vm_sim_get_imei = (_vm_sim_get_imei_t)vm_get_sym_entry("vm_sim_get_imei"); + if (NULL != _vm_sim_get_imei) + return _vm_sim_get_imei(); + return (VMSTR)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_imei_ext.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_imei_ext.c new file mode 100644 index 00000000..59140a95 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_imei_ext.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMSTR (*_vm_sim_get_imei_ext_t)(VMINT sim); +_vm_sim_get_imei_ext_t _vm_sim_get_imei_ext = NULL; + +VMSTR vm_sim_get_imei_ext(VMINT sim) +{ + if (NULL == _vm_sim_get_imei_ext) + _vm_sim_get_imei_ext = (_vm_sim_get_imei_ext_t)vm_get_sym_entry("vm_sim_get_imei_ext"); + if (NULL != _vm_sim_get_imei_ext) + return _vm_sim_get_imei_ext(sim); + return (VMSTR)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_imsi.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_imsi.c new file mode 100644 index 00000000..aa961ca9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_imsi.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMSTR (*_vm_sim_get_imsi_t)(void); +_vm_sim_get_imsi_t _vm_sim_get_imsi = NULL; + +VMSTR vm_sim_get_imsi(void) +{ + if (NULL == _vm_sim_get_imsi) + _vm_sim_get_imsi = (_vm_sim_get_imsi_t)vm_get_sym_entry("vm_sim_get_imsi"); + if (NULL != _vm_sim_get_imsi) + return _vm_sim_get_imsi(); + return (VMSTR)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_operator.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_operator.c new file mode 100644 index 00000000..1d593089 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_operator.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef operator_t (*_vm_sim_get_operator_t)(void); +_vm_sim_get_operator_t _vm_sim_get_operator = NULL; + +operator_t vm_sim_get_operator(void) +{ + if (NULL == _vm_sim_get_operator) + _vm_sim_get_operator = (_vm_sim_get_operator_t)vm_get_sym_entry("vm_sim_get_operator"); + if (NULL != _vm_sim_get_operator) + return _vm_sim_get_operator(); + return (operator_t)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_prefer_sim_card.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_prefer_sim_card.c new file mode 100644 index 00000000..89c1d7ea --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_get_prefer_sim_card.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sim_get_prefer_sim_card_t)(void); +_vm_sim_get_prefer_sim_card_t _vm_sim_get_prefer_sim_card = NULL; + +VMINT vm_sim_get_prefer_sim_card(void) +{ + if (NULL == _vm_sim_get_prefer_sim_card) + _vm_sim_get_prefer_sim_card = (_vm_sim_get_prefer_sim_card_t)vm_get_sym_entry("vm_sim_get_prefer_sim_card"); + + if (NULL != _vm_sim_get_prefer_sim_card) + return _vm_sim_get_prefer_sim_card(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_has_card.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_has_card.c new file mode 100644 index 00000000..5100d73b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_has_card.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMBOOL (*_vm_sim_has_card_t)(void); +_vm_sim_has_card_t _vm_sim_has_card = NULL; + +VMBOOL vm_sim_has_card(void) +{ + if (NULL == _vm_sim_has_card) + _vm_sim_has_card = (_vm_sim_has_card_t)vm_get_sym_entry("vm_sim_has_card"); + if (NULL != _vm_sim_has_card) + return _vm_sim_has_card(); + return (VMBOOL)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_max_card_count.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_max_card_count.c new file mode 100644 index 00000000..81a67c85 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_max_card_count.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sim_max_card_count_t)(void); +_vm_sim_max_card_count_t _vm_sim_max_card_count = NULL; + +VMINT vm_sim_max_card_count(void) +{ + if (NULL == _vm_sim_max_card_count) + _vm_sim_max_card_count = (_vm_sim_max_card_count_t)vm_get_sym_entry("vm_sim_max_card_count"); + + if (NULL != _vm_sim_max_card_count) + return _vm_sim_max_card_count(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_query_operator_code.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_query_operator_code.c new file mode 100644 index 00000000..151e9ab1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_query_operator_code.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sim_query_operator_code_t)(VMCHAR* buffer, VMUINT buffer_size); +_vm_sim_query_operator_code_t _vm_sim_query_operator_code = NULL; + +VMINT vm_sim_query_operator_code(VMCHAR* buffer, VMUINT buffer_size) +{ + if (NULL == _vm_sim_query_operator_code) + _vm_sim_query_operator_code = (_vm_sim_query_operator_code_t)vm_get_sym_entry("vm_sim_query_operator_code"); + if (NULL != _vm_sim_query_operator_code) + return _vm_sim_query_operator_code(buffer,buffer_size); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_set_active_card.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_set_active_card.c new file mode 100644 index 00000000..4a96353c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sim_set_active_card.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsim.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMBOOL (*_vm_sim_set_active_card_t)(VMINT sim); +_vm_sim_set_active_card_t _vm_sim_set_active_card = NULL; + +VMBOOL vm_sim_set_active_card(VMINT sim) +{ + if (NULL == _vm_sim_set_active_card) + _vm_sim_set_active_card = (_vm_sim_set_active_card_t)vm_get_sym_entry("vm_sim_set_active_card"); + if (NULL != _vm_sim_set_active_card) + return _vm_sim_set_active_card(sim); + return (VMBOOL)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sla_custom_logging.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sla_custom_logging.c new file mode 100644 index 00000000..8429c3de --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sla_custom_logging.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_sla_custom_logging_t)(VMSTR custom_label, vm_sla_action_type action); +_vm_sla_custom_logging_t _vm_sla_custom_logging = NULL; + +void vm_sla_custom_logging(VMSTR custom_label, vm_sla_action_type action) +{ + if (NULL == _vm_sla_custom_logging) + _vm_sla_custom_logging = (_vm_sla_custom_logging_t)vm_get_sym_entry("vm_sla_custom_logging"); + + if (NULL != _vm_sla_custom_logging) + _vm_sla_custom_logging(custom_label, action); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_add_msg.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_add_msg.c new file mode 100644 index 00000000..0dda5333 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_add_msg.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sms_add_msg_t)(vm_sms_add_msg_data_t * msg_data, VmSmsCallbackFunc callback_func, void* user_data); +_vm_sms_add_msg_t _vm_sms_add_msg = NULL; + +VMINT vm_sms_add_msg(vm_sms_add_msg_data_t * msg_data, VmSmsCallbackFunc callback_func, void* user_data) +{ + if (NULL == _vm_sms_add_msg) + _vm_sms_add_msg = (_vm_sms_add_msg_t)vm_get_sym_entry("vm_sms_add_msg"); + + if (NULL != _vm_sms_add_msg) + return _vm_sms_add_msg(msg_data,callback_func,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_clear_interrupt_event_handler.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_clear_interrupt_event_handler.c new file mode 100644 index 00000000..6c5a59df --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_clear_interrupt_event_handler.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sms_clear_interrupt_event_handler_t)(vm_sms_event_enum event_id, VmSmsEventFunc event_func, void* user_data); +_vm_sms_clear_interrupt_event_handler_t _vm_sms_clear_interrupt_event_handler = NULL; + +VMINT vm_sms_clear_interrupt_event_handler(vm_sms_event_enum event_id, VmSmsEventFunc event_func, void* user_data) +{ + if (NULL == _vm_sms_clear_interrupt_event_handler) + _vm_sms_clear_interrupt_event_handler = (_vm_sms_clear_interrupt_event_handler_t)vm_get_sym_entry("vm_sms_clear_interrupt_event_handler"); + + if (NULL != _vm_sms_clear_interrupt_event_handler) + return _vm_sms_clear_interrupt_event_handler(event_id,event_func,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_clear_interrupt_event_handler_forpay.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_clear_interrupt_event_handler_forpay.c new file mode 100644 index 00000000..e01e5455 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_clear_interrupt_event_handler_forpay.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sms_clear_interrupt_event_handler_forpay_t)(vm_sms_event_enum event_id, VmSmsEventFunc event_func, void* user_data); +_vm_sms_clear_interrupt_event_handler_forpay_t _vm_sms_clear_interrupt_event_handler_forpay = NULL; + +VMINT vm_sms_clear_interrupt_event_handler_forpay(vm_sms_event_enum event_id, VmSmsEventFunc event_func, void* user_data) +{ + if (NULL == _vm_sms_clear_interrupt_event_handler_forpay) + _vm_sms_clear_interrupt_event_handler_forpay = (_vm_sms_clear_interrupt_event_handler_forpay_t)vm_get_sym_entry("vm_sms_clear_interrupt_event_handler_forpay"); + + if (NULL != _vm_sms_clear_interrupt_event_handler_forpay) + return _vm_sms_clear_interrupt_event_handler_forpay(event_id,event_func,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_delete_msg.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_delete_msg.c new file mode 100644 index 00000000..31730d08 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_delete_msg.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sms_delete_msg_t)(VMUINT16 msg_id, VmSmsCallbackFunc callback_func, void* user_data); +_vm_sms_delete_msg_t _vm_sms_delete_msg = NULL; + +VMINT vm_sms_delete_msg(VMUINT16 msg_id, VmSmsCallbackFunc callback_func, void* user_data) +{ + if (NULL == _vm_sms_delete_msg) + _vm_sms_delete_msg = (_vm_sms_delete_msg_t)vm_get_sym_entry("vm_sms_delete_msg"); + + if (NULL != _vm_sms_delete_msg) + return _vm_sms_delete_msg(msg_id,callback_func,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_delete_msg_forpay.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_delete_msg_forpay.c new file mode 100644 index 00000000..46254c77 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_delete_msg_forpay.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sms_delete_msg_forpay_t)(VMUINT16 msg_id, VmSmsCallbackFunc callback_func, void* user_data); +_vm_sms_delete_msg_forpay_t _vm_sms_delete_msg_forpay = NULL; + +VMINT vm_sms_delete_msg_forpay(VMUINT16 msg_id, VmSmsCallbackFunc callback_func, void* user_data) +{ + if (NULL == _vm_sms_delete_msg_forpay) + _vm_sms_delete_msg_forpay = (_vm_sms_delete_msg_forpay_t)vm_get_sym_entry("vm_sms_delete_msg_forpay"); + + if (NULL != _vm_sms_delete_msg_forpay) + return _vm_sms_delete_msg_forpay(msg_id,callback_func,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_delete_msg_list.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_delete_msg_list.c new file mode 100644 index 00000000..14b67f23 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_delete_msg_list.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sms_delete_msg_list_t)(vm_sms_box_enum box_type, vm_sms_sim_enum sim_id, VmSmsCallbackFunc callback_func, void* user_data); +_vm_sms_delete_msg_list_t _vm_sms_delete_msg_list = NULL; + +VMINT vm_sms_delete_msg_list(vm_sms_box_enum box_type, vm_sms_sim_enum sim_id, VmSmsCallbackFunc callback_func, void* user_data) +{ + if (NULL == _vm_sms_delete_msg_list) + _vm_sms_delete_msg_list = (_vm_sms_delete_msg_list_t)vm_get_sym_entry("vm_sms_delete_msg_list"); + + if (NULL != _vm_sms_delete_msg_list) + return _vm_sms_delete_msg_list(box_type,sim_id,callback_func,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_box_size.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_box_size.c new file mode 100644 index 00000000..2f64adbb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_box_size.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT16 (*_vm_sms_get_box_size_t)(vm_sms_box_enum box_type); +_vm_sms_get_box_size_t _vm_sms_get_box_size = NULL; + +VMINT16 vm_sms_get_box_size(vm_sms_box_enum box_type) +{ + if (NULL == _vm_sms_get_box_size) + _vm_sms_get_box_size = (_vm_sms_get_box_size_t)vm_get_sym_entry("vm_sms_get_box_size"); + + if (NULL != _vm_sms_get_box_size) + return _vm_sms_get_box_size(box_type); + + return (VMINT16 )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_msg_id.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_msg_id.c new file mode 100644 index 00000000..4de5c5b3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_msg_id.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT16 (*_vm_sms_get_msg_id_t)(vm_sms_box_enum box_type, VMUINT16 msg_index); +_vm_sms_get_msg_id_t _vm_sms_get_msg_id = NULL; + +VMINT16 vm_sms_get_msg_id(vm_sms_box_enum box_type, VMUINT16 msg_index) +{ + if (NULL == _vm_sms_get_msg_id) + _vm_sms_get_msg_id = (_vm_sms_get_msg_id_t)vm_get_sym_entry("vm_sms_get_msg_id"); + + if (NULL != _vm_sms_get_msg_id) + return _vm_sms_get_msg_id(box_type,msg_index); + + return (VMINT16 )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_msg_id_list.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_msg_id_list.c new file mode 100644 index 00000000..2962d8be --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_msg_id_list.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sms_get_msg_id_list_t)(vm_sms_query_t* query_data, VmSmsCallbackFunc callback_func, void* user_data); +_vm_sms_get_msg_id_list_t _vm_sms_get_msg_id_list = NULL; + +VMINT vm_sms_get_msg_id_list(vm_sms_query_t* query_data, VmSmsCallbackFunc callback_func, void* user_data) +{ + if (NULL == _vm_sms_get_msg_id_list) + _vm_sms_get_msg_id_list = (_vm_sms_get_msg_id_list_t)vm_get_sym_entry("vm_sms_get_msg_id_list"); + + if (NULL != _vm_sms_get_msg_id_list) + return _vm_sms_get_msg_id_list(query_data,callback_func,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_sc_address.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_sc_address.c new file mode 100644 index 00000000..94b435fe --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_sc_address.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sms_get_sc_address_t)( vm_sms_sim_enum sim_id, VmSmsCallbackFunc callback_func, void* user_data); +_vm_sms_get_sc_address_t _vm_sms_get_sc_address = NULL; + +VMINT vm_sms_get_sc_address( vm_sms_sim_enum sim_id, VmSmsCallbackFunc callback_func, void* user_data) +{ + if (NULL == _vm_sms_get_sc_address) + _vm_sms_get_sc_address = (_vm_sms_get_sc_address_t)vm_get_sym_entry("vm_sms_get_sc_address"); + + if (NULL != _vm_sms_get_sc_address) + return _vm_sms_get_sc_address(sim_id,callback_func,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_sc_address_syn.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_sc_address_syn.c new file mode 100644 index 00000000..0a7675d2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_get_sc_address_syn.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sms_get_sc_address_syn_t)(vm_sms_get_sc_addr_cb_t * vm_sc_addr, vm_sms_sim_enum sim_id); +_vm_sms_get_sc_address_syn_t _vm_sms_get_sc_address_syn = NULL; + +VMINT vm_sms_get_sc_address_syn(vm_sms_get_sc_addr_cb_t * vm_sc_addr, vm_sms_sim_enum sim_id) +{ + if (NULL == _vm_sms_get_sc_address_syn) + _vm_sms_get_sc_address_syn = (_vm_sms_get_sc_address_syn_t)vm_get_sym_entry("vm_sms_get_sc_address_syn"); + + if (NULL != _vm_sms_get_sc_address_syn) + return _vm_sms_get_sc_address_syn(vm_sc_addr,sim_id); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_is_sms_ready.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_is_sms_ready.c new file mode 100644 index 00000000..78dc1793 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_is_sms_ready.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMBOOL (*_vm_sms_is_sms_ready_t)(void); +_vm_sms_is_sms_ready_t _vm_sms_is_sms_ready = NULL; + +VMBOOL vm_sms_is_sms_ready(void) +{ + if (NULL == _vm_sms_is_sms_ready) + _vm_sms_is_sms_ready = (_vm_sms_is_sms_ready_t)vm_get_sym_entry("vm_sms_is_sms_ready"); + if (NULL != _vm_sms_is_sms_ready) + return _vm_sms_is_sms_ready(); + return (VMBOOL)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_launch.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_launch.c new file mode 100644 index 00000000..7decb785 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_launch.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sms_launch_t)(vm_sms_launch_data* data, VMINT data_size); +_vm_sms_launch_t _vm_sms_launch = NULL; + +VMINT vm_sms_launch(vm_sms_launch_data* data, VMINT data_size) +{ + if (NULL == _vm_sms_launch) + _vm_sms_launch = (_vm_sms_launch_t)vm_get_sym_entry("vm_sms_launch"); + + if (NULL != _vm_sms_launch) + return _vm_sms_launch(data, data_size); + return -1; + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_read_msg.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_read_msg.c new file mode 100644 index 00000000..b0346361 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_read_msg.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sms_read_msg_t)(VMUINT16 msg_id, VMINT change_status, vm_sms_msg_data_t* msg_data, VmSmsCallbackFunc callback_func, void* user_data); +_vm_sms_read_msg_t _vm_sms_read_msg = NULL; + +VMINT vm_sms_read_msg(VMUINT16 msg_id, VMINT change_status, vm_sms_msg_data_t* msg_data, VmSmsCallbackFunc callback_func, void* user_data) +{ + if (NULL == _vm_sms_read_msg) + _vm_sms_read_msg = (_vm_sms_read_msg_t)vm_get_sym_entry("vm_sms_read_msg"); + + if (NULL != _vm_sms_read_msg) + return _vm_sms_read_msg(msg_id,change_status,msg_data,callback_func,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_set_interrupt_event_handler.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_set_interrupt_event_handler.c new file mode 100644 index 00000000..0d7f88ad --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_set_interrupt_event_handler.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sms_set_interrupt_event_handler_t)(vm_sms_event_enum event_id, VmSmsEventFunc event_func, void* user_data); +_vm_sms_set_interrupt_event_handler_t _vm_sms_set_interrupt_event_handler = NULL; + +VMINT vm_sms_set_interrupt_event_handler(vm_sms_event_enum event_id, VmSmsEventFunc event_func, void* user_data) +{ + if (NULL == _vm_sms_set_interrupt_event_handler) + _vm_sms_set_interrupt_event_handler = (_vm_sms_set_interrupt_event_handler_t)vm_get_sym_entry("vm_sms_set_interrupt_event_handler"); + + if (NULL != _vm_sms_set_interrupt_event_handler) + return _vm_sms_set_interrupt_event_handler(event_id,event_func,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_set_interrupt_event_handler_forpay.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_set_interrupt_event_handler_forpay.c new file mode 100644 index 00000000..57d63d13 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sms_set_interrupt_event_handler_forpay.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsms.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sms_set_interrupt_event_handler_forpay_t)(vm_sms_event_enum event_id, VmSmsEventFunc event_func, void* user_data); +_vm_sms_set_interrupt_event_handler_forpay_t _vm_sms_set_interrupt_event_handler_forpay = NULL; + +VMINT vm_sms_set_interrupt_event_handler_forpay(vm_sms_event_enum event_id, VmSmsEventFunc event_func, void* user_data) +{ + if (NULL == _vm_sms_set_interrupt_event_handler_forpay) + _vm_sms_set_interrupt_event_handler_forpay = (_vm_sms_set_interrupt_event_handler_forpay_t)vm_get_sym_entry("vm_sms_set_interrupt_event_handler_forpay"); + + if (NULL != _vm_sms_set_interrupt_event_handler_forpay) + return _vm_sms_set_interrupt_event_handler_forpay(event_id,event_func,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_get_account_localip.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_get_account_localip.c new file mode 100644 index 00000000..1fa1f77c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_get_account_localip.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_get_account_localip_t)(VMINT8 sock, VMUINT8 *local_ip); +_vm_soc_get_account_localip_t _vm_soc_get_account_localip = NULL; + +VMINT vm_soc_get_account_localip(VMINT8 sock, VMUINT8 *local_ip) +{ + if (NULL == _vm_soc_get_account_localip) + _vm_soc_get_account_localip = (_vm_soc_get_account_localip_t)vm_get_sym_entry("vm_soc_get_account_localip"); + if (NULL != _vm_soc_get_account_localip) + return _vm_soc_get_account_localip(sock,local_ip); + return (VMINT)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_get_host_by_name.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_get_host_by_name.c new file mode 100644 index 00000000..f1a7081e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_get_host_by_name.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_get_host_by_name_t)(VMINT apn, const VMCHAR * host, vm_soc_dns_result * result, VMINT (*callback)(vm_soc_dns_result *)); +_vm_soc_get_host_by_name_t _vm_soc_get_host_by_name = NULL; + +VMINT vm_soc_get_host_by_name(VMINT apn, const VMCHAR * host, vm_soc_dns_result * result, VMINT (*callback)(vm_soc_dns_result *)) +{ + if (NULL == _vm_soc_get_host_by_name) + _vm_soc_get_host_by_name = (_vm_soc_get_host_by_name_t)vm_get_sym_entry("vm_soc_get_host_by_name"); + + if (NULL != _vm_soc_get_host_by_name) + return _vm_soc_get_host_by_name(apn,host,result,callback); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_get_host_by_name_ex.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_get_host_by_name_ex.c new file mode 100644 index 00000000..2ddb5578 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_get_host_by_name_ex.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_get_host_by_name_ex_t)(VMINT apn, const VMCHAR * host, vm_soc_dns_result * result, VMINT (*callback)(VMINT, vm_soc_dns_result *, void *), void *user_data); +_vm_soc_get_host_by_name_ex_t _vm_soc_get_host_by_name_ex = NULL; + +VMINT vm_soc_get_host_by_name_ex(VMINT apn, const VMCHAR * host, vm_soc_dns_result * result, VMINT (*callback)(VMINT, vm_soc_dns_result *, void *), void *user_data) +{ + if (NULL == _vm_soc_get_host_by_name_ex) + _vm_soc_get_host_by_name_ex = (_vm_soc_get_host_by_name_ex_t)vm_get_sym_entry("vm_soc_get_host_by_name_ex"); + if (NULL != _vm_soc_get_host_by_name_ex) + return _vm_soc_get_host_by_name_ex(apn,host,result,callback,user_data); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_get_last_error.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_get_last_error.c new file mode 100644 index 00000000..e7d81fd5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_get_last_error.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_get_last_error_t)(void); +_vm_soc_get_last_error_t _vm_soc_get_last_error = NULL; + +VMINT vm_soc_get_last_error(void) +{ + if (NULL == _vm_soc_get_last_error) + _vm_soc_get_last_error = (_vm_soc_get_last_error_t)vm_get_sym_entry("vm_soc_get_last_error"); + if (NULL != _vm_soc_get_last_error) + return _vm_soc_get_last_error(); + return (VMINT)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_accept_sync.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_accept_sync.c new file mode 100644 index 00000000..7935ebaa --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_accept_sync.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_svr_accept_sync_t)(VMINT s_hdl, vm_sockaddr_struct *addr); +_vm_soc_svr_accept_sync_t _vm_soc_svr_accept_sync = NULL; + +VMINT vm_soc_svr_accept_sync(VMINT s_hdl, vm_sockaddr_struct *addr) +{ + if (NULL == _vm_soc_svr_accept_sync) + _vm_soc_svr_accept_sync = (_vm_soc_svr_accept_sync_t)vm_get_sym_entry("vm_soc_svr_accept_sync"); + if (NULL != _vm_soc_svr_accept_sync) + return _vm_soc_svr_accept_sync(s_hdl,addr); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_close_client.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_close_client.c new file mode 100644 index 00000000..98958b66 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_close_client.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_svr_close_client_t)(VMINT c_hdl); +_vm_soc_svr_close_client_t _vm_soc_svr_close_client = NULL; + +VMINT vm_soc_svr_close_client(VMINT c_hdl) +{ + if (NULL == _vm_soc_svr_close_client) + _vm_soc_svr_close_client = (_vm_soc_svr_close_client_t)vm_get_sym_entry("vm_soc_svr_close_client"); + if (NULL != _vm_soc_svr_close_client) + return _vm_soc_svr_close_client(c_hdl); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_close_client_sync.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_close_client_sync.c new file mode 100644 index 00000000..eb582730 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_close_client_sync.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_svr_close_client_sync_t)(VMINT c_hdl); +_vm_soc_svr_close_client_sync_t _vm_soc_svr_close_client_sync = NULL; + +VMINT vm_soc_svr_close_client_sync(VMINT c_hdl) +{ + if (NULL == _vm_soc_svr_close_client_sync) + _vm_soc_svr_close_client_sync = (_vm_soc_svr_close_client_sync_t)vm_get_sym_entry("vm_soc_svr_close_client_sync"); + if (NULL != _vm_soc_svr_close_client_sync) + return _vm_soc_svr_close_client_sync(c_hdl); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_deinit.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_deinit.c new file mode 100644 index 00000000..ef8c159a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_deinit.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_svr_deinit_t)(VMINT handle); +_vm_soc_svr_deinit_t _vm_soc_svr_deinit = NULL; + +VMINT vm_soc_svr_deinit(VMINT handle) +{ + if (NULL == _vm_soc_svr_deinit) + _vm_soc_svr_deinit = (_vm_soc_svr_deinit_t)vm_get_sym_entry("vm_soc_svr_deinit"); + if (NULL != _vm_soc_svr_deinit) + return _vm_soc_svr_deinit(handle); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_deinit_sync.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_deinit_sync.c new file mode 100644 index 00000000..952328fa --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_deinit_sync.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_svr_deinit_sync_t)(VMINT s_hdl); +_vm_soc_svr_deinit_sync_t _vm_soc_svr_deinit_sync = NULL; + +VMINT vm_soc_svr_deinit_sync(VMINT s_hdl) +{ + if (NULL == _vm_soc_svr_deinit_sync) + _vm_soc_svr_deinit_sync = (_vm_soc_svr_deinit_sync_t)vm_get_sym_entry("vm_soc_svr_deinit_sync"); + if (NULL != _vm_soc_svr_deinit_sync) + return _vm_soc_svr_deinit_sync(s_hdl); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_get_soc_id.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_get_soc_id.c new file mode 100644 index 00000000..99a57df8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_get_soc_id.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_svr_get_soc_id_t)(VMINT hdl); +_vm_soc_svr_get_soc_id_t _vm_soc_svr_get_soc_id = NULL; + +VMINT vm_soc_svr_get_soc_id(VMINT hdl) +{ + if (NULL == _vm_soc_svr_get_soc_id) + _vm_soc_svr_get_soc_id = (_vm_soc_svr_get_soc_id_t)vm_get_sym_entry("vm_soc_svr_get_soc_id"); + if (NULL != _vm_soc_svr_get_soc_id) + return _vm_soc_svr_get_soc_id(hdl); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_init.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_init.c new file mode 100644 index 00000000..a55ccb8a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_init.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_svr_init_t)(VMINT apn, VMINT port, void *user_data, void (*callback)(VMINT handle, VMINT event, VMINT param, void *user_data)); +_vm_soc_svr_init_t _vm_soc_svr_init = NULL; + +VMINT vm_soc_svr_init(VMINT apn, VMINT port, void *user_data, void (*callback)(VMINT handle, VMINT event, VMINT param, void *user_data)) +{ + if (NULL == _vm_soc_svr_init) + _vm_soc_svr_init = (_vm_soc_svr_init_t)vm_get_sym_entry("vm_soc_svr_init"); + if (NULL != _vm_soc_svr_init) + return _vm_soc_svr_init(apn,port,user_data,callback); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_init_sync.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_init_sync.c new file mode 100644 index 00000000..46c93fcf --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_init_sync.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_svr_init_sync_t)(VMINT apn, VMINT port); +_vm_soc_svr_init_sync_t _vm_soc_svr_init_sync = NULL; + +VMINT vm_soc_svr_init_sync(VMINT apn, VMINT port) +{ + if (NULL == _vm_soc_svr_init_sync) + _vm_soc_svr_init_sync = (_vm_soc_svr_init_sync_t)vm_get_sym_entry("vm_soc_svr_init_sync"); + if (NULL != _vm_soc_svr_init_sync) + return _vm_soc_svr_init_sync(apn,port); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_read.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_read.c new file mode 100644 index 00000000..0491d58f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_read.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_svr_read_t)(VMINT s_hdl, VMINT c_hdl, void *data, VMUINT len); +_vm_soc_svr_read_t _vm_soc_svr_read = NULL; + +VMINT vm_soc_svr_read(VMINT s_hdl, VMINT c_hdl, void *data, VMUINT len) +{ + if (NULL == _vm_soc_svr_read) + _vm_soc_svr_read = (_vm_soc_svr_read_t)vm_get_sym_entry("vm_soc_svr_read"); + if (NULL != _vm_soc_svr_read) + return _vm_soc_svr_read(s_hdl,c_hdl,data,len); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_read_sync.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_read_sync.c new file mode 100644 index 00000000..fe74ddd6 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_read_sync.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_svr_read_sync_t)(VMINT c_hdl, void *data, VMUINT len); +_vm_soc_svr_read_sync_t _vm_soc_svr_read_sync = NULL; + +VMINT vm_soc_svr_read_sync(VMINT c_hdl, void *data, VMUINT len) +{ + if (NULL == _vm_soc_svr_read_sync) + _vm_soc_svr_read_sync = (_vm_soc_svr_read_sync_t)vm_get_sym_entry("vm_soc_svr_read_sync"); + if (NULL != _vm_soc_svr_read_sync) + return _vm_soc_svr_read_sync(c_hdl,data,len); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_send.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_send.c new file mode 100644 index 00000000..9f1b772c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_send.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_svr_send_t)(VMINT s_hdl, VMINT c_hdl, const void *data, VMUINT len); +_vm_soc_svr_send_t _vm_soc_svr_send = NULL; + +VMINT vm_soc_svr_send(VMINT s_hdl, VMINT c_hdl, const void *data, VMUINT len) +{ + if (NULL == _vm_soc_svr_send) + _vm_soc_svr_send = (_vm_soc_svr_send_t)vm_get_sym_entry("vm_soc_svr_send"); + if (NULL != _vm_soc_svr_send) + return _vm_soc_svr_send(s_hdl,c_hdl,data,len); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_send_sync.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_send_sync.c new file mode 100644 index 00000000..d202a028 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_soc_svr_send_sync.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_soc_svr_send_sync_t)(VMINT c_hdl, const void *data, VMUINT len); +_vm_soc_svr_send_sync_t _vm_soc_svr_send_sync = NULL; + +VMINT vm_soc_svr_send_sync(VMINT c_hdl, const void *data, VMUINT len) +{ + if (NULL == _vm_soc_svr_send_sync) + _vm_soc_svr_send_sync = (_vm_soc_svr_send_sync_t)vm_get_sym_entry("vm_soc_svr_send_sync"); + if (NULL != _vm_soc_svr_send_sync) + return _vm_soc_svr_send_sync(c_hdl,data,len); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_socket.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_socket.c new file mode 100644 index 00000000..8e29d1ce --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_socket.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_socket_t)(int family, int type, int protocol); +_vm_socket_t _vm_socket = NULL; + +int vm_socket(int family, int type, int protocol) +{ + if (NULL == _vm_socket) + _vm_socket = (_vm_socket_t)vm_get_sym_entry("vm_socket"); + if (NULL != _vm_socket) + return _vm_socket(family,type,protocol); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_socket_ex.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_socket_ex.c new file mode 100644 index 00000000..d5ac7880 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_socket_ex.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_socket_ex_t)(int family, int type, int protocol, VMUINT32 data_account); +_vm_socket_ex_t _vm_socket_ex = NULL; + +int vm_socket_ex(int family, int type, int protocol, VMUINT32 data_account) +{ + if (NULL == _vm_socket_ex) + _vm_socket_ex = (_vm_socket_ex_t)vm_get_sym_entry("vm_socket_ex"); + if (NULL != _vm_socket_ex) + return _vm_socket_ex(family,type,protocol,data_account); + return (int)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sprintf.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sprintf.c new file mode 100644 index 00000000..18642cd3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sprintf.c @@ -0,0 +1,24 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_sprintf_t)( char * buf, const char * fmt, ... ); +_vm_sprintf_t _vm_sprintf = NULL; + +int vm_sprintf( char * buf, const char * fmt, ... ) +{ + int ret = {-1}; + if (NULL == _vm_sprintf) + _vm_sprintf = (_vm_sprintf_t)vm_get_sym_entry("vm_vsprintf"); + + if (NULL != _vm_sprintf) + { + va_list args; + va_start( args, fmt ); + ret = _vm_sprintf(buf, fmt, args); + va_end( args ); + } + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_bt_noti_check_connection.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_bt_noti_check_connection.c new file mode 100644 index 00000000..490bc3eb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_bt_noti_check_connection.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmbtnotify.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_srv_bt_noti_check_connection_t)(void); +_vm_srv_bt_noti_check_connection_t _vm_srv_bt_noti_check_connection = NULL; + +VMINT vm_srv_bt_noti_check_connection(void) +{ + if (NULL == _vm_srv_bt_noti_check_connection) + _vm_srv_bt_noti_check_connection = (_vm_srv_bt_noti_check_connection_t)vm_get_sym_entry("vm_srv_bt_noti_check_connection"); + if (NULL != _vm_srv_bt_noti_check_connection) + return _vm_srv_bt_noti_check_connection(); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_bt_noti_register_callback.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_bt_noti_register_callback.c new file mode 100644 index 00000000..802f515f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_bt_noti_register_callback.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmbtnotify.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_srv_bt_noti_register_callback_t)(const vm_srv_bt_cm_bt_addr *bt_addr, const VMCHAR sender[VM_MAX_IOER], vm_srv_bt_noti_callback cb); +_vm_srv_bt_noti_register_callback_t _vm_srv_bt_noti_register_callback = NULL; + +VMINT vm_srv_bt_noti_register_callback(const vm_srv_bt_cm_bt_addr *bt_addr, const VMCHAR sender[VM_MAX_IOER], vm_srv_bt_noti_callback cb) +{ + if (NULL == _vm_srv_bt_noti_register_callback) + _vm_srv_bt_noti_register_callback = (_vm_srv_bt_noti_register_callback_t)vm_get_sym_entry("vm_srv_bt_noti_register_callback"); + if (NULL != _vm_srv_bt_noti_register_callback) + return _vm_srv_bt_noti_register_callback(bt_addr,sender,cb); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_bt_noti_send_cmd_ext.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_bt_noti_send_cmd_ext.c new file mode 100644 index 00000000..3c09d343 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_bt_noti_send_cmd_ext.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmbtnotify.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_srv_bt_noti_send_cmd_ext_t)(const vm_srv_bt_cm_bt_addr *bt_addr, const VMCHAR reader[VM_MAX_IOER], VMINT data_type, const VMBYTE *data, VMINT len); +_vm_srv_bt_noti_send_cmd_ext_t _vm_srv_bt_noti_send_cmd_ext = NULL; + +VMINT vm_srv_bt_noti_send_cmd_ext(const vm_srv_bt_cm_bt_addr *bt_addr, const VMCHAR reader[VM_MAX_IOER], VMINT data_type, const VMBYTE *data, VMINT len) +{ + if (NULL == _vm_srv_bt_noti_send_cmd_ext) + _vm_srv_bt_noti_send_cmd_ext = (_vm_srv_bt_noti_send_cmd_ext_t)vm_get_sym_entry("vm_srv_bt_noti_send_cmd_ext"); + if (NULL != _vm_srv_bt_noti_send_cmd_ext) + return _vm_srv_bt_noti_send_cmd_ext(bt_addr,reader,data_type,data,len); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_bt_noti_send_ex.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_bt_noti_send_ex.c new file mode 100644 index 00000000..eacfeee0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_bt_noti_send_ex.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmbtnotify.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_srv_bt_noti_send_ex_t)(const vm_srv_bt_cm_bt_addr *bt_addr, const VMCHAR sender[VM_MAX_IOER], const VMCHAR receiver[VM_MAX_IOER], VMINT data_type, const VMBYTE *data, VMINT len); +_vm_srv_bt_noti_send_ex_t _vm_srv_bt_noti_send_ex = NULL; + +VMINT vm_srv_bt_noti_send_ex(const vm_srv_bt_cm_bt_addr *bt_addr, const VMCHAR sender[VM_MAX_IOER], const VMCHAR receiver[VM_MAX_IOER], VMINT data_type, const VMBYTE *data, VMINT len) +{ + if (NULL == _vm_srv_bt_noti_send_ex) + _vm_srv_bt_noti_send_ex = (_vm_srv_bt_noti_send_ex_t)vm_get_sym_entry("vm_srv_bt_noti_send_ex"); + if (NULL != _vm_srv_bt_noti_send_ex) + return _vm_srv_bt_noti_send_ex(bt_addr,sender,receiver,data_type,data,len); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_funet_trigger.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_funet_trigger.c new file mode 100644 index 00000000..71d20f64 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_funet_trigger.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmfota.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef vm_srv_funet_flag_enum (*_vm_srv_funet_trigger_t)(VMWCHAR * file_name, vm_srv_funet_update_type_enum update_type); +_vm_srv_funet_trigger_t _vm_srv_funet_trigger = NULL; + +vm_srv_funet_flag_enum vm_srv_funet_trigger(VMWCHAR * file_name, vm_srv_funet_update_type_enum update_type) +{ + if (NULL == _vm_srv_funet_trigger) + _vm_srv_funet_trigger = (_vm_srv_funet_trigger_t)vm_get_sym_entry("vm_srv_funet_trigger"); + + if (NULL != _vm_srv_funet_trigger) + return _vm_srv_funet_trigger(file_name,update_type); + + return (vm_srv_funet_flag_enum )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_nw_info_get_protocol.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_nw_info_get_protocol.c new file mode 100644 index 00000000..23f83219 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_nw_info_get_protocol.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_srv_nw_info_get_protocol_t)(VMINT sim_card); +_vm_srv_nw_info_get_protocol_t _vm_srv_nw_info_get_protocol = NULL; + +VMINT vm_srv_nw_info_get_protocol(VMINT sim_card) +{ + if (NULL == _vm_srv_nw_info_get_protocol) + _vm_srv_nw_info_get_protocol = (_vm_srv_nw_info_get_protocol_t)vm_get_sym_entry("vm_srv_nw_info_get_protocol"); + + if (NULL != _vm_srv_nw_info_get_protocol) + return _vm_srv_nw_info_get_protocol(sim_card); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_nw_info_get_service_availability.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_nw_info_get_service_availability.c new file mode 100644 index 00000000..59304339 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_nw_info_get_service_availability.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_srv_nw_info_get_service_availability_t)(VMINT sim_card); +_vm_srv_nw_info_get_service_availability_t _vm_srv_nw_info_get_service_availability = NULL; + +VMINT vm_srv_nw_info_get_service_availability(VMINT sim_card) +{ + if (NULL == _vm_srv_nw_info_get_service_availability) + _vm_srv_nw_info_get_service_availability = (_vm_srv_nw_info_get_service_availability_t)vm_get_sym_entry("vm_srv_nw_info_get_service_availability"); + + if (NULL != _vm_srv_nw_info_get_service_availability) + return _vm_srv_nw_info_get_service_availability(sim_card); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_acc_data_rigister_cb.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_acc_data_rigister_cb.c new file mode 100644 index 00000000..4d0457ed --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_acc_data_rigister_cb.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmsettings.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_srv_sensor_acc_data_rigister_cb_t)(vm_srv_sensor_acc_data_cb event_hdlr); +_vm_srv_sensor_acc_data_rigister_cb_t _vm_srv_sensor_acc_data_rigister_cb = NULL; +void vm_srv_sensor_acc_data_rigister_cb(vm_srv_sensor_acc_data_cb event_hdlr) + +{ + if (NULL == _vm_srv_sensor_acc_data_rigister_cb) + _vm_srv_sensor_acc_data_rigister_cb = (_vm_srv_sensor_acc_data_rigister_cb_t)vm_get_sym_entry("vm_srv_sensor_acc_data_rigister_cb"); + if (NULL != _vm_srv_sensor_acc_data_rigister_cb) + _vm_srv_sensor_acc_data_rigister_cb(event_hdlr); +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_disable_mode.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_disable_mode.c new file mode 100644 index 00000000..a1db84a6 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_disable_mode.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsensor.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VM_SRV_SENSOR_RESULT (*_vm_srv_sensor_disable_mode_t)(VM_SRV_SENSOR_HANDLE handle, VMUINT16 sensor_mode); +_vm_srv_sensor_disable_mode_t _vm_srv_sensor_disable_mode = NULL; + +VM_SRV_SENSOR_RESULT vm_srv_sensor_disable_mode(VM_SRV_SENSOR_HANDLE handle, VMUINT16 sensor_mode) +{ + if (NULL == _vm_srv_sensor_disable_mode) + _vm_srv_sensor_disable_mode = (_vm_srv_sensor_disable_mode_t)vm_get_sym_entry("vm_srv_sensor_disable_mode"); + + if (NULL != _vm_srv_sensor_disable_mode) + return _vm_srv_sensor_disable_mode(handle,sensor_mode); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_enable_mode.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_enable_mode.c new file mode 100644 index 00000000..abc9d559 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_enable_mode.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsensor.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VM_SRV_SENSOR_RESULT (*_vm_srv_sensor_enable_mode_t)(VM_SRV_SENSOR_HANDLE handle , VMUINT16 sensor_mode); +_vm_srv_sensor_enable_mode_t _vm_srv_sensor_enable_mode = NULL; + +VM_SRV_SENSOR_RESULT vm_srv_sensor_enable_mode(VM_SRV_SENSOR_HANDLE handle , VMUINT16 sensor_mode) +{ + if (NULL == _vm_srv_sensor_enable_mode) + _vm_srv_sensor_enable_mode = (_vm_srv_sensor_enable_mode_t)vm_get_sym_entry("vm_srv_sensor_enable_mode"); + + if (NULL != _vm_srv_sensor_enable_mode) + return _vm_srv_sensor_enable_mode(handle,sensor_mode); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_hr_data_rigister_cb.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_hr_data_rigister_cb.c new file mode 100644 index 00000000..d1621753 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_hr_data_rigister_cb.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmsettings.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_srv_sensor_hr_data_rigister_cb_t)(vm_srv_sensor_hr_data_cb event_hdlr); +_vm_srv_sensor_hr_data_rigister_cb_t _vm_srv_sensor_hr_data_rigister_cb = NULL; +void vm_srv_sensor_hr_data_rigister_cb(vm_srv_sensor_hr_data_cb event_hdlr) + +{ + if (NULL == _vm_srv_sensor_hr_data_rigister_cb) + _vm_srv_sensor_hr_data_rigister_cb = (_vm_srv_sensor_hr_data_rigister_cb_t)vm_get_sym_entry("vm_srv_sensor_hr_data_rigister_cb"); + if (NULL != _vm_srv_sensor_hr_data_rigister_cb) + _vm_srv_sensor_hr_data_rigister_cb(event_hdlr); +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_is_available.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_is_available.c new file mode 100644 index 00000000..b1c6ed39 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_is_available.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsensor.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_srv_sensor_is_available_t)(vm_srv_sensor_type_enum sensor_type); +_vm_srv_sensor_is_available_t _vm_srv_sensor_is_available = NULL; + +VMINT vm_srv_sensor_is_available(vm_srv_sensor_type_enum sensor_type) +{ + if (NULL == _vm_srv_sensor_is_available) + _vm_srv_sensor_is_available = (_vm_srv_sensor_is_available_t)vm_get_sym_entry("vm_srv_sensor_is_available"); + + if (NULL != _vm_srv_sensor_is_available) + return _vm_srv_sensor_is_available(sensor_type); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_start_listen.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_start_listen.c new file mode 100644 index 00000000..727fd95d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_start_listen.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsensor.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_srv_sensor_start_listen_t)(vm_srv_sensor_type_enum type, void *option, VM_SRV_SENSOR_EVENT_HDLR event_hdlr, void *user_data); +_vm_srv_sensor_start_listen_t _vm_srv_sensor_start_listen = NULL; + +VM_SRV_SENSOR_HANDLE vm_srv_sensor_start_listen(vm_srv_sensor_type_enum type, void *option, VM_SRV_SENSOR_EVENT_HDLR event_hdlr, void *user_data) +{ + if (NULL == _vm_srv_sensor_start_listen) + _vm_srv_sensor_start_listen = (_vm_srv_sensor_start_listen_t)vm_get_sym_entry("vm_srv_sensor_start_listen"); + + if (NULL != _vm_srv_sensor_start_listen) + return _vm_srv_sensor_start_listen(type,option,event_hdlr,user_data); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_stop_listen.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_stop_listen.c new file mode 100644 index 00000000..b1ea5e93 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_srv_sensor_stop_listen.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsensor.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VM_SRV_SENSOR_RESULT (*_vm_srv_sensor_stop_listen_t)(VM_SRV_SENSOR_HANDLE handle); +_vm_srv_sensor_stop_listen_t _vm_srv_sensor_stop_listen = NULL; + +VM_SRV_SENSOR_RESULT vm_srv_sensor_stop_listen(VM_SRV_SENSOR_HANDLE handle) +{ + if (NULL == _vm_srv_sensor_stop_listen) + _vm_srv_sensor_stop_listen = (_vm_srv_sensor_stop_listen_t)vm_get_sym_entry("vm_srv_sensor_stop_listen"); + + if (NULL != _vm_srv_sensor_stop_listen) + return _vm_srv_sensor_stop_listen(handle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sscanf.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sscanf.c new file mode 100644 index 00000000..ae0995a9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sscanf.c @@ -0,0 +1,24 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_sscanf_t)(const char * str, const char *format, va_list args); +_vm_sscanf_t _vm_sscanf = NULL; +int vm_sscanf(const char *str, const char *format, ...) +{ + VMINT result = -1; + if (_vm_sscanf == NULL) { + _vm_sscanf = (_vm_sscanf_t)vm_get_sym_entry("vm_sscanf"); + } + + if (_vm_sscanf != NULL) + { + va_list args; + va_start(args, format ); + result = _vm_sscanf(str, format, args); + va_end( args ); + } + return result; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_base64_decode.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_base64_decode.c new file mode 100644 index 00000000..f1a6e616 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_base64_decode.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmssl.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ssl_base64_decode_t)(VMBYTE *dst, VMINT *dlen, VMBYTE *src, VMINT slen); +_vm_ssl_base64_decode_t _vm_ssl_base64_decode = NULL; + +VMINT vm_ssl_base64_decode(VMBYTE *dst, VMINT *dlen, VMBYTE *src, VMINT slen) +{ + if (NULL == _vm_ssl_base64_decode) + _vm_ssl_base64_decode = (_vm_ssl_base64_decode_t)vm_get_sym_entry("vm_ssl_base64_decode"); + if (NULL != _vm_ssl_base64_decode) + return _vm_ssl_base64_decode(dst,dlen,src,slen); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_base64_encode.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_base64_encode.c new file mode 100644 index 00000000..47b3ed4a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_base64_encode.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmssl.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ssl_base64_encode_t)(VMBYTE *dst, VMINT *dlen, VMBYTE *src, VMINT slen); +_vm_ssl_base64_encode_t _vm_ssl_base64_encode = NULL; + +VMINT vm_ssl_base64_encode(VMBYTE *dst, VMINT *dlen, VMBYTE *src, VMINT slen) +{ + if (NULL == _vm_ssl_base64_encode) + _vm_ssl_base64_encode = (_vm_ssl_base64_encode_t)vm_get_sym_entry("vm_ssl_base64_encode"); + if (NULL != _vm_ssl_base64_encode) + return _vm_ssl_base64_encode(dst,dlen,src,slen); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_close.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_close.c new file mode 100644 index 00000000..a4abf78b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_close.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmssl.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ssl_close_t)(VMINT handle); +_vm_ssl_close_t _vm_ssl_close = NULL; + +VMINT vm_ssl_close(VMINT handle) +{ + if (NULL == _vm_ssl_close) + _vm_ssl_close = (_vm_ssl_close_t)vm_get_sym_entry("vm_ssl_close"); + if (NULL != _vm_ssl_close) + return _vm_ssl_close(handle); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_connect.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_connect.c new file mode 100644 index 00000000..70dbba95 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_connect.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmssl.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ssl_connect_t)(const vm_ssl_cntx *ctx); +_vm_ssl_connect_t _vm_ssl_connect = NULL; + +VMINT vm_ssl_connect(const vm_ssl_cntx *ctx) +{ + if (NULL == _vm_ssl_connect) + _vm_ssl_connect = (_vm_ssl_connect_t)vm_get_sym_entry("vm_ssl_connect"); + if (NULL != _vm_ssl_connect) + return _vm_ssl_connect(ctx); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_get_verify_result.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_get_verify_result.c new file mode 100644 index 00000000..bb57cc2a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_get_verify_result.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmssl.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ssl_get_verify_result_t)(VMINT handle); +_vm_ssl_get_verify_result_t _vm_ssl_get_verify_result = NULL; + +VMINT vm_ssl_get_verify_result(VMINT handle) +{ + if (NULL == _vm_ssl_get_verify_result) + _vm_ssl_get_verify_result = (_vm_ssl_get_verify_result_t)vm_get_sym_entry("vm_ssl_get_verify_result"); + if (NULL != _vm_ssl_get_verify_result) + return _vm_ssl_get_verify_result(handle); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_is_support.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_is_support.c new file mode 100644 index 00000000..6a858d26 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_is_support.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmssl.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ssl_is_support_t)(void); +_vm_ssl_is_support_t _vm_ssl_is_support = NULL; + +VMINT vm_ssl_is_support(void) +{ + if (NULL == _vm_ssl_is_support) + _vm_ssl_is_support = (_vm_ssl_is_support_t)vm_get_sym_entry("vm_ssl_is_support"); + if (NULL != _vm_ssl_is_support) + return _vm_ssl_is_support(); + return (VMINT)0; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_load_ca_chain_cert.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_load_ca_chain_cert.c new file mode 100644 index 00000000..d68fba70 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_load_ca_chain_cert.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmssl.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ssl_load_ca_chain_cert_t)(VMINT handle, const void *cert_buf, VMINT buf_len); +_vm_ssl_load_ca_chain_cert_t _vm_ssl_load_ca_chain_cert = NULL; + +VMINT vm_ssl_load_ca_chain_cert(VMINT handle, const void *cert_buf, VMINT buf_len) +{ + if (NULL == _vm_ssl_load_ca_chain_cert) + _vm_ssl_load_ca_chain_cert = (_vm_ssl_load_ca_chain_cert_t)vm_get_sym_entry("vm_ssl_load_ca_chain_cert"); + if (NULL != _vm_ssl_load_ca_chain_cert) + return _vm_ssl_load_ca_chain_cert(handle,cert_buf,buf_len); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_read.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_read.c new file mode 100644 index 00000000..91519db1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_read.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmssl.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ssl_read_t)(VMINT handle, VMUINT8 *buf, VMINT len); +_vm_ssl_read_t _vm_ssl_read = NULL; + +VMINT vm_ssl_read(VMINT handle, VMUINT8 *buf, VMINT len) +{ + if (NULL == _vm_ssl_read) + _vm_ssl_read = (_vm_ssl_read_t)vm_get_sym_entry("vm_ssl_read"); + if (NULL != _vm_ssl_read) + return _vm_ssl_read(handle,buf,len); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_sha1_hmac.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_sha1_hmac.c new file mode 100644 index 00000000..73be6453 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_sha1_hmac.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmssl.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ssl_sha1_hmac_t)(VMBYTE *key, VMINT keylen, VMBYTE *input, VMINT ilen, VMBYTE output[20]); +_vm_ssl_sha1_hmac_t _vm_ssl_sha1_hmac = NULL; + +VMINT vm_ssl_sha1_hmac(VMBYTE *key, VMINT keylen, VMBYTE *input, VMINT ilen, VMBYTE output[20]) +{ + if (NULL == _vm_ssl_sha1_hmac) + _vm_ssl_sha1_hmac = (_vm_ssl_sha1_hmac_t)vm_get_sym_entry("vm_ssl_sha1_hmac"); + if (NULL != _vm_ssl_sha1_hmac) + return _vm_ssl_sha1_hmac(key,keylen,input,ilen,output); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_write.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_write.c new file mode 100644 index 00000000..2245b694 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ssl_write.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmssl.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ssl_write_t)(VMINT handle, const VMUINT8 *buf, VMINT len); +_vm_ssl_write_t _vm_ssl_write = NULL; + +VMINT vm_ssl_write(VMINT handle, const VMUINT8 *buf, VMINT len) +{ + if (NULL == _vm_ssl_write) + _vm_ssl_write = (_vm_ssl_write_t)vm_get_sym_entry("vm_ssl_write"); + if (NULL != _vm_ssl_write) + return _vm_ssl_write(handle,buf,len); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_add_account.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_add_account.c new file mode 100644 index 00000000..33ea74d4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_add_account.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_add_account_t)(VMUINT32 provider, const VMWCHAR * username, const VMWCHAR * password, vm_sso_account_callback callback, void * user_data); +_vm_sso_add_account_t _vm_sso_add_account = NULL; + +VMINT vm_sso_add_account(VMUINT32 provider, const VMWCHAR * username, const VMWCHAR * password, vm_sso_account_callback callback, void * user_data) +{ + if (NULL == _vm_sso_add_account) + _vm_sso_add_account = (_vm_sso_add_account_t)vm_get_sym_entry("vm_sso_add_account"); + + if (NULL != _vm_sso_add_account) + return _vm_sso_add_account(provider,username,password,callback,user_data); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_cancel.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_cancel.c new file mode 100644 index 00000000..0a38a8d2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_cancel.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_cancel_t)(VMINT req_id); +_vm_sso_cancel_t _vm_sso_cancel = NULL; + +VMINT vm_sso_cancel(VMINT req_id) +{ + if (NULL == _vm_sso_cancel) + _vm_sso_cancel = (_vm_sso_cancel_t)vm_get_sym_entry("vm_sso_cancel"); + + if (NULL != _vm_sso_cancel) + return _vm_sso_cancel(req_id); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_del_account.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_del_account.c new file mode 100644 index 00000000..f6c2b617 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_del_account.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_del_account_t)(VMUINT32 provider, VMUINT8 account, vm_sso_result_callback callback, void * user_data); +_vm_sso_del_account_t _vm_sso_del_account = NULL; + +VMINT vm_sso_del_account(VMUINT32 provider, VMUINT8 account, vm_sso_result_callback callback, void * user_data) +{ + if (NULL == _vm_sso_del_account) + _vm_sso_del_account = (_vm_sso_del_account_t)vm_get_sym_entry("vm_sso_del_account"); + + if (NULL != _vm_sso_del_account) + return _vm_sso_del_account(provider,account,callback,user_data); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_account.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_account.c new file mode 100644 index 00000000..f76933f0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_account.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_get_account_t)(VMUINT32 provider, VMUINT8 account, vm_sso_account_struct * buffer); +_vm_sso_get_account_t _vm_sso_get_account = NULL; + +VMINT vm_sso_get_account(VMUINT32 provider, VMUINT8 account, vm_sso_account_struct * buffer) +{ + if (NULL == _vm_sso_get_account) + _vm_sso_get_account = (_vm_sso_get_account_t)vm_get_sym_entry("vm_sso_get_account"); + + if (NULL != _vm_sso_get_account) + return _vm_sso_get_account(provider,account,buffer); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_account_count.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_account_count.c new file mode 100644 index 00000000..43f3c16f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_account_count.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_get_account_count_t)(VMUINT32 provider, vm_sso_login_state login_state); +_vm_sso_get_account_count_t _vm_sso_get_account_count = NULL; + +VMINT vm_sso_get_account_count(VMUINT32 provider, vm_sso_login_state login_state) +{ + if (NULL == _vm_sso_get_account_count) + _vm_sso_get_account_count = (_vm_sso_get_account_count_t)vm_get_sym_entry("vm_sso_get_account_count"); + + if (NULL != _vm_sso_get_account_count) + return _vm_sso_get_account_count(provider,login_state); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_account_name.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_account_name.c new file mode 100644 index 00000000..e232e7f2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_account_name.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_get_account_name_t)(VMUINT32 provider, VMUINT8 account, VMWCHAR * buffer); +_vm_sso_get_account_name_t _vm_sso_get_account_name = NULL; + +VMINT vm_sso_get_account_name(VMUINT32 provider, VMUINT8 account, VMWCHAR * buffer) +{ + if (NULL == _vm_sso_get_account_name) + _vm_sso_get_account_name = (_vm_sso_get_account_name_t)vm_get_sym_entry("vm_sso_get_account_name"); + + if (NULL != _vm_sso_get_account_name) + return _vm_sso_get_account_name(provider,account,buffer); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_accounts.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_accounts.c new file mode 100644 index 00000000..6d57a446 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_accounts.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_get_accounts_t)(VMUINT32 provider, vm_sso_login_state login_state, vm_sso_account_struct * buffer, VMUINT8 buffer_items); +_vm_sso_get_accounts_t _vm_sso_get_accounts = NULL; + +VMINT vm_sso_get_accounts(VMUINT32 provider, vm_sso_login_state login_state, vm_sso_account_struct * buffer, VMUINT8 buffer_items) +{ + if (NULL == _vm_sso_get_accounts) + _vm_sso_get_accounts = (_vm_sso_get_accounts_t)vm_get_sym_entry("vm_sso_get_accounts"); + + if (NULL != _vm_sso_get_accounts) + return _vm_sso_get_accounts(provider,login_state,buffer,buffer_items); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_credentials.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_credentials.c new file mode 100644 index 00000000..e40c5eee --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_credentials.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_get_credentials_t)(VMUINT32 provider, VMUINT8 account, vm_sso_credential_struct * buffer); +_vm_sso_get_credentials_t _vm_sso_get_credentials = NULL; + +VMINT vm_sso_get_credentials(VMUINT32 provider, VMUINT8 account, vm_sso_credential_struct * buffer) +{ + if (NULL == _vm_sso_get_credentials) + _vm_sso_get_credentials = (_vm_sso_get_credentials_t)vm_get_sym_entry("vm_sso_get_credentials"); + + if (NULL != _vm_sso_get_credentials) + return _vm_sso_get_credentials(provider,account,buffer); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_provider.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_provider.c new file mode 100644 index 00000000..59e1303d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_provider.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_get_provider_t)(VMUINT32 provider, vm_sso_provider_struct * buffer); +_vm_sso_get_provider_t _vm_sso_get_provider = NULL; + +VMINT vm_sso_get_provider(VMUINT32 provider, vm_sso_provider_struct * buffer) +{ + if (NULL == _vm_sso_get_provider) + _vm_sso_get_provider = (_vm_sso_get_provider_t)vm_get_sym_entry("vm_sso_get_provider"); + + if (NULL != _vm_sso_get_provider) + return _vm_sso_get_provider(provider,buffer); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_provider_count.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_provider_count.c new file mode 100644 index 00000000..b000142d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_provider_count.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_get_provider_count_t)(void); +_vm_sso_get_provider_count_t _vm_sso_get_provider_count = NULL; + +VMINT vm_sso_get_provider_count(void) +{ + if (NULL == _vm_sso_get_provider_count) + _vm_sso_get_provider_count = (_vm_sso_get_provider_count_t)vm_get_sym_entry("vm_sso_get_provider_count"); + + if (NULL != _vm_sso_get_provider_count) + return _vm_sso_get_provider_count(); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_provider_icon.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_provider_icon.c new file mode 100644 index 00000000..811e08aa --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_provider_icon.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_get_provider_icon_t)(VMUINT32 provider, vm_sso_icon_enum type, VMWCHAR ** icon_path); +_vm_sso_get_provider_icon_t _vm_sso_get_provider_icon = NULL; + +VMINT vm_sso_get_provider_icon(VMUINT32 provider, vm_sso_icon_enum type, VMWCHAR ** icon_path) +{ + if (NULL == _vm_sso_get_provider_icon) + _vm_sso_get_provider_icon = (_vm_sso_get_provider_icon_t)vm_get_sym_entry("vm_sso_get_provider_icon"); + + if (NULL != _vm_sso_get_provider_icon) + return _vm_sso_get_provider_icon(provider,type,icon_path); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_provider_name.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_provider_name.c new file mode 100644 index 00000000..bec8fa54 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_provider_name.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_get_provider_name_t)(VMUINT32 provider, VMWCHAR * buffer); +_vm_sso_get_provider_name_t _vm_sso_get_provider_name = NULL; + +VMINT vm_sso_get_provider_name(VMUINT32 provider, VMWCHAR * buffer) +{ + if (NULL == _vm_sso_get_provider_name) + _vm_sso_get_provider_name = (_vm_sso_get_provider_name_t)vm_get_sym_entry("vm_sso_get_provider_name"); + + if (NULL != _vm_sso_get_provider_name) + return _vm_sso_get_provider_name(provider,buffer); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_providers.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_providers.c new file mode 100644 index 00000000..5bc2f2ab --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_get_providers.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_get_providers_t)(vm_sso_provider_struct * buffer, VMUINT8 buffer_items); +_vm_sso_get_providers_t _vm_sso_get_providers = NULL; + +VMINT vm_sso_get_providers(vm_sso_provider_struct * buffer, VMUINT8 buffer_items) +{ + if (NULL == _vm_sso_get_providers) + _vm_sso_get_providers = (_vm_sso_get_providers_t)vm_get_sym_entry("vm_sso_get_providers"); + + if (NULL != _vm_sso_get_providers) + return _vm_sso_get_providers(buffer,buffer_items); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_login_account.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_login_account.c new file mode 100644 index 00000000..4c03ff2b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_login_account.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_login_account_t)(VMUINT32 provider, VMUINT8 account, const VMWCHAR * password, vm_sso_account_callback callback, void * user_data); +_vm_sso_login_account_t _vm_sso_login_account = NULL; + +VMINT vm_sso_login_account(VMUINT32 provider, VMUINT8 account, const VMWCHAR * password, vm_sso_account_callback callback, void * user_data) +{ + if (NULL == _vm_sso_login_account) + _vm_sso_login_account = (_vm_sso_login_account_t)vm_get_sym_entry("vm_sso_login_account"); + + if (NULL != _vm_sso_login_account) + return _vm_sso_login_account(provider,account,password,callback,user_data); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_logout_account.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_logout_account.c new file mode 100644 index 00000000..c0c6cdf3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_logout_account.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_logout_account_t)(VMUINT32 provider, VMUINT8 account, vm_sso_result_callback callback, void * user_data); +_vm_sso_logout_account_t _vm_sso_logout_account = NULL; + +VMINT vm_sso_logout_account(VMUINT32 provider, VMUINT8 account, vm_sso_result_callback callback, void * user_data) +{ + if (NULL == _vm_sso_logout_account) + _vm_sso_logout_account = (_vm_sso_logout_account_t)vm_get_sym_entry("vm_sso_logout_account"); + + if (NULL != _vm_sso_logout_account) + return _vm_sso_logout_account(provider,account,callback,user_data); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_refresh_credentials.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_refresh_credentials.c new file mode 100644 index 00000000..c9f558ff --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sso_refresh_credentials.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsso.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sso_refresh_credentials_t)(VMUINT32 provider, VMUINT8 account, vm_sso_result_callback callback, void * user_data); +_vm_sso_refresh_credentials_t _vm_sso_refresh_credentials = NULL; + +VMINT vm_sso_refresh_credentials(VMUINT32 provider, VMUINT8 account, vm_sso_result_callback callback, void * user_data) +{ + if (NULL == _vm_sso_refresh_credentials) + _vm_sso_refresh_credentials = (_vm_sso_refresh_credentials_t)vm_get_sym_entry("vm_sso_refresh_credentials"); + + if (NULL != _vm_sso_refresh_credentials) + return _vm_sso_refresh_credentials(provider,account,callback,user_data); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_start_app.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_start_app.c new file mode 100644 index 00000000..1575c2ac --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_start_app.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_start_app_t)(const VMWCHAR* filepath, VMINT parent_app_handle, VMINT flag); +_vm_start_app_t _vm_start_app = NULL; + +void vm_start_app(const VMWCHAR* filepath, VMINT parent_app_handle, VMINT flag) +{ + if (NULL == _vm_start_app) + _vm_start_app = (_vm_start_app_t)vm_get_sym_entry("vm_start_app"); + + if (NULL != _vm_start_app) + _vm_start_app(filepath, parent_app_handle, flag); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_start_app_with_para.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_start_app_with_para.c new file mode 100644 index 00000000..24faa450 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_start_app_with_para.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmpromng.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_start_app_with_para_t)(const VMWCHAR* filepath, VMINT parent_app_handle, VMINT is_parent_exit,void* parameter,VMINT parameter_size); +_vm_start_app_with_para_t _vm_start_app_with_para = NULL; + +void vm_start_app_with_para(const VMWCHAR* filepath, VMINT parent_app_handle, VMINT is_parent_exit,void* parameter,VMINT parameter_size) +{ + if (NULL == _vm_start_app_with_para) + _vm_start_app_with_para = (_vm_start_app_with_para_t)vm_get_sym_entry("vm_start_app_with_para"); + + if (NULL != _vm_start_app_with_para) + _vm_start_app_with_para(filepath, parent_app_handle, is_parent_exit, parameter, parameter_size); +} + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_storage_close.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_storage_close.c new file mode 100644 index 00000000..d9780d54 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_storage_close.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_storage_close_t)(VMINT h); +_vm_storage_close_t _vm_storage_close = NULL; + +void vm_storage_close(VMINT h) +{ + if (NULL == _vm_storage_close) + _vm_storage_close = (_vm_storage_close_t)vm_get_sym_entry("vm_storage_close"); + + if (NULL != _vm_storage_close) + _vm_storage_close(h); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_storage_open.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_storage_open.c new file mode 100644 index 00000000..5a5b3cb1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_storage_open.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_storage_open_t)(void); +_vm_storage_open_t _vm_storage_open = NULL; + +VMINT vm_storage_open(void) +{ + if (NULL == _vm_storage_open) + _vm_storage_open = (_vm_storage_open_t)vm_get_sym_entry("vm_storage_open"); + + if (NULL != _vm_storage_open) + return _vm_storage_open(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_storage_read.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_storage_read.c new file mode 100644 index 00000000..cf4ebd52 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_storage_read.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_storage_read_t)(VMINT h, void * data, VMUINT offset, VMUINT size, VMUINT * read); +_vm_storage_read_t _vm_storage_read = NULL; + +VMINT vm_storage_read(VMINT h, void * data, VMUINT offset, VMUINT size, VMUINT * read) +{ + if (NULL == _vm_storage_read) + _vm_storage_read = (_vm_storage_read_t)vm_get_sym_entry("vm_storage_read"); + + if (NULL != _vm_storage_read) + return _vm_storage_read(h,data,offset,size,read); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_storage_write.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_storage_write.c new file mode 100644 index 00000000..004abd40 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_storage_write.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_storage_write_t)(VMINT h, const void * data, VMUINT offset, VMUINT size, VMUINT * written); +_vm_storage_write_t _vm_storage_write = NULL; + +VMINT vm_storage_write(VMINT h, const void * data, VMUINT offset, VMUINT size, VMUINT * written) +{ + if (NULL == _vm_storage_write) + _vm_storage_write = (_vm_storage_write_t)vm_get_sym_entry("vm_storage_write"); + + if (NULL != _vm_storage_write) + return _vm_storage_write(h,data,offset,size,written); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_stream_connect.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_stream_connect.c new file mode 100644 index 00000000..6cd215b9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_stream_connect.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstream.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_stream_connect_t)(vm_stream_connect_struct connect_info); +_vm_stream_connect_t _vm_stream_connect = NULL; + +VMINT vm_stream_connect(vm_stream_connect_struct connect_info) +{ + if (NULL == _vm_stream_connect) + _vm_stream_connect = (_vm_stream_connect_t)vm_get_sym_entry("vm_stream_connect"); + + if (NULL != _vm_stream_connect) + return _vm_stream_connect(connect_info); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_stream_disconnect.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_stream_disconnect.c new file mode 100644 index 00000000..0490aca8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_stream_disconnect.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstream.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_stream_disconnect_t)(VMUINT8 session_id); +_vm_stream_disconnect_t _vm_stream_disconnect = NULL; + +VMINT vm_stream_disconnect(VMUINT8 session_id) +{ + if (NULL == _vm_stream_disconnect) + _vm_stream_disconnect = (_vm_stream_disconnect_t)vm_get_sym_entry("vm_stream_disconnect"); + + if (NULL != _vm_stream_disconnect) + return _vm_stream_disconnect(session_id); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_stream_set_volume.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_stream_set_volume.c new file mode 100644 index 00000000..a39e0d79 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_stream_set_volume.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmstream.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_stream_set_volume_t)(vm_stream_volume_enum type, VMUINT value); +_vm_stream_set_volume_t _vm_stream_set_volume = NULL; + +void vm_stream_set_volume(vm_stream_volume_enum type, VMUINT value) +{ + if (NULL == _vm_stream_set_volume) + _vm_stream_set_volume = (_vm_stream_set_volume_t)vm_get_sym_entry("vm_stream_set_volume"); + + if (NULL != _vm_stream_set_volume) + _vm_stream_set_volume(type, value); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_string_equals_ignore_case.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_string_equals_ignore_case.c new file mode 100644 index 00000000..f28e6ec9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_string_equals_ignore_case.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_string_equals_ignore_case_t)(const char *s1, const char *s2); +_vm_string_equals_ignore_case_t _vm_string_equals_ignore_case = NULL; + +VMINT vm_string_equals_ignore_case(const char *s1, const char *s2) +{ + if (NULL == _vm_string_equals_ignore_case) + _vm_string_equals_ignore_case = (_vm_string_equals_ignore_case_t)vm_get_sym_entry("vm_string_equals_ignore_case"); + + if (NULL != _vm_string_equals_ignore_case) + return _vm_string_equals_ignore_case(s1,s2); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_strtol.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_strtol.c new file mode 100644 index 00000000..42908af5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_strtol.c @@ -0,0 +1,17 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef long(*_strtol_t)(const char * nptr, char **endptr, int base); + _strtol_t _strtol = NULL; +long vm_strtol(const char * nptr, char **endptr, int base) +{ + if (_strtol == NULL) { + _strtol = (_strtol_t)vm_get_sym_entry("strtol"); + } + if (_strtol != NULL) { + return _strtol(nptr, endptr, base); + } + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_switch_backlight.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_switch_backlight.c new file mode 100644 index 00000000..cd3b4916 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_switch_backlight.c @@ -0,0 +1,15 @@ +#include "vmsys.h" +#include "vmpwr.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_switch_backlight_t)(VMINT turn_on); +_vm_switch_backlight_t _vm_switch_backlight = NULL; +void vm_switch_backlight(VMINT turn_on) +{ + if (NULL == _vm_switch_backlight) + _vm_switch_backlight = (_vm_switch_backlight_t)vm_get_sym_entry("vm_switch_backlight"); + if (NULL != _vm_switch_backlight) + _vm_switch_backlight(turn_on); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_switch_power_saving_mode.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_switch_power_saving_mode.c new file mode 100644 index 00000000..df6bd722 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_switch_power_saving_mode.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_switch_power_saving_mode_t)(power_saving_mode_enum mode); +_vm_switch_power_saving_mode_t _vm_switch_power_saving_mode = NULL; + +VMINT vm_switch_power_saving_mode(power_saving_mode_enum mode) +{ + if (NULL == _vm_switch_power_saving_mode) + _vm_switch_power_saving_mode = (_vm_switch_power_saving_mode_t)vm_get_sym_entry("vm_switch_power_saving_mode"); + + if (NULL != _vm_switch_power_saving_mode) + return _vm_switch_power_saving_mode(mode); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_close.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_close.c new file mode 100644 index 00000000..7058bcff --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_close.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_sys_file_close_t)(VMFILE h); + _vm_sys_file_close_t _vm_sys_file_close = NULL; +void vm_sys_file_close(VMFILE h) +{ + if (_vm_sys_file_close == NULL) + _vm_sys_file_close = (_vm_sys_file_close_t)vm_get_sym_entry("vm_sys_file_close"); + + if (_vm_sys_file_close != NULL) + _vm_sys_file_close(h); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_delete.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_delete.c new file mode 100644 index 00000000..49a326d1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_delete.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sys_file_delete_t)(void); + _vm_sys_file_delete_t _vm_sys_file_delete = NULL; +VMINT vm_sys_file_delete(void) +{ + if (_vm_sys_file_delete == NULL) + _vm_sys_file_delete = (_vm_sys_file_delete_t)vm_get_sym_entry("vm_sys_file_delete"); + + if (_vm_sys_file_delete != NULL) + return _vm_sys_file_delete(); + else + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_get_space.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_get_space.c new file mode 100644 index 00000000..eb7a1c34 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_get_space.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_sys_file_get_space_t)(void); + _vm_sys_file_get_space_t _vm_sys_file_get_space = NULL; +VMINT vm_sys_file_get_space(void) +{ + if (_vm_sys_file_get_space == NULL) + _vm_sys_file_get_space = (_vm_sys_file_get_space_t)vm_get_sym_entry("vm_sys_file_get_space"); + + if (_vm_sys_file_get_space != NULL) + return _vm_sys_file_get_space(); + else + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_open.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_open.c new file mode 100644 index 00000000..add1bc0f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_open.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMFILE (*_vm_sys_file_open_t)(VMUINT mode, VMUINT binary); + _vm_sys_file_open_t _vm_sys_file_open = NULL; +VMFILE vm_sys_file_open(VMUINT mode, VMUINT binary) +{ + if (_vm_sys_file_open == NULL) + _vm_sys_file_open = (_vm_sys_file_open_t)vm_get_sym_entry("vm_sys_file_open"); + + if (_vm_sys_file_open != NULL) + return _vm_sys_file_open(mode, binary); + else + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_read.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_read.c new file mode 100644 index 00000000..2994fd62 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_read.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sys_file_read_t)(VMFILE handle, void * data, VMUINT length, VMUINT *nread); + _vm_sys_file_read_t _vm_sys_file_read = NULL; +VMINT vm_sys_file_read(VMFILE handle, void * data, VMUINT length, VMUINT *nread) +{ + if (_vm_sys_file_read == NULL) + _vm_sys_file_read = (_vm_sys_file_read_t)vm_get_sym_entry("vm_sys_file_read"); + + if (_vm_sys_file_read != NULL) + return _vm_sys_file_read(handle, data, length, nread); + else + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_seek.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_seek.c new file mode 100644 index 00000000..1e656aa5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_seek.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sys_file_seek_t)(VMFILE handle, VMINT offset, VMINT base); + _vm_sys_file_seek_t _vm_sys_file_seek = NULL; +VMINT vm_sys_file_seek(VMFILE handle, VMINT offset, VMINT base) +{ + if (_vm_sys_file_seek == NULL) + _vm_sys_file_seek = (_vm_sys_file_seek_t)vm_get_sym_entry("vm_sys_file_seek"); + + if (_vm_sys_file_seek != NULL) + return _vm_sys_file_seek(handle, offset, base); + else + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_write.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_write.c new file mode 100644 index 00000000..1f6f8db7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_sys_file_write.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_sys_file_write_t)(VMFILE handle, void * data, VMUINT length, VMUINT * written); + _vm_sys_file_write_t _vm_sys_file_write = NULL; +VMINT vm_sys_file_write(VMFILE handle, void * data, VMUINT length, VMUINT * written) +{ + if (_vm_sys_file_write == NULL) + _vm_sys_file_write = (_vm_sys_file_write_t)vm_get_sym_entry("vm_sys_file_write"); + + if (_vm_sys_file_write != NULL) + return _vm_sys_file_write(handle, data, length, written); + else + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_close.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_close.c new file mode 100644 index 00000000..d8abe855 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_close.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_tcp_close_t)(VMINT handle); +_vm_tcp_close_t _vm_tcp_close = NULL; + +void vm_tcp_close(VMINT handle) +{ + if (NULL == _vm_tcp_close) + _vm_tcp_close = (_vm_tcp_close_t)vm_get_sym_entry("vm_tcp_close"); + + if (NULL != _vm_tcp_close) + _vm_tcp_close(handle); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_close_sync.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_close_sync.c new file mode 100644 index 00000000..3b46b33a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_close_sync.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tcp_close_sync_t)(VMINT handle); +_vm_tcp_close_sync_t _vm_tcp_close_sync = NULL; + +VMINT vm_tcp_close_sync(VMINT handle) +{ + if (NULL == _vm_tcp_close_sync) + _vm_tcp_close_sync = (_vm_tcp_close_sync_t)vm_get_sym_entry("vm_tcp_close_sync"); + if (NULL != _vm_tcp_close_sync) + return _vm_tcp_close_sync(handle); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_connect.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_connect.c new file mode 100644 index 00000000..51dfd7f4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_connect.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tcp_connect_t)(const char* host, const VMINT port, const VMINT apn, void (*callback)(VMINT handle, VMINT event)); +_vm_tcp_connect_t _vm_tcp_connect = NULL; + +VMINT vm_tcp_connect(const char* host, const VMINT port, const VMINT apn, void (*callback)(VMINT handle, VMINT event)) +{ + if (NULL == _vm_tcp_connect) + _vm_tcp_connect = (_vm_tcp_connect_t)vm_get_sym_entry("vm_tcp_connect"); + + if (NULL != _vm_tcp_connect) + return _vm_tcp_connect(host,port,apn,callback); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_connect_ex.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_connect_ex.c new file mode 100644 index 00000000..699c4d29 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_connect_ex.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tcp_connect_ex_t)(const char* host, const VMINT port, const VMINT apn, void *user_data, void (*callback)(VMINT handle, VMINT event, void *user_data)); +_vm_tcp_connect_ex_t _vm_tcp_connect_ex = NULL; + +VMINT vm_tcp_connect_ex(const char* host, const VMINT port, const VMINT apn, void *user_data, void (*callback)(VMINT handle, VMINT event, void *user_data)) +{ + if (NULL == _vm_tcp_connect_ex) + _vm_tcp_connect_ex = (_vm_tcp_connect_ex_t)vm_get_sym_entry("vm_tcp_connect_ex"); + + if (NULL != _vm_tcp_connect_ex) + return _vm_tcp_connect_ex(host,port,apn, user_data, callback); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_connect_sync.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_connect_sync.c new file mode 100644 index 00000000..13816d88 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_connect_sync.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tcp_connect_sync_t)(const char* ip, const VMINT port, VMINT apn); +_vm_tcp_connect_sync_t _vm_tcp_connect_sync = NULL; + +VMINT vm_tcp_connect_sync(const char* ip, const VMINT port, VMINT apn) +{ + if (NULL == _vm_tcp_connect_sync) + _vm_tcp_connect_sync = (_vm_tcp_connect_sync_t)vm_get_sym_entry("vm_tcp_connect_sync"); + if (NULL != _vm_tcp_connect_sync) + return _vm_tcp_connect_sync(ip,port,apn); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_get_soc_id.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_get_soc_id.c new file mode 100644 index 00000000..31be9893 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_get_soc_id.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tcp_get_soc_id_t)(VMINT hdl); +_vm_tcp_get_soc_id_t _vm_tcp_get_soc_id = NULL; + +VMINT vm_tcp_get_soc_id(VMINT hdl) +{ + if (NULL == _vm_tcp_get_soc_id) + _vm_tcp_get_soc_id = (_vm_tcp_get_soc_id_t)vm_get_sym_entry("vm_tcp_get_soc_id"); + if (NULL != _vm_tcp_get_soc_id) + return _vm_tcp_get_soc_id(hdl); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_read.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_read.c new file mode 100644 index 00000000..bb49165d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_read.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tcp_read_t)(VMINT handle, void* buf, VMINT len); +_vm_tcp_read_t _vm_tcp_read = NULL; + +VMINT vm_tcp_read(VMINT handle, void* buf, VMINT len) +{ + if (NULL == _vm_tcp_read) + _vm_tcp_read = (_vm_tcp_read_t)vm_get_sym_entry("vm_tcp_read"); + + if (NULL != _vm_tcp_read) + return _vm_tcp_read(handle,buf,len); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_read_sync.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_read_sync.c new file mode 100644 index 00000000..a06a12ad --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_read_sync.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tcp_read_sync_t)(VMINT handle, void* buf, VMINT len); +_vm_tcp_read_sync_t _vm_tcp_read_sync = NULL; + +VMINT vm_tcp_read_sync(VMINT handle, void* buf, VMINT len) +{ + if (NULL == _vm_tcp_read_sync) + _vm_tcp_read_sync = (_vm_tcp_read_sync_t)vm_get_sym_entry("vm_tcp_read_sync"); + if (NULL != _vm_tcp_read_sync) + return _vm_tcp_read_sync(handle,buf,len); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_write.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_write.c new file mode 100644 index 00000000..1dbce8b0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_write.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tcp_write_t)(VMINT handle, void* buf, VMINT len); +_vm_tcp_write_t _vm_tcp_write = NULL; + +VMINT vm_tcp_write(VMINT handle, void* buf, VMINT len) +{ + if (NULL == _vm_tcp_write) + _vm_tcp_write = (_vm_tcp_write_t)vm_get_sym_entry("vm_tcp_write"); + + if (NULL != _vm_tcp_write) + return _vm_tcp_write(handle,buf,len); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_write_sync.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_write_sync.c new file mode 100644 index 00000000..48e38069 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tcp_write_sync.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tcp_write_sync_t)(VMINT handle, void* buf, VMINT len); +_vm_tcp_write_sync_t _vm_tcp_write_sync = NULL; + +VMINT vm_tcp_write_sync(VMINT handle, void* buf, VMINT len) +{ + if (NULL == _vm_tcp_write_sync) + _vm_tcp_write_sync = (_vm_tcp_write_sync_t)vm_get_sym_entry("vm_tcp_write_sync"); + if (NULL != _vm_tcp_write_sync) + return _vm_tcp_write_sync(handle,buf,len); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_create.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_create.c new file mode 100644 index 00000000..ab5da42c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_create.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmthread.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VM_THREAD_HANDLE (*_vm_thread_create_t)(VM_THREAD_FUNC thread_function, void* data,VMUINT8 priority); +_vm_thread_create_t _vm_thread_create = NULL; + +VM_THREAD_HANDLE vm_thread_create(VM_THREAD_FUNC thread_function, void* data,VMUINT8 priority) +{ + if (NULL == _vm_thread_create) + _vm_thread_create = (_vm_thread_create_t)vm_get_sym_entry("vm_thread_create"); + if (NULL != _vm_thread_create) + return _vm_thread_create(thread_function,data,priority); + return 0; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_get_current_handle.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_get_current_handle.c new file mode 100644 index 00000000..4a56dc3d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_get_current_handle.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmthread.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VM_THREAD_HANDLE (*_vm_thread_get_current_handle_t)(void); +_vm_thread_get_current_handle_t _vm_thread_get_current_handle = NULL; + +VM_THREAD_HANDLE vm_thread_get_current_handle(void) +{ + if (NULL == _vm_thread_get_current_handle) + _vm_thread_get_current_handle = (_vm_thread_get_current_handle_t)vm_get_sym_entry("vm_thread_get_current_handle"); + if (NULL != _vm_thread_get_current_handle) + return _vm_thread_get_current_handle(); + return 0; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_get_main_handle.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_get_main_handle.c new file mode 100644 index 00000000..5cbd1df7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_get_main_handle.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmthread.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VM_THREAD_HANDLE (*_vm_thread_get_main_handle_t)(void); +_vm_thread_get_main_handle_t _vm_thread_get_main_handle = NULL; + +VM_THREAD_HANDLE vm_thread_get_main_handle(void) +{ + if (NULL == _vm_thread_get_main_handle) + _vm_thread_get_main_handle = (_vm_thread_get_main_handle_t)vm_get_sym_entry("vm_thread_get_main_handle"); + if (NULL != _vm_thread_get_main_handle) + return _vm_thread_get_main_handle(); + return 0; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_get_msg.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_get_msg.c new file mode 100644 index 00000000..d5abb811 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_get_msg.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmthread.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_thread_get_msg_t)(VM_MSG_STRUCT* msg); +_vm_thread_get_msg_t _vm_thread_get_msg = NULL; + +void vm_thread_get_msg(VM_MSG_STRUCT* msg) +{ + if (NULL == _vm_thread_get_msg) + _vm_thread_get_msg = (_vm_thread_get_msg_t)vm_get_sym_entry("vm_thread_get_msg"); + if (NULL != _vm_thread_get_msg) + _vm_thread_get_msg(msg); +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_send_msg.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_send_msg.c new file mode 100644 index 00000000..5eade812 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_thread_send_msg.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmthread.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_thread_send_msg_t)(VM_THREAD_HANDLE thread_handle, VMUINT32 msg_id, void* user_data); +_vm_thread_send_msg_t _vm_thread_send_msg = NULL; + +void vm_thread_send_msg(VM_THREAD_HANDLE thread_handle, VMUINT32 msg_id, void* user_data) +{ + if (NULL == _vm_thread_send_msg) + _vm_thread_send_msg = (_vm_thread_send_msg_t)vm_get_sym_entry("vm_thread_send_msg"); + if (NULL != _vm_thread_send_msg) + _vm_thread_send_msg(thread_handle,msg_id,user_data); +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_auto_rehandshake.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_auto_rehandshake.c new file mode 100644 index 00000000..15fb2524 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_auto_rehandshake.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_auto_rehandshake_t)(VMINT res_id, VMINT onoff); +_vm_tls_auto_rehandshake_t _vm_tls_auto_rehandshake = NULL; + +VMINT vm_tls_auto_rehandshake(VMINT res_id, VMINT onoff) +{ + if (NULL == _vm_tls_auto_rehandshake) + _vm_tls_auto_rehandshake = (_vm_tls_auto_rehandshake_t)vm_get_sym_entry("vm_tls_auto_rehandshake"); + + if (NULL != _vm_tls_auto_rehandshake) + return _vm_tls_auto_rehandshake(res_id,onoff); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_check_invalid_cert.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_check_invalid_cert.c new file mode 100644 index 00000000..621420de --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_check_invalid_cert.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_check_invalid_cert_t)(VMINT res_id, VMINT onoff); +_vm_tls_check_invalid_cert_t _vm_tls_check_invalid_cert = NULL; + +VMINT vm_tls_check_invalid_cert(VMINT res_id, VMINT onoff) +{ + if (NULL == _vm_tls_check_invalid_cert) + _vm_tls_check_invalid_cert = (_vm_tls_check_invalid_cert_t)vm_get_sym_entry("vm_tls_check_invalid_cert"); + + if (NULL != _vm_tls_check_invalid_cert) + return _vm_tls_check_invalid_cert(res_id,onoff); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_check_peer_name.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_check_peer_name.c new file mode 100644 index 00000000..84ca2342 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_check_peer_name.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_check_peer_name_t)(VMINT res_id, const VMCHAR *const name); +_vm_tls_check_peer_name_t _vm_tls_check_peer_name = NULL; + +VMINT vm_tls_check_peer_name(VMINT res_id, const VMCHAR *const name) +{ + if (NULL == _vm_tls_check_peer_name) + _vm_tls_check_peer_name = (_vm_tls_check_peer_name_t)vm_get_sym_entry("vm_tls_check_peer_name"); + + if (NULL != _vm_tls_check_peer_name) + return _vm_tls_check_peer_name(res_id,name); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_connect.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_connect.c new file mode 100644 index 00000000..9202460b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_connect.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_connect_t)(VMINT res_id, vm_sockaddr_ex_struct * faddr); +_vm_tls_connect_t _vm_tls_connect = NULL; + +VMINT vm_tls_connect(VMINT res_id, vm_sockaddr_ex_struct * faddr) +{ + if (NULL == _vm_tls_connect) + _vm_tls_connect = (_vm_tls_connect_t)vm_get_sym_entry("vm_tls_connect"); + + if (NULL != _vm_tls_connect) + return _vm_tls_connect(res_id,faddr); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_delete_conn.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_delete_conn.c new file mode 100644 index 00000000..06ea3232 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_delete_conn.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_delete_conn_t)(VMINT res_id); +_vm_tls_delete_conn_t _vm_tls_delete_conn = NULL; + +VMINT vm_tls_delete_conn(VMINT res_id) +{ + if (NULL == _vm_tls_delete_conn) + _vm_tls_delete_conn = (_vm_tls_delete_conn_t)vm_get_sym_entry("vm_tls_delete_conn"); + + if (NULL != _vm_tls_delete_conn) + return _vm_tls_delete_conn(res_id); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_delete_ctx.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_delete_ctx.c new file mode 100644 index 00000000..454c2c55 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_delete_ctx.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_delete_ctx_t)(VMINT res_id); +_vm_tls_delete_ctx_t _vm_tls_delete_ctx = NULL; + +VMINT vm_tls_delete_ctx(VMINT res_id) +{ + if (NULL == _vm_tls_delete_ctx) + _vm_tls_delete_ctx = (_vm_tls_delete_ctx_t)vm_get_sym_entry("vm_tls_delete_ctx"); + + if (NULL != _vm_tls_delete_ctx) + return _vm_tls_delete_ctx(res_id); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_get_cipher.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_get_cipher.c new file mode 100644 index 00000000..4acb1a98 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_get_cipher.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_get_cipher_t)(VMINT res_id, vm_tls_ciphersuites_enum *cipher); +_vm_tls_get_cipher_t _vm_tls_get_cipher = NULL; + +VMINT vm_tls_get_cipher(VMINT res_id, vm_tls_ciphersuites_enum *cipher) +{ + if (NULL == _vm_tls_get_cipher) + _vm_tls_get_cipher = (_vm_tls_get_cipher_t)vm_get_sym_entry("vm_tls_get_cipher"); + + if (NULL != _vm_tls_get_cipher) + return _vm_tls_get_cipher(res_id,cipher); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_get_cipher_info.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_get_cipher_info.c new file mode 100644 index 00000000..1388e344 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_get_cipher_info.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_get_cipher_info_t)(VMINT res_id, vm_tls_cipher_info_struct *cipher_info); +_vm_tls_get_cipher_info_t _vm_tls_get_cipher_info = NULL; + +VMINT vm_tls_get_cipher_info(VMINT res_id, vm_tls_cipher_info_struct *cipher_info) +{ + if (NULL == _vm_tls_get_cipher_info) + _vm_tls_get_cipher_info = (_vm_tls_get_cipher_info_t)vm_get_sym_entry("vm_tls_get_cipher_info"); + + if (NULL != _vm_tls_get_cipher_info) + return _vm_tls_get_cipher_info(res_id,cipher_info); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_get_peer_cert.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_get_peer_cert.c new file mode 100644 index 00000000..1511ecd0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_get_peer_cert.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_get_peer_cert_t)(VMINT res_id, vm_tls_cert_struct *cert); +_vm_tls_get_peer_cert_t _vm_tls_get_peer_cert = NULL; + +VMINT vm_tls_get_peer_cert(VMINT res_id, vm_tls_cert_struct *cert) +{ + if (NULL == _vm_tls_get_peer_cert) + _vm_tls_get_peer_cert = (_vm_tls_get_peer_cert_t)vm_get_sym_entry("vm_tls_get_peer_cert"); + + if (NULL != _vm_tls_get_peer_cert) + return _vm_tls_get_peer_cert(res_id,cert); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_handshake.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_handshake.c new file mode 100644 index 00000000..084d5b56 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_handshake.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_handshake_t)(VMINT res_id); +_vm_tls_handshake_t _vm_tls_handshake = NULL; + +VMINT vm_tls_handshake(VMINT res_id) +{ + if (NULL == _vm_tls_handshake) + _vm_tls_handshake = (_vm_tls_handshake_t)vm_get_sym_entry("vm_tls_handshake"); + + if (NULL != _vm_tls_handshake) + return _vm_tls_handshake(res_id); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_log_plaintext.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_log_plaintext.c new file mode 100644 index 00000000..5adad45d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_log_plaintext.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_log_plaintext_t)(VMINT onoff); +_vm_tls_log_plaintext_t _vm_tls_log_plaintext = NULL; + +VMINT vm_tls_log_plaintext(VMINT onoff) +{ + if (NULL == _vm_tls_log_plaintext) + _vm_tls_log_plaintext = (_vm_tls_log_plaintext_t)vm_get_sym_entry("vm_tls_log_plaintext"); + + if (NULL != _vm_tls_log_plaintext) + return _vm_tls_log_plaintext(onoff); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_new_conn.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_new_conn.c new file mode 100644 index 00000000..bff4f29b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_new_conn.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_new_conn_t)(VMINT res_id, vm_sockaddr_ex_struct * faddr); +_vm_tls_new_conn_t _vm_tls_new_conn = NULL; + +VMINT vm_tls_new_conn(VMINT res_id, vm_sockaddr_ex_struct * faddr) +{ + if (NULL == _vm_tls_new_conn) + _vm_tls_new_conn = (_vm_tls_new_conn_t)vm_get_sym_entry("vm_tls_new_conn"); + + if (NULL != _vm_tls_new_conn) + return _vm_tls_new_conn(res_id,faddr); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_new_ctx.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_new_ctx.c new file mode 100644 index 00000000..4d5ac109 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_new_ctx.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_new_ctx_t)(vm_tls_version_enum ver, vm_socket_type_enum sock_type, VMINT apn, vm_tls_side_enum side, callback_t cb); +_vm_tls_new_ctx_t _vm_tls_new_ctx = NULL; + +VMINT vm_tls_new_ctx(vm_tls_version_enum ver, vm_socket_type_enum sock_type, VMINT apn, vm_tls_side_enum side, callback_t cb) +{ + if (NULL == _vm_tls_new_ctx) + _vm_tls_new_ctx = (_vm_tls_new_ctx_t)vm_get_sym_entry("vm_tls_new_ctx"); + + if (NULL != _vm_tls_new_ctx) + return _vm_tls_new_ctx(ver,sock_type, apn, side,cb); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_read.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_read.c new file mode 100644 index 00000000..6d67c384 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_read.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_read_t)(VMINT res_id, void* buf, VMINT32 len); +_vm_tls_read_t _vm_tls_read = NULL; + +VMINT vm_tls_read(VMINT res_id, void* buf, VMINT32 len) +{ + if (NULL == _vm_tls_read) + _vm_tls_read = (_vm_tls_read_t)vm_get_sym_entry("vm_tls_read"); + + if (NULL != _vm_tls_read) + return _vm_tls_read(res_id,buf,len); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_rehandshake.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_rehandshake.c new file mode 100644 index 00000000..e35e4898 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_rehandshake.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_rehandshake_t)(VMINT res_id); +_vm_tls_rehandshake_t _vm_tls_rehandshake = NULL; + +VMINT vm_tls_rehandshake(VMINT res_id) +{ + if (NULL == _vm_tls_rehandshake) + _vm_tls_rehandshake = (_vm_tls_rehandshake_t)vm_get_sym_entry("vm_tls_rehandshake"); + + if (NULL != _vm_tls_rehandshake) + return _vm_tls_rehandshake(res_id); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_ciphers.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_ciphers.c new file mode 100644 index 00000000..26b36555 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_ciphers.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_set_ciphers_t)(VMINT res_id, const vm_tls_cipher_enum ciphers[], VMINT num); +_vm_tls_set_ciphers_t _vm_tls_set_ciphers = NULL; + +VMINT vm_tls_set_ciphers(VMINT res_id, const vm_tls_cipher_enum ciphers[], VMINT num) +{ + if (NULL == _vm_tls_set_ciphers) + _vm_tls_set_ciphers = (_vm_tls_set_ciphers_t)vm_get_sym_entry("vm_tls_set_ciphers"); + + if (NULL != _vm_tls_set_ciphers) + return _vm_tls_set_ciphers(res_id,ciphers,num); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_client_auth.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_client_auth.c new file mode 100644 index 00000000..9b040473 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_client_auth.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_set_client_auth_t)(VMINT res_id, vm_tls_auth_mode_enum modes[], VMINT num); +_vm_tls_set_client_auth_t _vm_tls_set_client_auth = NULL; + +VMINT vm_tls_set_client_auth(VMINT res_id, vm_tls_auth_mode_enum modes[], VMINT num) +{ + if (NULL == _vm_tls_set_client_auth) + _vm_tls_set_client_auth = (_vm_tls_set_client_auth_t)vm_get_sym_entry("vm_tls_set_client_auth"); + + if (NULL != _vm_tls_set_client_auth) + return _vm_tls_set_client_auth(res_id,modes,num); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_identity.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_identity.c new file mode 100644 index 00000000..0b463e95 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_identity.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_set_identity_t)(VMINT res_id, VMUINT32 cert_id); +_vm_tls_set_identity_t _vm_tls_set_identity = NULL; + +VMINT vm_tls_set_identity(VMINT res_id, VMUINT32 cert_id) +{ + if (NULL == _vm_tls_set_identity) + _vm_tls_set_identity = (_vm_tls_set_identity_t)vm_get_sym_entry("vm_tls_set_identity"); + + if (NULL != _vm_tls_set_identity) + return _vm_tls_set_identity(res_id,cert_id); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_null_client_auth.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_null_client_auth.c new file mode 100644 index 00000000..cb3a8bea --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_null_client_auth.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_set_null_client_auth_t)(VMINT res_id); +_vm_tls_set_null_client_auth_t _vm_tls_set_null_client_auth = NULL; + +VMINT vm_tls_set_null_client_auth(VMINT res_id) +{ + if (NULL == _vm_tls_set_null_client_auth) + _vm_tls_set_null_client_auth = (_vm_tls_set_null_client_auth_t)vm_get_sym_entry("vm_tls_set_null_client_auth"); + + if (NULL != _vm_tls_set_null_client_auth) + return _vm_tls_set_null_client_auth(res_id); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_verify.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_verify.c new file mode 100644 index 00000000..b49453b8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_set_verify.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_set_verify_t)(VMINT res_id, VMUINT32 cert_id[], VMINT cert_num, vm_tls_filetype_enum type); +_vm_tls_set_verify_t _vm_tls_set_verify = NULL; + +VMINT vm_tls_set_verify(VMINT res_id, VMUINT32 cert_id[], VMINT cert_num, vm_tls_filetype_enum type) +{ + if (NULL == _vm_tls_set_verify) + _vm_tls_set_verify = (_vm_tls_set_verify_t)vm_get_sym_entry("vm_tls_set_verify"); + + if (NULL != _vm_tls_set_verify) + return _vm_tls_set_verify(res_id,cert_id,cert_num,type); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_shutdown.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_shutdown.c new file mode 100644 index 00000000..585b548f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_shutdown.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_shutdown_t)(VMINT res_id); +_vm_tls_shutdown_t _vm_tls_shutdown = NULL; + +VMINT vm_tls_shutdown(VMINT res_id) +{ + if (NULL == _vm_tls_shutdown) + _vm_tls_shutdown = (_vm_tls_shutdown_t)vm_get_sym_entry("vm_tls_shutdown"); + + if (NULL != _vm_tls_shutdown) + return _vm_tls_shutdown(res_id); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_soc_connect.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_soc_connect.c new file mode 100644 index 00000000..c18b6d25 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_soc_connect.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + + +typedef VMINT (*_vm_tls_soc_connect_t)(VMINT res_id, vm_sockaddr_ex_struct * faddr); +_vm_tls_soc_connect_t _vm_tls_soc_connect = NULL; +VMINT vm_tls_soc_connect(VMINT res_id, vm_sockaddr_ex_struct * faddr) +{ + if (NULL == _vm_tls_soc_connect) + _vm_tls_soc_connect = (_vm_tls_soc_connect_t)vm_get_sym_entry("vm_tls_soc_connect"); + + if (NULL != _vm_tls_soc_connect) + return _vm_tls_soc_connect(res_id,faddr); + + return (VMINT)-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_write.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_write.c new file mode 100644 index 00000000..570a4e73 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tls_write.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtls.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_tls_write_t)(VMINT res_id, const void* buf, VMINT32 len); +_vm_tls_write_t _vm_tls_write = NULL; + +VMINT vm_tls_write(VMINT res_id, const void* buf, VMINT32 len) +{ + if (NULL == _vm_tls_write) + _vm_tls_write = (_vm_tls_write_t)vm_get_sym_entry("vm_tls_write"); + + if (NULL != _vm_tls_write) + return _vm_tls_write(res_id,buf,len); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tmp_filename.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tmp_filename.c new file mode 100644 index 00000000..fc70ef48 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_tmp_filename.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_tmp_filename_t)(char* prefix, char* filename); +_vm_tmp_filename_t _vm_tmp_filename = NULL; + +void vm_tmp_filename(char* prefix, char* filename) +{ + if (NULL == _vm_tmp_filename) + _vm_tmp_filename = (_vm_tmp_filename_t)vm_get_sym_entry("vm_tmp_filename"); + + if (NULL != _vm_tmp_filename) + _vm_tmp_filename(prefix,filename); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ts_driver_free.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ts_driver_free.c new file mode 100644 index 00000000..cddbc113 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ts_driver_free.c @@ -0,0 +1,16 @@ +#include "vmsys.h" +#include "vmtsloader.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_ts_driver_free_t)(VMINT handle); +_vm_ts_driver_free_t _vm_ts_driver_free = NULL; +void vm_ts_driver_free(VMINT handle) +{ + if (NULL == _vm_ts_driver_free) + _vm_ts_driver_free = (_vm_ts_driver_free_t)vm_get_sym_entry("vm_ts_driver_free"); + + if (NULL != _vm_ts_driver_free) + _vm_ts_driver_free(handle); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ts_driver_get_handle.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ts_driver_get_handle.c new file mode 100644 index 00000000..f3121d0e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ts_driver_get_handle.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtsloader.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ts_driver_get_handle_t)(void); +_vm_ts_driver_get_handle_t _vm_ts_driver_get_handle = NULL; +VMINT vm_ts_driver_get_handle(void) +{ + if (NULL == _vm_ts_driver_get_handle) + _vm_ts_driver_get_handle = (_vm_ts_driver_get_handle_t)vm_get_sym_entry("vm_ts_driver_get_handle"); + + if (NULL != _vm_ts_driver_get_handle) + return _vm_ts_driver_get_handle(); + + return -1; +} + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ts_driver_get_mem.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ts_driver_get_mem.c new file mode 100644 index 00000000..a3f497a1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ts_driver_get_mem.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmtsloader.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void* (*_vm_ts_driver_get_mem_t)(VMINT handle); +_vm_ts_driver_get_mem_t _vm_ts_driver_get_mem = NULL; +void* vm_ts_driver_get_mem(VMINT handle) +{ + if (NULL == _vm_ts_driver_get_mem) + _vm_ts_driver_get_mem = (_vm_ts_driver_get_mem_t)vm_get_sym_entry("vm_ts_driver_get_mem"); + + if (NULL != _vm_ts_driver_get_mem) + return _vm_ts_driver_get_mem(handle); + + return (void*)NULL; +} + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ts_driver_load.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ts_driver_load.c new file mode 100644 index 00000000..0765b6cd --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ts_driver_load.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmtsloader.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + + +typedef VMINT (*_vm_ts_driver_load_t)(VMWSTR fileName, VMINT size); +_vm_ts_driver_load_t _vm_ts_driver_load = NULL; +VMINT vm_ts_driver_load(VMWSTR fileName, VMINT size) +{ + if (NULL == _vm_ts_driver_load) + _vm_ts_driver_load = (_vm_ts_driver_load_t)vm_get_sym_entry("vm_ts_driver_load"); + + if (NULL != _vm_ts_driver_load) + return _vm_ts_driver_load(fileName, size); + + return (VMINT )-1; +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ucs2_string_by_ascii.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ucs2_string_by_ascii.c new file mode 100644 index 00000000..396d6b0d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ucs2_string_by_ascii.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmchset.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMWSTR (*_vm_ucs2_string_by_ascii_t)(VMSTR s); +_vm_ucs2_string_by_ascii_t _vm_ucs2_string_by_ascii = NULL; + +VMWSTR vm_ucs2_string_by_ascii(VMSTR s) +{ + if (NULL == _vm_ucs2_string_by_ascii) + _vm_ucs2_string_by_ascii = (_vm_ucs2_string_by_ascii_t)vm_get_sym_entry("vm_ucs2_string_by_ascii"); + + if (NULL != _vm_ucs2_string_by_ascii) + return _vm_ucs2_string_by_ascii(s); + + return (VMWSTR )NULL; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ucs2_to_ascii.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ucs2_to_ascii.c new file mode 100644 index 00000000..64a94a31 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ucs2_to_ascii.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmchset.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ucs2_to_ascii_t)(VMSTR dst, VMINT size, VMWSTR src); +_vm_ucs2_to_ascii_t _vm_ucs2_to_ascii = NULL; + +VMINT vm_ucs2_to_ascii(VMSTR dst, VMINT size, VMWSTR src) +{ + if (NULL == _vm_ucs2_to_ascii) + _vm_ucs2_to_ascii = (_vm_ucs2_to_ascii_t)vm_get_sym_entry("vm_ucs2_to_ascii"); + + if (NULL != _vm_ucs2_to_ascii) + return _vm_ucs2_to_ascii(dst,size,src); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ucs2_to_gb2312.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ucs2_to_gb2312.c new file mode 100644 index 00000000..829a7214 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ucs2_to_gb2312.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmchset.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_ucs2_to_gb2312_t)(VMSTR dst, VMINT size, VMWSTR src); +_vm_ucs2_to_gb2312_t _vm_ucs2_to_gb2312 = NULL; + +VMINT vm_ucs2_to_gb2312(VMSTR dst, VMINT size, VMWSTR src) +{ + if (NULL == _vm_ucs2_to_gb2312) + _vm_ucs2_to_gb2312 = (_vm_ucs2_to_gb2312_t)vm_get_sym_entry("vm_ucs2_to_gb2312"); + + if (NULL != _vm_ucs2_to_gb2312) + return _vm_ucs2_to_gb2312(dst,size,src); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_udp_close.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_udp_close.c new file mode 100644 index 00000000..9dfaeaf7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_udp_close.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_udp_close_t)(VMINT hdl); +_vm_udp_close_t _vm_udp_close = NULL; + +VMINT vm_udp_close(VMINT hdl) +{ + if (NULL == _vm_udp_close) + _vm_udp_close = (_vm_udp_close_t)vm_get_sym_entry("vm_udp_close"); + + if (NULL != _vm_udp_close) + return _vm_udp_close(hdl); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_udp_create.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_udp_create.c new file mode 100644 index 00000000..5fbc2c32 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_udp_create.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_udp_create_t)(VMINT port, VMINT apn, void (*callback)(VMINT hdl, VMINT event), VMINT loopback); +_vm_udp_create_t _vm_udp_create = NULL; + +VMINT vm_udp_create(VMINT port, VMINT apn, void (*callback)(VMINT hdl, VMINT event), VMINT loopback) +{ + if (NULL == _vm_udp_create) + _vm_udp_create = (_vm_udp_create_t)vm_get_sym_entry("vm_udp_create"); + + if (NULL != _vm_udp_create) + return _vm_udp_create(port, apn, callback, loopback); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_udp_recvfrom.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_udp_recvfrom.c new file mode 100644 index 00000000..9d26509f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_udp_recvfrom.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_udp_recvfrom_t)(VMINT hdl, void * buf, VMINT32 len, vm_sockaddr_struct * addr); +_vm_udp_recvfrom_t _vm_udp_recvfrom = NULL; + +VMINT vm_udp_recvfrom(VMINT hdl, void * buf, VMINT32 len, vm_sockaddr_struct * addr) +{ + if (NULL == _vm_udp_recvfrom) + _vm_udp_recvfrom = (_vm_udp_recvfrom_t)vm_get_sym_entry("vm_udp_recvfrom"); + + if (NULL != _vm_udp_recvfrom) + return _vm_udp_recvfrom(hdl, buf, len, addr); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_udp_sendto.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_udp_sendto.c new file mode 100644 index 00000000..3b433741 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_udp_sendto.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_udp_sendto_t)(VMINT hdl, const void * buf, VMINT32 len, const vm_sockaddr_struct * addr); +_vm_udp_sendto_t _vm_udp_sendto = NULL; + +VMINT vm_udp_sendto(VMINT hdl, const void * buf, VMINT32 len, const vm_sockaddr_struct * addr) +{ + if (NULL == _vm_udp_sendto) + _vm_udp_sendto = (_vm_udp_sendto_t)vm_get_sym_entry("vm_udp_sendto"); + + if (NULL != _vm_udp_sendto) + return _vm_udp_sendto(hdl, buf, len, addr); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_cancel.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_cancel.c new file mode 100644 index 00000000..359d778e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_cancel.c @@ -0,0 +1,18 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT(*_vm_update_cancel_t)(VMINT handle); +_vm_update_cancel_t _vm_update_cancel = NULL; + +VMINT vm_update_cancel(VMINT handle) +{ + if (_vm_update_cancel == NULL) { + _vm_update_cancel = (_vm_update_cancel_t)vm_get_sym_entry("vm_update_cancel"); + } + if (_vm_update_cancel != NULL) { + return _vm_update_cancel(handle); + } + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_check_launch.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_check_launch.c new file mode 100644 index 00000000..eafe5832 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_check_launch.c @@ -0,0 +1,18 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT(*_vm_update_check_launch_t)(VMWSTR path, VMWSTR new_path); +_vm_update_check_launch_t _vm_update_check_launch = NULL; + +VMINT vm_update_check_launch(VMWSTR path, VMWSTR new_path) +{ + if (_vm_update_check_launch == NULL) { + _vm_update_check_launch = (_vm_update_check_launch_t)vm_get_sym_entry("vm_update_check_launch"); + } + if (_vm_update_check_launch != NULL) { + return _vm_update_check_launch(path, new_path); + } + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_check_version.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_check_version.c new file mode 100644 index 00000000..ab239b22 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_check_version.c @@ -0,0 +1,18 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT(*_vm_update_check_version_t)(VMSTR URL, VMINT port, VMINT apn, vm_update_app_callback callback, void* user_data); +_vm_update_check_version_t _vm_update_check_version = NULL; + +VMINT vm_update_check_version(VMSTR URL, VMINT port, VMINT apn, vm_update_app_callback callback, void* user_data) +{ + if (_vm_update_check_version == NULL) { + _vm_update_check_version = (_vm_update_check_version_t)vm_get_sym_entry("vm_update_check_version"); + } + if (_vm_update_check_version != NULL) { + return _vm_update_check_version(URL, port, apn, callback, user_data); + } + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_download.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_download.c new file mode 100644 index 00000000..f2051fc8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_download.c @@ -0,0 +1,18 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT(*_vm_update_download_t)(VMINT handle, VMINT bOnCard, vm_update_app_callback callback, void* user_data); +_vm_update_download_t _vm_update_download = NULL; + +VMINT vm_update_download(VMINT handle, VMINT bOnCard, vm_update_app_callback callback, void* user_data) +{ + if (_vm_update_download == NULL) { + _vm_update_download = (_vm_update_download_t)vm_get_sym_entry("vm_update_download"); + } + if (_vm_update_download != NULL) { + return _vm_update_download(handle, bOnCard, callback, user_data); + } + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_update_file.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_update_file.c new file mode 100644 index 00000000..b8c4eb49 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_update_update_file.c @@ -0,0 +1,18 @@ +#include "vmsys.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT(*_vm_update_update_file_t)(void); +_vm_update_update_file_t _vm_update_update_file = NULL; + +VMINT vm_update_update_file(void) +{ + if (_vm_update_update_file == NULL) { + _vm_update_update_file = (_vm_update_update_file_t)vm_get_sym_entry("vm_update_update_file"); + } + if (_vm_update_update_file != NULL) { + return _vm_update_update_file(); + } + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_upnp_get_ext_ip.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_upnp_get_ext_ip.c new file mode 100644 index 00000000..25278712 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_upnp_get_ext_ip.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnat.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_upnp_get_ext_ip_t)(VMUINT8 request_id, vm_upnp_result_cb cb, void *user_data); +_vm_upnp_get_ext_ip_t _vm_upnp_get_ext_ip = NULL; + +VMINT vm_upnp_get_ext_ip(VMUINT8 request_id, vm_upnp_result_cb cb, void *user_data) +{ + if (NULL == _vm_upnp_get_ext_ip) + _vm_upnp_get_ext_ip = (_vm_upnp_get_ext_ip_t)vm_get_sym_entry("vm_upnp_get_ext_ip"); + if (NULL != _vm_upnp_get_ext_ip) + return _vm_upnp_get_ext_ip(request_id,cb,user_data); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_upnp_mapping_ports.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_upnp_mapping_ports.c new file mode 100644 index 00000000..eca81a61 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_upnp_mapping_ports.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnat.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_upnp_mapping_ports_t)(VMUINT8 request_id, vm_upnp_result_cb cb, vm_upnp_map_info* request_data, void* user_data); +_vm_upnp_mapping_ports_t _vm_upnp_mapping_ports = NULL; + +VMINT vm_upnp_mapping_ports(VMUINT8 request_id, vm_upnp_result_cb cb, vm_upnp_map_info* request_data, void* user_data) +{ + if (NULL == _vm_upnp_mapping_ports) + _vm_upnp_mapping_ports = (_vm_upnp_mapping_ports_t)vm_get_sym_entry("vm_upnp_mapping_ports"); + if (NULL != _vm_upnp_mapping_ports) + return _vm_upnp_mapping_ports(request_id,cb,request_data,user_data); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_upper_case.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_upper_case.c new file mode 100644 index 00000000..7ff97225 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_upper_case.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_upper_case_t)(char* dst, char* src); +_vm_upper_case_t _vm_upper_case = NULL; + +void vm_upper_case(char* dst, char* src) +{ + if (NULL == _vm_upper_case) + _vm_upper_case = (_vm_upper_case_t)vm_get_sym_entry("vm_upper_case"); + + if (NULL != _vm_upper_case) + _vm_upper_case(dst,src); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_uriagent_uri_request.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_uriagent_uri_request.c new file mode 100644 index 00000000..31939c02 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_uriagent_uri_request.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmio.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_uriagent_uri_request_t)(const VMCHAR * str, VMINT confirm); +_vm_uriagent_uri_request_t _vm_uriagent_uri_request = NULL; + +VMINT vm_uriagent_uri_request(const VMCHAR * str, VMINT confirm) +{ + if (NULL == _vm_uriagent_uri_request) + _vm_uriagent_uri_request = (_vm_uriagent_uri_request_t)vm_get_sym_entry("vm_uriagent_uri_request"); + + if (NULL != _vm_uriagent_uri_request) + return _vm_uriagent_uri_request(str,confirm); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_url_decode_gb2312.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_url_decode_gb2312.c new file mode 100644 index 00000000..f756841b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_url_decode_gb2312.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_url_decode_gb2312_t)(VMSTR dst, VMUINT size, VMSTR src); +_vm_url_decode_gb2312_t _vm_url_decode_gb2312 = NULL; + +VMUINT vm_url_decode_gb2312(VMSTR dst, VMUINT size, VMSTR src) { + if (_vm_url_decode_gb2312 == NULL) + _vm_url_decode_gb2312 = (_vm_url_decode_gb2312_t)vm_get_sym_entry("vm_url_decode_gb2312"); + + if (_vm_url_decode_gb2312 != NULL) + return _vm_url_decode_gb2312(dst, size, src); + + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_url_encode_gb2312.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_url_encode_gb2312.c new file mode 100644 index 00000000..0a6c33ee --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_url_encode_gb2312.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT (*_vm_url_encode_gb2312_t)(VMSTR dst, VMUINT size, const VMSTR src); +_vm_url_encode_gb2312_t _vm_url_encode_gb2312 = NULL; + +VMUINT vm_url_encode_gb2312(VMSTR dst, VMUINT size, const VMSTR src) { + if (_vm_url_encode_gb2312 == NULL) + _vm_url_encode_gb2312 = (_vm_url_encode_gb2312_t)vm_get_sym_entry("vm_url_encode_gb2312"); + + if (_vm_url_encode_gb2312 != NULL) + return _vm_url_encode_gb2312(dst, size, src); + + return 0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_usb_get_cable_status.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_usb_get_cable_status.c new file mode 100644 index 00000000..c1c936f7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_usb_get_cable_status.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmusb.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_usb_get_cable_status_t)(); +_vm_usb_get_cable_status_t _vm_usb_get_cable_status = NULL; + +VMINT vm_usb_get_cable_status() +{ + if (NULL == _vm_usb_get_cable_status) + _vm_usb_get_cable_status = (_vm_usb_get_cable_status_t)vm_get_sym_entry("vm_usb_get_cable_status"); + + if (NULL != _vm_usb_get_cable_status) + return _vm_usb_get_cable_status(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ust_get_current_time.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ust_get_current_time.c new file mode 100644 index 00000000..4c9899f4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ust_get_current_time.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT32 (*_vm_ust_get_current_time_t)(void); +_vm_ust_get_current_time_t _vm_ust_get_current_time = NULL; +VMUINT32 vm_ust_get_current_time(void) +{ + if (_vm_ust_get_current_time == NULL) + _vm_ust_get_current_time = (_vm_ust_get_current_time_t)vm_get_sym_entry("vm_ust_get_current_time"); + + if (_vm_ust_get_current_time != NULL) + return _vm_ust_get_current_time(); + + return -1; + +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ust_get_duration.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ust_get_duration.c new file mode 100644 index 00000000..5df9d5f4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_ust_get_duration.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT32 (*_vm_ust_get_duration_t)(VMUINT32 start,VMUINT32 end); +_vm_ust_get_duration_t _vm_ust_get_duration = NULL; +VMUINT32 vm_ust_get_duration(VMUINT32 start,VMUINT32 end) +{ + if (_vm_ust_get_duration == NULL) + _vm_ust_get_duration = (_vm_ust_get_duration_t)vm_get_sym_entry("vm_ust_get_duration"); + + if (_vm_ust_get_duration != NULL) + return _vm_ust_get_duration(start,end); + + return -1; + +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_get_level.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_get_level.c new file mode 100644 index 00000000..cfdd6251 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_get_level.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvad.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMUINT8 (*_vm_vad_get_level_t)(void); +_vm_vad_get_level_t _vm_vad_get_level = NULL; + +VMUINT8 vm_vad_get_level(void) +{ + if (NULL == _vm_vad_get_level) + _vm_vad_get_level = (_vm_vad_get_level_t)vm_get_sym_entry("vm_vad_get_level"); + + if (NULL != _vm_vad_get_level) + return _vm_vad_get_level(); + + return (VMUINT8)0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_is_on.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_is_on.c new file mode 100644 index 00000000..7a41513a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_is_on.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvad.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMBOOL (*_vm_vad_is_on_t)(void); +_vm_vad_is_on_t _vm_vad_is_on = NULL; + +VMBOOL vm_vad_is_on(void) +{ + if (NULL == _vm_vad_is_on) + _vm_vad_is_on = (_vm_vad_is_on_t)vm_get_sym_entry("vm_vad_is_on"); + + if (NULL != _vm_vad_is_on) + return _vm_vad_is_on(); + + return (VMBOOL)0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_register_callback.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_register_callback.c new file mode 100644 index 00000000..a28a21be --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_register_callback.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmvad.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_vad_register_callback_t)(vm_vad_msg_hdlr callback); +_vm_vad_register_callback_t _vm_vad_register_callback = NULL; + +void vm_vad_register_callback(vm_vad_msg_hdlr callback) +{ + if (NULL == _vm_vad_register_callback) + _vm_vad_register_callback = (_vm_vad_register_callback_t)vm_get_sym_entry("vm_vad_register_callback"); + + if (NULL != _vm_vad_register_callback) + _vm_vad_register_callback(callback); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_set_level.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_set_level.c new file mode 100644 index 00000000..711d3ef3 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_set_level.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvad.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMBOOL (*_vm_vad_set_level_t)(VMUINT8 level); +_vm_vad_set_level_t _vm_vad_set_level = NULL; + +VMBOOL vm_vad_set_level(VMUINT8 level) +{ + if (NULL == _vm_vad_set_level) + _vm_vad_set_level = (_vm_vad_set_level_t)vm_get_sym_entry("vm_vad_set_level"); + + if (NULL != _vm_vad_set_level) + return _vm_vad_set_level(level); + + return (VMBOOL)0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_switch_on_off.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_switch_on_off.c new file mode 100644 index 00000000..596645a1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vad_switch_on_off.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmvad.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMBOOL (*_vm_vad_switch_on_off_t)(VMBOOL on, void* param); +_vm_vad_switch_on_off_t _vm_vad_switch_on_off = NULL; + +VMBOOL vm_vad_switch_on_off(VMBOOL on, void* param) +{ + if (NULL == _vm_vad_switch_on_off) + _vm_vad_switch_on_off = (_vm_vad_switch_on_off_t)vm_get_sym_entry("vm_vad_switch_on_off"); + + if (NULL != _vm_vad_switch_on_off) + return _vm_vad_switch_on_off(on,param); + + return (VMBOOL)0; +} + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_pause.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_pause.c new file mode 100644 index 00000000..f40b209e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_pause.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvdorec.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_vdorec_pause_t)(void); +_vm_vdorec_pause_t _vm_vdorec_pause = NULL; + +VMINT vm_vdorec_pause(void) +{ + if (NULL == _vm_vdorec_pause) + _vm_vdorec_pause = (_vm_vdorec_pause_t)vm_get_sym_entry("vm_vdorec_pause"); + + if (NULL != _vm_vdorec_pause) + return _vm_vdorec_pause(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_power_down.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_power_down.c new file mode 100644 index 00000000..f22d4a19 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_power_down.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvdorec.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_vdorec_power_down_t)(void); +_vm_vdorec_power_down_t _vm_vdorec_power_down = NULL; + +VMINT vm_vdorec_power_down(void) +{ + if (NULL == _vm_vdorec_power_down) + _vm_vdorec_power_down = (_vm_vdorec_power_down_t)vm_get_sym_entry("vm_vdorec_power_down"); + + if (NULL != _vm_vdorec_power_down) + return _vm_vdorec_power_down(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_power_up.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_power_up.c new file mode 100644 index 00000000..a2362b69 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_power_up.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvdorec.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_vdorec_power_up_t)(VMUINT16 camere_id, vm_vdorec_callback callback); +_vm_vdorec_power_up_t _vm_vdorec_power_up = NULL; + +VMINT vm_vdorec_power_up(VMUINT16 camere_id, vm_vdorec_callback callback) +{ + if (NULL == _vm_vdorec_power_up) + _vm_vdorec_power_up = (_vm_vdorec_power_up_t)vm_get_sym_entry("vm_vdorec_power_up"); + + if (NULL != _vm_vdorec_power_up) + return _vm_vdorec_power_up(camere_id, callback); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_preview.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_preview.c new file mode 100644 index 00000000..a7c25aba --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_preview.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvdorec.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_vdorec_preview_t)(vm_vdorec_preview_struct* para); +_vm_vdorec_preview_t _vm_vdorec_preview = NULL; + +VMINT vm_vdorec_preview(vm_vdorec_preview_struct* para) +{ + if (NULL == _vm_vdorec_preview) + _vm_vdorec_preview = (_vm_vdorec_preview_t)vm_get_sym_entry("vm_vdorec_preview"); + + if (NULL != _vm_vdorec_preview) + return _vm_vdorec_preview(para); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_record.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_record.c new file mode 100644 index 00000000..d9d9757f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_record.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvdorec.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_vdorec_record_t)(vm_vdorec_record_struct* para); +_vm_vdorec_record_t _vm_vdorec_record = NULL; + +VMINT vm_vdorec_record(vm_vdorec_record_struct* para) +{ + if (NULL == _vm_vdorec_record) + _vm_vdorec_record = (_vm_vdorec_record_t)vm_get_sym_entry("vm_vdorec_record"); + + if (NULL != _vm_vdorec_record) + return _vm_vdorec_record(para); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_resume.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_resume.c new file mode 100644 index 00000000..c564d920 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_resume.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvdorec.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_vdorec_resume_t)(void); +_vm_vdorec_resume_t _vm_vdorec_resume = NULL; + +VMINT vm_vdorec_resume(void) +{ + if (NULL == _vm_vdorec_resume) + _vm_vdorec_resume = (_vm_vdorec_resume_t)vm_get_sym_entry("vm_vdorec_resume"); + + if (NULL != _vm_vdorec_resume) + return _vm_vdorec_resume(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_rtsp_local_save_start.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_rtsp_local_save_start.c new file mode 100644 index 00000000..43802606 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_rtsp_local_save_start.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmvdorec.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_vdorec_rtsp_local_save_start_t)(VMWSTR filepath, vm_vdorec_callback callback); +_vm_vdorec_rtsp_local_save_start_t _vm_vdorec_rtsp_local_save_start = NULL; + +VMINT vm_vdorec_rtsp_local_save_start(VMWSTR filepath, vm_vdorec_callback callback) +{ + if (NULL == _vm_vdorec_rtsp_local_save_start) + _vm_vdorec_rtsp_local_save_start = (_vm_vdorec_rtsp_local_save_start_t)vm_get_sym_entry("vm_vdorec_rtsp_local_save_start"); + + if (NULL != _vm_vdorec_rtsp_local_save_start) + return _vm_vdorec_rtsp_local_save_start(filepath,callback); + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_rtsp_local_save_stop.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_rtsp_local_save_stop.c new file mode 100644 index 00000000..6727e0af --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_rtsp_local_save_stop.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvdorec.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_vdorec_rtsp_local_save_stop_t)(void); +_vm_vdorec_rtsp_local_save_stop_t _vm_vdorec_rtsp_local_save_stop = NULL; + +VMINT vm_vdorec_rtsp_local_save_stop(void) +{ + if (NULL == _vm_vdorec_rtsp_local_save_stop) + _vm_vdorec_rtsp_local_save_stop = (_vm_vdorec_rtsp_local_save_stop_t)vm_get_sym_entry("vm_vdorec_rtsp_local_save_stop"); + + if (NULL != _vm_vdorec_rtsp_local_save_stop) + return _vm_vdorec_rtsp_local_save_stop(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_save_to_file.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_save_to_file.c new file mode 100644 index 00000000..fd09413e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_save_to_file.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmvdorec.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_vdorec_save_to_file_t)(VMWSTR filepath, vm_vdorec_callback callback); +_vm_vdorec_save_to_file_t _vm_vdorec_save_to_file = NULL; + +void vm_vdorec_save_to_file(VMWSTR filepath, vm_vdorec_callback callback) +{ + if (NULL == _vm_vdorec_save_to_file) + _vm_vdorec_save_to_file = (_vm_vdorec_save_to_file_t)vm_get_sym_entry("vm_vdorec_save_to_file"); + + if (NULL != _vm_vdorec_save_to_file) + _vm_vdorec_save_to_file(filepath,callback); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_set_param.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_set_param.c new file mode 100644 index 00000000..5d4d1cf8 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_set_param.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvdorec.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_vdorec_set_param_t)(VMUINT32 param_id, VMUINT16 value); +_vm_vdorec_set_param_t _vm_vdorec_set_param = NULL; + +VMINT vm_vdorec_set_param(VMUINT32 param_id, VMUINT16 value) +{ + if (NULL == _vm_vdorec_set_param) + _vm_vdorec_set_param = (_vm_vdorec_set_param_t)vm_get_sym_entry("vm_vdorec_set_param"); + + if (NULL != _vm_vdorec_set_param) + return _vm_vdorec_set_param(param_id, value); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_stop.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_stop.c new file mode 100644 index 00000000..127e0092 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vdorec_stop.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvdorec.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_vdorec_stop_t)(void); +_vm_vdorec_stop_t _vm_vdorec_stop = NULL; + +VMINT vm_vdorec_stop(void) +{ + if (NULL == _vm_vdorec_stop) + _vm_vdorec_stop = (_vm_vdorec_stop_t)vm_get_sym_entry("vm_vdorec_stop"); + + if (NULL != _vm_vdorec_stop) + return _vm_vdorec_stop(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vibrator_off.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vibrator_off.c new file mode 100644 index 00000000..a9df16ef --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vibrator_off.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_vibrator_off_t)(void); +_vm_vibrator_off_t _vm_vibrator_off = NULL; + +void vm_vibrator_off(void) +{ + if (NULL == _vm_vibrator_off) + _vm_vibrator_off = (_vm_vibrator_off_t)vm_get_sym_entry("vm_vibrator_off"); + + if (NULL != _vm_vibrator_off) + _vm_vibrator_off(); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vibrator_on.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vibrator_on.c new file mode 100644 index 00000000..dc23f733 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vibrator_on.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_vibrator_on_t)(void); +_vm_vibrator_on_t _vm_vibrator_on = NULL; + +void vm_vibrator_on(void) +{ + if (NULL == _vm_vibrator_on) + _vm_vibrator_on = (_vm_vibrator_on_t)vm_get_sym_entry("vm_vibrator_on"); + + if (NULL != _vm_vibrator_on) + _vm_vibrator_on(); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vibrator_once.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vibrator_once.c new file mode 100644 index 00000000..4d5db696 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vibrator_once.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmmm.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_vibrator_once_t)(void); +_vm_vibrator_once_t _vm_vibrator_once = NULL; + +void vm_vibrator_once(void) +{ + if (NULL == _vm_vibrator_once) + _vm_vibrator_once = (_vm_vibrator_once_t)vm_get_sym_entry("vm_vibrator_once"); + + if (NULL != _vm_vibrator_once) + _vm_vibrator_once(); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_close_buffer.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_close_buffer.c new file mode 100644 index 00000000..8d9b4c88 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_close_buffer.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_close_buffer_t)(void); +_vm_video_close_buffer_t _vm_video_close_buffer = NULL; + +VMINT vm_video_close_buffer(void) +{ + if (NULL == _vm_video_close_buffer) + _vm_video_close_buffer = (_vm_video_close_buffer_t)vm_get_sym_entry("vm_video_close_buffer"); + + if (NULL != _vm_video_close_buffer) + return _vm_video_close_buffer(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_close_file.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_close_file.c new file mode 100644 index 00000000..43f49170 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_close_file.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_close_file_t)(void); +_vm_video_close_file_t _vm_video_close_file = NULL; + +VMINT vm_video_close_file(void) +{ + if (NULL == _vm_video_close_file) + _vm_video_close_file = (_vm_video_close_file_t)vm_get_sym_entry("vm_video_close_file"); + + if (NULL != _vm_video_close_file) + return _vm_video_close_file(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_get_cur_play_time.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_get_cur_play_time.c new file mode 100644 index 00000000..fabd26fa --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_get_cur_play_time.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_get_cur_play_time_t)(VMUINT64 *cur_play_time); +_vm_video_get_cur_play_time_t _vm_video_get_cur_play_time = NULL; + +VMINT vm_video_get_cur_play_time(VMUINT64 *cur_play_time) +{ + if (NULL == _vm_video_get_cur_play_time) + _vm_video_get_cur_play_time = (_vm_video_get_cur_play_time_t)vm_get_sym_entry("vm_video_get_cur_play_time"); + + if (NULL != _vm_video_get_cur_play_time) + return _vm_video_get_cur_play_time(cur_play_time); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_open_buffer.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_open_buffer.c new file mode 100644 index 00000000..bc7d8300 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_open_buffer.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_open_buffer_t)( const VMUSTR buffer, const VMUINT buffer_len, vm_video_info_struct *info); +_vm_video_open_buffer_t _vm_video_open_buffer = NULL; + +VMINT vm_video_open_buffer( const VMUSTR buffer, const VMUINT buffer_len, vm_video_info_struct *info) +{ + if (NULL == _vm_video_open_buffer) + _vm_video_open_buffer = (_vm_video_open_buffer_t)vm_get_sym_entry("vm_video_open_buffer"); + + if (NULL != _vm_video_open_buffer) + return _vm_video_open_buffer(buffer,buffer_len,info); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_open_file.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_open_file.c new file mode 100644 index 00000000..d6ab5043 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_open_file.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_open_file_t)( const VMWSTR filename, vm_video_open_result_callback open_result_callback); +_vm_video_open_file_t _vm_video_open_file = NULL; + +VMINT vm_video_open_file( const VMWSTR filename, vm_video_open_result_callback open_result_callback) +{ + if (NULL == _vm_video_open_file) + _vm_video_open_file = (_vm_video_open_file_t)vm_get_sym_entry("vm_video_open_file"); + + if (NULL != _vm_video_open_file) + return _vm_video_open_file(filename,open_result_callback); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_pause.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_pause.c new file mode 100644 index 00000000..b090ca1d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_pause.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_pause_t)(void); +_vm_video_pause_t _vm_video_pause = NULL; + +VMINT vm_video_pause(void) +{ + if (NULL == _vm_video_pause) + _vm_video_pause = (_vm_video_pause_t)vm_get_sym_entry("vm_video_pause"); + + if (NULL != _vm_video_pause) + return _vm_video_pause(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_play.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_play.c new file mode 100644 index 00000000..63644dfa --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_play.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_play_t)( VMUINT player_layer_handle, VMUINT base_layer_handle, VMUINT16 repeat_count, VMINT is_play_audio, VMINT audio_path, vm_video_finish_callback play_finish_callback); +_vm_video_play_t _vm_video_play = NULL; + +VMINT vm_video_play( VMUINT player_layer_handle, VMUINT base_layer_handle, VMUINT16 repeat_count, VMINT is_play_audio, VMINT audio_path, vm_video_finish_callback play_finish_callback) +{ + if (NULL == _vm_video_play) + _vm_video_play = (_vm_video_play_t)vm_get_sym_entry("vm_video_play"); + + if (NULL != _vm_video_play) + return _vm_video_play(player_layer_handle,base_layer_handle,repeat_count,is_play_audio,audio_path,play_finish_callback); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_play_by_filepath.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_play_by_filepath.c new file mode 100644 index 00000000..a68d8cb2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_play_by_filepath.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_play_by_filepath_t)(VMWSTR filename); +_vm_video_play_by_filepath_t _vm_video_play_by_filepath = NULL; + +VMINT vm_video_play_by_filepath(VMWSTR filename) +{ + if (NULL == _vm_video_play_by_filepath) + _vm_video_play_by_filepath = (_vm_video_play_by_filepath_t)vm_get_sym_entry("vm_video_play_by_filepath"); + + if (NULL != _vm_video_play_by_filepath) + return _vm_video_play_by_filepath(filename); + + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_play_stream_from_rtsp_link.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_play_stream_from_rtsp_link.c new file mode 100644 index 00000000..2493fec6 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_play_stream_from_rtsp_link.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_play_stream_from_rtsp_link_t)(VMWSTR url); +_vm_video_play_stream_from_rtsp_link_t _vm_video_play_stream_from_rtsp_link = NULL; + +VMINT vm_video_play_stream_from_rtsp_link(VMWSTR url) +{ + if (NULL == _vm_video_play_stream_from_rtsp_link) + _vm_video_play_stream_from_rtsp_link = (_vm_video_play_stream_from_rtsp_link_t)vm_get_sym_entry("vm_video_play_stream_from_rtsp_link"); + + if (NULL != _vm_video_play_stream_from_rtsp_link) + return _vm_video_play_stream_from_rtsp_link(url); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_play_stream_from_sdp_file.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_play_stream_from_sdp_file.c new file mode 100644 index 00000000..4a7a5b23 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_play_stream_from_sdp_file.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_play_stream_from_sdp_file_t)(VMWSTR filename, VMUCHAR is_short); +_vm_video_play_stream_from_sdp_file_t _vm_video_play_stream_from_sdp_file = NULL; + +VMINT vm_video_play_stream_from_sdp_file(VMWSTR filename, VMUCHAR is_short) +{ + if (NULL == _vm_video_play_stream_from_sdp_file) + _vm_video_play_stream_from_sdp_file = (_vm_video_play_stream_from_sdp_file_t)vm_get_sym_entry("vm_video_play_stream_from_sdp_file"); + + if (NULL != _vm_video_play_stream_from_sdp_file) + return _vm_video_play_stream_from_sdp_file(filename,is_short); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_resume.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_resume.c new file mode 100644 index 00000000..0b88727b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_resume.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_resume_t)(void); +_vm_video_resume_t _vm_video_resume = NULL; + +VMINT vm_video_resume(void) +{ + if (NULL == _vm_video_resume) + _vm_video_resume = (_vm_video_resume_t)vm_get_sym_entry("vm_video_resume"); + + if (NULL != _vm_video_resume) + return _vm_video_resume(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_seek_and_getframe.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_seek_and_getframe.c new file mode 100644 index 00000000..528d643b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_seek_and_getframe.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_seek_and_getframe_t)(VMUINT64 time, VMUINT player_layer_handle); +_vm_video_seek_and_getframe_t _vm_video_seek_and_getframe = NULL; + +VMINT vm_video_seek_and_getframe(VMUINT64 time, VMUINT player_layer_handle) +{ + if (NULL == _vm_video_seek_and_getframe) + _vm_video_seek_and_getframe = (_vm_video_seek_and_getframe_t)vm_get_sym_entry("vm_video_seek_and_getframe"); + + if (NULL != _vm_video_seek_and_getframe) + return _vm_video_seek_and_getframe(time,player_layer_handle); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_set_brightness.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_set_brightness.c new file mode 100644 index 00000000..4aeaa1aa --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_set_brightness.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_set_brightness_t)(VMUINT16 brightness); +_vm_video_set_brightness_t _vm_video_set_brightness = NULL; + +VMINT vm_video_set_brightness(VMUINT16 brightness) +{ + if (NULL == _vm_video_set_brightness) + _vm_video_set_brightness = (_vm_video_set_brightness_t)vm_get_sym_entry("vm_video_set_brightness"); + + if (NULL != _vm_video_set_brightness) + return _vm_video_set_brightness(brightness); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_set_contrast.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_set_contrast.c new file mode 100644 index 00000000..a2bb4b9d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_set_contrast.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_set_contrast_t)(VMUINT16 contrast); +_vm_video_set_contrast_t _vm_video_set_contrast = NULL; + +VMINT vm_video_set_contrast(VMUINT16 contrast) +{ + if (NULL == _vm_video_set_contrast) + _vm_video_set_contrast = (_vm_video_set_contrast_t)vm_get_sym_entry("vm_video_set_contrast"); + + if (NULL != _vm_video_set_contrast) + return _vm_video_set_contrast(contrast); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_snapshot.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_snapshot.c new file mode 100644 index 00000000..1f3f3fc1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_snapshot.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_snapshot_t)(VMUINT player_layer_handle, VMWSTR file_name); +_vm_video_snapshot_t _vm_video_snapshot = NULL; + +VMINT vm_video_snapshot(VMUINT player_layer_handle, VMWSTR file_name) +{ + if (NULL == _vm_video_snapshot) + _vm_video_snapshot = (_vm_video_snapshot_t)vm_get_sym_entry("vm_video_snapshot"); + + if (NULL != _vm_video_snapshot) + return _vm_video_snapshot(player_layer_handle,file_name); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_stop.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_stop.c new file mode 100644 index 00000000..a6ae2a44 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_video_stop.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmvideo.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_video_stop_t)(void); +_vm_video_stop_t _vm_video_stop = NULL; + +VMINT vm_video_stop(void) +{ + if (NULL == _vm_video_stop) + _vm_video_stop = (_vm_video_stop_t)vm_get_sym_entry("vm_video_stop"); + + if (NULL != _vm_video_stop) + return _vm_video_stop(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vsprintf.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vsprintf.c new file mode 100644 index 00000000..c3adf140 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vsprintf.c @@ -0,0 +1,20 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef int (*_vm_vsprintf_t)(char *buf, const char *fmt, va_list args); +_vm_vsprintf_t _vm_vsprintf = NULL; + +int vm_vsprintf(char *buf, const char *fmt, va_list args) +{ + int ret = {-1}; + if (NULL == _vm_vsprintf) + _vm_vsprintf = (_vm_vsprintf_t)vm_get_sym_entry("vm_vsprintf"); + + if (NULL != _vm_vsprintf) + return _vm_vsprintf(buf,fmt,args); + + return ret; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vwsprintf.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vwsprintf.c new file mode 100644 index 00000000..81486bad --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_vwsprintf.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef int (*_vm_vwsprintf_t)(VMWSTR buf, VMINT size, const VMWSTR fmt, va_list args); +_vm_vwsprintf_t _vm_vwsprintf = NULL; + +VMINT vm_vwsprintf(VMWSTR buf, VMINT size, const VMWSTR fmt, va_list args) +{ + int ret = {-1}; + if (NULL == _vm_vwsprintf) + _vm_vwsprintf = (_vm_vwsprintf_t)vm_get_sym_entry("vm_vwsprintf"); + + if (NULL != _vm_vwsprintf) + { + ret = _vm_vwsprintf(buf, size, fmt, args); + } + + return ret; +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wdt_feed.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wdt_feed.c new file mode 100644 index 00000000..e890724f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wdt_feed.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmwdt.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_wdt_feed_t)(VMINT handle); +_vm_wdt_feed_t _vm_wdt_feed = NULL; + +void vm_wdt_feed(VMINT handle) +{ + if (NULL == _vm_wdt_feed) + _vm_wdt_feed = (_vm_wdt_feed_t)vm_get_sym_entry("vm_wdt_feed"); + + if (NULL != _vm_wdt_feed) + _vm_wdt_feed(handle); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wdt_start.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wdt_start.c new file mode 100644 index 00000000..6678cf28 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wdt_start.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmwdt.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wdt_start_t)(VMUINT tick); +_vm_wdt_start_t _vm_wdt_start = NULL; + +VMINT vm_wdt_start(VMUINT tick) +{ + if (NULL == _vm_wdt_start) + _vm_wdt_start = (_vm_wdt_start_t)vm_get_sym_entry("vm_wdt_start"); + + if (NULL != _vm_wdt_start) + return _vm_wdt_start(tick); + + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wdt_stop.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wdt_stop.c new file mode 100644 index 00000000..188b1ce0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wdt_stop.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmwdt.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_wdt_stop_t)(VMINT handle); +_vm_wdt_stop_t _vm_wdt_stop = NULL; + +void vm_wdt_stop(VMINT handle) +{ + if (NULL == _vm_wdt_stop) + _vm_wdt_stop = (_vm_wdt_stop_t)vm_get_sym_entry("vm_wdt_stop"); + + if (NULL != _vm_wdt_stop) + _vm_wdt_stop(handle); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wends_with.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wends_with.c new file mode 100644 index 00000000..5e9746de --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wends_with.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wends_with_t)(const VMWSTR s1, const VMWSTR s2); +_vm_wends_with_t _vm_wends_with = NULL; + +VMINT vm_wends_with(const VMWSTR s1, const VMWSTR s2) +{ + if (NULL == _vm_wends_with) + _vm_wends_with = (_vm_wends_with_t)vm_get_sym_entry("vm_wends_with"); + + if (NULL != _vm_wends_with) + return _vm_wends_with(s1,s2); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wifi_is_connected.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wifi_is_connected.c new file mode 100644 index 00000000..a6d33562 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wifi_is_connected.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wifi_is_connected_t)(void); +_vm_wifi_is_connected_t _vm_wifi_is_connected = NULL; + +VMINT vm_wifi_is_connected(void) +{ + if (NULL == _vm_wifi_is_connected) + _vm_wifi_is_connected = (_vm_wifi_is_connected_t)vm_get_sym_entry("vm_wifi_is_connected"); + + if (NULL != _vm_wifi_is_connected) + return _vm_wifi_is_connected(); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_connect.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_connect.c new file mode 100644 index 00000000..b8654076 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_connect.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_connect_t)(vm_wlan_ap_info_struct *ap_info, vm_wlan_conn_res_cb_func_ptr callback, void *user_data); +_vm_wlan_connect_t _vm_wlan_connect = NULL; + +VMINT vm_wlan_connect(vm_wlan_ap_info_struct *ap_info, vm_wlan_conn_res_cb_func_ptr callback, void *user_data) +{ + if (NULL == _vm_wlan_connect) + _vm_wlan_connect = (_vm_wlan_connect_t)vm_get_sym_entry("vm_wlan_connect"); + if (NULL != _vm_wlan_connect) + return _vm_wlan_connect(ap_info,callback,user_data); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_dereg_noti.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_dereg_noti.c new file mode 100644 index 00000000..4e6b7d75 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_dereg_noti.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_dereg_noti_t)(VMINT noti_type, vm_wlan_noti_func_ptr callback, void *user_data); +_vm_wlan_dereg_noti_t _vm_wlan_dereg_noti = NULL; + +VMINT vm_wlan_dereg_noti(VMINT noti_type, vm_wlan_noti_func_ptr callback, void *user_data) +{ + if (NULL == _vm_wlan_dereg_noti) + _vm_wlan_dereg_noti = (_vm_wlan_dereg_noti_t)vm_get_sym_entry("vm_wlan_dereg_noti"); + if (NULL != _vm_wlan_dereg_noti) + return _vm_wlan_dereg_noti(noti_type,callback,user_data); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_disconnect.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_disconnect.c new file mode 100644 index 00000000..7fdfec1c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_disconnect.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_disconnect_t)(vm_wlan_cb_func_ptr callback, void *user_data); +_vm_wlan_disconnect_t _vm_wlan_disconnect = NULL; + +VMINT vm_wlan_disconnect(vm_wlan_cb_func_ptr callback, void *user_data) +{ + if (NULL == _vm_wlan_disconnect) + _vm_wlan_disconnect = (_vm_wlan_disconnect_t)vm_get_sym_entry("vm_wlan_disconnect"); + if (NULL != _vm_wlan_disconnect) + return _vm_wlan_disconnect(callback,user_data); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_get_connected_ap_info.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_get_connected_ap_info.c new file mode 100644 index 00000000..d66b692a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_get_connected_ap_info.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_get_connected_ap_info_t)(void *info, VMINT info_type); +_vm_wlan_get_connected_ap_info_t _vm_wlan_get_connected_ap_info = NULL; + +VMINT vm_wlan_get_connected_ap_info(void *info, VMINT info_type) +{ + if (NULL == _vm_wlan_get_connected_ap_info) + _vm_wlan_get_connected_ap_info = (_vm_wlan_get_connected_ap_info_t)vm_get_sym_entry("vm_wlan_get_connected_ap_info"); + if (NULL != _vm_wlan_get_connected_ap_info) + return _vm_wlan_get_connected_ap_info(info,info_type); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_get_ip_info.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_get_ip_info.c new file mode 100644 index 00000000..47cc7765 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_get_ip_info.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_get_ip_info_t)(vm_wlan_ip_info_struct* ip_info); +_vm_wlan_get_ip_info_t _vm_wlan_get_ip_info = NULL; + +VMINT vm_wlan_get_ip_info(vm_wlan_ip_info_struct* ip_info) +{ + if (NULL == _vm_wlan_get_ip_info) + _vm_wlan_get_ip_info = (_vm_wlan_get_ip_info_t)vm_get_sym_entry("vm_wlan_get_ip_info"); + if (NULL != _vm_wlan_get_ip_info) + return _vm_wlan_get_ip_info(ip_info); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_get_mac_address.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_get_mac_address.c new file mode 100644 index 00000000..8bd84ec7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_get_mac_address.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_get_mac_address_t)(vm_wlan_prof_str_info_qry_struct *mac_address_out); +_vm_wlan_get_mac_address_t _vm_wlan_get_mac_address = NULL; + +VMINT vm_wlan_get_mac_address(vm_wlan_prof_str_info_qry_struct *mac_address_out) +{ + if (NULL == _vm_wlan_get_mac_address) + _vm_wlan_get_mac_address = (_vm_wlan_get_mac_address_t)vm_get_sym_entry("vm_wlan_get_mac_address"); + if (NULL != _vm_wlan_get_mac_address) + return _vm_wlan_get_mac_address(mac_address_out); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_get_para.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_get_para.c new file mode 100644 index 00000000..4667760b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_get_para.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_get_para_t)(vm_wlan_set_mode_enum mode, void *para); +_vm_wlan_get_para_t _vm_wlan_get_para = NULL; + +VMINT vm_wlan_get_para(vm_wlan_set_mode_enum mode, void *para) +{ + if (NULL == _vm_wlan_get_para) + _vm_wlan_get_para = (_vm_wlan_get_para_t)vm_get_sym_entry("vm_wlan_get_para"); + if (NULL != _vm_wlan_get_para) + return _vm_wlan_get_para(mode,para); + return (VMINT)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_loc_get_connected_info.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_loc_get_connected_info.c new file mode 100644 index 00000000..743e910f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_loc_get_connected_info.c @@ -0,0 +1,18 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_loc_get_connected_info_t)(vm_wlan_loc_supc_abm_bss_info_struct * info); +_vm_wlan_loc_get_connected_info_t _vm_wlan_loc_get_connected_info = NULL; +VMINT vm_wlan_loc_get_connected_info(vm_wlan_loc_supc_abm_bss_info_struct * info) +{ + if (_vm_wlan_loc_get_connected_info == NULL) + _vm_wlan_loc_get_connected_info = (_vm_wlan_loc_get_connected_info_t)vm_get_sym_entry("vm_wlan_loc_get_connected_info"); + + if (_vm_wlan_loc_get_connected_info != NULL) + return _vm_wlan_loc_get_connected_info(info); + else + return -1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_loc_search.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_loc_search.c new file mode 100644 index 00000000..cdfeb39d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_loc_search.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_loc_search_t)(void (*callback)(vm_wlan_loc_data_t * data, void * user_data), void * user_data); +_vm_wlan_loc_search_t _vm_wlan_loc_search = NULL; +VMINT vm_wlan_loc_search(void (*callback)(vm_wlan_loc_data_t * data, void * user_data), void * user_data) +{ + if (_vm_wlan_loc_search == NULL) + _vm_wlan_loc_search = (_vm_wlan_loc_search_t)vm_get_sym_entry("vm_wlan_loc_search"); + + if (_vm_wlan_loc_search != NULL) + return _vm_wlan_loc_search(callback, user_data); + else + return -1; +} + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_loc_search_abort.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_loc_search_abort.c new file mode 100644 index 00000000..5aee5dec --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_loc_search_abort.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_loc_search_abort_t)(VMINT handle); +_vm_wlan_loc_search_abort_t _vm_wlan_loc_search_abort = NULL; +VMINT vm_wlan_loc_search_abort(VMINT handle) +{ + if (_vm_wlan_loc_search_abort == NULL) + _vm_wlan_loc_search_abort = (_vm_wlan_loc_search_abort_t)vm_get_sym_entry("vm_wlan_loc_search_abort"); + + if (_vm_wlan_loc_search_abort != NULL) + return _vm_wlan_loc_search_abort(handle); + else + return -1; +} + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_mode_get.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_mode_get.c new file mode 100644 index 00000000..db8da0c0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_mode_get.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_mode_get_t)(void); +_vm_wlan_mode_get_t _vm_wlan_mode_get = NULL; + +VMINT vm_wlan_mode_get(void) +{ + if (NULL == _vm_wlan_mode_get) + _vm_wlan_mode_get = (_vm_wlan_mode_get_t)vm_get_sym_entry("vm_wlan_mode_get"); + if (NULL != _vm_wlan_mode_get) + return _vm_wlan_mode_get(); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_mode_set.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_mode_set.c new file mode 100644 index 00000000..f532dfcd --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_mode_set.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_mode_set_t)(vm_wlan_set_mode_enum mode, vm_wlan_cb_func_ptr callback, void *user_data); +_vm_wlan_mode_set_t _vm_wlan_mode_set = NULL; + +VMINT vm_wlan_mode_set(vm_wlan_set_mode_enum mode, vm_wlan_cb_func_ptr callback, void *user_data) +{ + if (NULL == _vm_wlan_mode_set) + _vm_wlan_mode_set = (_vm_wlan_mode_set_t)vm_get_sym_entry("vm_wlan_mode_set"); + if (NULL != _vm_wlan_mode_set) + return _vm_wlan_mode_set(mode,callback,user_data); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_perfer.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_perfer.c new file mode 100644 index 00000000..ce3e975f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_perfer.c @@ -0,0 +1,21 @@ +#include "vmsys.h" +#include "vmsock.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_perfer_t)(VMINT disable); +_vm_wlan_perfer_t _vm_wlan_perfer = NULL; +VMINT vm_wlan_perfer(VMINT disable) +{ + if (NULL == _vm_wlan_perfer) + _vm_wlan_perfer = (_vm_wlan_perfer_t)vm_get_sym_entry("vm_wlan_perfer"); + + if (NULL != _vm_wlan_perfer) + return _vm_wlan_perfer(disable); + + return -1; + +} + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_add.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_add.c new file mode 100644 index 00000000..ba8a5951 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_add.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_prof_add_t)(const vm_wlan_prof_struct *prof, VMUINT32 *prof_id); +_vm_wlan_prof_add_t _vm_wlan_prof_add = NULL; + +VMINT vm_wlan_prof_add(const vm_wlan_prof_struct *prof, VMUINT32 *prof_id) +{ + if (NULL == _vm_wlan_prof_add) + _vm_wlan_prof_add = (_vm_wlan_prof_add_t)vm_get_sym_entry("vm_wlan_prof_add"); + if (NULL != _vm_wlan_prof_add) + return _vm_wlan_prof_add(prof,prof_id); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_connect.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_connect.c new file mode 100644 index 00000000..af043e1e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_connect.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_prof_connect_t)(VMUINT32 prof_id, vm_wlan_conn_res_cb_func_ptr callback, void *user_data); +_vm_wlan_prof_connect_t _vm_wlan_prof_connect = NULL; + +VMINT vm_wlan_prof_connect(VMUINT32 prof_id, vm_wlan_conn_res_cb_func_ptr callback, void *user_data) +{ + if (NULL == _vm_wlan_prof_connect) + _vm_wlan_prof_connect = (_vm_wlan_prof_connect_t)vm_get_sym_entry("vm_wlan_prof_connect"); + if (NULL != _vm_wlan_prof_connect) + return _vm_wlan_prof_connect(prof_id,callback,user_data); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_delete.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_delete.c new file mode 100644 index 00000000..c87b289e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_delete.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_prof_delete_t)(VMUINT32 prof_id); +_vm_wlan_prof_delete_t _vm_wlan_prof_delete = NULL; + +VMINT vm_wlan_prof_delete(VMUINT32 prof_id) +{ + if (NULL == _vm_wlan_prof_delete) + _vm_wlan_prof_delete = (_vm_wlan_prof_delete_t)vm_get_sym_entry("vm_wlan_prof_delete"); + if (NULL != _vm_wlan_prof_delete) + return _vm_wlan_prof_delete(prof_id); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_get_reconn_id.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_get_reconn_id.c new file mode 100644 index 00000000..99fd390c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_get_reconn_id.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_prof_get_reconn_id_t)(VMUINT32 *prof_id); +_vm_wlan_prof_get_reconn_id_t _vm_wlan_prof_get_reconn_id = NULL; + +VMINT vm_wlan_prof_get_reconn_id(VMUINT32 *prof_id) +{ + if (NULL == _vm_wlan_prof_get_reconn_id) + _vm_wlan_prof_get_reconn_id = (_vm_wlan_prof_get_reconn_id_t)vm_get_sym_entry("vm_wlan_prof_get_reconn_id"); + if (NULL != _vm_wlan_prof_get_reconn_id) + return _vm_wlan_prof_get_reconn_id(prof_id); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_init.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_init.c new file mode 100644 index 00000000..4b61dba0 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_init.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_prof_init_t)(vm_wlan_prof_struct *profile); +_vm_wlan_prof_init_t _vm_wlan_prof_init = NULL; + +VMINT vm_wlan_prof_init(vm_wlan_prof_struct *profile) +{ + if (NULL == _vm_wlan_prof_init) + _vm_wlan_prof_init = (_vm_wlan_prof_init_t)vm_get_sym_entry("vm_wlan_prof_init"); + if (NULL != _vm_wlan_prof_init) + return _vm_wlan_prof_init(profile); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_query.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_query.c new file mode 100644 index 00000000..f0a0c61a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_query.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_prof_query_t)(VMUINT32 prof_id, vm_wlan_prof_struct *prof); +_vm_wlan_prof_query_t _vm_wlan_prof_query = NULL; + +VMINT vm_wlan_prof_query(VMUINT32 prof_id, vm_wlan_prof_struct *prof) +{ + if (NULL == _vm_wlan_prof_query) + _vm_wlan_prof_query = (_vm_wlan_prof_query_t)vm_get_sym_entry("vm_wlan_prof_query"); + if (NULL != _vm_wlan_prof_query) + return _vm_wlan_prof_query(prof_id,prof); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_query_list.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_query_list.c new file mode 100644 index 00000000..b60a4eb5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_query_list.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_prof_query_list_t)(vm_wlan_prof_list_struct *prof_list); +_vm_wlan_prof_query_list_t _vm_wlan_prof_query_list = NULL; + +VMINT vm_wlan_prof_query_list(vm_wlan_prof_list_struct *prof_list) +{ + if (NULL == _vm_wlan_prof_query_list) + _vm_wlan_prof_query_list = (_vm_wlan_prof_query_list_t)vm_get_sym_entry("vm_wlan_prof_query_list"); + if (NULL != _vm_wlan_prof_query_list) + return _vm_wlan_prof_query_list(prof_list); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_set_reconn_id.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_set_reconn_id.c new file mode 100644 index 00000000..62a4ed43 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_set_reconn_id.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_prof_set_reconn_id_t)(VMUINT32 prof_id); +_vm_wlan_prof_set_reconn_id_t _vm_wlan_prof_set_reconn_id = NULL; + +VMINT vm_wlan_prof_set_reconn_id(VMUINT32 prof_id) +{ + if (NULL == _vm_wlan_prof_set_reconn_id) + _vm_wlan_prof_set_reconn_id = (_vm_wlan_prof_set_reconn_id_t)vm_get_sym_entry("vm_wlan_prof_set_reconn_id"); + if (NULL != _vm_wlan_prof_set_reconn_id) + return _vm_wlan_prof_set_reconn_id(prof_id); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_update.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_update.c new file mode 100644 index 00000000..a0b4c3ee --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_prof_update.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_prof_update_t)(VMUINT32 prof_id, vm_wlan_prof_struct *prof, VMUINT32 prof_fields); +_vm_wlan_prof_update_t _vm_wlan_prof_update = NULL; + +VMINT vm_wlan_prof_update(VMUINT32 prof_id, vm_wlan_prof_struct *prof, VMUINT32 prof_fields) +{ + if (NULL == _vm_wlan_prof_update) + _vm_wlan_prof_update = (_vm_wlan_prof_update_t)vm_get_sym_entry("vm_wlan_prof_update"); + if (NULL != _vm_wlan_prof_update) + return _vm_wlan_prof_update(prof_id,prof,prof_fields); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_reg_noti.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_reg_noti.c new file mode 100644 index 00000000..31747a0b --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_reg_noti.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_reg_noti_t)(VMINT noti_type, vm_wlan_noti_func_ptr callback, void *user_data); +_vm_wlan_reg_noti_t _vm_wlan_reg_noti = NULL; + +VMINT vm_wlan_reg_noti(VMINT noti_type, vm_wlan_noti_func_ptr callback, void *user_data) +{ + if (NULL == _vm_wlan_reg_noti) + _vm_wlan_reg_noti = (_vm_wlan_reg_noti_t)vm_get_sym_entry("vm_wlan_reg_noti"); + if (NULL != _vm_wlan_reg_noti) + return _vm_wlan_reg_noti(noti_type,callback,user_data); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_roaming_get.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_roaming_get.c new file mode 100644 index 00000000..6c9a72d9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_roaming_get.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_roaming_get_t)(VMINT *is_roaming); +_vm_wlan_roaming_get_t _vm_wlan_roaming_get = NULL; + +VMINT vm_wlan_roaming_get(VMINT *is_roaming) +{ + if (NULL == _vm_wlan_roaming_get) + _vm_wlan_roaming_get = (_vm_wlan_roaming_get_t)vm_get_sym_entry("vm_wlan_roaming_get"); + if (NULL != _vm_wlan_roaming_get) + return _vm_wlan_roaming_get(is_roaming); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_roaming_set.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_roaming_set.c new file mode 100644 index 00000000..de283acd --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_roaming_set.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_roaming_set_t)(VMINT enable_roaming, vm_wlan_cb_func_ptr callback, void *user_data); +_vm_wlan_roaming_set_t _vm_wlan_roaming_set = NULL; + +VMINT vm_wlan_roaming_set(VMINT enable_roaming, vm_wlan_cb_func_ptr callback, void *user_data) +{ + if (NULL == _vm_wlan_roaming_set) + _vm_wlan_roaming_set = (_vm_wlan_roaming_set_t)vm_get_sym_entry("vm_wlan_roaming_set"); + if (NULL != _vm_wlan_roaming_set) + return _vm_wlan_roaming_set(enable_roaming,callback,user_data); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_scan.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_scan.c new file mode 100644 index 00000000..1ef93ada --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_scan.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_scan_t)(vm_wlan_scan_res_cb_func_ptr callback, void *user_data); +_vm_wlan_scan_t _vm_wlan_scan = NULL; + +VMINT vm_wlan_scan(vm_wlan_scan_res_cb_func_ptr callback, void *user_data) +{ + if (NULL == _vm_wlan_scan) + _vm_wlan_scan = (_vm_wlan_scan_t)vm_get_sym_entry("vm_wlan_scan"); + if (NULL != _vm_wlan_scan) + return _vm_wlan_scan(callback,user_data); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_scan_abort.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_scan_abort.c new file mode 100644 index 00000000..4578bec1 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_scan_abort.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_scan_abort_t)(VMUINT32 job_id); +_vm_wlan_scan_abort_t _vm_wlan_scan_abort = NULL; + +VMINT vm_wlan_scan_abort(VMUINT32 job_id) +{ + if (NULL == _vm_wlan_scan_abort) + _vm_wlan_scan_abort = (_vm_wlan_scan_abort_t)vm_get_sym_entry("vm_wlan_scan_abort"); + if (NULL != _vm_wlan_scan_abort) + return _vm_wlan_scan_abort(job_id); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_scan_get_param.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_scan_get_param.c new file mode 100644 index 00000000..b52f54e9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_scan_get_param.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_scan_get_param_t)(void *param, VMINT32 param_type); +_vm_wlan_scan_get_param_t _vm_wlan_scan_get_param = NULL; + +VMINT vm_wlan_scan_get_param(void *param, VMINT32 param_type) +{ + if (NULL == _vm_wlan_scan_get_param) + _vm_wlan_scan_get_param = (_vm_wlan_scan_get_param_t)vm_get_sym_entry("vm_wlan_scan_get_param"); + if (NULL != _vm_wlan_scan_get_param) + return _vm_wlan_scan_get_param(param,param_type); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_scan_set_param.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_scan_set_param.c new file mode 100644 index 00000000..af358c82 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_scan_set_param.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_scan_set_param_t)(void *param, VMINT32 param_type, vm_wlan_cb_func_ptr callback, void *user_data); +_vm_wlan_scan_set_param_t _vm_wlan_scan_set_param = NULL; + +VMINT vm_wlan_scan_set_param(void *param, VMINT32 param_type, vm_wlan_cb_func_ptr callback, void *user_data) +{ + if (NULL == _vm_wlan_scan_set_param) + _vm_wlan_scan_set_param = (_vm_wlan_scan_set_param_t)vm_get_sym_entry("vm_wlan_scan_set_param"); + if (NULL != _vm_wlan_scan_set_param) + return _vm_wlan_scan_set_param(param,param_type,callback,user_data); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_set_para.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_set_para.c new file mode 100644 index 00000000..f2cb4a43 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_set_para.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_set_para_t)(vm_wlan_set_mode_enum mode, void *para, VMINT32 flag); +_vm_wlan_set_para_t _vm_wlan_set_para = NULL; + +VMINT vm_wlan_set_para(vm_wlan_set_mode_enum mode, void *para, VMINT32 flag) +{ + if (NULL == _vm_wlan_set_para) + _vm_wlan_set_para = (_vm_wlan_set_para_t)vm_get_sym_entry("vm_wlan_set_para"); + if (NULL != _vm_wlan_set_para) + return _vm_wlan_set_para(mode,para,flag); + return (VMINT)-100; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_sniffer_off.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_sniffer_off.c new file mode 100644 index 00000000..9e66624d --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_sniffer_off.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_sniffer_off_t)(vm_wlan_sniffer_off_cb_func_ptr callback, void *user_data); +_vm_wlan_sniffer_off_t _vm_wlan_sniffer_off = NULL; + +VMINT vm_wlan_sniffer_off(vm_wlan_sniffer_off_cb_func_ptr callback, void *user_data) +{ + if (NULL == _vm_wlan_sniffer_off) + _vm_wlan_sniffer_off = (_vm_wlan_sniffer_off_t)vm_get_sym_entry("vm_wlan_sniffer_off"); + if (NULL != _vm_wlan_sniffer_off) + return _vm_wlan_sniffer_off(callback,user_data); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_sniffer_on.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_sniffer_on.c new file mode 100644 index 00000000..65abe2c9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_sniffer_on.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_sniffer_on_t)(vm_wlan_sniffer_on_cfg_struct *sniffer_on_config, vm_wlan_sniffer_on_cb_func_ptr callback, void *user_data); +_vm_wlan_sniffer_on_t _vm_wlan_sniffer_on = NULL; + +VMINT vm_wlan_sniffer_on(vm_wlan_sniffer_on_cfg_struct *sniffer_on_config, vm_wlan_sniffer_on_cb_func_ptr callback, void *user_data) +{ + if (NULL == _vm_wlan_sniffer_on) + _vm_wlan_sniffer_on = (_vm_wlan_sniffer_on_t)vm_get_sym_entry("vm_wlan_sniffer_on"); + if (NULL != _vm_wlan_sniffer_on) + return _vm_wlan_sniffer_on(sniffer_on_config,callback,user_data); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_status.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_status.c new file mode 100644 index 00000000..514fa161 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wlan_status.c @@ -0,0 +1,17 @@ +#include "vmsys.h" +#include "vmnwsetting.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wlan_status_t)(void); +_vm_wlan_status_t _vm_wlan_status = NULL; + +VMINT vm_wlan_status(void) +{ + if (NULL == _vm_wlan_status) + _vm_wlan_status = (_vm_wlan_status_t)vm_get_sym_entry("vm_wlan_status"); + if (NULL != _vm_wlan_status) + return _vm_wlan_status(); + return (VMINT)-1; +} \ No newline at end of file diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_write_cache.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_write_cache.c new file mode 100644 index 00000000..9b2cb6a2 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_write_cache.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_write_cache_t)(vm_cache_t *cache, void *buf, VMINT buf_len); +_vm_write_cache_t _vm_write_cache = NULL; + +VMINT vm_write_cache(vm_cache_t *cache, void *buf, VMINT buf_len) +{ + if (NULL == _vm_write_cache) + _vm_write_cache = (_vm_write_cache_t)vm_get_sym_entry("vm_write_cache"); + + if (NULL != _vm_write_cache) + return _vm_write_cache(cache,buf,buf_len); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstarts_with.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstarts_with.c new file mode 100644 index 00000000..f15e966e --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstarts_with.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wstarts_with_t)(VMWSTR a, VMWSTR b); +_vm_wstarts_with_t _vm_wstarts_with = NULL; + +VMINT vm_wstarts_with(VMWSTR a, VMWSTR b) +{ + if (NULL == _vm_wstarts_with) + _vm_wstarts_with = (_vm_wstarts_with_t)vm_get_sym_entry("vm_wstarts_with"); + + if (NULL != _vm_wstarts_with) + return _vm_wstarts_with(a,b); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrcat.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrcat.c new file mode 100644 index 00000000..edcb131c --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrcat.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wstrcat_t)(VMWSTR dst, const VMWSTR src); +_vm_wstrcat_t _vm_wstrcat = NULL; + +VMINT vm_wstrcat(VMWSTR dst, const VMWSTR src) +{ + if (NULL == _vm_wstrcat) + _vm_wstrcat = (_vm_wstrcat_t)vm_get_sym_entry("vm_wstrcat"); + + if (NULL != _vm_wstrcat) + return _vm_wstrcat(dst,src); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrcmp.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrcmp.c new file mode 100644 index 00000000..4e92c3b7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrcmp.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wstrcmp_t)(VMWSTR str_1, VMWSTR str_2); +_vm_wstrcmp_t _vm_wstrcmp = NULL; + +VMINT vm_wstrcmp(VMWSTR str_1, VMWSTR str_2) +{ + if (NULL == _vm_wstrcmp) + _vm_wstrcmp = (_vm_wstrcmp_t)vm_get_sym_entry("vm_wstrcmp"); + + if (NULL != _vm_wstrcmp) + return _vm_wstrcmp(str_1,str_2); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrcmp_ignore_case.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrcmp_ignore_case.c new file mode 100644 index 00000000..5c6e031a --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrcmp_ignore_case.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wstrcmp_ignore_case_t)(VMWSTR str_1, VMWSTR str_2); +_vm_wstrcmp_ignore_case_t _vm_wstrcmp_ignore_case = NULL; + +VMINT vm_wstrcmp_ignore_case(VMWSTR str_1, VMWSTR str_2) +{ + if (NULL == _vm_wstrcmp_ignore_case) + _vm_wstrcmp_ignore_case = (_vm_wstrcmp_ignore_case_t)vm_get_sym_entry("vm_wstrcmp_ignore_case"); + + if (NULL != _vm_wstrcmp_ignore_case) + return _vm_wstrcmp_ignore_case(str_1,str_2); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrcpy.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrcpy.c new file mode 100644 index 00000000..d9f8eff9 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrcpy.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wstrcpy_t)(VMWSTR dst, const VMWSTR src); +_vm_wstrcpy_t _vm_wstrcpy = NULL; + +VMINT vm_wstrcpy(VMWSTR dst, const VMWSTR src) +{ + if (NULL == _vm_wstrcpy) + _vm_wstrcpy = (_vm_wstrcpy_t)vm_get_sym_entry("vm_wstrcpy"); + + if (NULL != _vm_wstrcpy) + return _vm_wstrcpy(dst,src); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrlen.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrlen.c new file mode 100644 index 00000000..01d5c9e4 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrlen.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wstrlen_t)(VMWSTR s); +_vm_wstrlen_t _vm_wstrlen = NULL; + +VMINT vm_wstrlen(VMWSTR s) +{ + if (NULL == _vm_wstrlen) + _vm_wstrlen = (_vm_wstrlen_t)vm_get_sym_entry("vm_wstrlen"); + + if (NULL != _vm_wstrlen) + return _vm_wstrlen(s); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrncpy.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrncpy.c new file mode 100644 index 00000000..248f8acb --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_wstrncpy.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmstdlib.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_wstrncpy_t)(VMWSTR dst, const VMWSTR src, VMINT length); +_vm_wstrncpy_t _vm_wstrncpy = NULL; + +VMINT vm_wstrncpy(VMWSTR dst, const VMWSTR src, VMINT length) +{ + if (NULL == _vm_wstrncpy) + _vm_wstrncpy = (_vm_wstrncpy_t)vm_get_sym_entry("vm_wstrncpy"); + + if (NULL != _vm_wstrncpy) + return _vm_wstrncpy(dst,src,length); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_get_error.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_get_error.c new file mode 100644 index 00000000..029bf5ca --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_get_error.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmxml.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMCHAR *(*_vm_xml_get_error_t)(void); +_vm_xml_get_error_t _vm_xml_get_error = NULL; + +VMCHAR *vm_xml_get_error(void) +{ + if (NULL == _vm_xml_get_error) + _vm_xml_get_error = (_vm_xml_get_error_t)vm_get_sym_entry("vm_xml_get_error"); + + if (NULL != _vm_xml_get_error) + return _vm_xml_get_error(); + + return (VMCHAR *)0; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_new_parser.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_new_parser.c new file mode 100644 index 00000000..926b9f9f --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_new_parser.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmxml.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_xml_new_parser_t)(VM_XML_PARSER_STRUCT *parser); +_vm_xml_new_parser_t _vm_xml_new_parser = NULL; + +VMINT vm_xml_new_parser(VM_XML_PARSER_STRUCT *parser) +{ + if (NULL == _vm_xml_new_parser) + _vm_xml_new_parser = (_vm_xml_new_parser_t)vm_get_sym_entry("vm_xml_new_parser"); + + if (NULL != _vm_xml_new_parser) + return _vm_xml_new_parser(parser); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_parse.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_parse.c new file mode 100644 index 00000000..1687b903 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_parse.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmxml.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VMINT (*_vm_xml_parse_t)(VM_XML_PARSER_STRUCT *parser, const VMCHAR *xmlsource, VMINT length); +_vm_xml_parse_t _vm_xml_parse = NULL; + +VMINT vm_xml_parse(VM_XML_PARSER_STRUCT *parser, const VMCHAR *xmlsource, VMINT length) +{ + if (NULL == _vm_xml_parse) + _vm_xml_parse = (_vm_xml_parse_t)vm_get_sym_entry("vm_xml_parse"); + + if (NULL != _vm_xml_parse) + return _vm_xml_parse(parser,xmlsource,length); + + return (VMINT )-1; +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_set_data_handler.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_set_data_handler.c new file mode 100644 index 00000000..fbb3b9f7 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_set_data_handler.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmxml.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_xml_set_data_handler_t)(VM_XML_PARSER_STRUCT *parser, XML_data_hdlr data_hdlr); +_vm_xml_set_data_handler_t _vm_xml_set_data_handler = NULL; + +void vm_xml_set_data_handler(VM_XML_PARSER_STRUCT *parser, XML_data_hdlr data_hdlr) +{ + if (NULL == _vm_xml_set_data_handler) + _vm_xml_set_data_handler = (_vm_xml_set_data_handler_t)vm_get_sym_entry("vm_xml_set_data_handler"); + + if (NULL != _vm_xml_set_data_handler) + _vm_xml_set_data_handler(parser,data_hdlr); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_set_doctype_handlers.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_set_doctype_handlers.c new file mode 100644 index 00000000..0d5f7abe --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_set_doctype_handlers.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmxml.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_xml_set_doctype_handlers_t)( VM_XML_PARSER_STRUCT *parser, XML_start_doctype_hdlr start_hdlr, XML_end_doctype_hdlr end_hdlr); +_vm_xml_set_doctype_handlers_t _vm_xml_set_doctype_handlers = NULL; + +void vm_xml_set_doctype_handlers( VM_XML_PARSER_STRUCT *parser, XML_start_doctype_hdlr start_hdlr, XML_end_doctype_hdlr end_hdlr) +{ + if (NULL == _vm_xml_set_doctype_handlers) + _vm_xml_set_doctype_handlers = (_vm_xml_set_doctype_handlers_t)vm_get_sym_entry("vm_xml_set_doctype_handlers"); + + if (NULL != _vm_xml_set_doctype_handlers) + _vm_xml_set_doctype_handlers(parser,start_hdlr,end_hdlr); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_set_element_handlers.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_set_element_handlers.c new file mode 100644 index 00000000..136e8d93 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vm_xml_set_element_handlers.c @@ -0,0 +1,19 @@ +#include "vmsys.h" +#include "vmxml.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef void (*_vm_xml_set_element_handlers_t)( VM_XML_PARSER_STRUCT *parser, XML_start_elem_hdlr start_hdlr, XML_end_elem_hdlr end_hdlr); +_vm_xml_set_element_handlers_t _vm_xml_set_element_handlers = NULL; + +void vm_xml_set_element_handlers( VM_XML_PARSER_STRUCT *parser, XML_start_elem_hdlr start_hdlr, XML_end_elem_hdlr end_hdlr) +{ + if (NULL == _vm_xml_set_element_handlers) + _vm_xml_set_element_handlers = (_vm_xml_set_element_handlers_t)vm_get_sym_entry("vm_xml_set_element_handlers"); + + if (NULL != _vm_xml_set_element_handlers) + _vm_xml_set_element_handlers(parser,start_hdlr,end_hdlr); + + +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vmdcl.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vmdcl.c new file mode 100644 index 00000000..64c7edcf --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vmdcl.c @@ -0,0 +1,134 @@ +#include "vmsys.h" +#include "vmdcl.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + + +typedef VM_DCL_HANDLE (*_vm_dcl_open_t)(VM_DCL_DEV dev, VM_DCL_FLAGS flags); +_vm_dcl_open_t _vm_dcl_open = NULL; +VM_DCL_HANDLE vm_dcl_open(VM_DCL_DEV dev, VM_DCL_FLAGS flags) +{ + if (NULL == _vm_dcl_open) + _vm_dcl_open = (_vm_dcl_open_t)vm_get_sym_entry("vm_dcl_open"); + + if (NULL != _vm_dcl_open) + return _vm_dcl_open(dev, flags); + + return (VMINT )VM_DCL_HANDLE_INVALID; +} + +typedef VM_DCL_STATUS (*_vm_dcl_control_t)(VM_DCL_HANDLE device_handle,VM_DCL_CTRL_CMD cmd, void* arg); +_vm_dcl_control_t _vm_dcl_control = NULL; +VM_DCL_STATUS vm_dcl_control(VM_DCL_HANDLE device_handle,VM_DCL_CTRL_CMD cmd, void* arg) +{ + if (NULL == _vm_dcl_control) + _vm_dcl_control = (_vm_dcl_control_t)vm_get_sym_entry("vm_dcl_control"); + + if (NULL != _vm_dcl_control) + return _vm_dcl_control(device_handle, cmd, arg); + + return (VMINT )VM_DCL_STATUS_FAIL; +} + +typedef VM_DCL_STATUS (*_vm_dcl_close_t)(VM_DCL_HANDLE device_handle); +_vm_dcl_close_t _vm_dcl_close = NULL; +VM_DCL_STATUS vm_dcl_close(VM_DCL_HANDLE device_handle) +{ + if (NULL == _vm_dcl_close) + _vm_dcl_close = (_vm_dcl_close_t)vm_get_sym_entry("vm_dcl_close"); + + if (NULL != _vm_dcl_close) + return _vm_dcl_close(device_handle); + + return (VMINT )VM_DCL_STATUS_FAIL; +} + +typedef VM_DCL_STATUS (*_vm_dcl_registercallback_t)(VM_DCL_HANDLE device_handle,VM_DCL_EVENT event, VM_DCL_CALLBACK callback,void* user_data); +_vm_dcl_registercallback_t _vm_dcl_registercallback = NULL; +VM_DCL_STATUS vm_dcl_registercallback(VM_DCL_HANDLE device_handle,VM_DCL_EVENT event, VM_DCL_CALLBACK callback,void* user_data) +{ + if (NULL == _vm_dcl_registercallback) + _vm_dcl_registercallback = (_vm_dcl_registercallback_t)vm_get_sym_entry("vm_dcl_registercallback"); + + if (NULL != _vm_dcl_registercallback) + return _vm_dcl_registercallback(device_handle,event, callback, user_data); + + return (VMINT )VM_DCL_STATUS_FAIL; +} + +typedef VM_DCL_STATUS (*_vm_dcl_addlistenevent_t)(VM_DCL_HANDLE device_handle,VM_DCL_EVENT event, void* user_data); +_vm_dcl_addlistenevent_t _vm_dcl_addlistenevent = NULL; +VM_DCL_STATUS vm_dcl_addlistenevent(VM_DCL_HANDLE device_handle,VM_DCL_EVENT event, void* user_data) +{ + if (NULL == _vm_dcl_addlistenevent) + _vm_dcl_addlistenevent = (_vm_dcl_addlistenevent_t)vm_get_sym_entry("vm_dcl_addlistenevent"); + + if (NULL != _vm_dcl_addlistenevent) + return _vm_dcl_addlistenevent(device_handle,event, user_data); + + return (VMINT )VM_DCL_STATUS_FAIL; +} + +typedef VM_DCL_STATUS (*_vm_dcl_read_t)(VM_DCL_HANDLE device_handle, VM_DCL_BUFF* buf, VM_DCL_BUFF_LEN buf_len, VM_DCL_BUFF_LEN* returned_len,VM_DCL_OPTIONS options); +_vm_dcl_read_t _vm_dcl_read = NULL; +VM_DCL_STATUS vm_dcl_read(VM_DCL_HANDLE device_handle, VM_DCL_BUFF* buf, VM_DCL_BUFF_LEN buf_len, VM_DCL_BUFF_LEN* returned_len,VM_DCL_OPTIONS options) +{ + if (NULL == _vm_dcl_read) + _vm_dcl_read = (_vm_dcl_read_t)vm_get_sym_entry("vm_dcl_read"); + + if (NULL != _vm_dcl_read) + return _vm_dcl_read(device_handle, buf, buf_len, returned_len, options); + + return (VMINT )VM_DCL_STATUS_FAIL; +} + +typedef VM_DCL_STATUS (*_vm_dcl_write_t)(VM_DCL_HANDLE device_handle,VM_DCL_BUFF* buf, VM_DCL_BUFF_LEN buf_len, VM_DCL_BUFF_LEN* writed_len,VM_DCL_OPTIONS options); +_vm_dcl_write_t _vm_dcl_write = NULL; +VM_DCL_STATUS vm_dcl_write(VM_DCL_HANDLE device_handle,VM_DCL_BUFF* buf, VM_DCL_BUFF_LEN buf_len, VM_DCL_BUFF_LEN* writed_len,VM_DCL_OPTIONS options) +{ + if (NULL == _vm_dcl_write) + _vm_dcl_write = (_vm_dcl_write_t)vm_get_sym_entry("vm_dcl_write"); + + if (NULL != _vm_dcl_write) + return _vm_dcl_write(device_handle,buf, buf_len, writed_len, options); + + return (VMINT )VM_DCL_STATUS_FAIL; +} + +typedef VM_DCL_MODULE_TYPE_T (*_vm_dcl_get_ownerid_t)(); +_vm_dcl_get_ownerid_t _vm_dcl_get_ownerid = NULL; +VM_DCL_MODULE_TYPE_T vm_dcl_get_ownerid() +{ + if (NULL == _vm_dcl_get_ownerid) + _vm_dcl_get_ownerid = (_vm_dcl_get_ownerid_t)vm_get_sym_entry("vm_dcl_get_ownerid"); + + if (NULL != _vm_dcl_get_ownerid) + return _vm_dcl_get_ownerid(); + + return 0; +} + +typedef VMUINT32 (*_vm_irq_mask_t)(); +_vm_irq_mask_t _vm_irq_mask = NULL; +VMUINT32 vm_irq_mask() +{ + if (NULL == _vm_irq_mask) + _vm_irq_mask = (_vm_irq_mask_t)vm_get_sym_entry("vm_irq_mask"); + + if (NULL != _vm_irq_mask) + return _vm_irq_mask(); + + return 0; +} + +typedef void (*_vm_irq_restore_t)(); +_vm_irq_restore_t _vm_irq_restore = NULL; +void vm_irq_restore(VMUINT32 mask) +{ + if (NULL == _vm_irq_restore) + _vm_irq_restore = (_vm_irq_restore_t)vm_get_sym_entry("vm_irq_restore"); + + if (NULL != _vm_irq_restore) + _vm_irq_restore(mask); +} diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vmlog.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vmlog.c new file mode 100644 index 00000000..b90f8937 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vmlog.c @@ -0,0 +1,115 @@ + +#include "vmlog.h" +#include "vmio.h" +#include "vmsys.h" +#include "vmchset.h" + +#include "vmstdlib.h" + +#define MAX_APP_NAME_LEN (260) + +static char * _cache_file_ = NULL; +static int _lineNo = 0; +static char g_log_buffer[MAX_APP_NAME_LEN]; + +static void log_it(VMINT level, char* fmt, va_list ap); + + +int _vm_log_module(const char* __file__, const int __line__) +{ + _lineNo = __line__; + _cache_file_ = (char*)__file__; + return 1; +} + +void vm_log_init(char* filename, int log_level) +{ + return ; +} + +void _vm_log_debug(char* fmt, ...) { + va_list ap; + + va_start(ap, fmt); + log_it(VM_DEBUG_LEVEL, fmt, ap); + va_end(ap); +} + +void _vm_log_info(char* fmt, ...) { + va_list ap; + + va_start(ap, fmt); + log_it(VM_INFO_LEVEL, fmt, ap); + va_end(ap); +} + +void _vm_log_warn(char* fmt, ...) { + va_list ap; + + va_start(ap, fmt); + log_it(VM_WARN_LEVEL, fmt, ap); + va_end(ap); +} + +void _vm_log_error(char* fmt, ...) { + va_list ap; + + va_start(ap, fmt); + log_it(VM_ERROR_LEVEL, fmt, ap); + va_end(ap); +} + +void _vm_log_fatal(char* fmt, ...) { + va_list ap; + + va_start(ap, fmt); + log_it(VM_FATAL_LEVEL, fmt, ap); + va_end(ap); +} + +void log_it(VMINT level, char* fmt, va_list ap) { + vm_time_t tm; + int len; + int i = 0; + char text[MAX_APP_NAME_LEN]; + + memset(text, 0x00, sizeof(text)); + + vm_get_time(&tm); + + len = strlen(_cache_file_); + + while (len>0) + { + if (_cache_file_[len-1] != '\\' && _cache_file_[len-1] != '/') + { + len--; + } + else + { + break; + } + } + + strncpy(g_log_buffer, (char*)&_cache_file_[len], 10); + + sprintf(text, "%d-%02.2d-%02.2d %02.2d:%02.2d:%02.2d\t%d\t%s:%d\t", tm.year, tm.mon, tm.day, tm.hour, + tm.min, tm.sec, level, g_log_buffer ,_lineNo); + + vsprintf(text + strlen(text), fmt, ap); + strcat(text, "\r\n"); + vm_app_log(text); +} + +void vm_log_close(void) +{ + return ; +} + +void vm_set_log_level(int log_level) +{ + return; +} + + + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vmthread.c b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vmthread.c new file mode 100644 index 00000000..8906c845 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/libmtk/vmthread.c @@ -0,0 +1,134 @@ +#include "vmsys.h" +#include "vmthread.h" + +typedef VMINT (*vm_get_sym_entry_t)(char* symbol); +extern vm_get_sym_entry_t vm_get_sym_entry; + +typedef VM_SIGNAL_ID (*_vm_signal_init_t)(void); +_vm_signal_init_t _vm_signal_init = NULL; +VM_SIGNAL_ID vm_signal_init(void) +{ + if (NULL == _vm_signal_init) + _vm_signal_init = (_vm_signal_init_t)vm_get_sym_entry("vm_signal_init"); + + if (NULL != _vm_signal_init) + return _vm_signal_init(); + + return 0; +} + +typedef void (*_vm_signal_clean_t)(VM_SIGNAL_ID s_id); +_vm_signal_clean_t _vm_signal_clean = NULL; +void vm_signal_clean(VM_SIGNAL_ID s_id) +{ + if (NULL == _vm_signal_clean) + _vm_signal_clean = (_vm_signal_clean_t)vm_get_sym_entry("vm_signal_clean"); + + if (NULL != _vm_signal_clean) + _vm_signal_clean(s_id); +} + +typedef void (*_vm_signal_post_t)(VM_SIGNAL_ID s_id); +_vm_signal_post_t _vm_signal_post = NULL; +void vm_signal_post(VM_SIGNAL_ID s_id) +{ + if (NULL == _vm_signal_post) + _vm_signal_post = (_vm_signal_post_t)vm_get_sym_entry("vm_signal_post"); + + if (NULL != _vm_signal_post) + _vm_signal_post(s_id); +} + +typedef VMINT32 (*_vm_signal_wait_t)(VM_SIGNAL_ID s_id); +_vm_signal_wait_t _vm_signal_wait = NULL; +VMINT32 vm_signal_wait(VM_SIGNAL_ID s_id) +{ + if (NULL == _vm_signal_wait) + _vm_signal_wait = (_vm_signal_wait_t)vm_get_sym_entry("vm_signal_wait"); + + if (NULL != _vm_signal_wait) + return _vm_signal_wait(s_id); + + return (VMINT )-1; +} + +typedef VMINT32 (*_vm_signal_timedwait_t)(VM_SIGNAL_ID s_id, VMUINT32 time_count); +_vm_signal_timedwait_t _vm_signal_timedwait = NULL; +VMINT32 vm_signal_timedwait(VM_SIGNAL_ID s_id, VMUINT32 time_count) +{ + if (NULL == _vm_signal_timedwait) + _vm_signal_timedwait = (_vm_signal_timedwait_t)vm_get_sym_entry("vm_signal_timedwait"); + + if (NULL != _vm_signal_timedwait) + return _vm_signal_timedwait(s_id, time_count); + + return (VMINT )0; +} + +typedef void (*_vm_signal_deinit_t)(VM_SIGNAL_ID s_id); +_vm_signal_deinit_t _vm_signal_deinit = NULL; +void vm_signal_deinit(VM_SIGNAL_ID s_id) +{ + if (NULL == _vm_signal_deinit) + _vm_signal_deinit = (_vm_signal_deinit_t)vm_get_sym_entry("vm_signal_deinit"); + + if (NULL != _vm_signal_deinit) + _vm_signal_deinit(s_id); +} + + +typedef void (*_vm_mutex_create_t)(vm_thread_mutex_struct *mutex); +_vm_mutex_create_t _vm_mutex_create = NULL; +void vm_mutex_create(vm_thread_mutex_struct *mutex) +{ + if (NULL == _vm_mutex_create) + _vm_mutex_create = (_vm_mutex_create_t)vm_get_sym_entry("vm_mutex_create"); + + if (NULL != _vm_mutex_create) + _vm_mutex_create(mutex); +} + +typedef void (*_vm_mutex_lock_t)(vm_thread_mutex_struct *mutex); +_vm_mutex_lock_t _vm_mutex_lock = NULL; +void vm_mutex_lock(vm_thread_mutex_struct *mutex) +{ + if (NULL == _vm_mutex_lock) + _vm_mutex_lock = (_vm_mutex_lock_t)vm_get_sym_entry("vm_mutex_lock"); + + if (NULL != _vm_mutex_lock) + _vm_mutex_lock(mutex); +} + +typedef void (*_vm_mutex_unlock_t)(vm_thread_mutex_struct *mutex); +_vm_mutex_unlock_t _vm_mutex_unlock = NULL; +void vm_mutex_unlock(vm_thread_mutex_struct *mutex) +{ + if (NULL == _vm_mutex_unlock) + _vm_mutex_unlock = (_vm_mutex_unlock_t)vm_get_sym_entry("vm_mutex_unlock"); + + if (NULL != _vm_mutex_unlock) + _vm_mutex_unlock(mutex); +} + +typedef void (*_vm_thread_sleep_t)(VMUINT32 timeout); +_vm_thread_sleep_t _vm_thread_sleep = NULL; +void vm_thread_sleep(VMUINT32 timeout) +{ + if (NULL == _vm_thread_sleep) + _vm_thread_sleep = (_vm_thread_sleep_t)vm_get_sym_entry("vm_thread_sleep"); + + if (NULL != _vm_thread_sleep) + _vm_thread_sleep(timeout); +} + +typedef void (*_vm_thread_change_priority_t)(VM_THREAD_HANDLE thread_handle, VMUINT32 new_priority); +_vm_thread_change_priority_t _vm_thread_change_priority = NULL; +void vm_thread_change_priority(VM_THREAD_HANDLE thread_handle, VMUINT32 new_priority) +{ + if (NULL == _vm_thread_change_priority) + _vm_thread_change_priority = (_vm_thread_change_priority_t)vm_get_sym_entry("vm_thread_change_priority"); + + if (NULL != _vm_thread_change_priority) + _vm_thread_change_priority(thread_handle, new_priority); +} + diff --git a/hardware/arduino/mtk/system/libmtk/source/modules/makefile b/hardware/arduino/mtk/system/libmtk/source/modules/makefile new file mode 100644 index 00000000..03133dd5 --- /dev/null +++ b/hardware/arduino/mtk/system/libmtk/source/modules/makefile @@ -0,0 +1,29 @@ + +STUB_INC = -I "../../../../system/libmtk/include" +OUTDIR = ../../debug + +STUB_SOURCES_PATH = ./$(MODULE) +STUB_SOURCES = $(patsubst $(STUB_SOURCES_PATH)/%, %,$(wildcard $(STUB_SOURCES_PATH)/*.c)) +STUB_OBJS = $(patsubst %.c, $(OUTDIR)/%.o, $(STUB_SOURCES)) + +INC_PATH_LIST = $(patsubst "%",%,$(filter "%",$(STUB_INC))) +STUB_HEADER_LIST = $(filter-out %enum_list.h,$(foreach list, $(INC_PATH_LIST), $(wildcard $(list)/*.h))) + +ifeq ($(strip $(COMPILER)), GCC) +CC=arm-none-eabi-gcc.exe +AR=arm-none-eabi-ar.exe +STUBCFLAG=-c -fpic -fvisibility=hidden -mthumb -mcpu=arm7tdmi-s -mlittle-endian -O2 -D__MRE_COMPILER_GCC__ -fno-exceptions -fno-non-call-exceptions +STUBARFLAG=cr +endif + +INC=$(STUB_INC) +OBJECTS=$(STUB_OBJS) +VPATH=$(STUB_SOURCES_PATH) + +$(OUTDIR)/%.o: %.c $(STUB_HEADER_LIST) + @echo Compiling $< & + @$(CC) $(STUBCFLAG) $(INC) $< -o $@ + +$(MODULE).a: $(OBJECTS) + @echo Linking $@ & + @$(AR) $(STUBARFLAG)$(OUTDIR)/$(MODULE).a $(OBJECTS) diff --git a/hardware/arduino/mtk/variants/arduino_due_x/linker_scripts/gcc/scat.ld b/hardware/arduino/mtk/variants/arduino_due_x/linker_scripts/gcc/scat.ld new file mode 100644 index 00000000..56e73f6c --- /dev/null +++ b/hardware/arduino/mtk/variants/arduino_due_x/linker_scripts/gcc/scat.ld @@ -0,0 +1,134 @@ + +/* Script for --shared -z combreloc: shared library, combine & sort relocs */ +OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", + "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(gcc_entry) + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .rel.dyn : + { + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + *(.rel.iplt) + } + .rela.dyn : + { + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + *(.rela.iplt) + } + .rel.plt : + { + *(.rel.plt) + } + .rela.plt : + { + *(.rela.plt) + } + .init : + { + KEEP (*(.init)) + } =0 + .plt : { *(.plt) } + .iplt : { *(.iplt) } + .text : + { + *(.text.unlikely .text.*_unlikely) + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx) + } =0 + .fini : + { + KEEP (*(.fini)) + } =0 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } + PROVIDE_HIDDEN (__exidx_start = .); + .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } + PROVIDE_HIDDEN (__exidx_end = .); + .init_array : + { + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + } + .fini_array : + { + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + } + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } + .dynamic : { *(.dynamic) } + .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } + .data : + { + __data_start = . ; + *(.data .data.* .gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + _edata = .; PROVIDE (edata = .); + __bss_start = .; + __bss_start__ = .; + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. + FIXME: Why do we need it? When there is no .bss section, we don't + pad the .data section. */ + . = ALIGN(. != 0 ? 32 / 8 : 1); + } + _bss_end__ = . ; __bss_end__ = . ; + . = ALIGN(32 / 8); + . = ALIGN(32 / 8); + __end__ = . ; + _end = .; PROVIDE (end = .); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) } + .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } +} diff --git a/hardware/arduino/mtk/variants/arduino_due_x/pins_arduino.h b/hardware/arduino/mtk/variants/arduino_due_x/pins_arduino.h new file mode 100644 index 00000000..4e279aa7 --- /dev/null +++ b/hardware/arduino/mtk/variants/arduino_due_x/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/hardware/arduino/mtk/variants/arduino_due_x/variant.cpp b/hardware/arduino/mtk/variants/arduino_due_x/variant.cpp new file mode 100644 index 00000000..89d28c15 --- /dev/null +++ b/hardware/arduino/mtk/variants/arduino_due_x/variant.cpp @@ -0,0 +1,313 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Pins descriptions + */ +PinDescription g_APinDescription[]= +{ + { VM_DCL_HANDLE_INVALID, 10, PIO_END, 0 }, + { VM_DCL_HANDLE_INVALID, 11, PIO_END, 0 }, + { VM_DCL_HANDLE_INVALID, 46, PIO_END, 1 }, + { VM_DCL_HANDLE_INVALID, 13, PIO_END, 1 }, + { VM_DCL_HANDLE_INVALID, 47, PIO_END, 1 }, + { VM_DCL_HANDLE_INVALID, 49, PIO_END, 1 }, + { VM_DCL_HANDLE_INVALID, 45, PIO_END, 1 }, + { VM_DCL_HANDLE_INVALID, 50, PIO_END, 1 }, + { VM_DCL_HANDLE_INVALID, 48, PIO_END, 0 }, + { VM_DCL_HANDLE_INVALID, 19, PIO_END, 1 }, + { VM_DCL_HANDLE_INVALID, 26, PIO_END, 1 }, + { VM_DCL_HANDLE_INVALID, 28, PIO_END, 1 }, + { VM_DCL_HANDLE_INVALID, 29, PIO_END, 1 }, + { VM_DCL_HANDLE_INVALID, 27, PIO_END, 1 }, + { VM_DCL_HANDLE_INVALID, 0, PIO_END, 0 }, + { VM_DCL_HANDLE_INVALID, 1, PIO_END, 0 }, + { VM_DCL_HANDLE_INVALID, 2, PIO_END, 0 }, + { VM_DCL_HANDLE_INVALID, 3, PIO_END, 0 }, + { VM_DCL_HANDLE_INVALID, 44, PIO_END, 0 }, + { VM_DCL_HANDLE_INVALID, 43, PIO_END, 0 } +} ; + +#ifdef __cplusplus +} +#endif + +boolean changePinType(uint32_t ulPin, uint32_t ulPinType, VM_DCL_HANDLE* handle) +{ + VM_DCL_HANDLE gpio_handle; + + if (ulPin > PIO_MAX_NUM) + { + return false; + } + + + + if(g_APinDescription[ulPin].ulPinType == ulPinType && g_APinDescription[ulPin].ulHandle != VM_DCL_HANDLE_INVALID) + { + *handle = g_APinDescription[ulPin].ulHandle; + return true; + } + + *handle = VM_DCL_HANDLE_INVALID; + + if(ulPinType == PIO_DIGITAL) + { + if(g_APinDescription[ulPin].ulHandle != VM_DCL_HANDLE_INVALID) + { + vm_dcl_close(g_APinDescription[ulPin].ulHandle); + } + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[ulPin].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_0,NULL); + vm_dcl_close(gpio_handle); + } + else if(ulPinType == PIO_ANALOG) + { + if(g_APinDescription[ulPin].ulHandle != VM_DCL_HANDLE_INVALID) + { + vm_dcl_close(g_APinDescription[ulPin].ulHandle); + } + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[ulPin].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_2,NULL); + vm_dcl_close(gpio_handle); + } + else if(ulPinType == PIO_EINT) + { + if(g_APinDescription[ulPin].ulHandle != VM_DCL_HANDLE_INVALID) + { + vm_dcl_close(g_APinDescription[ulPin].ulHandle); + } + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[ulPin].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_2,NULL); + vm_dcl_close(gpio_handle); + } + else if(ulPinType == PIO_PWM) + { + if(g_APinDescription[ulPin].ulHandle != VM_DCL_HANDLE_INVALID) + { + vm_dcl_close(g_APinDescription[ulPin].ulHandle); + } + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[ulPin].ulGpioId); + + if(ulPin == 3) + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_3,NULL); + else + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_2,NULL); + + vm_dcl_close(gpio_handle); + } + else if(ulPinType == PIO_SPI) + { + for(int i = 10; i<14; i++) + { + if(g_APinDescription[i].ulHandle != VM_DCL_HANDLE_INVALID) + { + vm_dcl_close(g_APinDescription[i].ulHandle); + } + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[i].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_4,NULL); + vm_dcl_close(gpio_handle); + g_APinDescription[i].ulHandle = VM_DCL_HANDLE_INVALID; + + } + } + else if(ulPinType == PIO_UART) + { + for(int i = 0; i<2; i++) + { + if(g_APinDescription[i].ulHandle != VM_DCL_HANDLE_INVALID) + { + vm_dcl_close(g_APinDescription[i].ulHandle); + } + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[i].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_1,NULL); + vm_dcl_close(gpio_handle); + g_APinDescription[i].ulHandle = VM_DCL_HANDLE_INVALID; + + } + } + else if(ulPinType == PIO_I2C) + { + for(int i = 18; i<20; i++) + { + if(g_APinDescription[i].ulHandle != VM_DCL_HANDLE_INVALID) + { + vm_dcl_close(g_APinDescription[i].ulHandle); + } + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[i].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_1,NULL); + vm_dcl_close(gpio_handle); + g_APinDescription[i].ulHandle = VM_DCL_HANDLE_INVALID; + + } + } + else + { + return false; + } + + g_APinDescription[ulPin].ulPinType = (EPioType)ulPinType; + + return true; +} + +void spiPinsRest(void) +{ + int i; + VM_DCL_HANDLE gpio_handle; + + for(int i = 10; i<14; i++) + { + gpio_handle = vm_dcl_open(VM_DCL_GPIO, g_APinDescription[i].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_0,NULL); + vm_dcl_close(gpio_handle); + g_APinDescription[i].ulHandle = VM_DCL_HANDLE_INVALID; + g_APinDescription[i].ulPinType = PIO_DIGITAL; + } +} + +void setPinHandle(uint32_t ulPin, VM_DCL_HANDLE handle) +{ + g_APinDescription[ulPin].ulHandle = handle; +} + +/* + * UART objects + */ +RingBuffer rx_buffer1; +RingBuffer rx_buffer2; + +UARTClass Serial(1, &rx_buffer1); +UARTClass Serial1(2, &rx_buffer2); + +void serialEvent() __attribute__((weak)); +void serialEventRun(void) +{ + if (Serial.available()) + { + if(serialEvent) + { + serialEvent(); + } + } + if (Serial1.available()) + { + if(serialEvent) + { + serialEvent(); + } + } +} + +#ifdef __cplusplus +extern "C" { +#endif + +void init( void ) +{ +#if 0 + SystemInit(); + + // Set Systick to 1ms interval, common to all SAM3 variants + if (SysTick_Config(SystemCoreClock / 1000)) + { + // Capture error + while (true); + } + + // Disable watchdog + WDT_Disable(WDT); + + // Disable pull-up on every pin + for (int i = 0; i < PINS_COUNT; i++) + digitalWrite(i, LOW); + + // Enable parallel access on PIO output data registers + PIOA->PIO_OWER = 0xFFFFFFFF; + PIOB->PIO_OWER = 0xFFFFFFFF; + PIOC->PIO_OWER = 0xFFFFFFFF; + PIOD->PIO_OWER = 0xFFFFFFFF; + + // Initialize Serial port U(S)ART pins + PIO_Configure( + g_APinDescription[PINS_UART].pPort, + g_APinDescription[PINS_UART].ulPinType, + g_APinDescription[PINS_UART].ulPin, + g_APinDescription[PINS_UART].ulPinConfiguration); + digitalWrite(0, HIGH); // Enable pullup for RX0 + PIO_Configure( + g_APinDescription[PINS_USART0].pPort, + g_APinDescription[PINS_USART0].ulPinType, + g_APinDescription[PINS_USART0].ulPin, + g_APinDescription[PINS_USART0].ulPinConfiguration); + PIO_Configure( + g_APinDescription[PINS_USART1].pPort, + g_APinDescription[PINS_USART1].ulPinType, + g_APinDescription[PINS_USART1].ulPin, + g_APinDescription[PINS_USART1].ulPinConfiguration); + PIO_Configure( + g_APinDescription[PINS_USART3].pPort, + g_APinDescription[PINS_USART3].ulPinType, + g_APinDescription[PINS_USART3].ulPin, + g_APinDescription[PINS_USART3].ulPinConfiguration); + + // Initialize USB pins + PIO_Configure( + g_APinDescription[PINS_USB].pPort, + g_APinDescription[PINS_USB].ulPinType, + g_APinDescription[PINS_USB].ulPin, + g_APinDescription[PINS_USB].ulPinConfiguration); + + // Initialize CAN pins + PIO_Configure( + g_APinDescription[PINS_CAN0].pPort, + g_APinDescription[PINS_CAN0].ulPinType, + g_APinDescription[PINS_CAN0].ulPin, + g_APinDescription[PINS_CAN0].ulPinConfiguration); + PIO_Configure( + g_APinDescription[PINS_CAN1].pPort, + g_APinDescription[PINS_CAN1].ulPinType, + g_APinDescription[PINS_CAN1].ulPin, + g_APinDescription[PINS_CAN1].ulPinConfiguration); + + // Initialize Analog Controller + pmc_enable_periph_clk(ID_ADC); + adc_init(ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP_FAST); + adc_configure_timing(ADC, 0, ADC_SETTLING_TIME_3, 1); + adc_configure_trigger(ADC, ADC_TRIG_SW, 0); // Disable hardware trigger. + adc_disable_interrupt(ADC, 0xFFFFFFFF); // Disable all ADC interrupts. + adc_disable_all_channel(ADC); + + // Initialize analogOutput module + analogOutputInit(); +#endif +} + +#ifdef __cplusplus +} +#endif + diff --git a/hardware/arduino/mtk/variants/arduino_due_x/variant.h b/hardware/arduino/mtk/variants/arduino_due_x/variant.h new file mode 100644 index 00000000..6f5fba30 --- /dev/null +++ b/hardware/arduino/mtk/variants/arduino_due_x/variant.h @@ -0,0 +1,99 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_ARDUINO_DUE_X_ +#define _VARIANT_ARDUINO_DUE_X_ + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC 12000000 + +/** Master clock frequency */ +#define VARIANT_MCK 84000000 + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "Arduino.h" +#ifdef __cplusplus +#include "UARTClass.h" +#endif + + +static const uint8_t A0 = 14;/*analog input pin A0*/ +static const uint8_t A1 = 15;/*analog input pin A1*/ +static const uint8_t A2 = 16;/*analog input pin A2*/ +static const uint8_t A3 = 17;/*analog input pin A3*/ + +#ifdef __cplusplus +extern UARTClass Serial; +extern UARTClass Serial1; +#endif + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define SPI_INTERFACE SPI0 +#define SPI_INTERFACE_ID ID_SPI0 +#define SPI_CHANNELS_NUM 4 +#define PIN_SPI_SS0 (10) +#define PIN_SPI_SS1 (10) +#define PIN_SPI_SS2 (10) +#define PIN_SPI_SS3 (10) +#define PIN_SPI_MOSI (11) +#define PIN_SPI_MISO (12) +#define PIN_SPI_SCK (13) +#define BOARD_SPI_SS0 (10) +#define BOARD_SPI_SS1 (10) +#define BOARD_SPI_SS2 (10) +#define BOARD_SPI_SS3 PIN_SPI_SS3 +#define BOARD_SPI_DEFAULT_SS BOARD_SPI_SS3 + +#define BOARD_PIN_TO_SPI_PIN(x) \ + (x==BOARD_SPI_SS0 ? PIN_SPI_SS0 : \ + (x==BOARD_SPI_SS1 ? PIN_SPI_SS1 : \ + (x==BOARD_SPI_SS2 ? PIN_SPI_SS2 : PIN_SPI_SS3 ))) +#define BOARD_PIN_TO_SPI_CHANNEL(x) \ + (x==BOARD_SPI_SS0 ? 0 : \ + (x==BOARD_SPI_SS1 ? 1 : \ + (x==BOARD_SPI_SS2 ? 2 : 3))) + +static const uint8_t SS = BOARD_SPI_SS0; +static const uint8_t SS1 = BOARD_SPI_SS1; +static const uint8_t SS2 = BOARD_SPI_SS2; +static const uint8_t SS3 = BOARD_SPI_SS3; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + + +#endif /* _VARIANT_ARDUINO_DUE_X_ */ + diff --git a/hardware/arduino/mtk/variants/linkit_one/libmtk.a b/hardware/arduino/mtk/variants/linkit_one/libmtk.a new file mode 100644 index 00000000..4b3feb1e Binary files /dev/null and b/hardware/arduino/mtk/variants/linkit_one/libmtk.a differ diff --git a/hardware/arduino/mtk/variants/linkit_one/linker_scripts/gcc/scat.ld b/hardware/arduino/mtk/variants/linkit_one/linker_scripts/gcc/scat.ld new file mode 100644 index 00000000..56e73f6c --- /dev/null +++ b/hardware/arduino/mtk/variants/linkit_one/linker_scripts/gcc/scat.ld @@ -0,0 +1,134 @@ + +/* Script for --shared -z combreloc: shared library, combine & sort relocs */ +OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", + "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(gcc_entry) + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .rel.dyn : + { + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + *(.rel.iplt) + } + .rela.dyn : + { + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + *(.rela.iplt) + } + .rel.plt : + { + *(.rel.plt) + } + .rela.plt : + { + *(.rela.plt) + } + .init : + { + KEEP (*(.init)) + } =0 + .plt : { *(.plt) } + .iplt : { *(.iplt) } + .text : + { + *(.text.unlikely .text.*_unlikely) + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx) + } =0 + .fini : + { + KEEP (*(.fini)) + } =0 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } + PROVIDE_HIDDEN (__exidx_start = .); + .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } + PROVIDE_HIDDEN (__exidx_end = .); + .init_array : + { + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + } + .fini_array : + { + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + } + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } + .dynamic : { *(.dynamic) } + .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } + .data : + { + __data_start = . ; + *(.data .data.* .gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + _edata = .; PROVIDE (edata = .); + __bss_start = .; + __bss_start__ = .; + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. + FIXME: Why do we need it? When there is no .bss section, we don't + pad the .data section. */ + . = ALIGN(. != 0 ? 32 / 8 : 1); + } + _bss_end__ = . ; __bss_end__ = . ; + . = ALIGN(32 / 8); + . = ALIGN(32 / 8); + __end__ = . ; + _end = .; PROVIDE (end = .); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) } + .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } +} diff --git a/hardware/arduino/mtk/variants/linkit_one/pins_arduino.h b/hardware/arduino/mtk/variants/linkit_one/pins_arduino.h new file mode 100644 index 00000000..4e279aa7 --- /dev/null +++ b/hardware/arduino/mtk/variants/linkit_one/pins_arduino.h @@ -0,0 +1,21 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// API compatibility +#include "variant.h" + diff --git a/hardware/arduino/mtk/variants/linkit_one/variant.cpp b/hardware/arduino/mtk/variants/linkit_one/variant.cpp new file mode 100644 index 00000000..01dbc30b --- /dev/null +++ b/hardware/arduino/mtk/variants/linkit_one/variant.cpp @@ -0,0 +1,343 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Pins descriptions + */ +PinDescription g_APinDescription[]= +{ + { VM_DCL_HANDLE_INVALID, 10, PIO_END, 0 }, // 0 + { VM_DCL_HANDLE_INVALID, 11, PIO_END, 0 }, // 1 + { VM_DCL_HANDLE_INVALID, 46, PIO_END, 1 }, // 2 + { VM_DCL_HANDLE_INVALID, 13, PIO_END, 1 }, // 3 +#ifdef __LINKIT_V1__ + { VM_DCL_HANDLE_INVALID, 47, PIO_END, 1 }, // 4 + { VM_DCL_HANDLE_INVALID, 49, PIO_END, 1 }, // 5 + { VM_DCL_HANDLE_INVALID, 45, PIO_END, 1 }, // 6 +#else + { VM_DCL_HANDLE_INVALID, 40, PIO_END, 1 }, // 4 + { VM_DCL_HANDLE_INVALID, 3, PIO_END, 1 }, // 5 + { VM_DCL_HANDLE_INVALID, 25, PIO_END, 1 }, // 6 +#endif + { VM_DCL_HANDLE_INVALID, 50, PIO_END, 1 }, // 7 + { VM_DCL_HANDLE_INVALID, 48, PIO_END, 0 }, // 8 + { VM_DCL_HANDLE_INVALID, 19, PIO_END, 1 }, // 9 + { VM_DCL_HANDLE_INVALID, 26, PIO_END, 1 }, // 10 + { VM_DCL_HANDLE_INVALID, 28, PIO_END, 1 }, // 11 + { VM_DCL_HANDLE_INVALID, 29, PIO_END, 1 }, // 12 + { VM_DCL_HANDLE_INVALID, 27, PIO_END, 1 }, // 13 + { VM_DCL_HANDLE_INVALID, 0, PIO_END, 0 }, // 14 + { VM_DCL_HANDLE_INVALID, 1, PIO_END, 0 }, // 15 + { VM_DCL_HANDLE_INVALID, 2, PIO_END, 0 }, // 16 +#ifdef __LINKIT_V1__ + { VM_DCL_HANDLE_INVALID, 3, PIO_END, 0 }, // 17 +#else + { VM_DCL_HANDLE_INVALID, -1, PIO_END, 0 }, // 17 +#endif + { VM_DCL_HANDLE_INVALID, 44, PIO_END, 0 }, // 18 + { VM_DCL_HANDLE_INVALID, 43, PIO_END, 0 } // 19 +} ; + +#ifdef __cplusplus +} +#endif + +boolean changePinType(uint32_t ulPin, uint32_t ulPinType, VM_DCL_HANDLE* handle) +{ + VM_DCL_HANDLE gpio_handle; + + if (ulPin > PIO_MAX_NUM) + { + return false; + } + + + + if(g_APinDescription[ulPin].ulPinType == ulPinType && g_APinDescription[ulPin].ulHandle != VM_DCL_HANDLE_INVALID) + { + *handle = g_APinDescription[ulPin].ulHandle; + return true; + } + + *handle = VM_DCL_HANDLE_INVALID; + + if(ulPinType == PIO_DIGITAL) + { + if(g_APinDescription[ulPin].ulHandle != VM_DCL_HANDLE_INVALID) + { + vm_dcl_close(g_APinDescription[ulPin].ulHandle); + } + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[ulPin].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_0,NULL); + vm_dcl_close(gpio_handle); + } + else if(ulPinType == PIO_ANALOG) + { + if(g_APinDescription[ulPin].ulHandle != VM_DCL_HANDLE_INVALID) + { + vm_dcl_close(g_APinDescription[ulPin].ulHandle); + } + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[ulPin].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_2,NULL); + vm_dcl_close(gpio_handle); + } + else if(ulPinType == PIO_EINT) + { + if(g_APinDescription[ulPin].ulHandle != VM_DCL_HANDLE_INVALID) + { + vm_dcl_close(g_APinDescription[ulPin].ulHandle); + } + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[ulPin].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_2,NULL); + vm_dcl_close(gpio_handle); + } + else if(ulPinType == PIO_PWM) + { + if(g_APinDescription[ulPin].ulHandle != VM_DCL_HANDLE_INVALID) + { + vm_dcl_close(g_APinDescription[ulPin].ulHandle); + } + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[ulPin].ulGpioId); + + if(ulPin == 3) + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_3,NULL); + else + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_2,NULL); + + vm_dcl_close(gpio_handle); + } + else if(ulPinType == PIO_SPI) + { + for(int i = 11; i<14; i++) + { + if(g_APinDescription[i].ulHandle != VM_DCL_HANDLE_INVALID) + { + vm_dcl_close(g_APinDescription[i].ulHandle); + } + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[i].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_4,NULL); + vm_dcl_close(gpio_handle); + g_APinDescription[i].ulHandle = VM_DCL_HANDLE_INVALID; + + } + } + else if(ulPinType == PIO_UART) + { + for(int i = 0; i<2; i++) + { + if(g_APinDescription[i].ulHandle != VM_DCL_HANDLE_INVALID) + { + vm_dcl_close(g_APinDescription[i].ulHandle); + } + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[i].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_1,NULL); + vm_dcl_close(gpio_handle); + g_APinDescription[i].ulHandle = VM_DCL_HANDLE_INVALID; + + } + } + else if(ulPinType == PIO_I2C) + { + for(int i = 18; i<20; i++) + { + if(g_APinDescription[i].ulHandle != VM_DCL_HANDLE_INVALID) + { + vm_dcl_close(g_APinDescription[i].ulHandle); + } + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[i].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_1,NULL); + vm_dcl_close(gpio_handle); + g_APinDescription[i].ulHandle = VM_DCL_HANDLE_INVALID; + + } + } + else + { + return false; + } + + g_APinDescription[ulPin].ulPinType = (EPioType)ulPinType; + + return true; +} + +void spiPinsRest(void) +{ + int i; + VM_DCL_HANDLE gpio_handle; + + for(int i = 11; i<14; i++) + { + gpio_handle = vm_dcl_open(VM_DCL_GPIO, g_APinDescription[i].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_0,NULL); + vm_dcl_close(gpio_handle); + g_APinDescription[i].ulHandle = VM_DCL_HANDLE_INVALID; + g_APinDescription[i].ulPinType = PIO_DIGITAL; + } +} + +void setPinHandle(uint32_t ulPin, VM_DCL_HANDLE handle) +{ + g_APinDescription[ulPin].ulHandle = handle; +} + +/* + * UART objects + */ +RingBuffer rx_buffer1; +RingBuffer rx_buffer2; + +UARTClass Serial(1, &rx_buffer1); +UARTClass Serial1(2, &rx_buffer2); + +void serialEvent() __attribute__((weak)); +void serialEvent1() __attribute__((weak)); +void serialEventRun(void) +{ + if (Serial.available()) + { + if(serialEvent) + { + serialEvent(); + } + } + if (Serial1.available()) + { + if(serialEvent1) + { + serialEvent1(); + } + } +} + +#ifdef __cplusplus +extern "C" { +#endif + +void init( void ) +{ + int i; + VM_DCL_HANDLE gpio_handle; + + for(i=2;i<14;i++) + { + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[i].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_0,NULL); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_DIR_OUT, NULL); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_WRITE_LOW, NULL); + vm_dcl_close(gpio_handle); + } + for(i=18;i<20;i++) + { + gpio_handle = vm_dcl_open(VM_DCL_GPIO,g_APinDescription[i].ulGpioId); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_MODE_0,NULL); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_SET_DIR_OUT, NULL); + vm_dcl_control(gpio_handle,VM_GPIO_CMD_WRITE_LOW, NULL); + vm_dcl_close(gpio_handle); + } +#if 0 + SystemInit(); + + // Set Systick to 1ms interval, common to all SAM3 variants + if (SysTick_Config(SystemCoreClock / 1000)) + { + // Capture error + while (true); + } + + // Disable watchdog + WDT_Disable(WDT); + + // Disable pull-up on every pin + for (int i = 0; i < PINS_COUNT; i++) + digitalWrite(i, LOW); + + // Enable parallel access on PIO output data registers + PIOA->PIO_OWER = 0xFFFFFFFF; + PIOB->PIO_OWER = 0xFFFFFFFF; + PIOC->PIO_OWER = 0xFFFFFFFF; + PIOD->PIO_OWER = 0xFFFFFFFF; + + // Initialize Serial port U(S)ART pins + PIO_Configure( + g_APinDescription[PINS_UART].pPort, + g_APinDescription[PINS_UART].ulPinType, + g_APinDescription[PINS_UART].ulPin, + g_APinDescription[PINS_UART].ulPinConfiguration); + digitalWrite(0, HIGH); // Enable pullup for RX0 + PIO_Configure( + g_APinDescription[PINS_USART0].pPort, + g_APinDescription[PINS_USART0].ulPinType, + g_APinDescription[PINS_USART0].ulPin, + g_APinDescription[PINS_USART0].ulPinConfiguration); + PIO_Configure( + g_APinDescription[PINS_USART1].pPort, + g_APinDescription[PINS_USART1].ulPinType, + g_APinDescription[PINS_USART1].ulPin, + g_APinDescription[PINS_USART1].ulPinConfiguration); + PIO_Configure( + g_APinDescription[PINS_USART3].pPort, + g_APinDescription[PINS_USART3].ulPinType, + g_APinDescription[PINS_USART3].ulPin, + g_APinDescription[PINS_USART3].ulPinConfiguration); + + // Initialize USB pins + PIO_Configure( + g_APinDescription[PINS_USB].pPort, + g_APinDescription[PINS_USB].ulPinType, + g_APinDescription[PINS_USB].ulPin, + g_APinDescription[PINS_USB].ulPinConfiguration); + + // Initialize CAN pins + PIO_Configure( + g_APinDescription[PINS_CAN0].pPort, + g_APinDescription[PINS_CAN0].ulPinType, + g_APinDescription[PINS_CAN0].ulPin, + g_APinDescription[PINS_CAN0].ulPinConfiguration); + PIO_Configure( + g_APinDescription[PINS_CAN1].pPort, + g_APinDescription[PINS_CAN1].ulPinType, + g_APinDescription[PINS_CAN1].ulPin, + g_APinDescription[PINS_CAN1].ulPinConfiguration); + + // Initialize Analog Controller + pmc_enable_periph_clk(ID_ADC); + adc_init(ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP_FAST); + adc_configure_timing(ADC, 0, ADC_SETTLING_TIME_3, 1); + adc_configure_trigger(ADC, ADC_TRIG_SW, 0); // Disable hardware trigger. + adc_disable_interrupt(ADC, 0xFFFFFFFF); // Disable all ADC interrupts. + adc_disable_all_channel(ADC); + + // Initialize analogOutput module + analogOutputInit(); +#endif +} + +#ifdef __cplusplus +} +#endif + diff --git a/hardware/arduino/mtk/variants/linkit_one/variant.h b/hardware/arduino/mtk/variants/linkit_one/variant.h new file mode 100644 index 00000000..e01dd821 --- /dev/null +++ b/hardware/arduino/mtk/variants/linkit_one/variant.h @@ -0,0 +1,104 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_ARDUINO_DUE_X_ +#define _VARIANT_ARDUINO_DUE_X_ + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC 12000000 + +/** Master clock frequency */ +#define VARIANT_MCK 84000000 + +//#define __LINKIT_V1__ + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "Arduino.h" +#ifdef __cplusplus +#include "UARTClass.h" +#endif + + +static const uint8_t A0 = 14;/*analog input pin A0*/ +static const uint8_t A1 = 15;/*analog input pin A1*/ +static const uint8_t A2 = 16;/*analog input pin A2*/ + +#ifdef __LINKIT_V1__ +static const uint8_t A3 = 17;/*analog input pin A3*/ +#endif + +#ifdef __cplusplus +extern UARTClass Serial; +extern UARTClass Serial1; +#endif + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define SPI_INTERFACE SPI0 +#define SPI_INTERFACE_ID ID_SPI0 +#define SPI_CHANNELS_NUM 4 +#define PIN_SPI_SS0 (10) +#define PIN_SPI_SS1 (10) +#define PIN_SPI_SS2 (10) +#define PIN_SPI_SS3 (10) +#define PIN_SPI_MOSI (11) +#define PIN_SPI_MISO (12) +#define PIN_SPI_SCK (13) +#define BOARD_SPI_SS0 (10) +#define BOARD_SPI_SS1 (10) +#define BOARD_SPI_SS2 (10) +#define BOARD_SPI_SS3 PIN_SPI_SS3 +#define BOARD_SPI_DEFAULT_SS BOARD_SPI_SS3 + +#define BOARD_PIN_TO_SPI_PIN(x) \ + (x==BOARD_SPI_SS0 ? PIN_SPI_SS0 : \ + (x==BOARD_SPI_SS1 ? PIN_SPI_SS1 : \ + (x==BOARD_SPI_SS2 ? PIN_SPI_SS2 : PIN_SPI_SS3 ))) +#define BOARD_PIN_TO_SPI_CHANNEL(x) \ + (x==BOARD_SPI_SS0 ? 0 : \ + (x==BOARD_SPI_SS1 ? 1 : \ + (x==BOARD_SPI_SS2 ? 2 : 3))) + +static const uint8_t SS = BOARD_SPI_SS0; +static const uint8_t SS1 = BOARD_SPI_SS1; +static const uint8_t SS2 = BOARD_SPI_SS2; +static const uint8_t SS3 = BOARD_SPI_SS3; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + + +#endif /* _VARIANT_ARDUINO_DUE_X_ */ + diff --git a/hardware/tools/mtk/FirmwareUpdater.exe b/hardware/tools/mtk/FirmwareUpdater.exe new file mode 100644 index 00000000..1652adf3 Binary files /dev/null and b/hardware/tools/mtk/FirmwareUpdater.exe differ diff --git a/hardware/tools/mtk/PackTag.exe b/hardware/tools/mtk/PackTag.exe new file mode 100644 index 00000000..762790c4 Binary files /dev/null and b/hardware/tools/mtk/PackTag.exe differ diff --git a/hardware/tools/mtk/PushTool.exe b/hardware/tools/mtk/PushTool.exe new file mode 100644 index 00000000..048b446e Binary files /dev/null and b/hardware/tools/mtk/PushTool.exe differ diff --git a/hardware/tools/mtk/firmware/Download_Agent/6261/EXT_RAM b/hardware/tools/mtk/firmware/Download_Agent/6261/EXT_RAM new file mode 100644 index 00000000..d322f0bf Binary files /dev/null and b/hardware/tools/mtk/firmware/Download_Agent/6261/EXT_RAM differ diff --git a/hardware/tools/mtk/firmware/Download_Agent/6261/INT_SYSRAM b/hardware/tools/mtk/firmware/Download_Agent/6261/INT_SYSRAM new file mode 100644 index 00000000..82a20f91 Binary files /dev/null and b/hardware/tools/mtk/firmware/Download_Agent/6261/INT_SYSRAM differ diff --git a/hardware/tools/mtk/firmware/Download_Agent/6261/NAND_FLASH_TABLE b/hardware/tools/mtk/firmware/Download_Agent/6261/NAND_FLASH_TABLE new file mode 100644 index 00000000..9e3cda77 Binary files /dev/null and b/hardware/tools/mtk/firmware/Download_Agent/6261/NAND_FLASH_TABLE differ diff --git a/hardware/tools/mtk/firmware/Download_Agent/6261/NOR_FLASH_TABLE b/hardware/tools/mtk/firmware/Download_Agent/6261/NOR_FLASH_TABLE new file mode 100644 index 00000000..47f4e91d Binary files /dev/null and b/hardware/tools/mtk/firmware/Download_Agent/6261/NOR_FLASH_TABLE differ diff --git a/hardware/tools/mtk/firmware/Download_Agent/Need DA version v5.1416 b/hardware/tools/mtk/firmware/Download_Agent/Need DA version v5.1416 new file mode 100644 index 00000000..e69de29b diff --git a/hardware/tools/mtk/firmware/Downloader.exe b/hardware/tools/mtk/firmware/Downloader.exe new file mode 100644 index 00000000..3a5b3de7 Binary files /dev/null and b/hardware/tools/mtk/firmware/Downloader.exe differ diff --git a/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/ALICE b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/ALICE new file mode 100644 index 00000000..2822607d Binary files /dev/null and b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/ALICE differ diff --git a/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/ALICE.bin b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/ALICE.bin new file mode 100644 index 00000000..e40614aa Binary files /dev/null and b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/ALICE.bin differ diff --git a/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/EXT_BOOTLOADER b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/EXT_BOOTLOADER new file mode 100644 index 00000000..1d9e079e Binary files /dev/null and b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/EXT_BOOTLOADER differ diff --git a/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/ROM b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/ROM new file mode 100644 index 00000000..6e768bb3 Binary files /dev/null and b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/ROM differ diff --git a/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/SEEED02A_DEMO_BB.cfg b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/SEEED02A_DEMO_BB.cfg new file mode 100644 index 00000000..092c1a7c --- /dev/null +++ b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/SEEED02A_DEMO_BB.cfg @@ -0,0 +1,81 @@ +############################################################################################################ +# +# General Setting +# +############################################################################################################ + +general: + config_version : alpha # config file version ("alpha", "beta" is used before SQC done.) + # After SQC done, the version should be "1" for the first release version. + platform: MT2502 # It is used for tool to identify the right setting for specific target + +############################################################################################################ +# +# Boot Region Setting +# +############################################################################################################ + +boot_region: + alignment: block # block[default], page(NAND:2K/512B, NOR: 1KB, eMMC: 512B, SF: 256B) + rom: + - file: SEEED02A_DEMO_BOOTLOADER_V005_MT2502_MAUI_LINKIT_ONE_DEV_W14_35.bin + - file: EXT_BOOTLOADER + +############################################################################################################ +# +# Control Block Region Setting +# +############################################################################################################ + +control_block_region: + rom: + + +############################################################################################################ +# +# Main Region Setting +# +############################################################################################################ + +main_region: + alignment: block # block[default], page(NAND:2K/512B, NOR: 1KB, eMMC: 512B, SF: 256B) + rom: + - file: ROM + - file: VIVA + +############################################################################################################ +# +# File System Region Setting +# +############################################################################################################ + +file_system_region: + rom: + + +############################################################################################################ +# +# External Memory Setting +# +############################################################################################################ + +external_memory: + parameters_version: v1 + parameters: + # EMI 1 + - flash_info: + flash_type: SF + id_length: 3 + flash_id: [0xC2, 0x25, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00] + memory_type: PSRAM_130MHz + EMI_Setting: + + # EMI 2 + - flash_info: + flash_type: SF + id_length: 3 + flash_id: [0xEF, 0x60, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00] + memory_type: PSRAM_130MHz + EMI_Setting: + + diff --git a/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/SEEED02A_DEMO_BOOTLOADER_V005_MT2502_MAUI_LINKIT_ONE_DEV_W14_35.bin b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/SEEED02A_DEMO_BOOTLOADER_V005_MT2502_MAUI_LINKIT_ONE_DEV_W14_35.bin new file mode 100644 index 00000000..52cf532c Binary files /dev/null and b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/SEEED02A_DEMO_BOOTLOADER_V005_MT2502_MAUI_LINKIT_ONE_DEV_W14_35.bin differ diff --git a/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/VIVA b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/VIVA new file mode 100644 index 00000000..133058a7 Binary files /dev/null and b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/VIVA differ diff --git a/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/VIVA.bin b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/VIVA.bin new file mode 100644 index 00000000..1960f21d Binary files /dev/null and b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/VIVA.bin differ diff --git a/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/backup/ROM.orig b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/backup/ROM.orig new file mode 100644 index 00000000..a144c517 Binary files /dev/null and b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/backup/ROM.orig differ diff --git a/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/backup/VIVA.orig b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/backup/VIVA.orig new file mode 100644 index 00000000..dcab246a Binary files /dev/null and b/hardware/tools/mtk/firmware/LinkIt_ONE/1.0.29/backup/VIVA.orig differ diff --git a/psvince.dll b/psvince.dll new file mode 100644 index 00000000..e910509d Binary files /dev/null and b/psvince.dll differ diff --git a/unins000.dat b/unins000.dat new file mode 100644 index 00000000..cdfa807b Binary files /dev/null and b/unins000.dat differ diff --git a/unins000.exe b/unins000.exe new file mode 100644 index 00000000..9990166f Binary files /dev/null and b/unins000.exe differ