BluetoothLEAdvertisementWatcher doesn't receive Advertisement payload - c#

I'm trying send Information from Device A to Device B using Bluetooth Low Energy Advertisements.
In order to receive the broadcasts, I'm using Windows UWP's Bluetooth Low Energy Library (https://learn.microsoft.com/en-us/windows/uwp/devices-sensors/ble-beacon)
My received advertisements should include Information, but they don't. I tried to use BluetoothLEAdvertisementDataSection and BluetoothLEManufacturerData. Both aren't working. If I receive the Advertisement, the BluetoothLEAdvertisementDataSection doesn't include my information and the BluetoothLEManufacturerData is just empty.
This is what I receive:
Address: 0x2462ABE13A7E; Name:CH1234; RSSI: -49
ManufacturerDataLength: 0
ManufacurerData: []
DataSectionsLength: 4
DataSections: [0x06] [0x43-48-31-32-33-34] [0x03] [0x20-00-40-00]
The DataSections are about DataType 0x01, DataType 0x09, DataType 0x0A and 0x12
Is there any way to get the raw advertisement message? Or any other way to get this information?
I tried to receive Information from Advertisements using bluepy on Linux and it is working. Therefore the problem must be within this library.
This is my Code: https://pastebin.com/rxcrjhpj
There is not mutch. Just the BluetoothLEAdvertisementWatcher and printing the received Information.
///Edit
I fixxed it. The mistake was within sending the broadcast.
I use nkolban's ESP32 BLE Library, there are two functions. One called "BLEAdvertisementData.setManufacturerData" and the other one "BLEAdvertisementData.addData". However by using "addData" it looks like the broadcast frame gets messed up somehow. It's working if I just use "setManufacturerData" instead of "addData"

Related

Can't find Serial Number attribute for PL2303 device in linux

When i run the following command after connecting PL2303 USB to serial converter to my ubuntu system:
dmesg | grep ttyUSB
i get:
usb 1-2: pl2303 converter now attached to ttyUSB0
then i run:
udevadm info -a -n /dev/ttyUSB0
i get:
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-2':
KERNELS=="1-2"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bMaxPower}=="100mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bcdDevice}=="0400"
ATTRS{bmAttributes}=="80"
ATTRS{busnum}=="1"
ATTRS{configuration}==""
ATTRS{devnum}=="27"
ATTRS{devpath}=="2"
ATTRS{idProduct}=="2303"
ATTRS{idVendor}=="067b"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Prolific Technology Inc. "
ATTRS{maxchild}=="0"
ATTRS{product}=="USB-Serial Controller D"
ATTRS{quirks}=="0x0"
ATTRS{removable}=="removable"
ATTRS{speed}=="12"
ATTRS{urbnum}=="20"
ATTRS{version}==" 1.10"
But no
ATTRS{serial}
is found for the above PL2303 USB to serial converter.
Can anyone please tell me why? I get the serial attribute for all other USB devices
The datasheet for the PL2303 serial converter chip includes a description of the EEPROM configuration data for the chip on page 11.
The EEPROM can specify the USB product and vendor IDs for the chip, so instead of using the generic USB-to-serial converter ID, someone using this chip in their products can use an ID that is specific to their product, allowing for seamless auto-detection and use of the product-specific driver, if desired. One would expect that the serial number might also be stored in that EEPROM. But there is no place for a serial number in the EEPROM data layout.
In fact, the entire datasheet does not document any way to retrieve an unique serial number from this serial converter at all. So I must conclude that this serial converter chip series simply does not have unique serial numbers, at least not in its earlier chip revisions (the datasheet is from year 2005).

C++ Create a handle to a NdisProt driver

