/* * This file is part of Generic-gsm. * * Generic-gsm is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Generic-gsm 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Generic-gsm; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * No rights reserved. This code is public domain. * * Peter Harper * * $Id: generic-gsm.h,v 1.1 2003/12/02 06:17:38 rmello Exp $ */ #include #include #include #ifndef _GENERICGSM_POCKET_H #define _GENERICGSM_POCKET_H /* * Define inter-pipe messages. Note that any messages with a value of * > 100, are considered state-changes (see below). */ #define GENERICGSM_ONLINE 0 #define GENERICGSM_OFFLINE 1 #define GENERICGSM_DELETE 2 #define GENERICGSM_UPDATE 3 #define GENERICGSM_CONNECTED 10 #define GENERICGSM_DISCONNECTED 11 #define GENERICGSM_GROUP_ACTIVITY 12 /* * Define message states. * Currently all the state change is hardcoded in switches and code logic. * This would be better done by defining a data-driven state machine. */ /* idle */ #define GSMSTATE_IDLE 100 /* ate0 */ #define GSMSTATE_ATE0 105 #define GSMSTATE_ATE0_ATE0 106 #define GSMSTATE_ATE0_OK 107 /* cpin */ #define GSMSTATE_CPIN 108 #define GSMSTATE_CPIN_OK 109 /* csca */ #define GSMSTATE_CSCA 110 #define GSMSTATE_CSCA_OK 111 /* cmgf */ #define GSMSTATE_CMGF 115 #define GSMSTATE_CMGF_OK 116 /* scrt */ #define GSMSTATE_CNMI 120 #define GSMSTATE_CNMI_OK 121 /* cmgs */ #define GSMSTATE_CMGS 125 #define GSMSTATE_CMGS_ARROW 126 #define GSMSTATE_CMGS_MESSAGE 127 #define GSMSTATE_CMGS_RESP 128 #define GSMSTATE_CMGS_OK 129 /* cmgl */ #define GSMSTATE_CMGL 130 #define GSMSTATE_CMGL_DATA 131 /* cmgd */ #define GSMSTATE_CMGD 135 #define GSMSTATE_CMGD_OK 136 #define GSMSTATE_FAILED_SYNC 200 #define GENERICGSM_MAX_BEFORE_READ 5 // #define Version "1.1" /* * Generic Gsm link datastructure */ struct generic_gsm_link { char link_id[20]; char device[1024]; int device_timeout_secs; char service_centre[1024]; char msisdn[1024]; char sim_pin[1024]; int poll_time_secs; int post_send_delay_usecs; unsigned char old_status; unsigned char status; unsigned char link_status; struct q_group *in_group_ptr; struct q_group *out_group_ptr; SOCKET msg_pipe[2]; int sock; struct termios tty; int non_read_count; struct q_message *msg_ptr; struct smsq_sms_submit *payload_ptr; int failed_sync_status; int cmgl_status; char cmgl_text[1024]; char cmgl_msg_num[128]; char cmgl_msisdn[128]; Tcl_HashTable cmgd_ids; Tcl_HashEntry *cmgd_search_ptr; int sent_wait_count; int use_pdu_p; unsigned char pdu_string[1024]; int pdu_length; int max_retries; }; /* * Function prototypes. */ static int generic_gsm_init(char *link_id, struct q_group *in_group_ptr, struct q_group *out_group_ptr, int status, char *device, int device_timeout_secs, char *service_centre, char *sim_pin, int poll_time_secs, int post_send_delay_usecs, int use_pdu_p, int max_retries, char *msisdn); static int generic_gsm_delete(struct generic_gsm_link *link_ptr); static int generic_gsm_set_status(struct generic_gsm_link *link_ptr, int status); static int generic_gsm_update(struct generic_gsm_link *link_ptr, char *device, int device_timeout_secs, char *service_centre, char *sim_pin, int poll_time_secs, int post_send_delay_usecs, int use_pdu_p, int max_retries, char *msisdn); static int generic_gsm_link_execute(struct generic_gsm_link *link_ptr); static void generic_gsm_link_reader(void *arg); static void generic_gsm_link_event_handler(void *arg); static void generic_gsm_encode_pdu(unsigned char *pdu_string_ptr, int *pdu_length, struct generic_gsm_link *link_ptr); static void generic_gsm_decode_pdu(unsigned char *pdu_string_ptr, char *msisdn_ptr, unsigned char *msg_data_ptr, int *msg_data_size_ptr, int *unpacked_size_ptr, int *data_coding_scheme, struct smsc_tm *smsc_timestamp_ptr); static void generic_gsm_byteswap(char *in_string_ptr, char *out_string_ptr); #endif