How to avoid Restart Bluetooth Printer after print? - printing

I have developed windows mobile 6.1 application which search nearby Bluetooth devices and send files.Also I did print functionality to print document on Bluetooth printer.
First time print functionality is working perfectly fine but when I print the document again, then I need to restart the printer and then after it will print.
Is there any solution to avoid restart printer??
Below is my print code from reference of https://32feet.codeplex.com/discussions/355451
private void btPrint_Click(object sender, EventArgs e)
{
// Activate BT
BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable;
System.Threading.Thread.Sleep(1000);
// Connect
BluetoothAddress btAddress;
btAddress = BluetoothAddress.Parse("0022583165F7");
BluetoothClient btClient = new BluetoothClient();
try
{
btClient.Connect(new BluetoothEndPoint(btAddress, BluetoothService.SerialPort));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
// Send data
string CPCLStr1 =
"! 0 200 200 210 1" + Environment.NewLine +
"ML 25" + Environment.NewLine +
"TEXT 7 0 10 20" + Environment.NewLine +
"Just" + Environment.NewLine +
"Testing" + Environment.NewLine +
"ENDML" + Environment.NewLine +
"FORM" + Environment.NewLine +
"PRINT" + Environment.NewLine;
// Convert CPCL String to byte array
byte[] CPCLbytes1 = ASCIIEncoding.ASCII.GetBytes(CPCLStr1);
NetworkStream ns = btClient.GetStream();
ns.Write(CPCLbytes1, 0, CPCLbytes1.Length);
btClient.Close();
}

Although you close the client stream, the printer seems to wait some time before it resets it's session.
Try to send a <EOF> or <EOT> byte at the end.
Acording to CPCL reference guide there is no simple reset command as with ESC/p for example ({esc}#).
Doing a device reset after every print seems an overkill.
EDIT: SDK sample for sendFile:
Byte[] cpclLabel = Encoding.Default.GetBytes("! 0 200 200 406 1\r\n" + "ON-FEED IGNORE\r\n"
+ "BOX 20 20 380 380 8\r\n"
+ "T 0 6 137 177 TEST\r\n"
+ "PRINT\r\n");
The above runs fine on my RW420 without the need to reset between prints.

Related

Alignment Issues and Counting Diagnosis issues. This is my first post, Sorry if anything is incorrectly formatted

Programming Project 3F
Vital signs of hospital patients are monitored and reported automatically. While each monitor has alarms which go off when a reading is out of range, combinations of readings are also important. Common vital signs and normal range is given below.
The use of functions is encouraged. If you create your own header file, name it Project3.h. This common name will allow me to easily include your header in the report I grade.
Write a program to read a series of patient records from the file PATIENTS.TXT. Use the Priming Read logic to process all records in the file. Each record (line of the file) contains the following fields delimited by a space: first name, lastname, pulse, respiration, oxygen, room. The file contains and unknown number of records. Unlike Program #2, simple stream input using >> from the file should suffice to read this file. You do not need to parse the file as you did in Project #2.
A sample file with one record per line might resemble the following
Buster Leggs 88 44 88 120
Charlie Horse 56 15 95 011
Wilma Moneylast 132 18 98 200
Willie Makit 75 30 94 121
Betty Wont 50 10 90 000
Eaton Buggs 79 16 97 111
Freda Spirit 110 23 90 220
Categorize each reading as Low, Normal or High. Print the result in the report detailed below. Normal range for each reading is as follows
Pulse 60-100
Respiration 12-20
Oxygen Level 92-100
Tag each record as according to the following and print any needed messages in the report for each record
CHECK – one indicator out of range
ALERT*** – two indicators out of range
CRITICAL***** – three indicators out of range
Room Name Pulse Respir Oxygen
120 Leggs, Buster 88 High=44 Low=88 ALERT***
011 Horse, Charlie Low= 56 15 95 CHECK
200 Moneylast, Wilma High=132 18 98 CHECK
111 Makit, Willie 75 20 94
000 Wont, Betty Low= 50 Low=10 Low=90 CRITICAL****
111 Buggs, Eaton 79 16 97
220 Spirit, Freda High=110 High=23 Low=90 CRITICAL****
Totals
2 Normal
1 ALERT
2 CHECK
2 CRITICAL
The Code I Currently have is:
\`#include "stdafx.h"
\#include \<iostream\>
\#include \<fstream\>
\#include \<string\>
\#include \<iomanip\>
using namespace std;
void Pause()
{
char junk;
cin.ignore(100,'\\n');
cout \<\< "\\n\\nPress enter to continue...";
cin.get(junk);
} // Pause()
int main()
{
//File Variables
ifstream PATIENTS_IN;
ofstream PATIENTS_LOG;
//Declare Variables and Constants
string Info, diag;
int pulseint, respint, O2int;
int count,count1, count2, count3,check, alert, critical;
string FirstName, LastName, Pulse, Resp, O2Lvl, RoomNum;
//Initalize Variables
count=0;
count1=1;
count2=0;
count3=0;
check=0;
alert=0;
critical=0;
Info= "no name read";
FirstName= "no name read";
LastName= "no name read";
// \*\* Open Data Files \*\*
PATIENTS_LOG.open("D:\\PATIENTS.log");
if(PATIENTS_LOG)
{//Last file operation was successful
}
else
{//last file operation FAILED!
cout \<\< "PATIENTS_LOG open FAILED!" \<\< endl;
}
PATIENTS_IN.open("D:\\PATIENTS.txt");
if (PATIENTS_IN)
{//last file operation was successful
PATIENTS_LOG \<\< "PATIENTS_IN file open successful" \<\< endl;
}
else
{//last file operation FAILED!
cout \<\< "PATIENTS_IN file FAILED!" \<\< endl;
}
getline(PATIENTS_IN, Info); //Priming read
if(PATIENTS_IN)
{//last file peration was successful
}
else
{PATIENTS_LOG << "Input file Priming read FAILED" << endl;
}
count=1;
//Header
cout \<\< "Room Name Pulse Respir Oxygen" \<\< endl;
cout \<\<"-----------------------------------------------------" \<\< endl;
while (!PATIENTS_IN.eof())
{PATIENTS_IN \>\> FirstName \>\>
LastName \>\> Pulse \>\> Resp \>\> O2Lvl \>\> RoomNum;
//Conversion
pulseint=stoi(Pulse);
respint=stoi(Resp);
O2int=stoi(O2Lvl);
if(pulseint\>100)
{Pulse="High=" + Pulse;
}
else if(pulseint\<60)
{Pulse="Low="+ Pulse;
}
else
{}//Do Nothing
if(respint\>20)
{Resp="High=" + Resp;
}
else if(respint\<12)
{Resp="Low="+ Resp;
}
else
{
}
if(O2int\>100)
{O2Lvl="High=" + O2Lvl;
}
else if(O2int\<92)
{O2Lvl="Low="+ O2Lvl;
}
else
{
}
if(pulseint\>100||pulseint\<60)
{count1++;
}
if(respint\>20||respint\<12)
{count2++;
}
if(O2int\>100||O2int\<92)
{count3++;
}
if(count1==1)
{diag="CHECK--";
check++;}
if(count1==2)
{diag= "ALERT ***";
alert++;}
if(count1==3)
{diag= "CRITICAL***\*\*";
critical++;}
else
{diag="";
}
cout << left <<RoomNum << " " << LastName << ", " << FirstName<< "";
cout << right <<""<<setw(12)<<Pulse <<right
cout << ""<<setw(10) <<Resp <<""<< right<<setw(10) << O2Lvl<<"\n";
}//End While
Pause();
return (0);
}
I have tried messing with the counters, others say they are having run time errors while trying to run the code while I don't get them, as well as alignment issues. I feel like Albert Einstein's definition of insanity.

Collecting card details within the app on Telr Payment gateway

I am integrating "Telr" payment gateway on my current app.I have read all docs part. My app will be collecting the card details (rather than using the hosted payment pages).This is the request i am making.If anybody has some demo or integrated Telr payment gateway, please feel free to reply.
let paramString: String = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<mobile>" +
"<store>\(12345)</store>" + "<key>somekey</key>" +
"<device>" +
"<type>\("iPhone6")</type>" +
"<id>\(deviceId)</id>" +
"<agent></agent>" +
"<accept></accept>" +
"</device>" +
"<app>" +
"<name>Telr_Payment_Demo</name>" +
"<version>1.0</version>" +
"<user>xyz.Demo</user>" +
"<id>1234567</id>" +
"</app>" +
"<tran>" +
"<test>12</test>" +
"<type>paypage</type>" +
"<class>moto</class>" +
"<cartid>syste1075</cartid>" +
"<description>this is demo on telr</description>" +
"<currency>AED</currency>" +
"<amount>\(9.80)</amount>" +
"<ref>\("000000000001")</ref>" +
"</tran>" +
"<card>" +
"<number>\("5555555555554444")</number>" +
"<expiry>" +
"<month>\(02)</month>" +
"<year>\(2018)</year>" +
"</expiry>" +
"<cvv>\(123)</cvv>" +
"</card>" +
"<billing>" +
"<name>" +
"<title>\("fsfsfs")</title>" +
"<first>\("First")</first>" +
"<last>\("last")</last>" +
"</name>\n" +
"<address>" +
"<line1>\("Kathmandu bazar")</line1>" +
"<line2>\("address 6")</line2>" +
"<line3>\("Near gausala")</line3>" +
"<city>\("kathmandu")</city>" +
"<region>\("Bagmati")</region>" +
"<country>\("Nepal")</country>" +
"<zip>\("977")</zip>" +
"</address>" +
"<email>\("s*********#gmail.com")</email>" +
"</billing>" +
"</mobile>"
I am getting following response from server
<mobile>
<webview>
<start>https://secure.innovatepayments.com/gateway/webview_start.html? code=f1caa6ce6c23595b71dc00369</start>
<close>https://secure.innovatepayments.com/gateway/webview_close.html</close>
<abort>https://secure.innovatepayments.com/gateway/webview_abort.html</abort>
<code>f1caa6ce6c23595b71dc00369</code>
</webview>
<trace>40008/1683846/595b7168dc</trace>
</mobile>
The first url will redirect to hosted payment pages card details view.I do not know what should i do with that response.This is the payment integration guidelines for developer.
From the docs you linked to say:
When a webview response is received, the App will need to direct the
customer to the URL given as the start address. The App should monitor
the progress of the webview, and once it reaches the URL provided as
the close address, it should close the web display and continue with
the transaction process.
To complete the transaction, the App must now make a second request to
the gateway. This request includes will trigger the final
authorisation stage of the transaction, and return the authorisation
response. The request must be sent to:
https://secure.innovatepayments.com/gateway/mobile_complete.xml
...
so I would start with that and see what happens

Detecting memory leak in cocos2dx project for WP8

I want to locate few memory leaks in my cocos2dx application for windows phone 8. IDE is Visual studio express 2012. I saw this link for app profiling. But as written on the page, "Only the Execution option is available for Direct3D apps". I am not able to figure out the option for memory profiling as cocos2dx uses directx in windows phone. How should I detect memory leak?
You can detect the application memory usage by following code.
Add the following code in App.xaml.cs
public partial class App : Application
{
private static Timer timer = null;
public static void BeginRecording()
{
if (System.Diagnostics.Debugger.IsAttached)
{
// start a timer to report memory conditions every 2 seconds
timer = new Timer(state =>
{
// every 2 seconds do something
string report =
DateTime.Now.ToLongTimeString() + " memory conditions: " +
Environment.NewLine +
"\tApplicationCurrentMemoryUsage: " +
getExactValue(DeviceStatus.ApplicationCurrentMemoryUsage) + " MB" +
Environment.NewLine +
"\tApplicationPeakMemoryUsage: " +
getExactValue(DeviceStatus.ApplicationPeakMemoryUsage) + " MB" +
Environment.NewLine +
"\tApplicationMemoryUsageLimit: " +
getActualValue(DeviceStatus.ApplicationMemoryUsageLimit) + " MB" +
Environment.NewLine +
"\tDeviceTotalMemory: " + getActualValue(DeviceStatus.DeviceTotalMemory) + " MB" + Environment.NewLine +
"\tApplicationWorkingSetLimit: " +
getActualValue(Convert.ToInt64(DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit"))) + " MB" +
Environment.NewLine;
// write to IsoStore or debug conolse
Debug.WriteLine(report);
},
null,
TimeSpan.FromSeconds(2),
TimeSpan.FromSeconds(2));
}
}
public static decimal getExactValue(long stats)
{
return Math.Round(((decimal)(stats) / (decimal)(1048576.00)), 2);
}
public static int getActualValue(long stats)
{
return ((int)Math.Ceiling(getExactValue(stats)));
}
now call the BeginRecording() function in application_launching.
this will give you the exact memory stats after every 2 seconds and you can identify the memory leaks.

alert message displaying while refresh the browser using pageregisterstartupscript

I am displaying alert message for un authenticated user but if refresh the browser the again alert is displaying.
ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script language=JavaScript>" + Environment.NewLine + "alert(\"" + msg + "\")" + Environment.NewLine + ";</script>");
If(user.IsAuthenticated)
{
//do something
}
else
{
ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script language=JavaScript>" + Environment.NewLine + "alert(\"" + msg + "\")" + Environment.NewLine + ";</script>");
}
depending on what technology you use if you just want to show the message the first time you load the page it works differently, I'm sorry if I'm prejudice if I say that I guess it's a WebForms application but then it should be something like
if(!IsPostBack)
{
ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script language=JavaScript>" + Environment.NewLine + "alert(\"" + msg + "\")" + Environment.NewLine + ";</script>");
}

Google Analytics & Blackberry UserAgent

I'm using this code to get the blackberry info on google analytics
private static String getUserAgent()
{
String userAgent = "Blackberry" + DeviceInfo.getDeviceName() + "/" +
getOsVersion() + " Profile/" + System.getProperty(
"microedition.profiles" ) + " Configuration/" + System.getProperty(
"microedition.configuration" ) + " VendorID/" +
Branding.getVendorId();
return userAgent;
}
And then using it here :
conn.setRequestProperty("User-Agent", userAgent);
The problem is that it doesn't recognize the terminal like a mobile phone , but it takes difference in browser .
Browser:
Navegador Visitas % Visitas
1. Blackberry8900 36 100,00%
Any idea if google analytics have some params to know that is a mobile phone ? or if i'm using a badformated useraggent.
Thanks for your answers.

Resources