Error occured when sending message through Google Play Game Service with Cocos2d-x - c++

I'm developing a multiplayer game with Google Play Services and Cocos2d-x. I already set up communication between Java and C++ using JNI, and can run processes like Sign-in, Create room, Invitation... Everything is fine until I need to send some struct to another players. When receive data from other, an error has occurred.
Here's the structs:
typedef enum
{
MESSAGE_TYPE_PING = -1,
MESSAGE_TYPE_PING_BACK = 0,
MESSAGE_TYPE_RTT = 3
} MESSAGE_TYPE;
typedef struct
{
MESSAGE_TYPE messType;
} MESSAGE;
typedef struct
{
MESSAGE mess;
timeval sendTime;
const char* text;
} PING_MESSAGE;
And in this code snippet I convert struct and send it to another players:
void MyClass::sendData()
{
// Send package
PING_MESSAGE ping;
ping.mess.messType = MESSAGE_TYPE_PING;
ping.sendTime = startTime;
ping.text = "Ohhhhhh";
char byte[sizeof(ping)];
memcpy(byte, &ping, sizeof(ping));
GCHelper::sendReliableRealTimeMessage(&byte[0]);
}
// In GCHelper's implementation
void GCHelper::sendReliableRealTimeMessage(const char* byteMess)
{
// Convert char* to jbyteArray
jbyteArray bArray = env->NewByteArray(16); //env is a static JNIEnv* in this class; 16 since my PING_MESSAGE struct is 16 bytes in size;
env->SetByteArrayRegion(bArray,0,16,(jbyte*)byteMess);
// Make Java call
env->CallStaticVoidMethod(classID, methodID, bArray);
methodInfo.env->DeleteLocalRef(bArray);
methodInfo.env->DeleteLocalRef(classID);
}
Now, Java code take responsibility to send the byte array to participants in room. At receiver side, I'm continue send received data to C++. And error occured here when I convert jbyteArray back to struct:
void Java_package_name_TestMulti_nativeOnRealTimeMessageReceived(JNIEnv *env, jobject thiz, jbyteArray receivedMess)
{
CCLOG("Called from java");
jboolean isCopy;
jbyte * pCData = env->GetByteArrayElements(receivedMess, &isCopy);
jsize size = env->GetArrayLength(receivedMess);
const char* sd = (const char*)pCData;
PING_MESSAGE result;
memcpy(&result, sd, sizeof(result));
CCLOG("TEST size: %d", size); // This log out: "TEST size: 16"
CCLOG("TEST type: %d", result.mess.messType); // This log out: "TEST type: -1"
CCLOG("TEST text: %s", result.text); // AND ERROR!!!!!!!
cocos2d::CCByteArray* data = cocos2d::CCByteArray::createWithData(sd);
cocos2d::CCNotificationCenter::sharedNotificationCenter()->postNotification("onRealTimeMessageReceived", data);
if(isCopy)
{
env->ReleaseByteArrayElements(receivedMess,pCData,JNI_ABORT);
}
}
I'm not understand here. If I don't send byte array to another players yet send that array back to C++ by calling nativeOnRealTimeMessageReceived() method from Java side, it runs fine and logs correctly. It's mean that with the same byte[] package converted from char* in C++, if I just pass it back to C++, it's correct, but if I send it through Google Play Game Services, it goes wrong. What does this mean?

Related

Callback function not called?

