Every bluetooth printer requires data to be sent in a particular format when it comes to printing.For
example Access printer -Model-DA320 (AMDL_BCTD)
requires data to be prefixed with a start packet and ends with a CRC value.
Please look at http://www.datecs.bg/en/products/DPP-350/2/162# , they seem to have a SDK for printing.
Please ask for protocol documentation from the printer, use AccessPrinter sample for reference and
use the code appropriately.
Dear,
>>
>>We are using the bluetooth printer with print, but we are in trouble at the time of printing. We are
using the example below contained in the help of the tool itself, but it performs all procedures at
the time of printing but it does not respond. The Code seeks bluetooth device, find, makes the pairing
of these, prompts for the password to connect to it, displays connected, but at press time it does not print, despite entering the method and pass all checks.
>>
>>The printer we are using is:
>>
>>Mobile Thermal Printer DPP-350 DATECS - http://www.datecs.bg/en/products/DPP-350/2/162
>>
>>The problem is in the execution of this command:
>>setosvar ("* btdevsenddata", "Thanks Lord Ganesh \ n")
>>
>>The printer does not print through the previous command.
>>
>>What are the standards supported by GoDB impressions?
>>
>>The code is used as an example:
>>
>>Q) How do I print to a bluetooth printer through a GoDB application.
>>A) Give Access Bluetooth permission to the apk. Read the app permissions section as listed above on
how to.
>>Note: It's important to know the following
>>a)Pairing the bluetooth printer has to be external to the GoDB application. To pair the bluetooth
printer go to your Android device settings and pair the device. For access code(bluetooth pin) refer
to the bluetooth printer documentation
>>b)The bluetooth printer must support the bluetooth serial port profile(spp). Please refer to the printer's
documentation about spp support.Normally most bluetooth
>>printers support spp. The following code sample describes how to print with GBasic code.
>>dimi ret
>>dimi status
>>
>>dims temp1$
>>dims temp2$
>>dims devices$
>>dims curseldevice$
>>
>>
>>#define STATUS_OFFLINE 0
>>#define STATUS_LISTING_DEVICES_STARTED 1
>>#define STATUS_LISTING_DEVICES_ENDED 1
>>#define STATUS_CONNECTING_TO_DEVICE 3
>>#define STATUS_CONNECTED_TO_DEVICE 4
>>#define STATUS_ERROR 5
>>
>>status = STATUS_OFFLINE
>>
>>end
>>
>>
>>sub form_notify
>> dimi NotifySrc,NotifyData
>> dims Message$,MsgType$
>> dimi i
>>
>> NotifySrc=220'initialize to bt related
>>
>> while NotifySrc<>0
>> NotifySrc=getmessage(NotifyData,MsgType$,Message$,"")
>> pprint "NotifySrc " + NotifySrc
>> pprint "MsgType$ " + MsgType$
>> pprint "Message$ " + Message$
>> if NotifySrc = 220 then'bt based notifications on android
>> if NotifyData = 1 then'successful listing of bt devices
>> if MsgType$ = "btdevpairedlist" then'listed paired devices successfully
>> pprint "btdevpairedlist Message$ " + Message$
>> pprint "Successfully found paired devices"
>> ret = split(temp1$, Message$, "|")
>> for i = 0 to ubound(temp1$)
>> if len(trim$(temp1$(i))) > 0 then
>> ret = split(temp2$, temp1$(i), "$")
>> #devices.additem(temp2$(1), temp2$(0)+"("+temp2$(1)+")")
>> end if
>> next
>> //#devices.paint(-1,-1,-1,-1)
>> status = STATUS_LISTING_DEVICES_ENDED
>> #msg$ = "Paired listing devices complete."
>> end if
>> end if
>> if NotifyData = 2 then'errors related to listing of bt devices
>> status = STATUS_OFFLINE
>> pprint "There was an error with listing devices " + Message$'
>> #msg$ = "There was an error with listing devices " + Message$'
>> end if
>> if NotifyData = 4 then'successful serial port connection to the device
>> pprint "Successfully connected to the device " + Message$'
>> #msg$ = "Successfully connected to the device " + Message$'
>> #connect$ = "Connected!!!"
>> status = STATUS_CONNECTED_TO_DEVICE
>> end if
>> if NotifyData = 3 then'errors related to connecting to device
>> status = STATUS_LISTING_DEVICES_ENDED
>> pprint "There was an error with connecting to device " + Message$'
>> #msg$ = "There was an error with connecting to device " + curseldevice$ + ":" + Message$'
>> end if
>> end if
>> wend
>> call paintall()
>>End Sub
>>
>>Sub BtnQuit_Click
>> exit
>>End Sub
>>
>>Sub send_Click
>> ' Add Handler Code Here
>> iff status <> STATUS_CONNECTED_TO_DEVICE then return
>>
>>
>>
>> 'To send Text use the below code
>> 'setosvar("*btdevsenddata","Thanks Lord Ganesh\n")
>>
>>
>> 'Esaping Nulls in GBasic Strings.
>> 'In case you want to specify Null chars in standard gbasic string then,
>> 'NULL char should be escaped with a /00 and forward slash / in the data
>> 'should be encoded as /2F. Other non printable binary chars can be appended using CHR function
>> 'or by specifying / and the Hex value of the char.
>> 'For example if the device you need to send "HEL/LO[CHAR 150][NULL] "
>> 'The string should be encoded as "HEL/2FLO/96/00"
>>
>>
>> 'To send binary data use encoded strings as explained above
>> 'setosvar("*btdevsenddata","HEL/2FLO/96/00")
>>
>>
>>
>>
>> 'To send binary data for example an image which is stored inside the bdb use below code
>> 'The below code will send godb.ppm(which is a portable bitmap) to a bluetooth printer that supports
ppm image printing
>> 'Note : ppm is not supported on all bluetooth printers change according to suit printer
requirements
>> 'Note : usually printer SDK documentation will have neccessary info on printing data
>>
>> h1=fopen("godb.ppm",0,1)'file internal to bdb
>>
>> sz = fsize(h1)
>> dims a$
>> pprint "size is " + sz
>>
>> while feof(h1)=0
>> ret=FREADBIN2(h1,_tmp$, 1)
>> a$ = a$ + _tmp$
>> wend
>>
>> fclose(h1)
>> setosvar("*btdevsenddata", a$)
>>
>>End Sub
>>
>>
>>Sub connect_Click
>> iff status <> STATUS_LISTING_DEVICES_ENDED then return
>> status = STATUS_CONNECTING_TO_DEVICE
>> if #devices.itemcount = 0 then
>> msgbox("No paired devices selected or paired device list is empty")
>> return
>> end if
>> #connect$ = "Connecting.."
>> curseldevice$ = #devices.itemvalue$(#devices.selidx)
>> pprint "curseldevice$ " + curseldevice$
>> setosvar("*btdevconnectpaired",curseldevice$)
>>End Sub
>>
>>sub setMessage(m$)
>> #msg$ = m$
>>End Sub
>>
>>sub paintall()
>> #msg.paint(1)
>> #devices.paint(1)
>> #connect.paint(1)
>>End Sub
>>
>>Sub listbtn_Click
>> iff status <> STATUS_OFFLINE then return
>> status = STATUS_LISTING_DEVICES_STARTED
>> setosvar("*btdevshowpaired","1")
>>End Sub
>>
>>Sub close_Click
>> ' Add Handler Code Here
>> iff status <> STATUS_CONNECTED_TO_DEVICE then return
>> #connect$ = "Connect"
>> paintall()
>> setosvar("*btdevclose","1")
>> status = STATUS_LISTING_DEVICES_ENDED
>>End Sub
>>
>>
>>dims file$
>>file$ = "tada.wav"'This file should have been added to assets folder as explained above.
>>PlaySound(0, 0,file$, len(file$))'Please note that sound can only be played asynchronously.
>>
|