b.liu | b17525e | 2025-05-14 17:22:29 +0800 | [diff] [blame] | 1 | #include <stdlib.h>
|
| 2 | #include <stdint.h>
|
| 3 | #include <string.h>
|
| 4 | #include <stdbool.h>
|
| 5 |
|
| 6 | #define GSW_HAL_SMS_ADDRESS_LEN 16
|
| 7 | #define GSW_HAL_SMS_RECV_CONT_MAX 1024
|
| 8 | #define GSW_HAL_SMS_CONTENT_LEN 1024
|
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame^] | 9 |
|
b.liu | b17525e | 2025-05-14 17:22:29 +0800 | [diff] [blame] | 10 |
|
| 11 | // gsw include
|
| 12 |
|
| 13 | #define GSW_HAL_SUCCESS 0
|
| 14 | #define GSW_HAL_FAIL -1
|
| 15 | #define GSW_HAL_MEM_INVAILD -2
|
| 16 |
|
| 17 | typedef enum gsw_hal_sms_state
|
| 18 | {
|
| 19 | GSW_SMS_FULL_FLG, /**< sms full flag*/
|
| 20 | GSW_SMS_RECEIVED_FLG, /**<recv new sms flag*/
|
| 21 | } gsw_hal_sms_state_e;
|
| 22 |
|
| 23 | typedef enum gsw_hal_sms_format
|
| 24 | {
|
| 25 | SMS_FORMAT_GSM_7BIT = 0, /**< 7bit econde*/
|
| 26 | SMS_FORMAT_BINARY_DATA = 1, /**< 8bit binary encode*/
|
| 27 | SMS_FORMAT_UCS2 = 2, /**< ucs2 encode*/
|
| 28 | } gsw_hal_sms_format_e;
|
| 29 |
|
| 30 | typedef struct gsw_hal_sms_date
|
| 31 | {
|
| 32 | uint8_t year[5]; /**< year of date*/
|
| 33 | uint8_t month[3]; /**< month of date*/
|
| 34 | uint8_t day[3]; /**< day of date*/
|
| 35 | uint8_t hour[3]; /**< hour of time*/
|
| 36 | uint8_t minutes[3]; /**< minute of time*/
|
| 37 | uint8_t seconds[3]; /**< second of time*/
|
| 38 | uint8_t timezone[4]; /**< timezone*/
|
| 39 | } gsw_hal_sms_date_s;
|
| 40 |
|
| 41 | typedef struct gsw_hal_sms_msg_type
|
| 42 | {
|
| 43 | int8_t src_num[GSW_HAL_SMS_ADDRESS_LEN+1]; /**< sms phone num send msg*/
|
| 44 | int8_t dest_num[GSW_HAL_SMS_ADDRESS_LEN + 1]; /**< sms phone num recv msg*/
|
| 45 | gsw_hal_sms_format_e content_encode; /**< sms content is 7bit or 8bit or Ucs2 encode*/
|
| 46 | uint32_t content_len; /**< sms content size*/
|
| 47 | int8_t content[GSW_HAL_SMS_RECV_CONT_MAX + 1]; /**< sms content*/
|
| 48 | gsw_hal_sms_date_s date; /**< message time*/
|
| 49 | } gsw_hal_sms_msg_type_s;
|
| 50 |
|
| 51 | typedef void (* GSW_HAL_SMS_CALLBACK_FUN)(gsw_hal_sms_state_e state, gsw_hal_sms_msg_type_s *report_info);
|
| 52 |
|
| 53 | /**
|
| 54 | * @brief SDK interface to call back sms messages
|
| 55 | * @param [in] handle_ptr
|
| 56 | * @retval 0: success
|
| 57 | * @retval other: fail
|
| 58 | */
|
| 59 | int gsw_sms_reg_callback(GSW_HAL_SMS_CALLBACK_FUN handle_ptr);
|
| 60 |
|
| 61 | /**
|
| 62 | * @brief sms sdk init
|
| 63 | * @param [in] token
|
| 64 | * @retval 0: success
|
| 65 | * @retval other: fail
|
| 66 | */
|
| 67 | int gsw_sms_sdk_init(int32_t token);
|
| 68 |
|
| 69 | /**
|
| 70 | * @brief sms sdk deinit
|
| 71 | * @param
|
| 72 | * @retval 0: success
|
| 73 | * @retval other: fail
|
| 74 | */
|
| 75 | int gsw_sms_sdk_deinit(void);
|
| 76 |
|
| 77 | /**
|
| 78 | * @brief send sms fuction *
|
| 79 | * @param [in] phone_num dest phone num send sms
|
| 80 | * @param [in] char_set encode format for sms 0 7bit 1 binary 2 usc2
|
| 81 | * @param [in] msg sms content
|
| 82 | * @param [in] msg_len send sms length,max is 1024
|
| 83 | * @retval 0: success
|
| 84 | * @retval other: fail
|
| 85 | */
|
| 86 | int gsw_send_sms(int8_t *phone_num, int32_t char_set, int8_t *msg, int32_t msg_len);
|
| 87 |
|
| 88 | /**
|
| 89 | * @brief get smsc fuction *
|
| 90 | * @param [in] len input buf len for smsc,max is 32
|
| 91 | * @param [out] smsc address for smsc get from this func *
|
| 92 | * @retval 0: success
|
| 93 | * @retval other: fail
|
| 94 | */
|
| 95 | int gsw_get_smsc_address(int32_t len, int8_t *smsc);
|
| 96 |
|
| 97 | /**
|
| 98 | * @brief set smsc fuction
|
| 99 | * @param [out] smsc string value for smsc,max length is 32 *
|
| 100 | * @retval 0: success
|
| 101 | * @retval other: fail
|
| 102 | */
|
| 103 | int gsw_set_smsc_address(const int8_t *smsc); |