CRYSTAL COMMUNICATION SDN BHD (306943 T)

Homepage

                   

About us

 

Content:

Manufacturing

- Telephone

- Smart card

- GPS

- CD

 

R&D

- Smart card

- PCB prototype

- Micro controller

- Electronics Design

 

International

- Sales office

 

Software

Caller ID

800MHz Cellular

1.2GHz Cellular

 

Specification

- Telephone

- CD

- Smart card

- GPS

 

Contact us:

[email protected]

 

 

Project cellular phone 1.2 ghz software

 

*********************************************
* Project : 1.2GHz Cellular phone by: HASSAN E *
* Microcontroller: XXX  Date :01-01-02 *
* Version No : 1.0 Release : 1.0 *
* This Program is the property of Crystal Communication with its regd. office, *
* Crystal Communication *
* Lot 8 *
* Putra World Trade Centre *
*41 Jln Tun Ismail*
* 50480, Kuala Lumpur, *
* MALAYSIA *
* and is protected by Copyright Protection Act of Malaysia. *
* It shall not be Copied or Modified or Circulated or Reproduced or *
* Duplicated by whatsoever means, Optical or Magnetic or Hardcopy or *
* Electrical or Electro-mechanical or Photographic without the prior *
* written permission and approval of Crystal Communication. *
*********************************************
#include "def.h"


/* displayed messages in module m.c */

extern code unsigned char lock2_d, code_d, lowbattd;
extern code unsigned char fulld, mute_d, ready_a, ready_b;
extern code unsigned char pwron_d, absmode;
extern code unsigned char touch_d, no_outd, no_longd, upldone, dwldone;
extern code unsigned char passw2[];


/* bits defined in modele asb.asm or esb.asm */

extern bit b_busy; /* mobile busy bit */


/* data defined in module in modele ab1.asm or eb1.asm */

extern data char cbstatus;
extern data char dtmfcode;


/* external data defined in module ad.asm or ed.asm */

extern xdata unsigned char scn_con, cond, sec_con, n1, pre_key, roam_st;
extern xdata unsigned char st_key, amode, counter1;
extern xdata unsigned char fcn_cd, b_cnt;
extern xdata unsigned char *source, *dest;
extern xdata int dest_st;
extern xdata unsigned char phone[], asc_ph[], last_ph[], strage[];
extern xdata int i, stor, numm, num2, num3, num4, rssi, secu_num;

extern xdata unsigned char state;
extern xdata unsigned char pre_cond;
extern xdata unsigned char alphfg;
extern xdata unsigned char alphdelf;
extern xdata unsigned char alphrclf;
extern xdata unsigned char entalph;
extern xdata unsigned char lastalph;
extern xdata unsigned char alphcnt;
extern xdata int phoneptr;
extern xdata unsigned char lock_act;
extern xdata int lock_cnt;
extern xdata unsigned char savlink;
extern xdata unsigned char outgof;
extern xdata unsigned char linkptr;
extern xdata unsigned char lstlink;
extern xdata unsigned char id_stat[64];
extern xdata unsigned char rclstolk;
extern xdata unsigned char stolinkf;
extern xdata unsigned char tmpsavl;
extern xdata int dial_off;
extern xdata unsigned char don_mute;
extern xdata unsigned char mute_cnt;
extern xdata unsigned char ss_stat;
extern xdata unsigned char sigpath;
extern xdata unsigned char dtmf_dig;
extern xdata unsigned char key;
extern xdata unsigned char techsub;

extern xdata unsigned char ancode;
extern xdata unsigned char *msgptr;
extern xdata unsigned char bar_case;
extern xdata unsigned char lite_fg;
extern xdata unsigned char fdbk_f;

extern xdata unsigned char *iocb_ptr;
extern xdata int loc_cnt;
extern xdata unsigned char idcnt;

extern xdata unsigned char indx;
extern xdata unsigned char cnumram[], id_ptr[], linknum[];