I have 2 callback functions in an Arduino file (.ino, c++):
void incomingPacket(const char* subject, const char* message){
Serial.print("subject: ");
Serial.println(subject);
Serial.print("message: ");
Serial.println(message);
}
void connectedProtocol(bool connected){
if(connected){
Serial.println("protocol server connected");
}else{
Serial.println("protocol server disconnected");
}
}
And in my Arduino file I have a custom class UDPProtocol protocol(Udp) which calls the callback functions after certain events, like:
_connectedcb(setTo); //this calls connectedProtocol callback in Arduino from UDPProtocol class
This above works fine, it calls the callback function connectedProtocol() with correct boolean value. However, when trying to call incomingPacket() callback function, nothing happens in my Arduino file. Method that calls the callback:
//this is from UDPProtocol class
void UDPProtocol::readPacketContents(char* content){
if(strlen(content)){ //if content size is greater than 0
const char* somemessage = "Hellomessage";
const char* subject;
const char* message;
subject = &somemessage[0]; //this depends on the actual format of udp packet
message = &somemessage[1];
_packetcb(subject,message);
}
_buffer[0] = 0;
}
Whenever this method runs, callback is not called in Arduino. Even if I try to fake the message like:
void UDPProtocol::readPacketContents(char* content){
if(strlen(content)){ //if content size is greater than 0
const char* somemessage = "Hellomessage";
const char* subject;
const char* message;
subject = &somemessage[0]; //this depends on the actual format of udp packet
message = &somemessage[1];
_packetcb(subject,message);
}
_buffer[0] = 0;
}
Still nothing happens (if(strlen(content)) does equal true). Any suggestions?
EDIT:
UDPProtocol.h file:
typedef void (*PackedCallback)(const char* subject, const char* message);
PackedCallback _packetcb;
UDPProtocol.cpp file:
void UDPProtocol::setPacketCallback(PackedCallback func){
this->_packetcb = func;
}
In Arduino.ino:
protocol.setPacketCallback(incomingPacket); //defined in this question above
EDIT 2:
I created a gist with the full code:
https://gist.github.com/aliamid93/64ba2ed0e06b1f9b4401474646f8083e

serialize complex C++ structures between client and server

I am writing C++ ZeroMQ Client and server programs for the same platform. I need to trigger some functions with arguments on the server. The arguments are complex structures. I have just started to try this out. I am trying to fill a structure and fill it to a char* buffer to see if the bytes are filled out in sequence as per the structure.
But when i try to print the buffer, it prints garbage. Please advice what might be wrong. And is this the elegant way to do this? I cannot use gRPC or Protobuffs as the message contains complex structures.
struct employee {
uint8_t byt;
int arr[10] = {0};
int number;
uint32_t acct;
};
int main ()
{
// Prepare our context and socket
zmq::context_t context (1);
zmq::socket_t socket (context, ZMQ_PAIR);
struct employee *e = new employee;
e->byt = 0xff;
e->arr[0] = 15;
e->number = 25555;
e->acct = 45;
std::cout << "Connecting to hello world server…" << std::endl;
socket.connect ("tcp://localhost:5555");
char *temp = (char*)malloc(sizeof(employee));
memcpy(temp,e,sizeof(employee));
zmq::message_t request(sizeof(employee));
char *temp1 = temp;
for (int i = 0;i<sizeof(employee);i++) {
std::cout<<temp1[i]<<std::endl;
}
memcpy ((void *)request.data(),(void*)temp, sizeof(employee));
socket.send (request);
// Get the reply.
zmq::message_t reply;
socket.recv (&reply);
return 0;
}
Two points I would like to share here.
the buffer (temp) contains binary representation of your data structure. If you want to check if the content is meaningful, you can cast the pointer type back to its original pointer.ie:
struct employee * employeePtr = static_cast< struct employee *>(temp);
cout << employeePtr ->number;
...
The way you de-serialize is okay when the object you are trying to
serialize occupies continuous memory. When it is not the case, you will have to handle them some other way (using stream for example). Examples of such cases include:
when you have pointer, shared_ptr etc. to some allocated memory
container classes

How to pass a member function pointer to libusb?

