/[gnokii]/gnokii/common/phones/nk6510.c
ViewVC logotype

Diff of /gnokii/common/phones/nk6510.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.170 by pkot, Tue May 3 22:58:44 2005 UTC revision 1.171 by pkot, Tue May 3 22:59:48 2005 UTC
# Line 327  static gn_error NK6510_Functions(gn_oper Line 327  static gn_error NK6510_Functions(gn_oper
327                  }                  }
328                  break;                  break;
329          case GN_OP_PollSMS:          case GN_OP_PollSMS:
330                  if (new_sms) return GN_ERR_NONE;                  if (new_sms) return GN_ERR_NONE;
331                  break;                  break;
332          case GONK6510_GetPicture:          case GONK6510_GetPicture:
333                  return NK6510_GetPicture(data, state);                  return NK6510_GetPicture(data, state);
# Line 709  static void ParseLayout(unsigned char *m Line 709  static void ParseLayout(unsigned char *m
709          case 0x01: /* delivery report */          case 0x01: /* delivery report */
710                  dprintf("Type: Delivery Report\n");                  dprintf("Type: Delivery Report\n");
711                  data->raw_sms->type = GN_SMS_MT_DeliveryReport;                  data->raw_sms->type = GN_SMS_MT_DeliveryReport;
712                  block = message + 20;                  block = message + 20;
713                  memcpy(data->raw_sms->smsc_time, message + 6, 7);                  memcpy(data->raw_sms->smsc_time, message + 6, 7);
714                  memcpy(data->raw_sms->time, message + 13, 7);                  memcpy(data->raw_sms->time, message + 13, 7);
715                  break;                  break;
# Line 732  static void ParseLayout(unsigned char *m Line 732  static void ParseLayout(unsigned char *m
732                          dprintf("Wrong type\n");                          dprintf("Wrong type\n");
733                          break;                          break;
734                  }                  }
735                  block = message + 8;                  block = message + 8;
736                  break;                  break;
737          case 0x80:          case 0x80:
738                  dprintf("Type: Picture\n");                  dprintf("Type: Picture\n");
# Line 751  static void ParseLayout(unsigned char *m Line 751  static void ParseLayout(unsigned char *m
751                          data->raw_sms->type = GN_SMS_MT_Picture;                          data->raw_sms->type = GN_SMS_MT_Picture;
752                          block = message + 20;                          block = message + 20;
753                          memcpy(data->raw_sms->smsc_time, message + 10, 7);                          memcpy(data->raw_sms->smsc_time, message + 10, 7);
754                          data->raw_sms->length = 256;                          data->raw_sms->length = 256;
755                          memcpy(data->raw_sms->user_data, message + 50, data->raw_sms->length);                          memcpy(data->raw_sms->user_data, message + 50, data->raw_sms->length);
756                          break;                          break;
757                  default:                  default:
# Line 796  static void ParseLayout(unsigned char *m Line 796  static void ParseLayout(unsigned char *m
796                          }                          }
797                          break;                          break;
798                  case 0x80: /* User Data */                  case 0x80: /* User Data */
799                          if ((data->raw_sms->type != GN_SMS_MT_Picture) && (data->raw_sms->type != GN_SMS_MT_PictureTemplate)) {                            if ((data->raw_sms->type != GN_SMS_MT_Picture) && (data->raw_sms->type != GN_SMS_MT_PictureTemplate)) {
800                                          /* Ignore the found user_data block for pictures */                                          /* Ignore the found user_data block for pictures */
801                                  data->raw_sms->length = block[3];                                  data->raw_sms->length = block[3];
802                                  memcpy(data->raw_sms->user_data, block + 4, data->raw_sms->length);                                  memcpy(data->raw_sms->user_data, block + 4, data->raw_sms->length);
# Line 905  static gn_error NK6510_IncomingFolder(in Line 905  static gn_error NK6510_IncomingFolder(in
905          case 0x09:          case 0x09:
906                  dprintf("SMS Status received\n");                  dprintf("SMS Status received\n");
907                  if (!data->sms_status) return GN_ERR_INTERNALERROR;                  if (!data->sms_status) return GN_ERR_INTERNALERROR;
908                  data->sms_status->number = (message[12] * 256 + message[13]) +                  data->sms_status->number = (message[12] * 256 + message[13]) +
909                          (message[24] * 256 + message[25]) + data->sms_folder->number;                          (message[24] * 256 + message[25]) + data->sms_folder->number;
910                  data->sms_status->unread = (message[14] * 256 + message[15]) +                  data->sms_status->unread = (message[14] * 256 + message[15]) +
911                          (message[26] * 256 + message[27]);                          (message[26] * 256 + message[27]);
# Line 930  static gn_error NK6510_IncomingFolder(in Line 930  static gn_error NK6510_IncomingFolder(in
930    
931          /* get message status */          /* get message status */
932          case 0x0f:          case 0x0f:
933                  dprintf("Message: SMS message(%i in folder %i) status received: %i\n",                  dprintf("Message: SMS message(%i in folder %i) status received: %i\n",
934                          message[10] * 256 + message[11],  message[12], message[13]);                          message[10] * 256 + message[11],  message[12], message[13]);
935    
936                  if (!data->raw_sms) return GN_ERR_INTERNALERROR;                  if (!data->raw_sms) return GN_ERR_INTERNALERROR;
# Line 1072  static gn_error NK6510_GetSMSFolders(gn_ Line 1072  static gn_error NK6510_GetSMSFolders(gn_
1072    
1073  static gn_error NK6510_DeleteSMSFolder(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_DeleteSMSFolder(gn_data *data, struct gn_statemachine *state)
1074  {  {
1075          unsigned char req[] = {FBUS_FRAME_HEADER, 0x14,          unsigned char req[] = {FBUS_FRAME_HEADER, 0x14,
1076                                 0x06, /* Folder ID */                                 0x06, /* Folder ID */
1077                                 0x00};                                 0x00};
1078    
# Line 1084  static gn_error NK6510_DeleteSMSFolder(g Line 1084  static gn_error NK6510_DeleteSMSFolder(g
1084    
1085  static gn_error NK6510_CreateSMSFolder(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_CreateSMSFolder(gn_data *data, struct gn_statemachine *state)
1086  {  {
1087          unsigned char req[50] = {FBUS_FRAME_HEADER, 0x10,          unsigned char req[50] = {FBUS_FRAME_HEADER, 0x10,
1088                                   0x01, 0x00, 0x01,                                   0x01, 0x00, 0x01,
1089                                   0x00, /* length */                                   0x00, /* length */
1090                                   0x00, 0x00 };                                   0x00, 0x00 };
# Line 1099  static gn_error NK6510_CreateSMSFolder(g Line 1099  static gn_error NK6510_CreateSMSFolder(g
1099    
1100  static gn_error NK6510_GetSMSFolderStatus(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_GetSMSFolderStatus(gn_data *data, struct gn_statemachine *state)
1101  {  {
1102          unsigned char req[] = {FBUS_FRAME_HEADER, 0x0C,          unsigned char req[] = {FBUS_FRAME_HEADER, 0x0C,
1103                                 0x02, /* 0x01 SIM, 0x02 ME*/                                 0x02, /* 0x01 SIM, 0x02 ME*/
1104                                 0x00, /* Folder ID */                                 0x00, /* Folder ID */
1105                                 0x0F, 0x55, 0x55, 0x55};                                 0x0F, 0x55, 0x55, 0x55};
# Line 1132  static gn_error NK6510_GetSMSFolderStatu Line 1132  static gn_error NK6510_GetSMSFolderStatu
1132                          data->sms_folder->number++;                          data->sms_folder->number++;
1133                  }                  }
1134                  return GN_ERR_NONE;                  return GN_ERR_NONE;
1135          }          }
1136          SEND_MESSAGE_BLOCK(NK6510_MSG_FOLDER, 10);          SEND_MESSAGE_BLOCK(NK6510_MSG_FOLDER, 10);
1137  }  }
1138    
1139  static gn_error NK6510_GetSMSMessageStatus(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_GetSMSMessageStatus(gn_data *data, struct gn_statemachine *state)
1140  {  {
1141          unsigned char req[] = {FBUS_FRAME_HEADER, 0x0E,          unsigned char req[] = {FBUS_FRAME_HEADER, 0x0E,
1142                                 0x02, /* 0x01 SIM, 0x02 phone*/                                 0x02, /* 0x01 SIM, 0x02 phone*/
1143                                 0x00, /* Folder ID */                                 0x00, /* Folder ID */
1144                                 0x00,                                 0x00,
1145                                 0x00, /* Location */                                 0x00, /* Location */
1146                                 0x55, 0x55};                                 0x55, 0x55};
1147    
# Line 1201  static gn_error ValidateSMS(gn_data *dat Line 1201  static gn_error ValidateSMS(gn_data *dat
1201          if (data->raw_sms->memory_type != data->sms_folder->folder_id) {          if (data->raw_sms->memory_type != data->sms_folder->folder_id) {
1202                  if ((error = NK6510_GetSMSFolders(data, state)) != GN_ERR_NONE) return error;                  if ((error = NK6510_GetSMSFolders(data, state)) != GN_ERR_NONE) return error;
1203    
1204                  if ((get_memory_type(data->raw_sms->memory_type) >                  if ((get_memory_type(data->raw_sms->memory_type) >
1205                       data->sms_folder_list->folder_id[data->sms_folder_list->number - 1]) ||                       data->sms_folder_list->folder_id[data->sms_folder_list->number - 1]) ||
1206                      (data->raw_sms->memory_type < 12))                      (data->raw_sms->memory_type < 12))
1207                          return GN_ERR_INVALIDMEMORYTYPE;                          return GN_ERR_INVALIDMEMORYTYPE;
# Line 1326  static gn_error NK6510_SaveSMS(gn_data * Line 1326  static gn_error NK6510_SaveSMS(gn_data *
1326          dprintf("Saving sms\n");          dprintf("Saving sms\n");
1327          if (data->raw_sms->memory_type == GN_MT_IN && data->raw_sms->type == GN_SMS_MT_Submit)          if (data->raw_sms->memory_type == GN_MT_IN && data->raw_sms->type == GN_SMS_MT_Submit)
1328                  return GN_ERR_INVALIDMEMORYTYPE;                  return GN_ERR_INVALIDMEMORYTYPE;
1329          if (data->raw_sms->memory_type != GN_MT_IN &&          if (data->raw_sms->memory_type != GN_MT_IN &&
1330              data->raw_sms->type == GN_SMS_MT_Deliver &&              data->raw_sms->type == GN_SMS_MT_Deliver &&
1331              data->raw_sms->status != GN_SMS_Sent)              data->raw_sms->status != GN_SMS_Sent)
1332                  return GN_ERR_INVALIDMEMORYTYPE;                  return GN_ERR_INVALIDMEMORYTYPE;
1333          if (data->raw_sms->memory_type == GN_MT_TE ||          if (data->raw_sms->memory_type == GN_MT_TE ||
# Line 1562  static gn_error NK6510_GetFileList(gn_da Line 1562  static gn_error NK6510_GetFileList(gn_da
1562          i = strlen(data->file_list->path);          i = strlen(data->file_list->path);
1563          req[5] = char_unicode_encode(req+6, data->file_list->path, i);          req[5] = char_unicode_encode(req+6, data->file_list->path, i);
1564    
1565          if (sm_message_send(req[5]+9, NK6510_MSG_FILE, req, state)) return GN_ERR_NOTREADY;          if (sm_message_send(req[5]+9, NK6510_MSG_FILE, req, state)) return GN_ERR_NOTREADY;
1566          return sm_block(NK6510_MSG_FILE, data, state);          return sm_block(NK6510_MSG_FILE, data, state);
1567  }  }
1568    
1569  static gn_error NK6510_GetFileId(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_GetFileId(gn_data *data, struct gn_statemachine *state)
# Line 1576  static gn_error NK6510_GetFileId(gn_data Line 1576  static gn_error NK6510_GetFileId(gn_data
1576          i = strlen(data->file->name);          i = strlen(data->file->name);
1577          req[5] = char_unicode_encode(req+6, data->file->name, i);          req[5] = char_unicode_encode(req+6, data->file->name, i);
1578    
1579          if ( sm_message_send(req[5]+9, NK6510_MSG_FILE, req, state) ) return GN_ERR_NOTREADY;          if ( sm_message_send(req[5]+9, NK6510_MSG_FILE, req, state) ) return GN_ERR_NOTREADY;
1580          return sm_block(NK6510_MSG_FILE, data, state);          return sm_block(NK6510_MSG_FILE, data, state);
1581  }  }
1582    
1583  static gn_error NK6510_GetFile(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_GetFile(gn_data *data, struct gn_statemachine *state)
1584  {  {
1585          unsigned char req[512] = {FBUS_FRAME_HEADER, 0x68, 0x00};          unsigned char req[512] = {FBUS_FRAME_HEADER, 0x68, 0x00};
1586          unsigned char req2[512] = {FBUS_FRAME_HEADER, 0x72, 0x00, 0x00, 0x00};          unsigned char req2[512] = {FBUS_FRAME_HEADER, 0x72, 0x00, 0x00, 0x00};
1587          unsigned char req3[] = {FBUS_FRAME_HEADER, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,          unsigned char req3[] = {FBUS_FRAME_HEADER, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
1588                                  0x00, 0x00, 0x00, 0x00, // Start position                                  0x00, 0x00, 0x00, 0x00, // Start position
1589                                  0x00, 0x00, 0x04, 0x00,                                  0x00, 0x00, 0x04, 0x00,
1590                                  0x00, 0x00, 0x00, 0x00}; // Size                                  0x00, 0x00, 0x00, 0x00}; // Size
1591          unsigned char req4[] = {FBUS_FRAME_HEADER, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03};          unsigned char req4[] = {FBUS_FRAME_HEADER, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03};
1592          gn_error err;          gn_error err;
1593          int i;          int i;
1594                    
1595          if (!data->file) return GN_ERR_INTERNALERROR;          if (!data->file)
1596                    return GN_ERR_INTERNALERROR;
1597          i = strlen(data->file->name);          i = strlen(data->file->name);
1598    
1599          /* Get the file size */          /* Get the file size */
1600          req[5] = char_unicode_encode(req+6, data->file->name, i);          req[5] = char_unicode_encode(req+6, data->file->name, i);
1601          if (sm_message_send(req[5]+9, NK6510_MSG_FILE, req, state)) return GN_ERR_NOTREADY;          if (sm_message_send(req[5] + 9, NK6510_MSG_FILE, req, state))
1602          err = sm_block(NK6510_MSG_FILE, data, state);                  return GN_ERR_NOTREADY;
1603          if (err!=GN_ERR_NONE) return err;          err = sm_block(NK6510_MSG_FILE, data, state);
1604            if (err != GN_ERR_NONE)
1605                    return err;
1606          data->file->file = malloc(data->file->file_length);          data->file->file = malloc(data->file->file_length);
1607          if (!data->file->file) return GN_ERR_INTERNALERROR;          if (!data->file->file)
1608                    return GN_ERR_INTERNALERROR;
1609    
1610          /* Start the transfer */          /* Start the transfer */
1611          req2[7] = char_unicode_encode(req2+8, data->file->name, i);          req2[7] = char_unicode_encode(req2 + 8, data->file->name, i);
1612          data->file->togo = 0;          data->file->togo = 0;
1613          if (sm_message_send(req2[7]+12, NK6510_MSG_FILE, req2, state)) return GN_ERR_NOTREADY;          if (sm_message_send(req2[7] + 12, NK6510_MSG_FILE, req2, state))
1614          err = sm_block(NK6510_MSG_FILE, data, state);                  return GN_ERR_NOTREADY;
1615          if (err!=GN_ERR_NONE) return err;          err = sm_block(NK6510_MSG_FILE, data, state);
1616          if (data->file->togo!=data->file->file_length) return GN_ERR_INTERNALERROR;          if (err != GN_ERR_NONE)
1617                    return err;
1618            if (data->file->togo != data->file->file_length)
1619                    return GN_ERR_INTERNALERROR;
1620    
1621          /* Get the data */          /* Get the data */
1622          while (data->file->togo>0) {          while (data->file->togo > 0) {
1623                  int progress;                  int progress;
1624                                    
1625                  i = data->file->file_length-data->file->togo;                  i = data->file->file_length - data->file->togo;
1626                  req3[11] = (i&0xff0000)>>16;                  req3[11] = (i & 0xff0000) >> 16;
1627                  req3[12] = (i&0xff00)>>8;                  req3[12] = (i & 0xff00) >> 8;
1628                  req3[13] = i&0xff;                  req3[13] = i & 0xff;
1629                  if (data->file->togo>0x100) {                  if (data->file->togo > 0x100) {
1630                          req3[20] = 0x01;                          req3[20] = 0x01;
1631                  } else {                  } else {
1632                          req3[19] = (data->file->togo&0xff0000)>>16;                          req3[19] = (data->file->togo & 0xff0000) >> 16;
1633                          req3[20] = (data->file->togo&0xff00)>>8;                          req3[20] = (data->file->togo & 0xff00) >> 8;
1634                          req3[21] = data->file->togo&0xff;                          req3[21] = data->file->togo & 0xff;
1635                  }                  }
1636                  if (sm_message_send(sizeof(req3), NK6510_MSG_FILE, req3, state)) return GN_ERR_NOTREADY;                  if (sm_message_send(sizeof(req3), NK6510_MSG_FILE, req3, state))
1637                  err = sm_block(NK6510_MSG_FILE, data, state);                          return GN_ERR_NOTREADY;
1638                  if (err!=GN_ERR_NONE) return err;                  err = sm_block(NK6510_MSG_FILE, data, state);
1639                    if (err != GN_ERR_NONE)
1640                            return err;
1641                  progress = 100 * (data->file->file_length - data->file->togo) / data->file->file_length;                  progress = 100 * (data->file->file_length - data->file->togo) / data->file->file_length;
1642                  fprintf(stderr, _("Progress: %d%% completed\n"), progress);                  fprintf(stderr, _("Progress: %d%% completed\n"), progress);
1643          }          }
1644                    
1645          /* Finish the transfer */          /* Finish the transfer */
1646          if (sm_message_send(sizeof(req4), NK6510_MSG_FILE, req4, state)) return GN_ERR_NOTREADY;          if (sm_message_send(sizeof(req4), NK6510_MSG_FILE, req4, state))
1647          return sm_block(NK6510_MSG_FILE, data, state);                  return GN_ERR_NOTREADY;
1648            return sm_block(NK6510_MSG_FILE, data, state);
1649  }  }
1650    
1651  static gn_error NK6510_PutFile(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_PutFile(gn_data *data, struct gn_statemachine *state)
1652  {  {
1653          unsigned char req1[512] = {FBUS_FRAME_HEADER, 0x72, 0x11, 0x00, 0x00};          unsigned char req1[512] = {FBUS_FRAME_HEADER, 0x72, 0x11, 0x00, 0x00};
1654          unsigned char req2[512] = {FBUS_FRAME_HEADER, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,          unsigned char req2[512] = {FBUS_FRAME_HEADER, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
1655                                  0x00, 0x00, 0x00, 0x00}; // Size                                  0x00, 0x00, 0x00, 0x00}; // Size
1656          unsigned char req3[] = {FBUS_FRAME_HEADER, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03};          unsigned char req3[] = {FBUS_FRAME_HEADER, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03};
1657          gn_error err;          gn_error err;
# Line 1653  static gn_error NK6510_PutFile(gn_data * Line 1663  static gn_error NK6510_PutFile(gn_data *
1663          /* Start the transfer */          /* Start the transfer */
1664          req1[7] = char_unicode_encode(req1+8, data->file->name, i);          req1[7] = char_unicode_encode(req1+8, data->file->name, i);
1665          data->file->togo = 0;          data->file->togo = 0;
1666          if (sm_message_send(req1[7]+12, NK6510_MSG_FILE, req1, state)) return GN_ERR_NOTREADY;          if (sm_message_send(req1[7]+12, NK6510_MSG_FILE, req1, state)) return GN_ERR_NOTREADY;
1667          err = sm_block(NK6510_MSG_FILE, data, state);          err = sm_block(NK6510_MSG_FILE, data, state);
1668          if (err!=GN_ERR_NONE) return err;          if (err!=GN_ERR_NONE) return err;
1669          if (data->file->togo!=data->file->file_length) return GN_ERR_INTERNALERROR;          if (data->file->togo!=data->file->file_length) return GN_ERR_INTERNALERROR;
1670    
# Line 1671  static gn_error NK6510_PutFile(gn_data * Line 1681  static gn_error NK6510_PutFile(gn_data *
1681                          data->file->just_sent = data->file->togo;                          data->file->just_sent = data->file->togo;
1682                  }                  }
1683                  memcpy(req2+14, data->file->file + data->file->file_length - data->file->togo, data->file->just_sent);                  memcpy(req2+14, data->file->file + data->file->file_length - data->file->togo, data->file->just_sent);
1684                  if (sm_message_send(14+data->file->just_sent, NK6510_MSG_FILE, req2, state)) return GN_ERR_NOTREADY;                  if (sm_message_send(14+data->file->just_sent, NK6510_MSG_FILE, req2, state)) return GN_ERR_NOTREADY;
1685                  err = sm_block(NK6510_MSG_FILE, data, state);                  err = sm_block(NK6510_MSG_FILE, data, state);
1686                  if (err!=GN_ERR_NONE) return err;                  if (err!=GN_ERR_NONE) return err;
1687                  if (data->file->togo!=i-data->file->just_sent) return GN_ERR_INTERNALERROR;                  if (data->file->togo!=i-data->file->just_sent) return GN_ERR_INTERNALERROR;
1688          }          }
1689                    
1690          /* Finish the transfer */          /* Finish the transfer */
1691          if (sm_message_send(sizeof(req3), NK6510_MSG_FILE, req3, state)) return GN_ERR_NOTREADY;          if (sm_message_send(sizeof(req3), NK6510_MSG_FILE, req3, state)) return GN_ERR_NOTREADY;
1692          return sm_block(NK6510_MSG_FILE, data, state);          return sm_block(NK6510_MSG_FILE, data, state);
1693  }  }
1694    
# Line 1691  static gn_error NK6510_DeleteFile(gn_dat Line 1701  static gn_error NK6510_DeleteFile(gn_dat
1701          i = strlen(data->file->name);          i = strlen(data->file->name);
1702    
1703          req[5] = char_unicode_encode(req+6, data->file->name, i);          req[5] = char_unicode_encode(req+6, data->file->name, i);
1704          if (sm_message_send(req[5]+9, NK6510_MSG_FILE, req, state)) return GN_ERR_NOTREADY;          if (sm_message_send(req[5]+9, NK6510_MSG_FILE, req, state)) return GN_ERR_NOTREADY;
1705          return sm_block(NK6510_MSG_FILE, data, state);          return sm_block(NK6510_MSG_FILE, data, state);
1706  }  }
1707    
1708    
# Line 1736  static gn_error NK6510_IncomingFile(int Line 1746  static gn_error NK6510_IncomingFile(int
1746                          dprintf("Empty directory\n");                          dprintf("Empty directory\n");
1747                          goto out;                          goto out;
1748                  }                  }
1749                  if (data->file) {                  if (data->file) {
1750                          file = data->file;                          file = data->file;
1751                  } else if (data->file_list) {                  } else if (data->file_list) {
1752                          data->file_list->files[data->file_list->file_count] = malloc(sizeof(gn_file));                          data->file_list->files[data->file_list->file_count] = malloc(sizeof(gn_file));
# Line 1906  static gn_error NK6510_ReadPhonebookLoca Line 1916  static gn_error NK6510_ReadPhonebookLoca
1916  {  {
1917          unsigned char req[] = {FBUS_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01,          unsigned char req[] = {FBUS_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01,
1918                                 0x02, 0x05, /* memory type */                                 0x02, 0x05, /* memory type */
1919                                 0x00, 0x00, 0x00, 0x00,                                 0x00, 0x00, 0x00, 0x00,
1920                                 0x00, 0x01, /*location */                                 0x00, 0x01, /*location */
1921                                 0x00, 0x00};                                 0x00, 0x00};
1922    
# Line 1937  static unsigned char PackBlock(u8 id, u8 Line 1947  static unsigned char PackBlock(u8 id, u8
1947    
1948  static gn_error NK6510_SetSpeedDial(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_SetSpeedDial(gn_data *data, struct gn_statemachine *state)
1949  {  {
1950          unsigned char req[40] = {FBUS_FRAME_HEADER, 0x0B, 0x00, 0x01, 0x01, 0x00, 0x00, 0x10,          unsigned char req[40] = {FBUS_FRAME_HEADER, 0x0B, 0x00, 0x01, 0x01, 0x00, 0x00, 0x10,
1951                                   0xFF, 0x0E,                                   0xFF, 0x0E,
1952                                   0x00, 0x06, /* number */                                   0x00, 0x06, /* number */
1953                                   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,                                   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1954                                   0x01}; /* blocks */                                   0x01}; /* blocks */
1955          char string[40];          char string[40];
1956    
# Line 1953  static gn_error NK6510_SetSpeedDial(gn_d Line 1963  static gn_error NK6510_SetSpeedDial(gn_d
1963          string[2] = data->speed_dial->location;          string[2] = data->speed_dial->location;
1964          memcpy(string + 3, "\x00\x00\x00\x00", 4);          memcpy(string + 3, "\x00\x00\x00\x00", 4);
1965    
1966          if (data->speed_dial->memory_type == GN_MT_SM)          if (data->speed_dial->memory_type == GN_MT_SM)
1967                  string[7] = 0x06;                  string[7] = 0x06;
1968          else          else
1969                  string[7] = 0x05;                  string[7] = 0x05;
# Line 1965  static gn_error NK6510_SetSpeedDial(gn_d Line 1975  static gn_error NK6510_SetSpeedDial(gn_d
1975    
1976  static gn_error SetCallerBitmap(gn_data *data, struct gn_statemachine *state)  static gn_error SetCallerBitmap(gn_data *data, struct gn_statemachine *state)
1977  {  {
1978          unsigned char req[400] = {FBUS_FRAME_HEADER, 0x0B, 0x00, 0x01, 0x01, 0x00, 0x00, 0x10,          unsigned char req[400] = {FBUS_FRAME_HEADER, 0x0B, 0x00, 0x01, 0x01, 0x00, 0x00, 0x10,
1979                                   0xFF, 0x10,                                   0xFF, 0x10,
1980                                   0x00, 0x06, /* number */                                   0x00, 0x06, /* number */
1981                                   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,                                   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1982                                   0x01}; /* blocks */                                   0x01}; /* blocks */
1983          unsigned int count = 22, block = 0;          unsigned int count = 22, block = 0;
1984          char string[150];          char string[150];
1985          int i;          int i;
1986    
1987  /*  /*
1988    00 01 00 0B 00 01 01 00 00 10    00 01 00 0B 00 01 01 00 00 10
1989    FE 10    FE 10
1990    00 02    00 02
1991    00 00 00 00 00 00 00    00 00 00 00 00 00 00
1992    04    04
1993    1C 00 00 08 01 01 00 00    1C 00 00 08 01 01 00 00
1994    1E 00 00 08 02 02 00 00    1E 00 00 08 02 02 00 00
1995    1B 00 00 88 03 48 0E 00 00 7E CE A4 01 7D E0    1B 00 00 88 03 48 0E 00 00 7E CE A4 01 7D E0
1996    .....    .....
1997    07 00 00 0E 04 08 00 56 00 49 00 50 00 00    07 00 00 0E 04 08 00 56 00 49 00 50 00 00
1998  */  */
1999          if (!data->bitmap) return GN_ERR_INTERNALERROR;          if (!data->bitmap) return GN_ERR_INTERNALERROR;
2000    
# Line 2048  static gn_error GetCallerBitmap(gn_data Line 2058  static gn_error GetCallerBitmap(gn_data
2058          unsigned char req[] = {FBUS_FRAME_HEADER, 0x07,          unsigned char req[] = {FBUS_FRAME_HEADER, 0x07,
2059                                 0x01, 0x01, 0x00, 0x01,                                 0x01, 0x01, 0x00, 0x01,
2060                                 0xFE, 0x10,                                 0xFE, 0x10,
2061                                 0x00, 0x00, 0x00, 0x00, 0x00,                                 0x00, 0x00, 0x00, 0x00, 0x00,
2062                                 0x03,  /* location */                                 0x03,  /* location */
2063                                 0x00, 0x00};                                 0x00, 0x00};
2064    
# Line 2064  static gn_error GetCallerBitmap(gn_data Line 2074  static gn_error GetCallerBitmap(gn_data
2074  static gn_error NK6510_DeletePhonebookLocation(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_DeletePhonebookLocation(gn_data *data, struct gn_statemachine *state)
2075  {  {
2076          unsigned char req[] = {FBUS_FRAME_HEADER, 0x0f, 0x55, 0x01, 0x04, 0x55, 0x00, 0x10, 0xFF, 0x02,          unsigned char req[] = {FBUS_FRAME_HEADER, 0x0f, 0x55, 0x01, 0x04, 0x55, 0x00, 0x10, 0xFF, 0x02,
2077                                 0x00, 0x08,  /* location */                                 0x00, 0x08,  /* location */
2078                                 0x00, 0x00, 0x00, 0x00,                                 0x00, 0x00, 0x00, 0x00,
2079                                 0x05,  /* memory type */                                 0x05,  /* memory type */
2080                                 0x55, 0x55, 0x55};                                 0x55, 0x55, 0x55};
2081          gn_phonebook_entry *entry;          gn_phonebook_entry *entry;
2082    
2083          if (data->phonebook_entry)          if (data->phonebook_entry)
2084                  entry = data->phonebook_entry;                  entry = data->phonebook_entry;
2085          else          else
2086                  return GN_ERR_TRYAGAIN;                  return GN_ERR_TRYAGAIN;
2087    
2088          req[12] = (entry->location >> 8);          req[12] = (entry->location >> 8);
# Line 2094  static gn_error NK6510_WritePhonebookLoc Line 2104  static gn_error NK6510_WritePhonebookLoc
2104          unsigned int count = 22;          unsigned int count = 22;
2105          gn_phonebook_entry *entry;          gn_phonebook_entry *entry;
2106    
2107          if (data->phonebook_entry)          if (data->phonebook_entry)
2108                  entry = data->phonebook_entry;                  entry = data->phonebook_entry;
2109          else          else
2110                  return GN_ERR_TRYAGAIN;                  return GN_ERR_TRYAGAIN;
2111    
2112          req[11] = get_memory_type(entry->memory_type);          req[11] = get_memory_type(entry->memory_type);
# Line 2182  static gn_error NK6510_IncomingClock(int Line 2192  static gn_error NK6510_IncomingClock(int
2192  Unknown subtype of type 0x19 (clock handling): 0x1c  Unknown subtype of type 0x19 (clock handling): 0x1c
2193  UNHANDLED FRAME RECEIVED  UNHANDLED FRAME RECEIVED
2194  request: 0x19 / 0x0004  request: 0x19 / 0x0004
2195  00 01 00 1b                                     |                  00 01 00 1b                                     |                
2196  reply: 0x19 / 0x0012  reply: 0x19 / 0x0012
2197  01 23 00 1c 06 01 ff ff ff ff 00 00 49 4c 01 3e |  #    ÿÿÿÿ  IL >  01 23 00 1c 06 01 ff ff ff ff 00 00 49 4c 01 3e |  #    ÿÿÿÿ  IL >
2198  01 56  01 56
# Line 2246  static gn_error NK6510_GetDateTime(gn_da Line 2256  static gn_error NK6510_GetDateTime(gn_da
2256    
2257  static gn_error NK6510_SetDateTime(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_SetDateTime(gn_data *data, struct gn_statemachine *state)
2258  {  {
2259          unsigned char req[] = {FBUS_FRAME_HEADER, 0x01, 0x00, 0x01,          unsigned char req[] = {FBUS_FRAME_HEADER, 0x01, 0x00, 0x01,
2260                                 0x01, 0x0c, 0x01, 0x03,                                 0x01, 0x0c, 0x01, 0x03,
2261                                 0x07, 0xd2,      /* Year */                                 0x07, 0xd2,      /* Year */
2262                                 0x08, 0x01,     /* Month & Day */                                 0x08, 0x01,     /* Month & Day */
# Line 2290  static gn_error NK6510_GetAlarm(gn_data Line 2300  static gn_error NK6510_GetAlarm(gn_data
2300    
2301  static gn_error NK6510_SetAlarm(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_SetAlarm(gn_data *data, struct gn_statemachine *state)
2302  {  {
2303          unsigned char req[] = {FBUS_FRAME_HEADER, 0x11, 0x00, 0x01,          unsigned char req[] = {FBUS_FRAME_HEADER, 0x11, 0x00, 0x01,
2304                                 0x01, 0x0c, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00,                                 0x01, 0x0c, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00,
2305                                 0x00, 0x00,              /* Hours, Minutes */                                 0x00, 0x00,              /* Hours, Minutes */
2306                                 0x00, 0x00, 0x00 };                                 0x00, 0x00, 0x00 };
# Line 2327  static gn_error NK6510_IncomingCalendar( Line 2337  static gn_error NK6510_IncomingCalendar(
2337                  for (i = 0; i < message[6]; i++) {                  for (i = 0; i < message[6]; i++) {
2338                          if (8 + 2 * i >= length) break;                          if (8 + 2 * i >= length) break;
2339                          data->calnote_list->location[data->calnote_list->last+i] = message[8 + 2 * i] * 256 + message[9 + 2 * i];                          data->calnote_list->location[data->calnote_list->last+i] = message[8 + 2 * i] * 256 + message[9 + 2 * i];
2340                          dprintf("%i ", data->calnote_list->location[data->calnote_list->last+i]);                          dprintf("%i ", data->calnote_list->location[data->calnote_list->last+i]);
2341                  }                  }
2342                  dprintf("\n");                  dprintf("\n");
2343                  data->calnote_list->last += i;                  data->calnote_list->last += i;
# Line 2793  static gn_error NK6510_IncomingNetwork(i Line 2803  static gn_error NK6510_IncomingNetwork(i
2803                          dprintf("size: %i\n", data->bitmap->size);                          dprintf("size: %i\n", data->bitmap->size);
2804                          memcpy(data->bitmap->bitmap, message + 26, data->bitmap->size);                          memcpy(data->bitmap->bitmap, message + 26, data->bitmap->size);
2805                          dprintf("Logo (%dx%d) \n", data->bitmap->height, data->bitmap->width);                          dprintf("Logo (%dx%d) \n", data->bitmap->height, data->bitmap->width);
2806                  } else                  } else
2807                          return GN_ERR_INTERNALERROR;                          return GN_ERR_INTERNALERROR;
2808                  break;                  break;
2809          case 0x26:          case 0x26:
# Line 2838  static gn_error SetOperatorBitmap(gn_dat Line 2848  static gn_error SetOperatorBitmap(gn_dat
2848                                    0x0c, 0x08, /* type, length */                                    0x0c, 0x08, /* type, length */
2849                                    /* 0x62, 0xf2, 0x20, 0x03, 0x55, 0x55, */                                    /* 0x62, 0xf2, 0x20, 0x03, 0x55, 0x55, */
2850                                    0x62, 0xf2, 0x20, 0x03, 0x00, 0x00,                                    0x62, 0xf2, 0x20, 0x03, 0x00, 0x00,
2851                                    0x1a};                                    0x1a};
2852    
2853          memset(req + 19, 0, 881);          memset(req + 19, 0, 881);
2854          /*          /*
2855            00 01 00 25 01 55 00 00 55 02            00 01 00 25 01 55 00 00 55 02
2856            0C 08 62 F2 20 03 55 55            0C 08 62 F2 20 03 55 55
2857            1A F4 4E 15 00 EA 00 EA 5F 91 4E 80 5F 95 51 80 DF C2 DF 7D E0 4E 11 0E 80 55 20 E0 E0 F0 EA 7D E0 E0 7D E0 E            1A F4 4E 15 00 EA 00 EA 5F 91 4E 80 5F 95 51 80 DF C2 DF 7D E0 4E 11 0E 80 55 20 E0 E0 F0 EA 7D E0 E0 7D E0 E
2858          */          */
2859          if ((data->bitmap->width != state->driver.phone.operator_logo_width) ||          if ((data->bitmap->width != state->driver.phone.operator_logo_width) ||
2860              (data->bitmap->height != state->driver.phone.operator_logo_height)) {              (data->bitmap->height != state->driver.phone.operator_logo_height)) {
2861                  dprintf("Invalid image size - expecting (%dx%d) got (%dx%d)\n",                  dprintf("Invalid image size - expecting (%dx%d) got (%dx%d)\n",
2862                          state->driver.phone.operator_logo_height, state->driver.phone.operator_logo_width, data->bitmap->height, data->bitmap->width);                          state->driver.phone.operator_logo_height, state->driver.phone.operator_logo_width, data->bitmap->height, data->bitmap->width);
2863                  return GN_ERR_INVALIDSIZE;                  return GN_ERR_INVALIDSIZE;
2864          }          }
# Line 3100  static gn_error NK6510_IncomingStartup(i Line 3110  static gn_error NK6510_IncomingStartup(i
3110          /*          /*
3111  UNHANDLED FRAME RECEIVED  UNHANDLED FRAME RECEIVED
3112  request: 0x7a / 0x0005  request: 0x7a / 0x0005
3113  00 01 00 02 0b                                  |                  00 01 00 02 0b                                  |                
3114  reply: 0x7a / 0x0036  reply: 0x7a / 0x0036
3115  01 44 00 03 0b 00 00 00 01 38 00 00 00 00 00 00 |  D       8        01 44 00 03 0b 00 00 00 01 38 00 00 00 00 00 00 |  D       8    
3116  35 5f 00 00 00 00 00 00 00 3e 00 00 00 00 00 00 | 5_       >        35 5f 00 00 00 00 00 00 00 3e 00 00 00 00 00 00 | 5_       >    
3117  36 97 00 00 00 00 01 55 55 55 55 55 55 55 55 55 | 6      UUUUUUUUU  36 97 00 00 00 00 01 55 55 55 55 55 55 55 55 55 | 6      UUUUUUUUU
3118  55 55 55 55 55 55                               | UUUUUU            55 55 55 55 55 55                               | UUUUUU        
3119          */          */
3120          switch (message[3]) {          switch (message[3]) {
3121          case 0x03:          case 0x03:
# Line 3168  reply: 0x7a / 0x0036 Line 3178  reply: 0x7a / 0x0036
3178    
3179  static gn_error SetStartupBitmap(gn_data *data, struct gn_statemachine *state)  static gn_error SetStartupBitmap(gn_data *data, struct gn_statemachine *state)
3180  {  {
3181          unsigned char req[1000] = {FBUS_FRAME_HEADER, 0x04, 0x0f, 0x00, 0x00, 0x00, 0x04,          unsigned char req[1000] = {FBUS_FRAME_HEADER, 0x04, 0x0f, 0x00, 0x00, 0x00, 0x04,
3182                                     0xc0, 0x02, 0x00, 0x00,           /* Height */                                     0xc0, 0x02, 0x00, 0x00,           /* Height */
3183                                     0xc0, 0x03, 0x00, 0x00,           /* Width */                                     0xc0, 0x03, 0x00, 0x00,           /* Width */
3184                                     0xc0, 0x04, 0x03, 0x60 };         /* size */                                     0xc0, 0x04, 0x03, 0x60 };         /* size */
# Line 3177  static gn_error SetStartupBitmap(gn_data Line 3187  static gn_error SetStartupBitmap(gn_data
3187    
3188          if ((data->bitmap->width != state->driver.phone.startup_logo_width) ||          if ((data->bitmap->width != state->driver.phone.startup_logo_width) ||
3189              (data->bitmap->height != state->driver.phone.startup_logo_height)) {              (data->bitmap->height != state->driver.phone.startup_logo_height)) {
3190                  dprintf("Invalid image size - expecting (%dx%d) got (%dx%d)\n",                  dprintf("Invalid image size - expecting (%dx%d) got (%dx%d)\n",
3191                          state->driver.phone.startup_logo_height, state->driver.phone.startup_logo_width,                          state->driver.phone.startup_logo_height, state->driver.phone.startup_logo_width,
3192                          data->bitmap->height, data->bitmap->width);                          data->bitmap->height, data->bitmap->width);
3193    
3194              return GN_ERR_INVALIDSIZE;              return GN_ERR_INVALIDSIZE;
# Line 3299  static gn_error NK6510_IncomingProfile(i Line 3309  static gn_error NK6510_IncomingProfile(i
3309                  for (i = 0; i < message[5]; i++) {                  for (i = 0; i < message[5]; i++) {
3310                          switch (blockstart[2]) {                          switch (blockstart[2]) {
3311                          case 0x00:                          case 0x00:
3312                                  if (message[4] == 0x00)                                  if (message[4] == 0x00)
3313                                          dprintf("keypad tone level successfully set!\n");                                          dprintf("keypad tone level successfully set!\n");
3314                                  else                                  else
3315                                          dprintf("failed to set keypad tone level! error: %i\n", message[4]);                                          dprintf("failed to set keypad tone level! error: %i\n", message[4]);
3316                                  break;                                  break;
3317                          case 0x02:                          case 0x02:
3318                                  if (message[4] == 0x00)                                  if (message[4] == 0x00)
3319                                          dprintf("call alert successfully set!\n");                                          dprintf("call alert successfully set!\n");
3320                                  else                                  else
3321                                          dprintf("failed to set call alert! error: %i\n", message[4]);                                          dprintf("failed to set call alert! error: %i\n", message[4]);
3322                                  break;                                  break;
3323                          case 0x03:                          case 0x03:
3324                                  if (message[4] == 0x00)                                  if (message[4] == 0x00)
3325                                          dprintf("ringtone successfully set!\n");                                          dprintf("ringtone successfully set!\n");
3326                                  else                                  else
3327                                          dprintf("failed to set ringtone! error: %i\n", message[4]);                                          dprintf("failed to set ringtone! error: %i\n", message[4]);
3328                                  break;                                  break;
3329                          case 0x04:                          case 0x04:
3330                                  if (message[4] == 0x00)                                  if (message[4] == 0x00)
3331                                          dprintf("ringtone volume successfully set!\n");                                          dprintf("ringtone volume successfully set!\n");
3332                                  else                                  else
3333                                          dprintf("failed to set ringtone volume! error: %i\n", message[4]);                                          dprintf("failed to set ringtone volume! error: %i\n", message[4]);
3334                                  break;                                  break;
3335                          case 0x05:                          case 0x05:
3336                                  if (message[4] == 0x00)                                  if (message[4] == 0x00)
3337                                          dprintf("message tone successfully set!\n");                                          dprintf("message tone successfully set!\n");
3338                                  else                                  else
3339                                          dprintf("failed to set message tone! error: %i\n", message[4]);                                          dprintf("failed to set message tone! error: %i\n", message[4]);
3340                                  break;                                  break;
3341                          case 0x06:                          case 0x06:
3342                                  if (message[4] == 0x00)                                  if (message[4] == 0x00)
3343                                          dprintf("vibration successfully set!\n");                                          dprintf("vibration successfully set!\n");
3344                                  else                                  else
3345                                          dprintf("failed to set vibration! error: %i\n", message[4]);                                          dprintf("failed to set vibration! error: %i\n", message[4]);
3346                                  break;                                  break;
3347                          case 0x07:                          case 0x07:
3348                                  if (message[4] == 0x00)                                  if (message[4] == 0x00)
3349                                          dprintf("warning tone level successfully set!\n");                                          dprintf("warning tone level successfully set!\n");
3350                                  else                                  else
3351                                          dprintf("failed to set warning tone level! error: %i\n", message[4]);                                          dprintf("failed to set warning tone level! error: %i\n", message[4]);
3352                                  break;                                  break;
3353                          case 0x08:                          case 0x08:
3354                                  if (message[4] == 0x00)                                  if (message[4] == 0x00)
3355                                          dprintf("caller groups successfully set!\n");                                          dprintf("caller groups successfully set!\n");
3356                                  else                                  else
3357                                          dprintf("failed to set caller groups! error: %i\n", message[4]);                                          dprintf("failed to set caller groups! error: %i\n", message[4]);
3358                                  break;                                  break;
3359                          case 0x0c:                          case 0x0c:
3360                                  if (message[4] == 0x00)                                  if (message[4] == 0x00)
3361                                          dprintf("name successfully set!\n");                                          dprintf("name successfully set!\n");
3362                                  else                                  else
3363                                          dprintf("failed to set name! error: %i\n", message[4]);                                          dprintf("failed to set name! error: %i\n", message[4]);
# Line 3639  static gn_error NK6510_IncomingSecurity( Line 3649  static gn_error NK6510_IncomingSecurity(
3649                          dprintf("SIM rejected!\n");                          dprintf("SIM rejected!\n");
3650                          data->security_code->type = GN_SCT_None;                          data->security_code->type = GN_SCT_None;
3651                          break;                          break;
3652                  default:                  default:
3653                          dprintf(_("Unknown!\n"));                          dprintf(_("Unknown!\n"));
3654                          return GN_ERR_UNHANDLEDFRAME;                          return GN_ERR_UNHANDLEDFRAME;
3655                  }                  }
3656                  break;                  break;
# Line 3663  static gn_error NK6510_GetSecurityCodeSt Line 3673  static gn_error NK6510_GetSecurityCodeSt
3673    
3674  static gn_error NK6510_EnterSecurityCode(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_EnterSecurityCode(gn_data *data, struct gn_statemachine *state)
3675  {  {
3676          unsigned char req[35] = {FBUS_FRAME_HEADER, 0x07,          unsigned char req[35] = {FBUS_FRAME_HEADER, 0x07,
3677                                   0x02 }; /* 0x02 PIN, 0x03 PUK */                                   0x02 }; /* 0x02 PIN, 0x03 PUK */
3678          int len ;          int len ;
3679                    
# Line 3732  static gn_error NK6510_Reset(gn_data *da Line 3742  static gn_error NK6510_Reset(gn_data *da
3742          else if (data->reset_type == 0x04) {          else if (data->reset_type == 0x04) {
3743                  printf("Hard resetting....\n");                  printf("Hard resetting....\n");
3744                  if (sm_message_send(10, NK6510_MSG_RADIO, req2, state)) return GN_ERR_NOTREADY;                  if (sm_message_send(10, NK6510_MSG_RADIO, req2, state)) return GN_ERR_NOTREADY;
3745                  return sm_block(NK6510_MSG_RADIO, data, state);                  return sm_block(NK6510_MSG_RADIO, data, state);
3746          } else return GN_ERR_INTERNALERROR;          } else return GN_ERR_INTERNALERROR;
3747  }  }
3748    
# Line 3963  static gn_error NK6510_IncomingWAP(int m Line 3973  static gn_error NK6510_IncomingWAP(int m
3973                  pos = string_length + 6;                  pos = string_length + 6;
3974                  if (!(string_length % 2)) pad = 1;                  if (!(string_length % 2)) pad = 1;
3975    
3976                  string_length = message[pos++] << 8;                  string_length = message[pos++] << 8;
3977                  string_length = (string_length | message[pos++]) << 1;                  string_length = (string_length | message[pos++]) << 1;
3978                  char_unicode_decode(data->wap_setting->home, message + pos, string_length);                  char_unicode_decode(data->wap_setting->home, message + pos, string_length);
3979                  dprintf("Home: %s\n", data->wap_setting->home);                  dprintf("Home: %s\n", data->wap_setting->home);
3980                  pos += string_length;                  pos += string_length;
3981    
3982                  if (!((string_length + pad) % 2))                  if (!((string_length + pad) % 2))
3983                          pad = 2;                          pad = 2;
3984                  else                  else
3985                          pad = 0;                          pad = 0;
3986                                    
3987                  data->wap_setting->session = message[pos++];                  data->wap_setting->session = message[pos++];
# Line 3997  static gn_error NK6510_IncomingWAP(int m Line 4007  static gn_error NK6510_IncomingWAP(int m
4007                  dprintf("   IP: %s\n", data->wap_setting->gsm_data_ip);                  dprintf("   IP: %s\n", data->wap_setting->gsm_data_ip);
4008                  pos += string_length;                  pos += string_length;
4009    
4010                  string_length = message[pos++] << 8;                  string_length = message[pos++] << 8;
4011                  string_length = (string_length | message[pos++]) << 1;                  string_length = (string_length | message[pos++]) << 1;
4012                  char_unicode_decode(data->wap_setting->number, message + pos, string_length);                  char_unicode_decode(data->wap_setting->number, message + pos, string_length);
4013                  dprintf("   Number: %s\n", data->wap_setting->number);                  dprintf("   Number: %s\n", data->wap_setting->number);
4014                  pos += string_length;                  pos += string_length;
4015    
4016                  string_length = message[pos++] << 8;                  string_length = message[pos++] << 8;
4017                  string_length = (string_length | message[pos++]) << 1;                  string_length = (string_length | message[pos++]) << 1;
4018                  char_unicode_decode(data->wap_setting->gsm_data_username, message + pos, string_length);                  char_unicode_decode(data->wap_setting->gsm_data_username, message + pos, string_length);
4019                  dprintf("   Username: %s\n", data->wap_setting->gsm_data_username);                  dprintf("   Username: %s\n", data->wap_setting->gsm_data_username);
4020                  pos += string_length;                  pos += string_length;
4021    
4022                  string_length = message[pos++] << 8;                  string_length = message[pos++] << 8;
4023                  string_length = (string_length | message[pos++]) << 1;                  string_length = (string_length | message[pos++]) << 1;
4024                  char_unicode_decode(data->wap_setting->gsm_data_password, message + pos, string_length);                  char_unicode_decode(data->wap_setting->gsm_data_password, message + pos, string_length);
4025                  dprintf("   Password: %s\n", data->wap_setting->gsm_data_password);                  dprintf("   Password: %s\n", data->wap_setting->gsm_data_password);
# Line 4029  static gn_error NK6510_IncomingWAP(int m Line 4039  static gn_error NK6510_IncomingWAP(int m
4039                  dprintf("   Access point: %s\n", data->wap_setting->access_point_name);                  dprintf("   Access point: %s\n", data->wap_setting->access_point_name);
4040                  pos += string_length;                  pos += string_length;
4041    
4042                  string_length = message[pos++] << 8;                  string_length = message[pos++] << 8;
4043                  string_length = (string_length | message[pos++]) << 1;                  string_length = (string_length | message[pos++]) << 1;
4044                  char_unicode_decode(data->wap_setting->gprs_ip, message + pos, string_length);                  char_unicode_decode(data->wap_setting->gprs_ip, message + pos, string_length);
4045                  dprintf("   IP: %s\n", data->wap_setting->gprs_ip);                  dprintf("   IP: %s\n", data->wap_setting->gprs_ip);
4046                  pos += string_length;                  pos += string_length;
4047    
4048                  string_length = message[pos++] << 8;                  string_length = message[pos++] << 8;
4049                  string_length = (string_length | message[pos++]) << 1;                  string_length = (string_length | message[pos++]) << 1;
4050                  char_unicode_decode(data->wap_setting->gprs_username, message + pos, string_length);                  char_unicode_decode(data->wap_setting->gprs_username, message + pos, string_length);
4051                  dprintf("   Username: %s\n", data->wap_setting->gprs_username);                  dprintf("   Username: %s\n", data->wap_setting->gprs_username);
4052                  pos += string_length;                  pos += string_length;
4053    
4054                  if (message[pos] != 0x80) {                  if (message[pos] != 0x80) {
4055                          string_length = message[pos++] << 8;                          string_length = message[pos++] << 8;
4056                          string_length |= message[pos++];                          string_length |= message[pos++];
4057                          char_unicode_decode(data->wap_setting->gprs_password, message + pos, string_length);                          char_unicode_decode(data->wap_setting->gprs_password, message + pos, string_length);
4058                          dprintf("   Password: %s\n", data->wap_setting->gprs_password);                          dprintf("   Password: %s\n", data->wap_setting->gprs_password);
# Line 4134  static gn_error NK6510_WriteWAPSetting(g Line 4144  static gn_error NK6510_WriteWAPSetting(g
4144    
4145          /* Home */          /* Home */
4146          length = strlen(data->wap_setting->home);          length = strlen(data->wap_setting->home);
4147          if (((length + pad) % 2))          if (((length + pad) % 2))
4148                  pad = 2;                  pad = 2;
4149          else          else
4150                  pad = 0;                  pad = 0;
4151          pos += PackWAPString(req + pos, data->wap_setting->home, 2);          pos += PackWAPString(req + pos, data->wap_setting->home, 2);
4152    
# Line 4326  static gn_error NK6510_ActivateWAPSettin Line 4336  static gn_error NK6510_ActivateWAPSettin
4336    
4337  static gn_error NK6510_GetToDo_Internal(gn_data *data, struct gn_statemachine *state, int location)  static gn_error NK6510_GetToDo_Internal(gn_data *data, struct gn_statemachine *state, int location)
4338  {  {
4339          unsigned char req[] = {FBUS_FRAME_HEADER, 0x03,          unsigned char req[] = {FBUS_FRAME_HEADER, 0x03,
4340                                 0x00, 0x00, 0x80, 0x00,                                 0x00, 0x00, 0x80, 0x00,
4341                                 0x00, 0x01};             /* Location */                                 0x00, 0x01};             /* Location */
4342    
# Line 4415  static gn_error NK6510_IncomingToDo(int Line 4425  static gn_error NK6510_IncomingToDo(int
4425    
4426  static gn_error NK6510_GetToDoLocations(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_GetToDoLocations(gn_data *data, struct gn_statemachine *state)
4427  {  {
4428          unsigned char req[] = { FBUS_FRAME_HEADER, 0x15,          unsigned char req[] = { FBUS_FRAME_HEADER, 0x15,
4429                                  0x01, 0x00, 0x00,                                  0x01, 0x00, 0x00,
4430                                  0x00, 0x00, 0x00};                                  0x00, 0x00, 0x00};
4431    
# Line 4438  static gn_error GetNextFreeToDoLocation( Line 4448  static gn_error GetNextFreeToDoLocation(
4448    
4449  static gn_error NK6510_GetToDo(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_GetToDo(gn_data *data, struct gn_statemachine *state)
4450  {  {
4451          unsigned char req[] = {FBUS_FRAME_HEADER, 0x03,          unsigned char req[] = {FBUS_FRAME_HEADER, 0x03,
4452                                 0x00, 0x00, 0x80, 0x00,                                 0x00, 0x00, 0x80, 0x00,
4453                                 0x00, 0x01};             /* Location */                                 0x00, 0x01};             /* Location */
4454          gn_error error;          gn_error error;
# Line 4459  static gn_error NK6510_GetToDo(gn_data * Line 4469  static gn_error NK6510_GetToDo(gn_data *
4469    
4470  static gn_error NK6510_WriteToDo(gn_data *data, struct gn_statemachine *state)  static gn_error NK6510_WriteToDo(gn_data *data, struct gn_statemachine *state)
4471  {  {
4472          unsigned char req[300] = {FBUS_FRAME_HEADER, 0x01,          unsigned char req[300] = {FBUS_FRAME_HEADER, 0x01,
4473                                    0x02, /* prority */                                    0x02, /* prority */
4474                                    0x0E, /* length of the text + 1 */                                    0x0E, /* length of the text + 1 */
4475                                    0x80, 0x00,                                    0x80, 0x00,
# Line 4814  static int sms_encode(gn_data *data, str Line 4824  static int sms_encode(gn_data *data, str
4824                  req[pos++] = 0x02; /* message type: submit */                  req[pos++] = 0x02; /* message type: submit */
4825                    
4826          req[pos++] = 0x00; /* will be set at the end */          req[pos++] = 0x00; /* will be set at the end */
4827          /*        is supposed to be the length of the whole message          /*        is supposed to be the length of the whole message
4828                    starting from req[10], which is the message type */                    starting from req[10], which is the message type */
4829    
4830          if (data->raw_sms->type == GN_SMS_MT_Deliver) {          if (data->raw_sms->type == GN_SMS_MT_Deliver) {

Legend:
Removed from v.1.170  
changed lines
  Added in v.1.171

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26