extern xdata unsigned char *ptr_id1, *ptr_id2, *ptr_tph, *ptr_num;
extern xdata unsigned char *ptr_tid, *ptr_link, *ptr_np1, *ptr_bnp1, *ptr_np2;
extern xdata unsigned char id1, id2, grp_act, tphcnt, tidcnt;
extern xdata unsigned char np1, bnp1, np2, wnv_act, wnv_del;
extern xdata unsigned char tphone[16], tid[16];
extern xdata int savnumm;
extern xdata unsigned char owner[8], sys_stat;
extern xdata unsigned char lph1[], lph1_nv1[], freemesd[], meslen[];
extern xdata unsigned char mute_fg;
extern xdata unsigned char msgin_fg, num_msg, mscalcnt, scr_stat, accept_f;
extern xdata unsigned char absent_f, calin_fg, num_cal, dtmfidx, n_dtmf;
extern xdata unsigned char freephd[], phactive[], autophon[];
extern xdata unsigned char srxbuff[], stxbuff[], pmesbuf[], ikeybuf[];
extern xdata unsigned char rec_byte, tra_byte, srxcnt, stxcnt;
extern xdata unsigned char stxindx, chksum, pmescnt, pmes_fg;
extern xdata unsigned char wim_fg, device, wcntmes, wrt_type;
extern xdata unsigned char *ptr_twm;
extern xdata unsigned char ikeycnt, iidx, ioff, ikeyidx, dumb_fg;
extern xdata unsigned char hltone_f, hldelcnt, abs_dcnt;
extern xdata unsigned char rmlock_f, sbyterml, nlock, lockbuf[], fgdat_nv[];
extern xdata unsigned char load_f, canld_f, packcnt, stxc_sav;
extern xdata unsigned char *load_ptr;
extern xdata unsigned char sstat_nv, flagdata[];


/* conversion table for incoming key from serial port */

code unsigned char ikcv2hk[23] = { 10,14,7,0,15,8,1,16,9,2,0xff,
17,3,13,6,19,18,11,4,20,12,5,21};



/* generate high or low tone */

hltone_g()
{
s_rxmute(); /* set rx audio mute */
sigpath = (sigpath & 0x3b) | 0x22;
/* enable tone transmission */
gen_dtmf(); /* generate tone */
s_dtmffg(); /* set dtmf on flag */
hltone_f = 1; /* set high or low enable */
}

/* generate tone 770 hz */

genltone()
{
dtmf_dig = 13; /* low tone 770 hz */
hltone_g(); /* generate this tone */
}


/* check for output 770 hz tone or 1209 hz tone */

hltone_o()
{
if ( sbyterml == STAR )
genltone(); /* generate tone 770 hz */
else
genhtone(); /* generate tone 1209 hz */
}


/* clear remote lock sequence data */

clr_linf()
{
rmlock_f = 0; /* clear remote lock start */
sbyterml = 0; /* clear second byte of remote lock sequence */
nlock = 0; /* clear number lock byte count */
}


/* This routine is called from the low level routine */
/* to check the remote sequence for lock or for unlock */
/* */
/* return code in r5r6 : 0 valid dtmf number */
/* 1 invalid dtmf number */

chk_rmot()
{
if ( rmlock_f ) /* check remote lock start */
{
if ( !sbyterml ) /* check the second byte of remote lock squence receive */
{
if ( dtmfcode > 10 )
{
sbyterml = dtmfcode;
hltone_o(); /* check for output 770 hz tone or 1209 hz tone */
hldelcnt = 10; /* timeout for 0.5 sec */
}
else
{
rmlock_f = 0; /* clear remote lock start */
return(0);
}
}
else
{
if ( nlock == 4 )
{
num3 = (int)lockbuf[3] + ((int)lockbuf[2] * 10) + ((int)lockbuf[1] * 100) + ((int)lockbuf[0] * 1000);

if ( (dtmfcode == NUM) && !(num3 - secu_num) ) /* valid lock code */
{
if ( sbyterml == STAR )
outgof = 1; /* no outgoing */
else
outgof = 0; /* ok outgoing */
fgdat_nv[8] = outgof; /* update outgoing flag in nvram */
wnv_del = 2; /* delay for 10 msec to write the next */
wnv_act = 1; /* set write nvram active */
hltone_o(); /* check for output 770 hz tone or 1209 hz tone */
hldelcnt = 20; /* timeout for 1 sec */
n_dtmf = 0; /* no dtmf # */
}
clr_linf(); /* clear remote lock sequence data */
}
else
{
lockbuf[nlock++] = dtmfcode;
}
}
}
else
{
if ( dtmfcode == STAR )
rmlock_f = 1; /* set remote lock start */
else
{
if ( dtmfcode < 10 ) /* 0 - 9 */
return(0);
}
}
return(1);
}