I'm writing a simple library that uses libusb to connect to my custom hardware that sends signals to a host device every 50ms. It's designed to provide a simple abstraction layer so that users are not bothered with libusb at all. I need to pass a pointer to a non-static class member function to libusb_fill_bulk_transfer. I.e. I need to have a separate callback for every instance of MyDevice without exposing libusb logic to my users.
The basic design is:
init the lib
int mylib_init(){
libusb_init(&context);
}
find all compatible devices
int mylib_get_valid_devices(vector devs){
//...
libusb_device **devs1;
int countAll = libusb_get_device_list(context, &devs1);
//... fill devs
}
int mylib_print_device_info(MyDevice* dev);
connect to as many devices as the user likes
int mylib_init_device(MyDevice* dev){
libusb_open(dev->device, &dev->dev_handle);
// check for kernel driver & remove if needed
libusb_claim_interface(dev->dev_handle, 0);
//...
}
set up callbacks for incoming data to all instances of connected devices
int mylib_start_transmission_async(MyDevice* dev, MyLibCallbackIn user_cb, unsigned char* buffer_in, int bufferSize){
libusb_control_transfer(dev->dev_handle, p1, p2, p3, p4, p5, p6, p7);
// .. rest of libusb_control_transfer -s
//start device:
int actual;
unsigned char startSig = 0b00110111;
libusb_bulk_transfer(dev->dev_handle, (1 | LIBUSB_ENDPOINT_OUT), &tosend, 1, &actual, 100);
dev->user_callback = user_cb;
dev->buffer_in = buffer_in;
dev->bufferSize = bufferSize;
//setup transfer
dev->transfer_in = libusb_alloc_transfer(0);
libusb_fill_bulk_transfer(dev->transfer_in, dev->dev_handle, LIBUSB_ENDPOINT_IN, dev->buffer_in,dev->bufferSize, cb_in, NULL, 0);
libusb_submit_transfer(dev->transfer_in);
}
disconnect when finished
int mylib_disconnect_device(MyDevice* device);
exit the lib
int mylib_exit();
MyDevice is defined as:
typedef int (*MyLibdCallbackIn)(unsigned char* buffer, int length);
class MyDevice{
unsigned char* buffer_in;
unsigned char* buffer_out;
libusb_device* device = nullptr;
libusb_device_handle* dev_handle = nullptr;
struct libusb_transfer* transfer_in = nullptr;
struct libusb_transfer* transfer_out = nullptr;
//this obviously wouldn't work because libusb doesn't accept it as a param:
void LIBUSB_CALL cb_in(struct libusb_transfer* transfer);
MyLibCallbackIn user_callback;
void run();
//...
}
and cb_in is defined as:
void LIBUSB_CALL MyDevice::cb_in(libusb_transfer* transfer){
int r = libusb_submit_transfer(this->transfer_in);
callback_in(transfer->buffer, transfered);
}
I can't pass MyDevice::cb_in to libusb_fill_bulk_transfer because the function pointer types are incompatible. In the same time I don't want my users to have to write a callback function with libusb_transfer* as a parameter (exposing to libusb) to pass directly to libusb_fill_bulk_transfer.
EDIT:
I tried with
void LIBUSB_CALL callback_wrapper(struct libusb_transfer* transfer){
MyDevice* dev = reinterpret_cast<MyDevice*>(transfer->user_data);
dev->cb_in(transfer);
}
but get Sementation fault (Core dumped) error
As per Max Langhof and Sam Varshavchik's comments the solution is to pass the instance of MyDevice to libusb_fill_bulk_transfer . So:
int mylib_start_transmission_async(MyDevice* dev, MyLibCallbackIn user_cb, unsigned char* buffer_in, int bufferSize){
//...
// setup transfer:
dev->transfer_in = libusb_alloc_transfer(0);
libusb_fill_bulk_transfer(dev->transfer_in, dev->dev_handle, LIBUSB_ENDPOINT_IN, dev->buffer_in,dev->bufferSize, cb_in, dev, 0);
libusb_submit_transfer(dev->transfer_in); ^^^
}
and then use the callback_wrapper as in the Edit. Thanks!

Inter process communication between C# and C++ (using QT4.8)

