BLE disconnect. Gatt error 133
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
connectDevice.connectGatt(context, Consts.autoConnect, gatt_callback, BluetoothDevice.TRANSPORT_LE);
}else {
connectDevice.connectGatt(context, Consts.autoConnect, gatt_callback);
}
標籤
- C
- android
- Objective-c
- Sort
- BlueTooth
- Python
- 133
- Apache
- ArrayList
- BluetoothChat
- C sharp
- C#
- CVS
- CheckBox
- Closest Pair
- Console.ReadLine
- HashMap
- NFC
- NSDocumentDirectory
- NSString
- Pandaboard
- SQLite
- UIAlertController
- VB
- Xcode6
- driver
- execSQL
- gatt error
- httpd.conf
- office
- primie check
- property
- sharedApplication
- 小小問題
2019年1月15日 星期二
2016年3月14日 星期一
Delete a branch in "CVS"
Delete a branch in "CVS"
command: tag -dB branchname
-d: delete
-B: override and let it know to delete the branch (not a tag).
2015年9月23日 星期三
Two floating numbers 四捨五入
Input two floating numbers X and P.
a. 0 < X <1
b. P = 1 / 0.1 / 0.01/ 0.001
c. answer format %.4f
ex:
if X is 0.5678 and P is 0.01, then the answer is 0.5700
if X is 0.1269 and P is 0.1, then the answer is 0.1000
2015年9月17日 星期四
C int mapping string
Encoding scheme defined by the following mapping:
1->'A',
2->'B',
3->'C',
...,
9->'I',
0->'J'.
Input A three-digit integer N
Output The encoding result
2014年9月24日 星期三
Xcode 6.0.1 / iOS 8 UIAlertController
UIAlertControllerStyleAlert with Buttons
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action)
{
NSLog(@"Cancel Action");
}];
UIAlertAction *deleteAction = [UIAlertAction actionWithTitle:@"Delete"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
NSLog(@"Delete Action");
}];
[alertController addAction:cancelAction];
[alertController addAction:deleteAction];
[self presentViewController:alertController animated:YES completion:nil];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action)
{
NSLog(@"Cancel Action");
}];
UIAlertAction *deleteAction = [UIAlertAction actionWithTitle:@"Delete"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
NSLog(@"Delete Action");
}];
[alertController addAction:cancelAction];
[alertController addAction:deleteAction];
[self presentViewController:alertController animated:YES completion:nil];
2014年9月10日 星期三
iOS set UIImageView to CircleView
- (id)imageViewSetCornerRadius:(UIImageView *)imageView withImage:(UIImage *)image {
imageView.image = image;
imageView.layer.borderWidth = 3.0f;
imageView.layer.borderColor = [UIColor whiteColor].CGColor;
imageView.layer.cornerRadius = imageView.frame.size.width / 2;
imageView.clipsToBounds = YES;
return imageView;
}
2014年7月13日 星期日
[iOS] Objective-c sharedApplication delegate, global @property
AppDelegate.h
#define appDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])
@property (nonatomic, assign)NSInteger globalCount;
How to use?
2014年7月10日 星期四
[Android] ArrayList save HashMap
ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
//Save
for(int i=0;i<5;i++) {
HashMap<String,String> tempMap = new HashMap<String,String>();
String name = "server"+i;
String mac = "11:22:33:44:55:6"+i;
tempMap.put("DEVICE_NAME",name);
tempMap.put("DEVICE_MAC",mac);
peripheralScanResultList.add(tempMap);
}
//Get
for(HashMap<String, String> tempMap: peripheralScanResultList) {
Iterator<String> iterator = tempMap.keySet().iterator();
while( iterator.hasNext() ){
String key=(String)iterator.next();
String value=(String)tempMap.get(key);
Log.i(TAG, key + ", " +value);
}
}
[Android] SQLite execSQL, rawQuery
SQLiteDatabase db = dbHelper.getWritableDatabase();
a. Create table
String INIT_TABLE = "CREATE TABLE IF NOT EXISTS " + tableName + " ("
+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ field1 + " TEXT, "
+ field2 + " INTEGER, "
+ field3 + " VARCHAR );" ;
a. Create table
String INIT_TABLE = "CREATE TABLE IF NOT EXISTS " + tableName + " ("
+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ field1 + " TEXT, "
+ field2 + " INTEGER, "
+ field3 + " VARCHAR );" ;
db.execSQL(INIT_TABLE);
b. Delete table
try {
db.execSQL("delete from "+ tableName);
} catch (SQLException e) {
Log.e("ERROR", e.toString());
}
db.close();
2014年6月20日 星期五
[iOS] Objective-c save/load image under APP document
Objective-c save/load image under APP document
Save image:
[self saveImageInDocumenet:Image withName:@"blue"];
Load image with name:
UIImage *image = [self loadImageFromDocumentWithName:@"blue"];
- (void)saveImageInDocumenet:(UIImage *)image withName:(NSString *)name {
if (image != nil) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString* path = [documentsDirectory stringByAppendingPathComponent:name];
NSData* data = UIImagePNGRepresentation(image);
[data writeToFile:path atomically:YES];
}
}
[iOS] Objective-c NSString to Hex string
Objective-c NSString to Hex string
NSData *data = [self parseMacAddress:@"AABBCCDDEEFF "];
NSLog(@"After transfer: %@", data);
= > AABBCCDDEEFF (Hex)
標籤:
NSString,
Objective-c
2013年6月14日 星期五
[Android] Bluetooth Chat receive data lost
原先:
while (true) {
try {
// Read from the InputStream
bytes = mmInStream.read(buffer);
// Send the obtained bytes to the UI Activity
mHandler.obtainMessage(BluetoothChat.MESSAGE_READ, bytes, -1, buffer)
.sendToTarget();
} catch (IOException e) {
Log.e(TAG, "disconnected", e);
connectionLost();
// Start the service over to restart listening mode
BluetoothChatService.this.start();
break;
}
}
while (true) {
try {
// Read from the InputStream
bytes = mmInStream.read(buffer);
// Send the obtained bytes to the UI Activity
mHandler.obtainMessage(BluetoothChat.MESSAGE_READ, bytes, -1, buffer)
.sendToTarget();
} catch (IOException e) {
Log.e(TAG, "disconnected", e);
connectionLost();
// Start the service over to restart listening mode
BluetoothChatService.this.start();
break;
}
}
標籤:
BlueTooth,
BluetoothChat
2013年4月29日 星期一
[Android] remember me checkbox
private CheckBox checkBox;
SharedPreferences login_pref;
private SharedPreferences.Editor loginPrefsEditor;
private Boolean saveLogin;
// onCreate
username = (EditText) findViewById(R.id.editText_username);
password = (EditText) findViewById(R.id.editText_password);
login = (Button) findViewById(R.id.button_login);
checkBox = (CheckBox)findViewById(R.id.checkBox1);
login.setOnClickListener(this);
login_pref = getSharedPreferences("loginPrefs", MODE_PRIVATE);
loginPrefsEditor = login_pref.edit();
saveLogin = login_pref.getBoolean("saveLogin", false);
if (saveLogin == true) {
username.setText(login_pref.getString("username", ""));
password.setText(login_pref.getString("password", ""));
checkBox.setChecked(true);
}
2013年4月25日 星期四
PandaBoard driver install
PandaBoard Driver Install
find sdk\extras\google\usb_driver\android_winusb.inf
open it and
add:
;OMAP-3/4
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_D002&REV_0216
%CompositeAdbInterface% = USB_Install, USB\VID_0451&PID_D102&MI_01
%CompositeAdbInterface% = USB_Install, USB\VID_0451&PID_D106&MI_02
%CompositeAdbInterface% = USB_Install, USB\VID_0451&PID_D107&MI_03
%SingleAdbInterface% = USB_Install, USB\VID_0451&PID_FFFFE
%CompositeAdbInterface% = USB_Install, USB\VID_0451&PID_FFFE&MI_01
in [Google.NTx86]
設定好之後, 再更新驅動程式 from sdk\extras\google\usb_driver folder
便可以順利安裝
find sdk\extras\google\usb_driver\android_winusb.inf
open it and
add:
;OMAP-3/4
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_D002&REV_0216
%CompositeAdbInterface% = USB_Install, USB\VID_0451&PID_D102&MI_01
%CompositeAdbInterface% = USB_Install, USB\VID_0451&PID_D106&MI_02
%CompositeAdbInterface% = USB_Install, USB\VID_0451&PID_D107&MI_03
%SingleAdbInterface% = USB_Install, USB\VID_0451&PID_FFFFE
%CompositeAdbInterface% = USB_Install, USB\VID_0451&PID_FFFE&MI_01
in [Google.NTx86]
( PandaBoard 硬體識別碼)
設定好之後, 再更新驅動程式 from sdk\extras\google\usb_driver folder
便可以順利安裝
標籤:
driver,
Pandaboard
2013年4月18日 星期四
[Android] NFC API application
如何註冊我的APP是NFC程式呢?
1. 首先要先開起 AndroidManifest.xml
<activity android:configchanges="locale" android:label="@string/app_name" android:name=".MyNfc" android:screenorientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN">
<category android:name="android.intent.category.LAUNCHER">
</category></action>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED">
</action>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED">
</action></intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/nfc_tech_filter.xml">
</meta-data>
</activity>
1. 首先要先開起 AndroidManifest.xml
<activity android:configchanges="locale" android:label="@string/app_name" android:name=".MyNfc" android:screenorientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN">
<category android:name="android.intent.category.LAUNCHER">
</category></action>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED">
</action>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED">
</action></intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/nfc_tech_filter.xml">
</meta-data>
</activity>
2012年5月3日 星期四
[Android] SimpleDateFormat ms
java.text.SimpleDateFormat date =
new java.text.SimpleDateFormat(""yyyy/MM/dd HH:mm:ss:SSS"); //SS = ms
saveTime = date.format(new Date(System.currentTimeMillis()));
new java.text.SimpleDateFormat(""yyyy/MM/dd HH:mm:ss:SSS"); //SS = ms
saveTime = date.format(new Date(System.currentTimeMillis()));
2011年5月22日 星期日
apache httpd.conf virtual directory
Apache virtual directory設定:
以windows 7安裝appserv為例
appserv www 目錄在 C:\AppServ\www
想要新增一virtual directory取代本機端檔案夾目錄
找到apache的httpd.conf
以我的安裝為例, C:\AppServ\Apache2.2\conf
在空白處加上:
以windows 7安裝appserv為例
appserv www 目錄在 C:\AppServ\www
想要新增一virtual directory取代本機端檔案夾目錄
找到apache的httpd.conf
以我的安裝為例, C:\AppServ\Apache2.2\conf
在空白處加上:
標籤:
小小問題,
Apache,
httpd.conf
2011年5月16日 星期一
[C] read txt file number and separate save
ex:
輸入:
1 5 3 5
23 59 0 34
21 33 21 10
0 0 0 0
輸出 :
1 5 3 5
23 59 0 34
21 33 21 10
0 0 0 0
#include<stdio.h>
int main( void )
{
int h1 , m1 , h2 , m2;
while(1)
{
輸入:
1 5 3 5
23 59 0 34
21 33 21 10
0 0 0 0
輸出 :
1 5 3 5
23 59 0 34
21 33 21 10
0 0 0 0
#include<stdio.h>
int main( void )
{
int h1 , m1 , h2 , m2;
while(1)
{
[C#] Console.ReadLine txt file
ex:
輸入:
1 5 3 5
23 59 0 34
21 33 21 10
0 0 0 0
輸出 :
1 5 3 5
23 59 0 34
21 33 21 10
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Collections;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string line;
while( (line=Console.ReadLine()) != null)
輸入:
1 5 3 5
23 59 0 34
21 33 21 10
0 0 0 0
輸出 :
1 5 3 5
23 59 0 34
21 33 21 10
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Collections;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string line;
while( (line=Console.ReadLine()) != null)
訂閱:
文章 (Atom)