/* Redisplay the current telephone number */
phone_dis ()
{
if ( !n1 )
{
clr_scr(); /* clear display */
return;
}
--n1;
indx = phone[n1]; /* get last digit of the phone # */

if ( n1 >= 32 )
return;
phone [n1] = indx;
++n1;

wrt_ph(); /* display phone # */
}


/* copy dtmf number in temporary buffer */

tph_save()
{
if ( tphcnt < 16 )
tphcnt = tphcnt + 1;

for ( indx = 0; indx < tphcnt; indx++ )
tphone[indx] = strage[indx];
}


/* store dtmf number */

savedtmf()
{
sto_dtmf(); /* routine to convert 32 bytes to 16 bytes */

for (dtmfidx = 0; dtmfidx < 20; dtmfidx++ )
{
if ( !freephd[dtmfidx] )
break;
}

if ( dtmfidx >= 20 )
dtmfidx = 0;

dis_int(); /* disable interrupt */
tphcnt = n_dtmf/2;
tph_save(); /* copy dtmf number in temporary buffer */

ptr_num = &autophon[(int)(dtmfidx * 16)];
ptr_tph = &tphone[0];

if ( num_cal < 20 ) /* maximum store 20 numbers */
{
if ( !(phactive[dtmfidx] & 0x80) )
num_cal++; /* increment counter */
}
np1 = 0x81; /* set dtmf receive active */
ptr_np1 = &phactive[dtmfidx];

bnp1 = 0xff;
ptr_bnp1 = &freephd[dtmfidx];

dtmfidx++;
if ( dtmfidx >= 20 )
dtmfidx = 0;
np2 = 0; /* set free directory */
ptr_np2 = &freephd[dtmfidx];
grp_act = grp_act | 0x07;
n_dtmf = accept_f = 0; /* clear accept flag also dtmf # */
wnv_act = 1; /* set write nvram active */
calin_fg = 1; /* set absence call active */
ena_int(); /* enable interrupt */
}


/* Store the current telephone number into storage [numm - 1] */
stor_it ()
{
stor = n1;
sto_ph ();

tphcnt = n1/2; /* save phone number in nvram */
tph_save(); /* copy dtmf number in temporary buffer */

ptr_num = &cnumram[numm * 16];
ptr_tph = &tphone[0];

if ( !stolinkf ) /* if no id number */
{
id1 = 0; /* clear link dialing pointer */
}
ptr_id1 = &id_ptr[numm];
grp_act = grp_act | 0x40;
}


/* read phone number from the phone directory */

rd_phone()
{
fcn_cd = 8; /* read ram */
b_cnt = 16; /* number of byte to read */
dest = &strage[0]; /* where to restore packed numbers */
dest_st = numm * 16 + PHONE_TAB_ADD;
phoneptr = numm + IDPOINT; /* save phone pointer for link dialing */
source = &dest_st; /* where in ram to read */
iocb_ptr = &fcn_cd;
cellbios();
}


/* recall phone number by alpha */

recall_it ()
{
n1 = 0;

rd_phone(); /* read phone number from e2prom */

rcl_ph (); /* convert to 32 digit */

for ( i = 0; phone [i] != 0x0f; ++i )
{
last_ph[i] = phone[i];
}

n1 = i;

get_dial(); /* get pointer for link dialing table */
lstlink = linkptr; /* save link pointer */
if ( linkptr ) /* if link exist */
id2buf(); /* put id to id buffer */
}


/* mute audio transmit during conversation mode */

mute_con ()
{
if ( state != 26 ) /* if not in conversation task then return */
return;

scn_con = NORMAL;
if (cond == INUSE)
{
cond = MUTE_CONDITION;
mute_fg = 1; /* set mute flag */
amode = 5;
audio_md ();
showmute(); /* display mute message */
pre_key = 0;
return;
}

if (cond == MUTE_CONDITION)
{
cond = INUSE;
mute_fg = 0; /* clear mute flag */
amode = 2; /* back to conversation mode */
audio_md();
redispl();
}
}


