/* * Copyright (C) 2003 BLADOX, s.r.o. All rights reserved. * * This file is part of an example program for Turbo. This example * program may be used, distributed and modified without limitation. * */ #include <config.h> #include <turbo/turbo.h> #include <stdlib.h> u8 PROGMEM t_cells[] = "celllog"; u8 PROGMEM t_ext_txt[] = "txt"; void seek_cells () { b32 b; cd_i (root ()); b = cd (t_cells); if (b > 0) return; b = create_dir (root (), t_cells, SORT); cd_i (b); } u8 PROGMEM t_lac[] = "LAC: "; u8 PROGMEM t_mmc[] = "MMC: "; u8 PROGMEM t_cellid[] = "CellID: "; void write_loc_info (u8 * s) { u8 j, i; MCFILE *fd; b32 b; u8 *buf = malloc (100); u8 *r; if (buf == NULL) return; j = get_tag (s, T_LOCATION_STATUS); if (j != 0 && s[j + 2] == 0) //Location status==0x00, i.e. normal service { j = get_tag (s, T_LOCATION_INFO); if (j != 0) { j++; j++; seek_cells (); r = buf; for (i = 5; i < 7; i++) r = sprintch (r, s[j + i]); r = sprintc (r, '\0'); b = create_file (pwd (), buf, SORT_SMS); if (b > 0) { r = buf; r = sprints (r, t_mmc); for (i = 0; i < 3; i++) r = sprintch (r, s[j + i]); r = sprintc (r, '\n'); r = sprints (r, t_lac); for (; i < 5; i++) r = sprintch (r, s[j + i]); r = sprintc (r, '\n'); r = sprints (r, t_cellid); for (; i < 7; i++) r = sprintch (r, s[j + i]); r = sprintc (r, '\n'); mc_set_type (b, t_ext_txt); fd = mc_open (b, FILE_APPEND); mc_append (fd, buf, r - buf); mc_close (fd); } } } free (buf); } void turbo_handler (u8 action, void *data) { switch (action) { case ACTION_APP_INIT: reg_action (ACTION_EVENT_LOCATION_STATUS); break; case ACTION_EVENT_LOCATION_STATUS: if (mc_detect () == MC_OK) write_loc_info (data); break; default: break; } }
Copyright © 2004-2006 BLADOX | Turbo version 1.2
|