I am facing issue in passing data between c# and C++ (QT) application through named pipe communication. C# client application connects to NamedPipe server which is in c++ but message is not being parsed correctly on server. Example, I am sending value of short variable = 2 and c++ code parse byte array into unsigned int but value is coming always zero in server. Could you please let me know what I am doing wrong?
Client and server code:
NamedPipe Server code in C++ using QT Library
QLocalSocket *local_socket = _local_server->nextPendingConnection();
if (!local_socket->waitForReadyRead(gft::PROC_TIMEOUT)) {
qDebug() << "gft_plugin: timeout while waiting for data";
return;
}
int bytesavailable = local_socket->bytesAvailable();
QByteArray buffer;
QDataStream in(&buffer, QIODevice::ReadOnly);
buffer.append(local_socket->readAll());
unsigned int msg;
in >> msg;
unsigned int a_id = msg;
NamedPipe Client (C#)
var clientStream = new NamedPipeClientStream("localhost", "gft_plugin_server", PipeDirection.InOut);
clientStream.Connect();
if (clientStream.IsConnected)
{
_stop = false;
UInt16 a_id = 2;
byte[] b = BitConverter.GetBytes(a_id);
clientStream.Write(b, 0, b.Count());
clientStream.Flush();
}
else
{
MessageBox.Show("Could not connected");
}

Audio data polluting my RFCOMM channel using the IOBluetooth framework

I'm working on simple host program (c++/xcode/osx) that establishes a connection to a Bluetooth client and opens an RFCOMM channel for data transmission. When I send data from the BT client to the host I get my data mixed with random dumps from what looks to be a Bluetooth Audio Agent. Is it possible that I'm sharing my RFCOMM channel with the OS X Bluetooth Audio Agent?
My Bluetooth device needs to support both Serial (SPP) and Hands-Free (HFP) profiles. So I strongly believe that the issue is around the HFP or SCO profile polluting my RFCOMM channel with it's data. Is there a way to make sure that I only get my data coming through the channel?
Here's a condensed version of my project. When the client is connected it starts echoing the letter a. The host app prints what it receives from the client, and if the received data is an a it also logs OK!\n.
#include <IOBluetooth/IOBluetoothUserLib.h>
#include <IOBluetooth/IOBluetoothUtilities.h>
#include <IOBluetoothUI/IOBluetoothUI.h>
#include <IOBluetoothUI/IOBluetoothUIUserLib.h>
#include "testApp.h"
// Callback function create-connection
void bluetoothCreateConnection_c(void *userRefCon, IOBluetoothDeviceRef deviceRef, IOReturn status) {
printf("Created connection\n");
}
// Callback for RFCOMM events
void rfcommEventListener_c (IOBluetoothRFCOMMChannelRef channel_ref, void *userRefCon, IOBluetoothRFCOMMChannelEvent *event) {
if (event->eventType == kIOBluetoothRFCOMMNewDataEvent) {
const char *data_const = (const char *)event->u.data.dataPtr;
char *dataAsBytes = const_cast<char *>(data_const);
string in_s = (string)dataAsBytes;
printf("%s", dataAsBytes);
if(in_s == "a") {
printf("OK!\n");
}
}
}
void testApp::setup() {
BluetoothDeviceAddress *addr;
string s = "00-16-a4-00-72-3d"; // hardcoded BT address
CFStringRef str_addr;
str_addr = CFStringCreateWithCString(kCFAllocatorDefault, s.c_str(), kCFStringEncodingMacRoman);
IOBluetoothCFStringToDeviceAddress(str_addr, addr);
IOBluetoothDeviceRef dev = IOBluetoothDeviceCreateWithAddress(addr);
IOBluetoothDeviceOpenConnection(dev, &bluetoothCreateConnection_c, NULL);
printf("in openRFCOMMChannel\n");
CFArrayRef device_services = IOBluetoothDeviceGetServices(dev);
printf("Getting SDP service record\n");
IOBluetoothSDPServiceRecordRef service_record = (IOBluetoothSDPServiceRecordRef) CFArrayGetValueAtIndex(device_services, 0);
UInt8 channel_id;
IOBluetoothRFCOMMChannelRef channel_ref;
printf("Finding channel ID\n");
IOBluetoothSDPServiceRecordGetRFCOMMChannelID(service_record, &channel_id);
// Open channel and listen for RFCOMM data
IOBluetoothDeviceOpenRFCOMMChannelAsync(dev, &channel_ref, channel_id, &rfcommEventListener_c, NULL);
}
Here's the output from the program:
run
[Switching to process 41228]
Running…
in openRFCOMMChannel
2011-06-13 13:44:04.762 test (Debug)[41228:a0f] *** __NSAutoreleaseNoPool(): Object 0x1d27770 of class NSCFArray autoreleased with no pool in place - just leaking
Getting SDP service record
Finding channel ID
Created connection
aOK!
aaOK!
aaOK!
a!()*\251\253\274_BluetoothVersionNumber_PersistentServicesZHIDDevices_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionarya)*\251\253\274_BluetoothVersionNumber_PersistentServicesZHIDDevices_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionarya\251\253\274_BluetoothVersionNumber_PersistentServicesZHIDDevices_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionarya_BluetoothVersionNumber_PersistentServicesZHIDDevices_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryauetoothVersionNumber_PersistentServicesZHIDDevices_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryathVersionNumber_PersistentServicesZHIDDevices_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryasionNumber_PersistentServicesZHIDDevices_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaumber_PersistentServicesZHIDDevices_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionarya_PersistentServicesZHIDDevices_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryarsistentServicesZHIDDevices_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaentServicesZHIDDevices_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryarvicesZHIDDevices_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryasZHIDDevices_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaDevices_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaes_SCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaSCOAudioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryadioDevices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryavices_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionarya_DaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaemonNoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaoRoleSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaSwitchDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryahDeviceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaceList_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryat_!DaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaaemonControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaControllersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaollersConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryasConfigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaigurationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryationKey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaey_ControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaControllerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaollerPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaPowerState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaState_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionarya_BluetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryauetoothAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryathAutoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaoSeekHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaHIDDevices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryavices_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionarya_PersistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryarsistentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaentPortsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryartsZPANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaANDevices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaices]PairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaPairedDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryadDevices_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaces_PersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaPersistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaistentPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryatPortsServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryasServicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaicesOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryaOMstreamtyped\201\350\204#\204\204\204NSMutableDictionaryastreamtyped\201\350\204#\204\204\204NSMutableDictionaryaamtyped\201\350\204#\204\204\204NSMutableDictionaryaed\201\350\204#\204\204\204NSMutableDictionarya\204#\204\204\204NSMutableDictionarya\204NSMutableDictionaryaaeDictionaryaionaryayaNSDictionaryationaryaryaNSObjectajectaa\206\242a_00-14-51-cc-20-41_00-0a-95-3f-fe-8a\324a0-14-51-cc-20-41_00-0a-95-3f-fe-8a\324a51-cc-20-41_00-0a-95-3f-fe-8a\324a-20-41_00-0a-95-3f-fe-8a\324a1_00-0a-95-3f-fe-8a\324a0-0a-95-3f-fe-8a\324a95-3f-fe-8a\324a-fe-8a\324aa\324a\324aOK!
a\232a00-16-a4-00-17-7e_00-16-a4-00-72-3d_00-23-7f-49-98-a6_00-1a-10-04-13-9a\323a6-a4-00-17-7e_00-16-a4-00-72-3d_00-23-7f-49-98-a6_00-1a-10-04-13-9a\323a00-17-7e_00-16-a4-00-72-3d_00-23-7f-49-98-a6_00-1a-10-04-13-9a\323a-7e_00-16-a4-00-72-3d_00-23-7f-49-98-a6_00-1a-10-04-13-9a\323a00-16-a4-00-72-3d_00-23-7f-49-98-a6_00-1a-10-04-13-9a\323a6-a4-00-72-3d_00-23-7f-49-98-a6_00-1a-10-04-13-9a\323a00-72-3d_00-23-7f-49-98-a6_00-1a-10-04-13-9a\323a-3d_00-23-7f-49-98-a6_00-1a-10-04-13-9a\323a00-23-7f-49-98-a6_00-1a-10-04-13-9a\323a3-7f-49-98-a6_00-1a-10-04-13-9a\323a49-98-a6_00-1a-10-04-13-9a\323a-a6_00-1a-10-04-13-9a\323a00-1a-10-04-13-9a\323aa-10-04-13-9a\323a04-13-9a\323a-9a\323a\323aOK!
aYAgentPathXDriverID_IOAudioControls_W/System/Library/CoreServices/BluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244antPathXDriverID_IOAudioControls_W/System/Library/CoreServices/BluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244ahXDriverID_IOAudioControls_W/System/Library/CoreServices/BluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244averID_IOAudioControls_W/System/Library/CoreServices/BluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244a_IOAudioControls_W/System/Library/CoreServices/BluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244aAudioControls_W/System/Library/CoreServices/BluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244aControls_W/System/Library/CoreServices/BluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244aols_W/System/Library/CoreServices/BluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244aW/System/Library/CoreServices/BluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244atem/Library/CoreServices/BluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244aibrary/CoreServices/BluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244ay/CoreServices/BluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244aeServices/BluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244aices/BluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244aBluetoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244aoothAudioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244audioAgent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244agent.app/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244aapp/Contents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244aontents/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244ats/MacOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244acOS/BluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244aluetoothAudioAgent_00-16-a4-00-17-7e-SCO\244aothAudioAgent_00-16-a4-00-17-7e-SCO\244adioAgent_00-16-a4-00-17-7e-SCO\244aent_00-16-a4-00-17-7e-SCO\244a00-16-a4-00-17-7e-SCO\244a6-a4-00-17-7e-SCO\244a00-17-7e-SCO\244a-7e-SCO\244aCO\244aOK!
aN\332a\332aOK!
a%aOK!
aaOK!
a.aOK!
aIOAudioControlType_IOAudioControlSubType_IOAudioControlChannelID_IOAudioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaioControlType_IOAudioControlSubType_IOAudioControlChannelID_IOAudioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeatrolType_IOAudioControlSubType_IOAudioControlChannelID_IOAudioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaype_IOAudioControlSubType_IOAudioControlChannelID_IOAudioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaIOAudioControlSubType_IOAudioControlChannelID_IOAudioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeadioControlSubType_IOAudioControlChannelID_IOAudioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeantrolSubType_IOAudioControlChannelID_IOAudioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaSubType_IOAudioControlChannelID_IOAudioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaaIOAudioControlChannelID_IOAudioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaioControlChannelID_IOAudioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeatrolChannelID_IOAudioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeahannelID_IOAudioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmealID_IOAudioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaIOAudioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeadioControlValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeantrolValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaValue_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmea_IOAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaAudioControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaControlChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaolChannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeannelName_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaaaaaaaaaaaaaaaame_IOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaIOAudioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeadioLevelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeavelControlMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeantrolMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaMaxDB_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmea_IOAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaAudioLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaLevelControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaControlMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaolMaxValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaValue_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmea_IOAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaAudioLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaLevelControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaControlMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaolMinValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaValue_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmea_IOAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaAudioLevelControlMinDB_IOAudioControlUsagelevlvlmeaLevelControlMinDB_IOAudioControlUsagelevlvlmeaControlMinDB_IOAudioControlUsagelevlvlmeaolMinDB_IOAudioControlUsagelevlvlmeaaIOAudioControlUsagelevlvlmeaioControlUsagelevlvlmeatrolUsagelevlvlmeasagelevlvlmealevlvlmeavlmeaOK!
Ok, I'm pretty sure I found my problem. The data pointer that I copied over to a char * wasn't 0 terminated. I rewrote this:
const char *data_const = (const char *)event->u.data.dataPtr;
char *dataAsBytes = const_cast<char *>(data_const);
string in_s = (string)dataAsBytes;
To this:
const char *data_const = (const char *)data.dataPtr;
char *dataAsBytes = const_cast<char *>(data_const);
dataAsBytes[data.dataSize] = '\0';
printf("%s %i %i\n", dataAsBytes, data.dataSize);