/* show in use indication */

showinus()
{
ancode = 17;
pos_dsp(); /* set symbol position */
if ( roam_st )
ancode = '5'; /* SVC & ROAM & INUSE */
else
ancode = 'B'; /* SVC & HOME & INUSE */
char_dsp();
}


/* show no service indication */

shownsvc()
{
ancode = 17;
pos_dsp(); /* set symbol position */
ancode = 'a'; /* NO SVC */
char_dsp();
}


/* display absence mode message */

dp_absmd()
{
msgptr = &absmode;
str_disp();
}


/* display power on message and owner name */

dp_pwow()
{
msgptr = &pwron_d;
str_disp();
curs_l2(); /* set cursor at 1st char. in line 2 */
indx = 0;
while ( owner[indx] )
{
ancode = owner[indx++];
char_dsp();
if ( indx == 8 )
break;
}
}


/* display ready message */

showrdy()
{
ancode = 17;
pos_dsp(); /* set symbol position */
if ( roam_st )
ancode = 'U'; /* SVC & ROAM */
else
ancode = 'b'; /* SVC & HOME */
char_dsp();

clr_scr(); /* clear display */

if ( n1 )
phone_dis(); /* display phone # */
else
{
if ( absent_f ) /* if absence mode active */
dp_absmd();
else
{
dp_pwow(); /* display power on message and owner name */
if ( ss_stat )
msgptr = &ready_a;
else
msgptr = &ready_b;
str_disp();
}
}
}


/* show low battery message */

showbatt()
{
msgptr = &lowbattd;
str_disp();
}


/* clear low battery message */

clrbatt()
{
redispl(); /* re-display correct message */
}


/* show sig. indication */

showsig()
{
ancode = 18;
pos_dsp(); /* set signal strength position */
rd_rssi(); /* read signal strength */
if ( state < 13 ) /* idle mode */
{
/* if ( rssi > 204 )*/ /* higher than 1.0 volt */
if ( rssi > 225 ) /* higher than 1.1 volt */
dis_lna(); /* disable LNA */
else
{
/* if ( rssi < 184 )*/ /* lower than 0.9 volt */
if ( rssi < 204 ) /* lower than 1.0 volt */
ena_lna(); /* enable LNA */
}
}
else
ena_lna(); /* enable LNA */


if ( rssi > 409 ) /* more than 2.0 volt */
rssi = 410; /* 2.0 volt <=> 410 & 0.8 volt <=> 164 */
/* 0.2 volt <=> 41 */

bar_case = (rssi - 123)/41; /* (rssi - 164 + 41)/41 */
switch( bar_case )
{
case 7:
ancode = 'M'; /* 7 bars */
break;
case 6:
ancode = 'A'; /* 6 bars */
break;
case 5:
ancode = 'p'; /* 5 bars */
break;
case 4:
ancode = 'u'; /* 4 bars */
break;
case 3:
ancode = 'v'; /* 3 bars */
break;
case 2:
ancode = 'y'; /* 2 bars */
break;
case 1:
ancode = 'q'; /* 1 bar */
break;
default:
ancode = ' '; /* no bar */
break;
}
char_dsp();
}

/* re-display the corresponding message */

redispl()
{
if ( alphfg )
{
showcond(); /* display no svc or ready or in use condition */
stoal_dp(); /* display store alpha message */
dp_albuf(); /* display alpha buffer */
return;
}

if ( rclstolk ) /* store-recall for link dialing */
{
showcond(); /* display no svc or ready or in use condition */
if ( stolinkf ) /* store for link dialing # */
stoal_dp();
else /* recall for link dialing # */
rclal_dp();
chk_rcdl();
return;
}
else
{
if ( alphrclf ) /* recall alpha */
{
showcond(); /* display no svc or ready or in use condition */
rclal_dp();
chk_rcdl();
return;
}

if ( alphdelf ) /* delete alpha */
{
showcond(); /* display no svc or ready or in use condition */
delal_dp();
chk_rcdl();
return;
}
}

switch (cond)
{
case SETUSE: /* added 7/2/94 */
case INUSE:
showinus();
break;
case CALL_END: /* added 7/2/94 */
case READY:
showrdy(); /* show ready message */
return;
case NO_SERVICE:
shownsvc(); /* show no service indication */
break;
case REORDER:
break;
case MUTE_CONDITION:
showinus();
return;
}

clr_scr(); /* clear display */
if (n1)
phone_dis();
else
{
if ( absent_f ) /* if absence mode active */
dp_absmd();
else
dp_pwow(); /* display power on message and owner name */
}
}


