#include // time to advertise in milliseconds char siteID = 2; int duration = SECONDS(1); char tbuffer[3]; char gasSensorName[] = "g"; int sensorValue = 0xFF; void setup() { Serial.begin(2400, 3, 4); // Starts the UART at 2400 with RX on GPIO3 and TX on GPIO 4 } void loop() { int v1,v2,v3,hdrfound; hdrfound=0; while( Serial.available() ) { v1 = Serial.read(); if( v1 == 0xA5 ) { hdrfound = 1; break; } } if( hdrfound ) { v2 = Serial.read(); v3 = Serial.read(); sensorValue = v3; } tbuffer[0] = siteID; tbuffer[1] = ( sensorValue & 0xFF ); tbuffer[2] = 0; RFduinoBLE.deviceName = gasSensorName; RFduinoBLE.advertisementData = tbuffer; // start the BLE stack RFduinoBLE.begin(); // advertise for ms milliseconds RFduino_ULPDelay(duration); // stop the BLE stack RFduinoBLE.end(); }