X-Git-Url: https://git.kernelconcepts.de/?p=metawatch.git;a=blobdiff_plain;f=metawatch.c;h=2d9b929e2da28c83f32b35294fbb42365f92494e;hp=4576d9f6d175a16df63ce79f7180b76cfe3b5287;hb=b11171caa5c6ef0a685c134ea01b89a8330bd74e;hpb=9dfd9948629cef149bc4d3ff7f4d949072959e64 diff --git a/metawatch.c b/metawatch.c index 4576d9f..2d9b929 100644 --- a/metawatch.c +++ b/metawatch.c @@ -130,6 +130,22 @@ int mw_set_rtc(mwdevice_t *mwdevice, unsigned char clk1224, unsigned char date_f return mw_send_frame(mwdevice, MW_SET_REAL_TIME_CLOCK, 0, data, 10); } +int mw_nval_operation(mwdevice_t *mwdevice, unsigned char operation, unsigned short identifier, unsigned char size, void *mdata) +{ + unsigned char data[32]; + + data[0] = (identifier & 0xff00) >> 8; + data[1] = (identifier & 0x00ff); + data[2] = size; + if (size > 0 && mdata != NULL) + memcpy((data+3), mdata, size); + + if (operation == MW_NVAL_OPERATION_READ || operation == MW_NVAL_OPERATION_WRITE) { + return mw_send_frame(mwdevice, MW_NVAL_OPERATION, operation, data, 3+size); + } else + return -1; +} + int mw_set_vibrate_mode(mwdevice_t *mwdevice, unsigned char enable, unsigned short on_time, unsigned short off_time, unsigned char cycles) { unsigned char mdata[7]; @@ -292,11 +308,11 @@ int mw_advance_watch_hands(mwdevice_t *mwdevice, unsigned char hours, unsigned c return mw_send_frame(mwdevice, MW_ADVANCE_WATCH_HANDS, 0, mdata, 3); } + /* ---------------------------------------------------------------------- * Watch responses, events or notifications * ---------------------------------------------------------------------- */ - int mw_get_device_type_response(mwdevice_t *mwdevice, unsigned char devtype) { #ifdef DEBUG @@ -336,6 +352,10 @@ void mw_set_get_device_type_response_cb(mwdevice_t *mwdevice, void (*mw_get_devi mwdevice->mw_gdtypersp_data = user_data; } +int mw_nval_operation_response(mwdevice_t *mwdevice, unsigned char operation, unsigned short identifier, unsigned char size, void *mdata) +{ + return -1; +} int mw_get_real_time_clock_response(mwdevice_t *mwdevice, unsigned char *rtcrsp, int len) { @@ -535,6 +555,29 @@ int mw_decode_frame(mwdevice_t *mwdevice, unsigned char *buf, int len) case MW_LOW_BATTERY_BT_OFF_MSG: fprintf(stderr, "Watch battery extremely low - radio will turn off\n"); break; + case MW_NVAL_OPERATION_RSP: + fprintf(stderr, "NVAL operation response - "); + switch (msgopt) { + case 0x00: + fprintf(stderr, "success\n"); + break; + case 0x01: + fprintf(stderr, "failure!\n"); + break; + case 0x09: + fprintf(stderr, "Item Not initialized (Identifier Not found\n"); + break; + case 0x0a: + fprintf(stderr, "Operation failed\n"); + break; + case 0x0c: + fprintf(stderr, "Bad Item length\n"); + break; + default: + fprintf(stderr, "unknown status 0x%02x\n", msgopt); + break; + }; + break; case MW_STATUS_CHANGE_EVENT: mw_status_change_event(mwdevice, msgopt, msgdata, msgdatalen); break; @@ -571,7 +614,7 @@ int mw_feed_msg_buffer(mwdevice_t *mwdevice, unsigned char *buf, int len) } /* here we have a complete msg */ memcpy(msgbuf, mwdevice->pbuf, tlen); - mw_decode_frame(mwdevice, msgbuf, tlen); + mw_decode_frame(mwdevice, (unsigned char *)msgbuf, tlen); memmove(mwdevice->pbuf, (mwdevice->pbuf+tlen), tlen); mwdevice->pbuf_len -= tlen; }