showcond()
{
switch (cond)
{
case SETUSE: /* added 7/2/94 */
case INUSE:
showinus();
return;
case READY: /* show ready message */
ancode = 17;
pos_dsp(); /* set symbol position */
if ( roam_st )
ancode = 'U'; /* SVC & ROAM */
else
ancode = 'b'; /* SVC & HOME */
char_dsp();
return;
case NO_SERVICE:
shownsvc(); /* show no service indication */
return;
}
}


/* set lock or power off condition */

lock_off()
{
scn_con = NORMAL;
cond = LOCKED;
pre_cond = LOCKED;
sec_con = LOCKED;
for ( num3 = 0; num3 < 170; num3++ )
{
if ( lph1_nv1[num3] - lph1[num3] ) /* if not matched then updated */
{
lph1_nv1[num3] = lph1[num3];
wait10ms(); /* delay 10 msec to nvram write */
}
}
lock_act = 1; /* set lock active */
lock_cnt = 100; /* set lock timeout for 0.5 second */
fcn_s255();
}


/* display system lock message */

lock_dis()
{
num4 = 1000;
num3 = 0;
pre_key = PWR;
scn_con = NORMAL;
cond = LOCKED;
pre_cond = LOCKED;
msgptr = &lock2_d;
str_disp();
msgptr = &code_d;
str_disp();
}



/* store link dialing number in memory table */

stoldial()
{
sto_id(); /* store id number */

tidcnt = idcnt/2;
if ( tidcnt < 16 )
tidcnt = tidcnt + 1;

for ( indx = 0; indx < tidcnt; indx++ )
tid[indx] = strage[indx];

ptr_link = &linknum[savnumm * 16];
ptr_tid = &tid[0];

id1 = savnumm + 1; /* save link pointer */
id2 = id1;
ptr_id2 = &id_stat[savnumm]; /* set that link directory not free */
grp_act = grp_act | 0x80; /* restore link dialing pointer */
return(0);
}


/* count incoming message */

countmsg()
{
num_msg = 0;

for ( indx = 0; indx < 50; indx++ )
{
if ( !(freemesd[indx] - 0x3f) && meslen[indx] )
num_msg++;
}

if ( num_msg )
{
msgin_fg = 1; /* incoming message exist */
mscalcnt = 15; /* timeout .75 sec */
scr_stat = 6;
}
else
msgin_fg = 0; /* no incoming message */

}


/* turn on dtmf */

on_dtmf() /* input : dtmf_dig ( 0 - 12 without 10 ) */
{
sigpath = (sigpath & 0xfb) | 0x22;
/* enable DTMF transmission */
/* and side tone enable */
gen_dtmf(); /* generate dtmf */
}


/* send dtmf with tone or mute tone */

key_dtmf() /* input : dtmf_dig ( 0 - 12 without 10 ) */
{
s_rxmute(); /* set rx audio mute */
if ( fdbk_f ) /* if keypad tone enable */
{
set_svol(); /* set spearker volume */
/* sigpath = (sigpath & 0x7b) | 0x62;*/
sigpath = (sigpath & 0x68) | 0x62;
/* enable DTMF transmission */
/* and side tone enable */
}
else
/* sigpath = (sigpath & 0x3b) | 0x22;*/
sigpath = (sigpath & 0x38) | 0x22;
/* enable DTMF transmission */
gen_dtmf(); /* generate dtmf */
s_dtmffg(); /* set dtmf on flag */
}

/* speed dial touch */

