-
Notifications
You must be signed in to change notification settings - Fork 0
/
Print2BT.h
75 lines (59 loc) · 1.85 KB
/
Print2BT.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* File: Print2BT.h
*
* Author: IvanU @ Ivanix Mobile LLC
*
* Description: Code for use with MoSync SDK (3.3) to provide Html5 Hybrid app with
* javascript access to Bluetooth Printer with optional Magnetic Card Reader
* Atm, only printers with SPP profile supported. Tested on Android platform only.
*
* Credit to Sam Pickard and Naveed Asif examples of MoSync BT api
* http://www.mosync.com/docs/sdk/cpp/guides/bluetooth/discovering-devices-and-services-bluetooth/index.html
*/
#ifndef BluePrintPlus_H_
#define BluePrintPlus_H_
#include <MAUtil/BluetoothDiscovery.h>
#include <MAUtil/BluetoothConnection.h>
#include <MAUtil/MAUUID.h>
#include <conprint.h>
/*
#include <Wormhole/WebAppMoblet.h>>
*/
#include <Wormhole/HybridMoblet.h>
#include <Wormhole/Encoder.h>
using namespace MAUtil;
using namespace Wormhole;
class Print2BT :
public BluetoothDeviceDiscoveryListener,
public ConnectionListener
{
public:
Print2BT(HybridMoblet* webApp);
virtual ~Print2BT();
BluetoothConnection channel;
// Callbacks Required By BluetoothDeviceDiscoveryListener
void btNewDevice (const BtDevice &dev);
void btDeviceDiscoveryFinished (int state);
void connectFinished (Connection *conn, int result);
void connRecvFinished (Connection *conn, int result);
void connWriteFinished (Connection *conn, int result);
void connReadFinished (Connection *conn, int result);
void Discover();
void Cancel();
void Open(int idx, const MAUUID &uuidProfile);
void Read();
void ReadBase64();
void Recv();
void RecvBase64();
private:
HybridMoblet* webApp;
BluetoothDiscoverer* dvcDiscover;
bool btBusy;
bool base64Conv;
Vector<BtDevice> dvcVector;
char readbuf[512];
void jsStatus(const char *msg);
void jsEvent(const char *event, const char *args);
void dvcReset();
};
#endif /* BluePrintPlus_H_ */