Bluetooth example [DEPRECATED]

Bluetooth example [DEPRECATED]

This content is archived.
deprecated
Bluetooth example
#include <io> #include <read> #include <float> #include <string> #include <core> #include <write> #include <define> #include <bluetooth> new hostName[20]; new ReceiveBuffer[256]; forward public callback (arg); public callback (arg) { switch(arg) { case Bluetooth_connect_request: { Bluetooth(BT_ACCEPT_CONNECTION); } case Bluetooth_pair_request: { Bluetooth(BT_PAIR); } } } main() { new RxLength = 0; new isPowerOn = 0; new isConnected = 0; while((get_val(Sensor_SystemTime) == 0) && (get_val(Sensor_SignalModemOn) == 0)) { Delay(1000); } while(1) { if (Bluetooth(BT_GET_STATUS, isPowerOn, isConnected) != 0) { if (isPowerOn == 0) { if (get_val(Sensor_SignalModemOn == 1)) { Init(Bluetooth_RF); Bluetooth(BT_GET_HOSTNAME, hostName, 20); if (strcmp(hostName, "XtCAN", false, strlen("XtCAN")) != 0) Bluetooth(BT_SET_HOSTNAME, "XtCAN",6); } } else { if (isConnected == 1) { RxLength = Bluetooth(BT_GET_RX_LENGTH); if (RxLength > 0) { Bluetooth(BT_RECEIVE, ReceiveBuffer, RxLength); if (strcmp(ReceiveBuffer, "Laba diena", false, strlen("Laba diena")) == 0) Bluetooth(BT_SEND, "Kaip sekasi", strlen("Kaip sekasi")); } } } } Delay(500); } }