touchmsg()
{
msgptr = &touch_d; /* display 1 touch message */
str_disp();
/* scn_con = UNNORMAL;*/ /* Screen condition unnormal */
sc_unnor(); /* delay about 6 sec then update screen */
pre_key = 0;
}


/* display no long distance call message */

restlock()
{
/* scn_con = UNNORMAL;*/
sc_unnor(); /* delay about 6 sec then update screen */
msgptr = &no_longd;
str_disp();
}


/* display no outgoing call message */

outglock()
{
/* scn_con = UNNORMAL;*/
sc_unnor(); /* delay about 6 sec then update screen */
msgptr = &no_outd;
str_disp();
}


/* check password for ESN setup */

pasw2chk()
{
for ( iidx = 1; iidx < 9; iidx++ )
{
if ( srxbuff[iidx] != passw2[iidx-1] )
return(1); /* password not matched */
}
return(0); /* password matched */
}


/* end of upload */

end_upld()
{
stxbuff[0] = 0x09;
stxbuff[1] = 0; /* end of transmission */
stxbuff[2] = 0x89;
stxcnt = stxc_sav = 3; /* 3 bytes to reply */
}


/* end of download */

end_dwld()
{
stxbuff[0] = 0x0a;
stxbuff[1] = 0; /* end of transmission */
stxbuff[2] = 0x8a;
stxcnt = 3; /* 3 bytes to reply */
}


/* save data from async. communication */

