aboutsummaryrefslogtreecommitdiff
path: root/smartpen.h
diff options
context:
space:
mode:
Diffstat (limited to 'smartpen.h')
-rw-r--r--smartpen.h37
1 files changed, 28 insertions, 9 deletions
diff --git a/smartpen.h b/smartpen.h
index 18ac955..e3dadad 100644
--- a/smartpen.h
+++ b/smartpen.h
@@ -27,7 +27,7 @@
#define SMARTPEN_DPI_X (677.3333)
#define SMARTPEN_DPI_Y (677.3333)
-// TODO: These values are mostly random.
+// TODO: These values are obtained by observation and may be wrong
#define SMARTPEN_BLEED_X 333.3
#define SMARTPEN_BLEED_Y 333.3
@@ -40,19 +40,29 @@ public:
~Smartpen();
typedef QPair<unsigned int, unsigned int> Address;
- typedef qint64 PenTime;
typedef quint64 PenId;
+ typedef quint64 PenTime;
bool isConnected() const;
- enum Parameters {
- PenName = 8011
+ enum class Parameter : quint16 {
+ Id = 0x0000,
+ /// The offset between the RtcTime (see below) and the user's configured time. This value is fixed at setup time.
+ UserTime = 0x8003,
+ /// The current time as reported by the pen's rtc
+ RtcTime = 0x8004,
+ Type = 0x8006,
+ Name = 0x8011
};
QByteArray getObject(const QString& name);
- QString getParameter(Parameters parameter);
+ QByteArray getParameter(Parameter parameter);
+ PenId getPenId();
+ QString getPenSerial();
QString getPenName();
+ PenTime getPenTime(Parameter parameter);
+
QVariantMap getPenInfo();
struct ChangeReport {
@@ -67,18 +77,19 @@ public:
QByteArray getLspData(const QString &name, PenTime from = 0);
QByteArray getPaperReplay(PenTime from = 0);
- static PenTime toPenTime(const QDateTime &dt);
- static QDateTime fromPenTime(PenTime t);
+ static QDateTime fromPenTime(PenTime userTime, PenTime penTime);
static QString toPenSerial(PenId id);
static PenId toPenId(const QString &serial);
+ static bool reset(const Address &addr);
+
public slots:
bool connectToPen(const Address &addr);
void disconnectFromPen();
signals:
- void error();
+ void linkError(const QString &msg);
private:
static void obexEventCb(obex_t *handle, obex_object_t *obj,
@@ -86,17 +97,25 @@ private:
void handleObexEvent(obex_object_t *object,
int event, int obex_cmd, int obex_rsp);
void handleObexRequestDone(obex_object_t *object, int obex_cmd, int obex_rsp);
+ void handleObexContinue(obex_object_t *object, int obex_cmd);
+
+ void prepareRequest();
+ bool waitForRequestComplete(int timeout);
+ void addConnHeader(obex_object_t *object) const;
+ bool sendContinue(int obex_cmd);
static QString toPenSerialSegment(quint32 id, int len);
static quint32 fromPenSerialSegment(const QString &s);
static QByteArray encodeUtf16(const QString &s);
- void addConnHeader(obex_object_t *object) const;
+
private:
obex_t * _obex;
quint32 _connId;
QByteArray _inBuf;
+ bool _reqComplete;
+ uint _continueReceived;
};
#endif // SMARTPEN_H