/* The Network Wizards Interface cable ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ With the interface cable, one can program the NAM and ESN on the phone with this mod. Clone a phone fast, easy and fun! ESN Location #1 $be8e-$be91 ESN Location #2 $be93-$be96 ESN Location #3 $be98-$be9b ESN Location #4 $be9d-$bea0 ESN location #5 $BEA2-$BEA5 */ #include #include #include #include #include #include #include #define FALSE 0 #define TRUE 1 #define SWAP(a,b) (a^=b,b^=a,a^=b) typedef unsigned char bool; typedef unsigned char byte; typedef unsigned int word; #include "ctlib.h" /* Defines that CTLIB does not have */ #define CT_KEY_1AND3 0x30 #define CT_KEY_4AND6 0x31 #define CT_KEY_7AND9 0x32 #define CT_KEY_STAR_POUND 0x33 #define CT_KEY_RCL_MENU 0x28 #define CT_KEY_SND_END 0x35 /* You may want to use these too!#@ */ #define BUFLEN 128 #define ESC 0x1B char buf[BUFLEN]; char ps_system; byte nambyte = 0x00; byte namonebyte =0x01; int ps_cc; /* control channel */ int ps_cc_rss; /* control channel last rss */ char ournum[32]; /* our telephone number */ unsigned long ouresn; /* our esn */ main(argc,argv) int argc; char *argv[]; { int i; /* initialize ct library using the specified COM port */ if (argc > 1) { if (*argv[1] == '1') ct_lib_init(900,0x3f8,4); else if (*argv[1] == '2') ct_lib_init(900,0x2f8,3); else if (*argv[1] == '3') ct_lib_init(900,0x3e8,5); else { puts("Type 'TMPRO 2' to use COM2"); exit(0); } } else ct_lib_init(900,0x3f8,4); /* com1 by default */ /* power up oki and tell it what mode to use */ if (!ct_on(MODE_TEST)) { fprintf(stderr,"?No response from OKI\n"); cleanup(); exit(1); } if (!ct_on(MODE_TEST)) { fprintf(stderr,"?No response from OKI\n"); cleanup(); exit(1); } strcpy(ournum,nam_info[ct_state.namindex].number); /* use current nam */ printf("Current NAM index #: %d\n",ct_state.namindex); printf("Current NAM number : %d\n",nam_info[ct_state.namindex].number); printf("Tel# is %s, ",ournum); if (!ct_get_esn(&ouresn)) { fprintf(stderr,"?Can't get ESN\n"); cleanup(); exit(1); } printf("ESN is %08lx\n\n",ouresn); cmd_elite_stuff(); cleanup(); exit(0); } cleanup() { ct_off(); /* turn off phone */ ct_lib_done(); /* cleanup library stuff */ } cmd_power_messages() { byte c,x,pointer; char powerstring[8]; char ch; for (c=1;c<32;c++) { for (x=0;x<8;x++) { powerstring[x] = (c*8) + x; printf("%x ",powerstring[x]); pointer = 0xBEAF + x; ct_set_block(&powerstring[x],pointer,1); } printf("\n"); ct_off(); ct_on(MODE_NORMAL); ch = getche(); ct_off(); if (ch == 'x') { cleanup(); exit(1); } delay(1000); ct_on(MODE_TEST); ct_get_nams(); } } cmd_elite_stuff() { char ch; unsigned long esn; byte counter; char sysid[6]; fetch_esn(&esn,1); printf("our NAM#1 ESN : %08lx\n",esn); fetch_esn(&esn,2); printf("our NAM#2 ESN : %08lx\n",esn); fetch_esn(&esn,3); printf("our NAM#3 ESN : %08lx\n",esn); fetch_esn(&esn,4); printf("our NAM#4 ESN : %08lx\n",esn); fetch_esn(&esn,5); printf("our NAM#5 ESN : %08lx\n",esn); printf("Enter number of NAM to configure (1-5) : "); ch = getche(); printf("\nEnter new ESN : "); scanf("%8lx", &esn); printf("Enter new MIN : "); scanf("%10s", &ournum); printf("Enter system ID : "); scanf("%5s", &sysid); store_esn(esn, ch-48); nambyte = ch-48; ct_set_block(&nambyte,0xBF2C,1); ct_set_block(&nambyte,0xC0FF,1); store_min((ch-48),ournum,sysid); } int fetch_esn(esn,nam) unsigned long *esn; int nam; { word addr; union esn_un { unsigned long l; byte b[4]; } myesn; switch (nam) { case 1: addr = 0xBE8E; break; case 2: addr = 0xBE93; break; case 3: addr = 0xBE98; break; case 4: addr = 0xBE9D; break; case 5: addr = 0xBEA2; break; default: return(1); break; } ct_read_block(esn,addr,4); myesn.l = *esn; SWAP(myesn.b[0],myesn.b[3]); SWAP(myesn.b[1],myesn.b[2]); *esn = myesn.l; return(0); } int store_esn(unsigned long stored_esn, int nam) { word addr; union esn_un { unsigned long l; byte b[4]; } myesn; switch (nam) { case 1: addr = 0xBE8E; break; case 2: addr = 0xBE93; break; case 3: addr = 0xBE98; break; case 4: addr = 0xBE9D; break; case 5: addr = 0xBEA2; break; default: return(1); break; } myesn.l = stored_esn; SWAP(myesn.b[0],myesn.b[3]); SWAP(myesn.b[1],myesn.b[2]); stored_esn = myesn.l; ct_set_block(&stored_esn,addr,4); return(0); } store_min(int nam, char *num, char *sysid) { int x; ct_off(); ct_on(MODE_NORMAL); delay(1000); send(CT_KEY_RCL_MENU); send(CT_KEY_STAR); send(CT_KEY_6); send(CT_KEY_2); send(CT_KEY_7); send(CT_KEY_2); send(CT_KEY_9); send(CT_KEY_8); send(CT_KEY_5); send(CT_KEY_4); send(CT_KEY_POUND); printf("Waiting for messages to settle\n"); delay(4000); for (x=0;x<4+nam;x++) send(CT_KEY_DOWN); printf("Waiting for NAM %d to fall through\n",nam); delay(3000); sendnum(num); send(CT_KEY_STO); send(CT_KEY_DOWN); sendnum(sysid); send(CT_KEY_STO); send(CT_KEY_CLR); send(CT_KEY_CLR); ct_off(); } sendnum(char *number) { int x; for (x=0;x