sav_data()
{
srxbuff[srxcnt] = rec_byte;
if ( rec_byte & 0x80 ) /* end of the block */
{
if ( (chksum | 0x80) - rec_byte )
/* if error */
{
stxbuff[0] = 0x07; /* request resend packet */
stxbuff[1] = 0x87;
stxcnt = 2; /* 2 bytes to reply */
}
else /* receive block ok */
{
switch(srxbuff[0])
{
case 1: /* sequential keypad input */
srxcnt--; /* not count the command byte */
ikeycnt = 0;
for ( iidx = 0; iidx < srxcnt; iidx++ )
/* convert input key */
{
ioff = srxbuff[iidx+1] - 0x30;
if ( ioff <= 22 ) /* if valid key */
{
if ( ioff != 10 ) /* valid offset */
{
ikeybuf[ikeycnt] = ikcv2hk[ioff];
/* get conversion for hard key */
ikeycnt++;
}
}
}
ikeyidx = 0; /* set incoming key index start from zero */
b_busy = 1; /* set cellular busy to process incoming message */
stxbuff[0] = 0x01;
stxbuff[1] = 0x81;
stxcnt = 2; /* 2 bytes to reply */
break;

case 2: /* message string input store in nvram */
if ( srxcnt > 81 ) /* if more than 81 bytes */
srxcnt = 81; /* force maximum 81 bytes */
for ( iidx = 0; iidx < srxcnt; iidx++ )
pmesbuf[iidx] = srxbuff[iidx];
pmescnt = srxcnt - 1; /* # of bytes to write */
pmes_fg = 1; /* raise incoming message flag */
b_busy = 1; /* set cellular busy to process incoming message */
stxbuff[0] = 0x02;
stxbuff[1] = 0x82;
stxcnt = 2; /* 2 bytes to reply */
break;

case 3: /* message string input for display only */
clr_scr(); /* clear display */

ancode = 1; /* set position 1 */
pos_dsp();
indx = 1;
srxcnt--; /* not count the command byte */
if ( srxcnt > 16 )
srxcnt = 16; /* maximum 16 bytes */
while ( srxcnt-- )
{
ancode = srxbuff[indx++];
char_dsp();
if ( indx == 9 )
{
ancode = 9; /* set position 9 = start from line 2 */
pos_dsp();
}
}
stxbuff[0] = 0x03;
stxbuff[1] = 0x83;
stxcnt = 2; /* 2 bytes to reply */
pre_key = 0;
break;

case 4: /* receive device # */
device = srxbuff[1];
/* save device # */
break;

case 6: /* cellular phone status */
stxbuff[0] = 0x06;
stxbuff[1] = cbstatus; /* status */
stxbuff[2] = (stxbuff[0] ^ stxbuff[1]) | 0x80;
stxcnt = 3; /* 3 bytes to reply */
break;

case 8: /* setup ESN & SCMp */
stxbuff[0] = 0x07;
stxbuff[1] = 0x87;
stxcnt = 2; /* 2 bytes to reply */

if ( !dumb_fg ) /* if not dumb terminal mode */
break;
/* check password */
/* if ( srxbuff[1] != '*' || srxbuff[2] != '7' || srxbuff[3] != '2' || srxbuff[4] != '7' || srxbuff[5] != '8' || srxbuff[6] != '7' || srxbuff[7] != '2' || srxbuff[8] != '*' )
break;*/
if ( pasw2chk() ) /* if invalid password then exit */
break;

cal_pwsn(); /* convert serial number & scmp power to hex format */

stxbuff[0] = 0x08;
stxbuff[1] = 0x88;
stxcnt = 2; /* 2 bytes to reply */
break;

if ( packcnt > 100 )
{
load_f = 0; /* clear upload or download flag */
msgptr = &upldone;
str_disp();
clr_mnum(); /* cancel this sub-menu */
break;
}

stxbuff[0] = 0x09;
stxbuff[1] = 120;
for ( iidx = 2; iidx < 122; iidx = iidx + 2 )
{
indx = *load_ptr++;
stxbuff[iidx] = indx & 0x0f;
stxbuff[iidx+1] = (indx >> 4) & 0x0f;
}
indx = 0;
for ( iidx = 0; iidx < 122; iidx++ ) /* do checksum */
{
indx = indx ^ stxbuff[iidx];
}
stxbuff[122] = 0x80 | indx;
stxcnt = stxc_sav = 123; /* 123 bytes to reply */
packcnt++; /* increment package counter */
}
else
{
if ( canld_f )
{
canld_f = 0; /* clear cancel upload flag */
end_upld(); /* end of upload */
break;
}
}
break;

case 10: /* download telephone directory from pc */
if ( techsub == 43 && load_f )
{
if ( packcnt >= 100 )
{
end_dwld(); /* end of dwonload */
load_f = 0; /* clear upload or download flag */
msgptr = &dwldone;
str_disp();
clr_mnum(); /* cancel this sub-menu */
break;
}

for ( iidx = 2; iidx < 122; iidx = iidx + 2 )
{
indx = srxbuff[iidx] | (srxbuff[iidx+1] << 4);
*load_ptr++ = indx;
wdogwait(); /* delay 10 msec to nvram write */
}
stxbuff[0] = 0x0a;
stxbuff[1] = 120; /* confirm receive 120 bytes */
stxbuff[2] = 0xf2; /* checksum byte */
stxcnt = 3; /* 3 bytes to reply */
packcnt++; /* increment package counter */
}
else
{
if ( canld_f )
{
canld_f = 0; /* clear cancel upload flag */
end_dwld(); /* end of download */
break;
}
}
break;

default: /* invalid command */
break;
}
}
stxindx = 0;
srxcnt = 0; /* reset receive count */
chksum = 0; /* reset checksum */
return;
}
else
{
chksum = chksum ^ rec_byte;
srxcnt++; /* point to the next byte */
}
}


/* get async. transmit data */

get_data()
{
tra_byte = stxbuff[stxindx++]; /* get tx data */
stxcnt--; /* decrement tx count */
}

/* write incoming message in nvram */

pmwrite()
{
pmes_fg = 0; /* clear incoming message flag */
ptr_twm = &pmesbuf[1]; /* setup message buffer to write */
wcntmes = pmescnt; /* # of byte to write */
wrt_type = 0; /* incoming message from async. comm. */
writemsg(); /* write message in nvram */

b_busy = 1; /* set cellular busy to process incoming message */
wim_fg = 1; /* write incoming message active */
}


/* save flags and data if changed */

savefgdt()
{
if ( sys_stat - sstat_nv )
{
sstat_nv = sys_stat;
wait10ms(); /* delay 10 msec to nvram write */
}

for ( indx = 0; indx < 27; indx++ )
{
if ( flagdata[indx] - fgdat_nv[indx] )
{
fgdat_nv[indx] = flagdata[indx];
wait10ms(); /* delay 10 msec to nvram write */
}
}
}

 

 

Hosted by www.Geocities.ws

1