App Inventor Bluetooth Print SendText issue - bluetooth

I'm sending the text 'Цена:' to a printing device?
But result is
These are my blocks

Related

Using Noble to communicate with BLE device

I have spent the last couple of days researching and understanding GATT to control my new adjustable bed which I can currently only control via Manufacturer's app but I want to control via my smart home setup.
I am able to get characteristics which are read and write with/without response so I know I am on right track and I have used PacketLogger on OSX to get values which I now know are acceptable when sent by myself using an IOS app called BLE Scanner which just asks for a Hex or Text Value to send to the characteristics for the device (bed) and I have sent the values I extracted from PacketLogger when using the manufacturer's app (5212 006E 0100 4EBD) as Hex separately and it vibrates the bed!
I just need to be able to this myself now with Noble by sending either straight to the peripheral.writeHandle function or via the characteristic.write function. I have tried many different things but I don't get the same effect as BLE Scanner app when it sends the values individually as Hex so I know the device isn't happy with what i'm sending. I noticed there is some padding added for what I think is L2CAP but as I say BLE Scanner just works for (5212 006E 0100 4EBD) as long as they are sent separately as Hex.
Would really appreciate some help to get me over the line.
I have tried so far to write to the characteristic and also tried direct to the periphel as there is no mention of the characteristic UUID in the PacketLogger logs when writing via BLE Scanner whereas when using the Manaufacturer app PacketLogger shows the write characteristic UUID so both I think will work.
I have tried many variations of
peripheral.writeHandle(18, Buffer.from("5212006E01004EBD", "hex"),
true, function(err) { console.log('writehandle'+err) });
and
characteristic.write(Buffer.from("5212006E01004EBD", "hex"), true,
function (error) {
if (!error) {
console.log("write succesful");
} else {
console.log("write unsuccesful");
}
}.bind(this));
I do see a difference in the ATT Send PacketLogger entry for the BLE Scanner App which works and my attempt in Noble which doesn't work - Write Request - Handle:0x0012 - Value: 5212 006E 0100 4EBD Opcode is 0x0012 is the working packetlogger entry for BLE Scanner whereas my attempt shows multiple entries for each attempt and the first entry is always Exchange MTU Request - MTU: 104 and the Opcode is 0x0002. No matter what I change in Noble the Opcode remains the same.

Is it possible to scan barcodes into a process in the background?

I'm making a gym management web app that handles sign-ins. Members have a barcode on a tag that they scan when they arrive to the gym.
I've heard that most barcode scanners simply act as a keyboard. This would require the scanning-in page to be open and in the foreground when a barcode is scanned.
If it's just a keyboard, how would I send the barcode scanner input to a single background process running on the computer, and have it ignore by all processes that may be in focus?
You're right that most scanner can support HID in keyboard emulation, but that's just the start.
If you want to have a bit more control over the data you can use a scanners that support the OPOS driver model.
Take a look at Zebra's Windows SDK to have a overview of the things that you can do. It may be a better solution than try to steal the barcode data coming in the OS as a keyboard entry to the foreground app.
Disclaimer: I work for Zebra Technologies
Other Barcode scanner vendor support a similar driver model.
I found an interesting post with a simple solution:
On the form constructor
InitializeComponent():
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Form1_KeyPress);
Handler & supporting items:
DateTime _lastKeystroke = new DateTime(0);
List<char> _barcode = new List<char>(10);
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
// check timing (keystrokes within 100 ms)
TimeSpan elapsed = (DateTime.Now - _lastKeystroke);
if (elapsed.TotalMilliseconds > 100)
_barcode.Clear();
// record keystroke & timestamp
_barcode.Add(e.KeyChar);
_lastKeystroke = DateTime.Now;
// process barcode
if (e.KeyChar == 13 && _barcode.Count > 0) {
string msg = new String(_barcode.ToArray());
MessageBox.Show(msg);
_barcode.Clear();
}
}
Credits: #ltiong_sh
Original post: Here
Use RawInput API (https://www.codeproject.com/Articles/17123/Using-Raw-Input-from-C-to-handle-multiple-keyboard#_Toc156395975) and check device ID for incoming keystrokes. Different devices have different IDs. You can also block keystrokes from scanner from reaching your application and interfering with input fields.
One thing you might want to add is option for user to identity which device is used as a barcode scanner. I did it by asking user to test-scan barcode with scanner on first application startup or in settings.
Works with any barcode scanner which outputs keystrokes.

Windows Phone 8.1 play audio data stream through speaker?

I receive over network PCM audio data stream and this part works fine so I am ending up with
DataReader incomming = args.GetDataReader();
byte[] RcvBuffer = new byte[incomming.UnconsumedBufferLength];
incomming.ReadBytes(RcvBuffer);
I have all audio data in buffer.
How I can play this through telephone Speaker ? Can you point me in some direction ?
Thanks
There're many ways to do that.
You can prepend the WAVE header to your data, and use MediaElement for playback, see the documentation for SetSource method.
If however by “telephone speaker” you mean the earphone, then it is only possible if you are creating a VoIP app.
It took a while but I sorted it, maybe someone else will need help in the future.
First Problem - since I just started app development for Windows Phone I have chosen Blank App (Windows Phone) instead Blank App (Windows Phone Silverlight) and I did not have access to many features that are available in Silverlight projects, so my suggestions for beginners: understand what each project is for.
Like Soonts said there are many ways to do this, this is one that I used.
I simplified this code and retyped this so there can be some typos.
using Microsoft.Xna.Framework.Audio;
using System.IO;
1) Create Stream to load your incoming data:
MemoryStream stream = new MemoryStream();
2) Load data from buffer to stream:
stream.Write(RcvBuffer, 0, RcvBuffer.Length);
3) I am using SoundEfect to play this through Loud-Speaker. Sample rate that I use is 8 kHz
SoundEffect sound;
sound = new SoundEffect(stream.toArray(), 8000, AudioChannels.Mono)
sound.Play();

