24 #ifdef GSM_ENABLE_ATGEN 30 #define TOKEN_DATA_0 0x00 31 #define TOKEN_DATA_1 0x01 32 #define TOKEN_DATA_2 0x02 33 #define TOKEN_DATA_3 0x03 34 #define TOKEN_DATA_4 0x04 35 #define TOKEN_DATA_5 0x05 36 #define TOKEN_DATA_6 0x06 37 #define TOKEN_DATA_7 0x07 38 #define TOKEN_DATA_8 0x08 39 #define TOKEN_DATA_9 0x09 40 #define TOKEN_DATA_A 0x0A 41 #define TOKEN_DATA_B 0x0B 42 #define TOKEN_DATA_C 0x0C 43 #define TOKEN_DATA_D 0x0D 44 #define TOKEN_DATA_E 0x0E 45 #define TOKEN_DATA_F 0x0F 46 #define TOKEN_COMMAND_ZISI_ECHO 0x10 47 #define TOKEN_RESPONSE_ZISI 0x11 48 #define TOKEN_RESPONSE_OK 0x12 49 #define TOKEN_WHITESPACE 0x13 50 #define TOKEN_UNKNOWN 0x14 52 #define STATE_ALPHA0 0 53 #define STATE_ALPHA1 1 56 #define STATE_GREEN0 4 57 #define STATE_GREEN1 5 61 typedef unsigned char u8;
62 typedef unsigned short u16;
63 typedef unsigned int u32;
71 smprintf(s,
"Get Sony Ericsson screenshot\n");
92 int h, w, param3, param4;
96 smprintf(s,
"Screenshot size received\n");
111 "*ZISI: @i, @i, @i, @i",
132 smprintf(s,
"Screen size is %ix%i\n", w, h);
140 }
while (strcmp(
"OK",
string) != 0);
157 static void u32_store(u8 *p, u32 data) {
170 static void u16_store(u8 *p, u16 data) {
179 static int SONYERICSSON_Screenshot_createBMPHeader(
unsigned int w,
unsigned int h, u8 *p) {
188 data = 14 + 40 + w * h * 4;
189 u32_store(p+2, data);
193 u32_store(p+6, data);
197 u32_store(p+10, data);
201 u32_store(p+14, data);
205 u32_store(p+18, data);
209 u32_store(p+22, data);
213 u16_store(p+26, data16);
217 u16_store(p+28, data16);
221 u32_store(p+30, data);
225 u32_store(p+34, data);
229 u32_store(p+38, data);
233 u32_store(p+42, data);
237 u32_store(p+46, data);
241 u32_store(p+50, data);
246 static int SONYERICSSON_Screenshot_addPixel(u8 alpha, u8 red, u8 green, u8 blue, u8 *p) {
264 u8 alpha = 0, red = 0, green = 0, blue = 0;
271 smprintf(s,
"Screenshot data received\n");
283 length = SONYERICSSON_Screenshot_createBMPHeader(w, h, p);
288 state = STATE_ALPHA0;
289 while (i < msg->BufferUsed) {
315 if (strlen(
"AT*ZISI") <= msg->
BufferUsed - i && strncmp(&msg->
Buffer[i],
"AT*ZISI", strlen(
"AT*ZISI")) == 0) {
316 token = TOKEN_COMMAND_ZISI_ECHO;
317 i += strlen(
"AT*ZISI");
319 token = TOKEN_DATA_A;
324 if (strlen(
"*ZISI:") <= msg->
BufferUsed - i && strncmp(&msg->
Buffer[i],
"*ZISI:", strlen(
"*ZISI:")) == 0) {
325 token = TOKEN_RESPONSE_ZISI;
326 i += strlen(
"*ZISI:");
328 token = TOKEN_UNKNOWN;
333 if (strlen(
"OK") <= msg->
BufferUsed - i && strncmp(&msg->
Buffer[i],
"OK", strlen(
"OK")) == 0) {
334 token = TOKEN_RESPONSE_OK;
337 token = TOKEN_UNKNOWN;
344 token = TOKEN_WHITESPACE;
348 token = TOKEN_DATA_0;
352 token = TOKEN_DATA_1;
356 token = TOKEN_DATA_2;
360 token = TOKEN_DATA_3;
364 token = TOKEN_DATA_4;
368 token = TOKEN_DATA_5;
372 token = TOKEN_DATA_6;
376 token = TOKEN_DATA_7;
380 token = TOKEN_DATA_8;
384 token = TOKEN_DATA_9;
388 token = TOKEN_DATA_B;
392 token = TOKEN_DATA_C;
396 token = TOKEN_DATA_D;
400 token = TOKEN_DATA_E;
404 token = TOKEN_DATA_F;
408 token = TOKEN_UNKNOWN;
413 case TOKEN_COMMAND_ZISI_ECHO:
414 case TOKEN_RESPONSE_ZISI:
415 case TOKEN_RESPONSE_OK:
416 case TOKEN_WHITESPACE:
438 state = STATE_ALPHA1;
441 alpha = (alpha << 4) | token;
449 red = (red << 4) | token;
450 state = STATE_GREEN0;
454 state = STATE_GREEN1;
457 green = (green << 4) | token;
465 blue = (blue << 4) | token;
466 length = SONYERICSSON_Screenshot_addPixel(alpha, red, green, blue, p);
469 state = STATE_ALPHA0;
GSM_BinaryPicture * Picture
GSM_Error ATGEN_HandleCMEError(GSM_StateMachine *s)
GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *s)
const char * GetLineString(const char *message, GSM_CutLines *lines, int start)
GSM_BinaryPicture_Types Type
#define SONYERICSSON_TIMEOUT
#define GSM_WaitForAutoLen(s, buffer, type, timeout, request)
struct GSM_Phone_Data::@2 Priv
GSM_Error ATGEN_ParseReply(GSM_StateMachine *s, const unsigned char *input, const char *format,...)
GSM_Error SONYERICSSON_Reply_ScreenshotData(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error SONYERICSSON_Reply_Screenshot(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error SONYERICSSON_GetScreenshot(GSM_StateMachine *s, GSM_BinaryPicture *picture)
GSM_AT_Reply_State ReplyState
int smprintf(GSM_StateMachine *s, const char *format,...)