CoreBluetooth - Writing data from Central to Peripheral - bluetooth-lowenergy

I referred Sample app provided by Apple for CoreBluetooth and I succeeded in sending Data from Peripheral to Central, Now I need to write Data from Central to Peripheral. After Googling i found that It can be done using [_discoveredPeripheral writeValue:aData forCharacteristic:charc type:CBCharacteristicWriteWithResponse];
Following is my Implementation of Central, to send Message to peripheral:
-(void)sendMessage:(NSString *)strMessage{
NSData *aData = [strMessage dataUsingEncoding:NSUTF8StringEncoding];
CBMutableCharacteristic *charc =[[CBMutableCharacteristic alloc] initWithType:[CBUUID UUIDWithString:TRANSFER_CHARACTERISTIC_UUID] properties:CBCharacteristicPropertyWrite value:nil permissions: CBAttributePermissionsWriteable];
[_discoveredPeripheral writeValue:aData forCharacteristic:charc type:CBCharacteristicWriteWithResponse];
}
When I call this method, It is not able to write data, instead of that I can see a CoreBluetooth Warning on console as below,
CoreBluetooth[WARNING] <CBMutableCharacteristic: 0x15e8e420 UUID = 08590F7E-DB05-467E-8757-72F6FAEB13D4, Value = (null), Properties = 0x8, Permissions = 0x2, Descriptors = (null), SubscribedCentrals = (
)> is not a valid characteristic for peripheral <CBPeripheral: 0x15d91250 identifier = 37C314AF-FDB3-1F24-6937-8780B97AAB45, Name = "iPad", state = disconnected>
It would be nice if someone give the best way to get Object of Peripheral and how to initiate sending of data from Central to Peripheral.
EDIT
I have tried the way that is shown in How to get the characteristic from UUID in objective-C?
But, In this case I am not able to Loop Services whenever I try for that It returns services=nil.

Related

How to enable CTR encryption in Rocksdb

I am trying to enable CTR encryption in rocksdb 7.8.3 on Windows.
The history indicates it is possible using CreateFromString("CTR").
I am getting an error "NotFound: Missing configurable object: cipher"
it fails at the last line. I cannot find any examples or documentation for this. I am thinking I'm probably missing a crypto library of some kind.
thanks.
this is my code:
rocksdb::Status status;
rocksdb::ConfigOptions config_options;
std::string CTR = "CTR";
config_options.invoke_prepare_options = false;
std::shared_ptr<rocksdb::EncryptionProvider> provider;
status = rocksdb::EncryptionProvider::CreateFromString(config_options, CTR, &provider);
status = provider->AddCipher("", "a6d2ae2816157e2b3c4fcf098815f7xb", 32, false);
status = provider->PrepareOptions(config_options);

Is it possible to know which input gate triggered the handleMessage() method of Omnet++?

I have a simple network in Omnet++ where lower levels of the network are received in one in gate (inLower) and same-level network data is retrieved in another in gate (inMid).
I am using the handleMessage() method of Omnet++ to trigger some action upon receiving a message. Is there any way to distinguish which input gate received the message? I know that I can specify which output gate a message is sent through.
You can get the arrival gate for a given cMessage by using cMessage::getArrivalGate().
void handleMessage(cMessage *msg) {
cGate *arrivalGate = msg->getArrivalGate();
if (arrivalGate == gate("inMid")) {
// do stuff
} else {
// or y'know
}
}
The example above assumes inMid is the string identifier for a scalar gate. If your gate is a vector gate you can first check if it has any gates (gateSize("inMid") > 0), then acquire its base gate (cGate inMidBaseGate = gate("inMid", 0);). You could then get its base id (auto inMidBaseId = inMidBaseGate.getBaseId()) which you could compare to the arrival gate and its base ID (inMidBaseId == arrivalGate->getBaseId()).

Use R serial package to extract information stored in a Trovan GR250 RFID reader

I try to access to informations stored inside a Trovan reader using R serial package via a serial port. Connexion seems to be effective since the reader red led is shortly activated when serialConnection function is run but
read.serialConnection function give an empty string instead of the expected tag code. Have someone any ideas ? below a link to the reader documentation and the R script.
Many thanks
http://www.vantro.biz/GR-250%20Computer%20Interface%20Manual.pdf
trovan<-serialConnection(NA,port = "com1", mode = "9600,N,8,1",translation = 'cr', handshake = 'xonxoff')
open(trovan)
res<-read.serialConnection(trovan)
close(trovan)
res
[1] " "
library(serial)
library(radio)###have to add some waiting time between each step
trovan<-serialConnection("get_rfid", port = "COM4", mode ="9600,N,8,1", newline = 1, translation = "cr", handshake = "xonxoff") ##windows os
open(trovan)
wait(1)
write.serialConnection(trovan,"N")
wait(2.5)
res<-read.serialConnection(trovan)
close(trovan)

setup bosun snmp scollector to monitor CPU memory keep get error

i am trying to run scollector from bosun.
after I run the scolector, It cannot show me the memory information, but CPU information was right.
this CODE:
Host = "http://localhost:8070"
DisableSelf = true
Freq = 60
Filter = ["snmp-generic", "snmp-ifaces"]
[[SNMP]]
Community = "test"
Host = "name"
MIBs = [ "devicename"]
[Tags]
product = "fw"
[MIBs]
[MIBs.fw]
BaseOid = ".1.3.6.1.4.1.2620"
[[MIBs.fw.Metrics]]
Metric = "os.cpu"
Oid = ".1.6.7.2.4.0"
Unit = "percent"
RateType = "gauge"
[[MIBs.fw.Metrics]]
Metric = "os.mem.used"
Oid = ".1.6.7.4.5.0"
Unit = "bytes"
RateType = "gauge"
THIS IS LOG
**2016/11/07 17:24:42 error: interval.go:64: snmp-generic-name-fw: asn1: structure error: tags don't match (2 vs {class:0 tag:4 length:11 isCompound:false}) {optional:false explicit:false application:false defaultValue:<nil> tag:<nil> stringType:0 timeType:0 set:false omitEmpty:false} #2**
2016/11/07 17:24:43 info: queue.go:90: {"metric":"os.cpu","timestamp":1478539482,"value":2,"tags":{"host":"name","product":"fw"}}
It looks to me like this is an issue converting data types. The error is from deep in the bowels of the asn1 library we are using but I think it boils down to: cpu is represented as an integer, while memory is a string.
Our snmp collector attempts to parse all values into a big.Int, but apparently the string value is not able to be coerced into that by our asn1 library.
Unfortunately I don't see a good way to make this work, except perhaps look for an oid that returns an integer type. Without knowing what device you are using, that is as good as I can offer I'm afraid.

NSString format not working on device but working on simulator

just making a basic game and used the NSUserDefaults to save the high score. while calling the i needed to use a NSString with a Format of "Best Time : %i". I Ran the game on the simulator and it worked perfectly.
However when I went to run it on the device the label that i formatted using the NSString(format "Best Time : %i") did not work nothing appeared in the label?
Here is the code I used for calling the saved Best time:
//The previous games best time
var highscoreDefaults = NSUserDefaults.standardUserDefaults()
if (highscoreDefaults.valueForKey("Highscore") != nil){
theNewTime = highscoreDefaults.valueForKey("Highscore") as! NSInteger!
thehighscore.text = NSString(format: "Best Time : %i" , theNewTime) as String
}
//---------------------
You can use Swift's string interpolation as you don't need any advanced features from the C-format specifier:
thehighscore.text = "Best Time : \(theNewTime)"

Resources