Sending commands from custom made Bluetooth device to android phone to control music player

I have created a simple Bluetooth device using following components
HC05 module
Arduino Uno board (with re-programmable micro-controller)
I am wondering if it is possible to send commands from my BT device, as if these commands were sent from Bluetooth headset?
What I mean is:
we send 0x00000055 keycode - and the music pauses
(KEYCODE_MEDIA_PLAY_PAUSE)
we send 0x00000058 - previous song starts playing
(KEYCODE_MEDIA_PREVIOUS)
...
Here is the full list of keycodes which android uses: http://developer.android.com/reference/android/view/KeyEvent.html
I can probably create a separate app, which will read incoming commands and simulate headset button presses, but that is not what I want. As far as I'm concerned - some of the headsets are plug-and-play, meaning that no additional apps must be installed on android device. Here is the code I am currently use to send commands to Android phone:
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
enum { LED_PIN = 6 };
enum LedState { LED_ON, LED_OFF, LED_BLINK };
LedState led_state;
void setup()
{
led_state = LED_OFF;
pinMode(LED_PIN, OUTPUT);
pinMode(9, OUTPUT);
digitalWrite(9, LOW);
Serial.begin(9600);
Serial.println("Enter AT commands:");
BTSerial.begin(38400); // HC-05 default speed in AT command more
}
const int COMMAND_MUSIC = 85;
void loop()
{
digitalWrite(LED_PIN, HIGH);
delay(100);
digitalWrite(LED_PIN, LOW);
delay(100);
delay(10000);
// trying to play or pause once in 10 seconds
BTSerial.write(0x00000055);
//BTSerial.print(0x00000055, HEX);
}
Both devices are paired but music player on my phone stays unaffected by these commands..Is it possible to control music player without creating a side app for "incoming commands from BT"?
Question is if your board supports AVRCP controller BT profile?
If it does you "only" need to connect against your phones AVRCP target BT profile. When you have a AVRCP BT connection there is specified commands how to pause and skip songs.
This is how the "plug and play" headset does.
Read more about Bluetooth profiles.
http://en.wikipedia.org/wiki/Bluetooth_profile
Looking at your code you have set up a serial link towards a phone.
This link uses SPP profile and you will only be able to send raw data over that link.
If this is the only profile that your BT stack on your Arduino Uno board have you will be forced to create an application on the phone side to be able to read the raw data and do something with it e.g. pause music.
Hope this cleared things little for you.
Probably it is to late for you, but maybe I can help someone else.
Firstly, Bluetooth devices like BT headphones, keyboards etc, are known as HID (Human Interface devices). HC05 are not one of this out of the box, but there is a solution introduced by Evan Kale (link: https://www.youtube.com/watch?v=BBqsVKMYz1I) how to update one of this using serial port connection.
Other solution is to buy BT HID module, but they are more expensive (about 10 times)

Connect to LightBlue peripheral mode

I used LightBlue app on an IOS Devices (iPhone 4s, iOS 6.1.3) in peripheral mode and another IOS device (iPhone 4s, iOS 6.1.3) in a central mode.
I'm using BTLE Transfer example code from Apple, it's working properly on these two devices. However, It does not work on LightBlue. As I just want to develop a simple app that read data from Blood Pressure Device, I've just changed the following service and characteristic UUID in Transfer.h file
define TRANSFER_SERVICE_UUID #"1810"
define TRANSFER_CHARACTERISTIC_UUID #"2A49" // just read value
My plan is going to clone a real device structure on LightBlue and then develop a central app to connect with LightBlue peripheral (I think it then will work with real devices because I donot have any real device at the moment). I set a device as a peripheral and the second one will install modified app (from apple sample) as a central or client.
The following delegate method provided by Apple:
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
// Reject any where the value is above reasonable range
if (RSSI.integerValue > -15) {
return;
}
// Reject if the signal strength is too low to be close enough (Close is around -22dB)
if (RSSI.integerValue < -35) {
return;
}
NSLog(#"Discovered %# at %#", peripheral.name, RSSI);
// Ok, it's in range - have we already seen it?
if (self.discoveredPeripheral != peripheral) {
// Save a local copy of the peripheral, so CoreBluetooth doesn't get rid of it
self.discoveredPeripheral = peripheral;
// And connect
NSLog(#"Connecting to peripheral %#", peripheral);
[self.centralManager connectPeripheral:peripheral options:nil];
self.connectingPeripheral=peripheral; // this line of code I have added as recommended from a member
}
}
And the problem is, this delegate method have been fired and log panel display "Discovered LightBlue at -32".It likely cannot connect to the Lightblue peripheral as I cannot see the output of the line of code NSLog(#"Connecting to peripheral %#", peripheral);
All suggestion are welcome and highly appreciated.

Resources