Modem.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /********************************************************************************
  2. * File Name: Modem.h
  3. * Function Describe: Header file for Modem.c
  4. * Explain:
  5. * Writer: ShiLiangWen
  6. * Date: 2015-1-30
  7. *******************************************************************************/
  8. #ifndef __MODEM_H
  9. #define __MODEM_H
  10. /***********************************************************************************/
  11. #include <rtl.h>
  12. //Modem Power Ctrl
  13. #define MODEM_PWREN_PIN GPIO_Pin_1
  14. #define MODEM_PWREN_PORT GPIOB
  15. #define MODEM_PWREN_ENABLE MODEM_PWREN_PORT->BSRR = MODEM_PWREN_PIN
  16. #define MODEM_PWREN_DISABLE MODEM_PWREN_PORT->BRR = MODEM_PWREN_PIN
  17. //Modem Power Key
  18. #define MODEM_PWRKEY_PIN GPIO_Pin_6
  19. #define MODEM_PWRKEY_PORT GPIOB
  20. #define MODEM_PWRKEY_HIGH MODEM_PWRKEY_PORT->BRR = MODEM_PWRKEY_PIN
  21. #define MODEM_PWRKEY_LOW MODEM_PWRKEY_PORT->BSRR = MODEM_PWRKEY_PIN
  22. //Modem Reset
  23. #define MODEM_RESET_PIN GPIO_Pin_7
  24. #define MODEM_RESET_PORT GPIOB
  25. #define MODEM_RESET_HIGH MODEM_RESET_PORT->BRR = MODEM_RESET_PIN
  26. #define MODEM_RESET_LOW MODEM_RESET_PORT->BSRR = MODEM_RESET_PIN
  27. typedef enum {TIMEOUT=-1,SUCCEED=0,FAIL=1} M_RESULT;
  28. typedef enum {INVALID=0, OPENED=1,CLOSED=2} M_STATUE;
  29. //#define MODEM_POC_MSG_DATA_LEN 100
  30. //typedef struct{
  31. // unsigned short MsgLen;
  32. // unsigned char MsgData[MODEM_POC_MSG_DATA_LEN];
  33. //}SUT_MODEM_POC_MSG;
  34. #define MODEM_AT_MSG_DATA_LEN 255
  35. typedef struct{
  36. unsigned short MsgLen;
  37. unsigned char MsgData[MODEM_AT_MSG_DATA_LEN];
  38. }SUT_MODEM_AT_MSG;
  39. typedef void (*ModemAtHandle)(char *msg,unsigned short msglen);
  40. extern OS_MBX AtMsgBox;
  41. extern U32 AtMpool[];
  42. #define MODEM_AT_MSG_BUF 1300
  43. extern char ModemMsgBuf[MODEM_AT_MSG_BUF];
  44. char* strchrN(const char *str,char ch,int n);
  45. int GetSubFromStr(char *str,int n,char *val,unsigned short vallen);
  46. void ModemDelayAndDiscardMsg(int time);
  47. M_RESULT ModemSendToSocket(unsigned char socket,unsigned char *pData,unsigned short len);
  48. M_RESULT ModemGetCCID(char *pCCID);
  49. M_RESULT ModemGetCardStatus(void);
  50. M_RESULT ModemGetIMEI(char *pIMEI);
  51. M_RESULT WaitingForCReg(int second);
  52. M_RESULT ModemGetCSQ(unsigned char *CSQ);
  53. void ModemPowerOff(void);
  54. M_RESULT ModemGetPDP(void);
  55. M_RESULT ModemOpenPDP(void);
  56. M_RESULT ModemQueryPDP(void);
  57. M_RESULT ModemClosePDP(void);
  58. M_RESULT ModemGetSocket(int socket,int timeout);
  59. M_RESULT ModemOpenSocket(int socket,char *tcp_udp,char *server,unsigned short Port);
  60. M_RESULT ModemCloseSocket(int socket);
  61. M_RESULT ModemSetAPN(char *pApn,char *pUsrName, char *pUsrPass);
  62. M_RESULT ModemWaitOpened(int times);
  63. M_RESULT ModemInit(void);
  64. void ModemReboot(int t);
  65. void ModemSetAtResHandle(ModemAtHandle AtResHandle);
  66. int ModemStrCmp(char *msg,char *str);
  67. void ModemSendAT(char *p);
  68. M_RESULT ModemSetATE0(void);
  69. M_RESULT ModemGetIPbyDNS(char *Demain,unsigned char IP[4]);
  70. M_RESULT ModemSendToUdpSocket(unsigned char socket,unsigned char *pData,unsigned short len);
  71. #endif
  72. /***********************************************************************************/