I try to write to a NdisProt driver and send raw ethernet packets. I imported some C++ comands to my C# program, so that I can access the driver. When I try to open a handle to the driver I always get a invalid handle. I already tried it with just "NdisProt" as the path, but it didn't solve it. Do you have any suggestions why i get a invalid handle?
private bool OpenDriver()
{
// User the CreateFile API to open a handle to the file
this.m_iHandle = CreateFile("\\\\.\\NdisProt,
GENERIC_WRITE | GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
// Check to see if we got a valid handle
if ((int)m_iHandle <= 0)
{
// If not, then return false and reset the handle to 0
this.m_iHandle = IntPtr.Zero;
return false;
}
If you now any other solutions to send raw ethernet packets in a C# program please let me know.
Thanks for any help!
Update: I just solved the problem by adding another manifest, so that the application is run as admin.
The solution with the NDIS Driver did still not work so I searched for another solution. I found the SharpPcap library. With that library I am able to modify the packets I want to send e.g. change the Destination-MAC-Adress.
Thanks for your answers!
If you now any other solutions to send raw ethernet packets in a C#
program please let me know.
What about Socket class?
Constructor:
public Socket (System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType),
where socketType can take the next value: SocketType.Raw
If you now any other solutions to send raw ethernet packets in a C# program please let me know.
You can import functions from Windows Winsock library and use SOCK_RAW flag when creating a socket.
int sock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);

C# / nAudio - Sending a MIDI message to controller

I'm building my own custom midi mapping app, and so far so good. I've been using nAudio to recieve midi messages, and it's working like a charm.
But when wanting to send something back, I run into some trouble. To enable a light on my controller I gotta send a Note On message: 90 kk 01 for example, where kk equals the corresponding key. (see picture below)
However, it is not working. I'm not getting any error messages at all, but nothing is lighting up neither.
Example of what I'm sending:
midiOut = new MidiOut(MIDIInDevice);
midiOut.Send(MidiMessage.StartNote(56, 1, 0).RawData);
56 is the Note, 1 the volume, and 0 the channel.
Any idea what i'm doing wrong?
The page you posted says that the lights are controlled with Note On messages. I'm not familiar with the C# library, but I'm guessing StopNote sends a Note Off message. Try using the equivalent that sends a Note On message. (Perhaps StartNote?)
Choose right channel and try to send NoteOn event.
var noteOnEvent = new NoteOnEvent(0L, channel, note, 127, 200);
midi.Send(noteOnEvent.GetAsShortMessage());
midi.Send(noteOnEvent.OffEvent.GetAsShortMessage());

C# send text msg/sms via USB-HSDPA Modem -> unsupported message type

I am trying to create a text msg/sms gateway using a USB-HSDPA Modem from Huawei (E122-1).
I have done this with an older Modem some time ago. After some troubles installing the driver and receiving the correct comPort of the new device I have finally established to communicate with the device.
comPort Check and PIN-Check are already done.
Now I'm switching to textmode (CMGF) and write the message (CMGS):
comPort.Write("AT+CMGF=1\r\n");
Thread.Sleep(1000);
comPort.Write("AT+CMGS=\"" + "some tel no" + "\"" + Environment.NewLine);
comPort.Write("text content" + (char)26 + Environment.NewLine);
Thread.Sleep(2000);
response = comPort.ReadExisting();
everything works fine, i get proper responses and everything.
BUT, here is the problem: the sent text message can't be read on all mobile phones/smart phones:
- my old Nokia 6300 says 'unsupported message type'.
- HTC Desire shows an empty message.
- Samsung Galaxy S2 'content is not supported'.
- Samsung Galaxy S shows the message just fine.
Now here is the weird thing, if i use the application which comes with the modem (t-mobile austria internet manager) to send a text message, all of the listed devices can display it correctly.
am I missing something with the encoding or some kind of a header? (which the 't-mobile internet manager' apparently is using for correct displaying of the text message at the receiver side)
any suggestions or ideas?
thanks,
Sise
somehow, the receiver devices are expecting PDU format and not ascii.
something like:
http://www.dreamfabric.com/sms/
but the receiver device i'm requiring this method for is a gps-tracking box and it does understand ascii, so pdu is not required and the application is working fine.
thanks anyways! :)
Try to send in text mode: https://www.diafaan.com/sms-tutorials/gsm-modem-tutorial/at-cmgf/
AT+CMGF=
1 = Text Mode

.NET or COM HID iCLASS Smart Card Reader

I have coding I almost always use with my Omnikey RFID CardMan 5321 smart cards. Problem is we received new cards today which are marked "HID iCLASS GL" which do not appear to be working well with our coding.
Without going through the whole source, our problem is arising when we are calling the following line, which basically tells us the length of the data:
lResult = SCardTransmit(hCard, 0, bytCommand, lLen, 0, byReadBuffer, iReturnlength)
We are returning only a length of 2, which the data is marked as "x69 x86". Even if I tell it to read all 255 chr's the rest are just marked as null.
Now I know our reader can read these cards since the OMNIKEY Diagnostic tool is showing us the following:
Status: Smart Card Inserted
FW: 5.10
Port: USB
Lib: 1.0
Smart Card Nme: iCLASS 32KS 8x2+16
ART: Valid
Protocol: ISO 15693 (Part 2)
PICCtoPCD: 26,48 kbps
PCDtoPICC: 26,48 kbps
Frequ: 13.56 MHz
As I explained before, everything is working fine in my coding except no data is being returned for my card besides "x69 x86", which is surely not correct.
If anyone has any experience reading from a HID iCLASS card, I would greatly appreciate some feedback on how to. Even if we have to license software, that is ok.
Thanks in advance!
in case you are trying to access physical access data, I would thoroughly check the crypto protocol between reader and host first and also meke sure you are using a reader with teh latest firmware (5.20 for the OMNIKEY 5321).
I would also introduce code to check the card system withour secure communication channel between host and reader application.
Further references:
http://www.hidglobal.com/documents/ok_contactless_developer_guide_an_en.pdf
The reason cause you get a 2 Byte array is cause your command runs on an error so the chip returns only SW1 and SW2 Flag
in your case it's meaning is
x69 --> Command not allowed (further qualification in SW2, see table 17)
x86 --> Command not allowed (no current EF)
So you might proof that your application file on the chip is correctly selected
further information #
http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4_5_basic_organizations.aspx#table17

Categories

Resources