SIM808 bluetooth issue - bluetooth

I've connected my sim808 module to a HC05 bluetooth module with SPP profile.
Hc05 UART config is 9600 , no parity,1 stop.
i'm connecting with these at commands:
AT+BTPOWER=1
AT+BTCONNECT=1,4 // I have already paired two devices
when i send message printf("0adch=0&temp=27&hu=14") via HC05 to SIM808 , it breaks message to multiple parts like below (I've connected SIM808 to PC via a usb-ttl convertor,so i can see messages on sim RX port) :
+BTSPPDATA: 1,1,0
+BTSPPDATA: 1,10,adch=0&tem
+BTSPPDATA: 1,10,p=27&hu=14

Related

How to detect 4G dongle(s) connected to my computer using NodeJs

How can I detect 4G dongle(s) connected to my computer using NodeJS?
I tried the following code:
var os = require('os');
var allNetworkInterfaces = os.networkInterfaces();
console.log(allNetworkInterfaces);
It works, but I got all network interfaces... I would like to get a list with my 4G dongles only. Knowing that I could have either 1 dongle, or several dongles connected to the same computer, as well as other USB hardwares connected.
After installing the usb package by running npm install usb I was able to get a list of usb devices using the following code:
const usb = require('usb');
const devices = usb.getDeviceList();
console.log( devices );
You will have to go through that list and decide which is your "4G dongle".

How to write to a Characteristic as of Bluez 5.48

I am using Bluez 5.50; 5.48 was the version acquire-write became officially (non-experimentally) supported. Am I using the acquire-write / write feature properly?
On my Raspberry Pi Zero W:
pi#raspberrypi:~ $ bluetoothctl
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# scan on
Discovery started
[bluetooth]# connect B8:27:E8:72:33:7A
Attempting to connect to B8:27:E8:72:33:7A
Connection successful
[DSD TECH]# menu gatt
[DSD TECH]# select-attribute 0000ffe1-0000-1000-8000-00805f9b34fb
[DSD TECH:/service0010/char0011]# acquire-write
[CHG] Attribute /org/bluez/hci0/dev_B8_27_E8_72_33_7A/service0010/char0011 WriteAcquired: yes
AcquireWrite success: fd 7 MTU 23
[DSD TECH:/service0010/char0011]# write("h")
[DSD TECH:/service0010/char0011]# write('h')
[DSD TECH:/service0010/char0011]# write(h)
[DSD TECH:/service0010/char0011]# write(0x68)
On my Arduino Nano connected to HM-10:
void setup()
{
Serial.begin(9600);
}
void loop() {
delay(10);
if (Serial.available())
{
char c = Serial.read();
Serial.println("Read value");
}
}
I use the iOS app named "Serial" which connects to my HM-10. I send the letter h over and read "Read value" on the arduino serial monitor. I do this directly before and after using the raspberry pi, on the same arduino serial monitor. The raspberry pi notifications never come thru. Yes, I am certain it is the same HM-10. It is the only HM-10 I have powered on in BLE range, and I cannot connect to the UUID while my phone is connected. (Actually, I submit connect B8:27:E8:72:33:7A to the raspberry pi, and keeps trying, and then disconnect from phone, and rpi automatically connects).
Thanks in advance!
When using gatt services with bluetoothctl, leave off the parentheses and just use:
write 0x68
acquire-write returns a file descriptor that can be used for writing to the GATT characteristic, usage of write will be locked. so either use acquire-write (which requires a write-without-response flag) or use write.
void WriteValue(array{byte} value, dict options)
Issues a request to write the value of the
characteristic.
Possible options: "offset": Start offset
"device": Device path (Server only)
"link": Link type (Server only)
"prepare-authorize": boolean Is prepare
authorization
request
Possible Errors: org.bluez.Error.Failed
org.bluez.Error.InProgress
org.bluez.Error.NotPermitted
org.bluez.Error.InvalidValueLength
org.bluez.Error.NotAuthorized
org.bluez.Error.NotSupported
fd, uint16 AcquireWrite(dict options) [optional]
Acquire file descriptor and MTU for writing. Usage of
WriteValue will be locked causing it to return
NotPermitted error.
For server the MTU returned shall be equal or smaller
than the negotiated MTU.
For client it only works with characteristic that has
WriteAcquired property which relies on
write-without-response Flag.
To release the lock the client shall close the file
descriptor, a HUP is generated in case the device
is disconnected.
Note: the MTU can only be negotiated once and is
symmetric therefore this method may be delayed in
order to have the exchange MTU completed, because of
that the file descriptor is closed during
reconnections as the MTU has to be renegotiated.
Possible options: "device": Object Device (Server only)
"MTU": Exchanged MTU (Server only)
"link": Link type (Server only)
Possible Errors: org.bluez.Error.Failed
org.bluez.Error.NotSupported

Does WiPy Pysense Device will connect with Other Bluetooth Sensor Devices.?

Does the Pysense(WiPy) device will connect and get service from any other Bluetooth Sensor Devices available in the market.?
Yes we can connect any Bluetooth sensor with mac address using
bluetooth = Bluetooth()
bluetooth.start_scan(5)
while bluetooth.isscanning():
adv = bluetooth.get_adv()
if adv:
if(str(binascii.hexlify(adv.mac).decode()) == '78a50454b267'):
conn = bluetooth.connect(adv.mac)
print(type(conn))

Bluez DBus API to set duplicate filter to disable

How to set scan parameters and disable the filter duplicates, so that I can receive all advertisement from the controller ?
StartDiscovery API only notifies, whenever new device is identified but I want to set filter duplicate to disabled, so that I can receive each and every advertisement from the controller?.
But I didn't find any DBus API to set the scan parameters nor set scan enable API.
My Goal is simple I need get notify each advertisement received on controller to my client app, How can I do that with Bluez?
Note : I might missing some basic points because new to bluetooth and bluez.
In the below output you can see that the Device "Parthiban" is already present under /org/bluez/hci0/dev_44_D8_84_02_A3_17. I have started the scan which in turn triggers "StartDiscovery()" method and the same device is updated with RSSI value.
root#mx6q:~# bluetoothctl
[NEW] Controller 5C:F3:70:6E:26:02 Adapter [default]
**[NEW] Device 44:D8:84:02:A3:17 Parthiban**
[NEW] Device 2C:F0:A2:26:D7:F5 iPhone tteam
[NEW] Device 78:F8:82:10:E7:0C Nexus 5X
[bluetooth]# scan on
Discovery started
[CHG] Controller 5C:F3:70:6E:26:02 Discovering: yes
**[CHG] Device 44:D8:84:02:A3:17 RSSI: -52**
So you can use "g_dbus_connection_signal_subscribe" on the interface "org.freedesktop.DBus.Properties" for "PropertiesChanged" signal.
while(g_variant_iter_loop(&iter, "{sv}", &property, &value)) {
if(strcasecmp(property, "RSSI") == 0) {
/*
* - Extract the device address from object path
* /org/bluez/hci0/dev_44_D8_84_02_A3_17
* - Play with the device
*/
}

Windows 10 - how to detect when a Bluetooth device is in range

I have previously paired with a Bluetooth device that supports RFCOMM.
When my app is opened I continuously try to connect to the device by opening the RFCOMM. This way my app automatically connects when the device comes in range.
deviceInfoCollection = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));
LogData(String.Format("Number of mldp devices is {0}", deviceInfoCollection.Count));
foreach (DeviceInformation deviceInfo in deviceInfoCollection)
{
LogData(String.Format("ID:{0}, NAME:{1}", deviceInfo.Id, deviceInfo.Name));
}
Then run this on a timer:
try
{
// The first time this method is invoked by a store app, it should be called
// from a UI thread in order to display the consent prompt
// https://msdn.microsoft.com/en-us/windows.devices.bluetooth.rfcomm.rfcommdeviceservice.fromidasync
RfcommDeviceService rfcommService = await RfcommDeviceService.FromIdAsync(deviceInfo.Id);
LogData(String.Format("ID:{0}, NAME:{1}", deviceInfo.Id, deviceInfo.Name));
}
catch (Exception)
{
LogData(String.Format("Can not request rfcomm service from device ID:{0}, NAME:{1}", deviceInfo.Id, deviceInfo.Name));
}
Is there any way to query when the device is in range , rather than trying to connect? I would prefer to only attempt connection when the device is in range.
For RFCOMM (BT2.0, BT2.1) you can run a device enumeration periodically, see also Get bluetooth devices in range
However your actual implementation with a connection attempt may work a little better.
For Bluetooth 4.0, you can listen to the advertisements of the BT module, see also https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/BluetoothAdvertisement
If you're talking to an embedded device (e.g. some robot, or homebrew appliances using RFCOMM) I am afraid there is no better solution than what you're doing.
If you're taking to a phone (which supports both BT4.0 and BT2.1) you can use the BT4 advertisements to signal the proximity of the device, then connect via RFCOMM.

Resources